diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f96ff72e0..41e5a77fae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,16 +1,40 @@ name: build +concurrency: preview-${{ github.ref }} + +permissions: + contents: write + pull-requests: write + on: pull_request: jobs: ci: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + - name: Install Dependencies run: sudo apt-get install gettext - - name: Validate - run: VERSION=${{ github.event.repository.default_branch }} MODE=dummy make all + - name: Install uv + uses: astral-sh/setup-uv@v6 + + - name: Build HTML Docs + run: VERSION=${{ github.event.repository.default_branch }} JOBS=4 MODE=html make all + + - name: Deploy PR Doc Preview + # PR from the forked repo would be denied as the permission is not granted. + # Allow only PR from this repo. + if: ${{ ( github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name ) }} + uses: rossjrw/pr-preview-action@v1 + with: + source-dir: ../cpython/Doc/build/html + preview-branch: gh-pages + umbrella-dir: pr-preview + action: auto diff --git a/.github/workflows/deploy-gh-page.yml b/.github/workflows/deploy-gh-page.yml index 38d9e70fa1..05f00a9ad1 100644 --- a/.github/workflows/deploy-gh-page.yml +++ b/.github/workflows/deploy-gh-page.yml @@ -3,7 +3,7 @@ name: deploy-gh-page on: push: branches: - - "3.12" + - "3.13" jobs: cd: @@ -14,13 +14,17 @@ jobs: - name: Install Dependencies run: sudo apt-get install gettext + - name: Install uv + uses: astral-sh/setup-uv@v6 + - name: Build - run: make all + run: JOBS=4 MODE=html make all - name: Deploy to gh page - uses: JamesIves/github-pages-deploy-action@v4.6.3 + uses: JamesIves/github-pages-deploy-action@v4.7.3 with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: gh-pages - FOLDER: ../cpython/Doc/build/html - CLEAN: true + token: ${{ secrets.GITHUB_TOKEN }} + branch: gh-pages + folder: ../cpython/Doc/build/html + clean: true + clean-exclude: pr-preview/ diff --git a/.github/workflows/py312-sync-cpython.yml b/.github/workflows/py313-sync-cpython.yml similarity index 74% rename from .github/workflows/py312-sync-cpython.yml rename to .github/workflows/py313-sync-cpython.yml index f10378c019..e826525144 100644 --- a/.github/workflows/py312-sync-cpython.yml +++ b/.github/workflows/py313-sync-cpython.yml @@ -1,9 +1,9 @@ -name: python-3.12-sync-with-cpython +name: python-3.13-sync-with-cpython on: push: branches: - - "3.12" + - "3.13" schedule: - cron: "0 0 * * *" @@ -11,8 +11,8 @@ jobs: sync: runs-on: ubuntu-latest env: - VERSION: "3.12" - BRANCH: "cron/sync/3.12" + VERSION: "3.13" + BRANCH: "cron/sync/3.13" steps: - uses: actions/checkout@v4 with: @@ -30,35 +30,38 @@ jobs: - name: Install Dependencies run: sudo apt-get install gettext + - name: Install uv + uses: astral-sh/setup-uv@v6 + - name: Sync with CPython - run: make clone && make merge && make rm_cpython + run: make clone merge rm_cpython wrap - - uses: tibdex/github-app-token@v2 - id: generate-token + - uses: actions/create-github-app-token@v2 + id: app-token with: - app_id: ${{ secrets.APP_ID }} - private_key: ${{ secrets.APP_PRIVATE_KEY }} + app-id: ${{ secrets.APP_ID }} + private-key: ${{ secrets.APP_PRIVATE_KEY }} - name: Create Pull Request id: cpr uses: peter-evans/create-pull-request@v6 with: - token: ${{ steps.generate-token.outputs.token }} + token: ${{ steps.app-token.outputs.token }} commit-message: sync with cpython ${{ env.LATEST_COMMIT_ID }} committer: GitHub author: github-actions[bot] base: ${{ env.VERSION }} branch: ${{ env.BRANCH }} delete-branch: false - title: 'Sync with CPython ${{ env.VERSION }}' + title: "Sync with CPython ${{ env.VERSION }}" body: | Sync with CPython ${{ env.VERSION }} draft: true labels: | sync-cpython automation - + - name: Check outputs run: | echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" - echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" \ No newline at end of file + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" diff --git a/.github/workflows/summarize_progress.yml b/.github/workflows/summarize_progress.yml index 3ffccb41a9..ec594b0666 100644 --- a/.github/workflows/summarize_progress.yml +++ b/.github/workflows/summarize_progress.yml @@ -1,6 +1,7 @@ name: summarize_progress on: + workflow_dispatch: schedule: - cron: '30 23 * * 5' @@ -16,7 +17,7 @@ jobs: - uses: actions/checkout@v4 - name: Install poetry - uses: abatilo/actions-poetry@v3 + uses: abatilo/actions-poetry@v4 - name: Execute Check Process run: | @@ -37,7 +38,7 @@ jobs: shell: bash - name: Commit wiki code - uses: stefanzweifel/git-auto-commit-action@v5 + uses: stefanzweifel/git-auto-commit-action@v6 with: commit_message: Weekly Update -- Summarize Progress - repository: markdown \ No newline at end of file + repository: markdown diff --git a/.gitignore b/.gitignore index 185f2c0f70..948c289ec6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,12 @@ *.mo __pycache__ .DS_Store + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7cf6db96a6..33a264ab44 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,6 +7,6 @@ repos: - repo: https://git.afpy.org/AFPy/powrap # there's no release tag in repo, use the latest commit hash id instead - rev: a34a9fed116d24562fbe4bb8d456ade85f056c36 + rev: v1.0.2 hooks: - id: powrap \ No newline at end of file diff --git a/.scripts/google_translate/utils.py b/.scripts/google_translate/utils.py index fe2066dfc5..a75e4c0957 100644 --- a/.scripts/google_translate/utils.py +++ b/.scripts/google_translate/utils.py @@ -46,6 +46,7 @@ '變量': '變數', # variable '常量': '常數', # constant '添加': '新增', # add + '轉義': '跳脫', # escape '基類': '基底類別', # base class } diff --git a/.scripts/poetry.lock b/.scripts/poetry.lock index 482702ad5f..7b17f463ce 100644 --- a/.scripts/poetry.lock +++ b/.scripts/poetry.lock @@ -1,9 +1,10 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.4.2 and should not be changed by hand. [[package]] name = "certifi" version = "2024.8.30" description = "Python package for providing Mozilla's CA Bundle." +category = "main" optional = false python-versions = ">=3.6" files = [ @@ -15,6 +16,7 @@ files = [ name = "chardet" version = "3.0.4" description = "Universal encoding detector for Python 2 and 3" +category = "main" optional = false python-versions = "*" files = [ @@ -24,107 +26,124 @@ files = [ [[package]] name = "charset-normalizer" -version = "3.3.2" +version = "3.4.0" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." +category = "main" optional = false python-versions = ">=3.7.0" files = [ - {file = "charset-normalizer-3.3.2.tar.gz", hash = "sha256:f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:25baf083bf6f6b341f4121c2f3c548875ee6f5339300e08be3f2b2ba1721cdd3"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:06435b539f889b1f6f4ac1758871aae42dc3a8c0e24ac9e60c2384973ad73027"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9063e24fdb1e498ab71cb7419e24622516c4a04476b17a2dab57e8baa30d6e03"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6897af51655e3691ff853668779c7bad41579facacf5fd7253b0133308cf000d"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1d3193f4a680c64b4b6a9115943538edb896edc190f0b222e73761716519268e"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cd70574b12bb8a4d2aaa0094515df2463cb429d8536cfb6c7ce983246983e5a6"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8465322196c8b4d7ab6d1e049e4c5cb460d0394da4a27d23cc242fbf0034b6b5"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a9a8e9031d613fd2009c182b69c7b2c1ef8239a0efb1df3f7c8da66d5dd3d537"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:beb58fe5cdb101e3a055192ac291b7a21e3b7ef4f67fa1d74e331a7f2124341c"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:e06ed3eb3218bc64786f7db41917d4e686cc4856944f53d5bdf83a6884432e12"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:2e81c7b9c8979ce92ed306c249d46894776a909505d8f5a4ba55b14206e3222f"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:572c3763a264ba47b3cf708a44ce965d98555f618ca42c926a9c1616d8f34269"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:fd1abc0d89e30cc4e02e4064dc67fcc51bd941eb395c502aac3ec19fab46b519"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-win32.whl", hash = "sha256:3d47fa203a7bd9c5b6cee4736ee84ca03b8ef23193c0d1ca99b5089f72645c73"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-win_amd64.whl", hash = "sha256:10955842570876604d404661fbccbc9c7e684caf432c09c715ec38fbae45ae09"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:802fe99cca7457642125a8a88a084cef28ff0cf9407060f7b93dca5aa25480db"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:573f6eac48f4769d667c4442081b1794f52919e7edada77495aaed9236d13a96"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:549a3a73da901d5bc3ce8d24e0600d1fa85524c10287f6004fbab87672bf3e1e"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f27273b60488abe721a075bcca6d7f3964f9f6f067c8c4c605743023d7d3944f"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1ceae2f17a9c33cb48e3263960dc5fc8005351ee19db217e9b1bb15d28c02574"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:65f6f63034100ead094b8744b3b97965785388f308a64cf8d7c34f2f2e5be0c4"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:753f10e867343b4511128c6ed8c82f7bec3bd026875576dfd88483c5c73b2fd8"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4a78b2b446bd7c934f5dcedc588903fb2f5eec172f3d29e52a9096a43722adfc"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e537484df0d8f426ce2afb2d0f8e1c3d0b114b83f8850e5f2fbea0e797bd82ae"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:eb6904c354526e758fda7167b33005998fb68c46fbc10e013ca97f21ca5c8887"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:deb6be0ac38ece9ba87dea880e438f25ca3eddfac8b002a2ec3d9183a454e8ae"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:4ab2fe47fae9e0f9dee8c04187ce5d09f48eabe611be8259444906793ab7cbce"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:80402cd6ee291dcb72644d6eac93785fe2c8b9cb30893c1af5b8fdd753b9d40f"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-win32.whl", hash = "sha256:7cd13a2e3ddeed6913a65e66e94b51d80a041145a026c27e6bb76c31a853c6ab"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-win_amd64.whl", hash = "sha256:663946639d296df6a2bb2aa51b60a2454ca1cb29835324c640dafb5ff2131a77"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:0b2b64d2bb6d3fb9112bafa732def486049e63de9618b5843bcdd081d8144cd8"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:ddbb2551d7e0102e7252db79ba445cdab71b26640817ab1e3e3648dad515003b"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:55086ee1064215781fff39a1af09518bc9255b50d6333f2e4c74ca09fac6a8f6"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8f4a014bc36d3c57402e2977dada34f9c12300af536839dc38c0beab8878f38a"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a10af20b82360ab00827f916a6058451b723b4e65030c5a18577c8b2de5b3389"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8d756e44e94489e49571086ef83b2bb8ce311e730092d2c34ca8f7d925cb20aa"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:90d558489962fd4918143277a773316e56c72da56ec7aa3dc3dbbe20fdfed15b"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6ac7ffc7ad6d040517be39eb591cac5ff87416c2537df6ba3cba3bae290c0fed"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:7ed9e526742851e8d5cc9e6cf41427dfc6068d4f5a3bb03659444b4cabf6bc26"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:8bdb58ff7ba23002a4c5808d608e4e6c687175724f54a5dade5fa8c67b604e4d"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:6b3251890fff30ee142c44144871185dbe13b11bab478a88887a639655be1068"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_s390x.whl", hash = "sha256:b4a23f61ce87adf89be746c8a8974fe1c823c891d8f86eb218bb957c924bb143"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:efcb3f6676480691518c177e3b465bcddf57cea040302f9f4e6e191af91174d4"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-win32.whl", hash = "sha256:d965bba47ddeec8cd560687584e88cf699fd28f192ceb452d1d7ee807c5597b7"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-win_amd64.whl", hash = "sha256:96b02a3dc4381e5494fad39be677abcb5e6634bf7b4fa83a6dd3112607547001"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:95f2a5796329323b8f0512e09dbb7a1860c46a39da62ecb2324f116fa8fdc85c"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c002b4ffc0be611f0d9da932eb0f704fe2602a9a949d1f738e4c34c75b0863d5"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a981a536974bbc7a512cf44ed14938cf01030a99e9b3a06dd59578882f06f985"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3287761bc4ee9e33561a7e058c72ac0938c4f57fe49a09eae428fd88aafe7bb6"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:42cb296636fcc8b0644486d15c12376cb9fa75443e00fb25de0b8602e64c1714"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0a55554a2fa0d408816b3b5cedf0045f4b8e1a6065aec45849de2d6f3f8e9786"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:c083af607d2515612056a31f0a8d9e0fcb5876b7bfc0abad3ecd275bc4ebc2d5"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:87d1351268731db79e0f8e745d92493ee2841c974128ef629dc518b937d9194c"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:bd8f7df7d12c2db9fab40bdd87a7c09b1530128315d047a086fa3ae3435cb3a8"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:c180f51afb394e165eafe4ac2936a14bee3eb10debc9d9e4db8958fe36afe711"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:8c622a5fe39a48f78944a87d4fb8a53ee07344641b0562c540d840748571b811"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-win32.whl", hash = "sha256:db364eca23f876da6f9e16c9da0df51aa4f104a972735574842618b8c6d999d4"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-win_amd64.whl", hash = "sha256:86216b5cee4b06df986d214f664305142d9c76df9b6512be2738aa72a2048f99"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:6463effa3186ea09411d50efc7d85360b38d5f09b870c48e4600f63af490e56a"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:6c4caeef8fa63d06bd437cd4bdcf3ffefe6738fb1b25951440d80dc7df8c03ac"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:37e55c8e51c236f95b033f6fb391d7d7970ba5fe7ff453dad675e88cf303377a"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fb69256e180cb6c8a894fee62b3afebae785babc1ee98b81cdf68bbca1987f33"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ae5f4161f18c61806f411a13b0310bea87f987c7d2ecdbdaad0e94eb2e404238"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b2b0a0c0517616b6869869f8c581d4eb2dd83a4d79e0ebcb7d373ef9956aeb0a"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:45485e01ff4d3630ec0d9617310448a8702f70e9c01906b0d0118bdf9d124cf2"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:eb00ed941194665c332bf8e078baf037d6c35d7c4f3102ea2d4f16ca94a26dc8"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:2127566c664442652f024c837091890cb1942c30937add288223dc895793f898"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:a50aebfa173e157099939b17f18600f72f84eed3049e743b68ad15bd69b6bf99"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:4d0d1650369165a14e14e1e47b372cfcb31d6ab44e6e33cb2d4e57265290044d"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:923c0c831b7cfcb071580d3f46c4baf50f174be571576556269530f4bbd79d04"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:06a81e93cd441c56a9b65d8e1d043daeb97a3d0856d177d5c90ba85acb3db087"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-win32.whl", hash = "sha256:6ef1d82a3af9d3eecdba2321dc1b3c238245d890843e040e41e470ffa64c3e25"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-win_amd64.whl", hash = "sha256:eb8821e09e916165e160797a6c17edda0679379a4be5c716c260e836e122f54b"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:c235ebd9baae02f1b77bcea61bce332cb4331dc3617d254df3323aa01ab47bd4"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:5b4c145409bef602a690e7cfad0a15a55c13320ff7a3ad7ca59c13bb8ba4d45d"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:68d1f8a9e9e37c1223b656399be5d6b448dea850bed7d0f87a8311f1ff3dabb0"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:22afcb9f253dac0696b5a4be4a1c0f8762f8239e21b99680099abd9b2b1b2269"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e27ad930a842b4c5eb8ac0016b0a54f5aebbe679340c26101df33424142c143c"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1f79682fbe303db92bc2b1136016a38a42e835d932bab5b3b1bfcfbf0640e519"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b261ccdec7821281dade748d088bb6e9b69e6d15b30652b74cbbac25e280b796"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:122c7fa62b130ed55f8f285bfd56d5f4b4a5b503609d181f9ad85e55c89f4185"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:d0eccceffcb53201b5bfebb52600a5fb483a20b61da9dbc885f8b103cbe7598c"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:9f96df6923e21816da7e0ad3fd47dd8f94b2a5ce594e00677c0013018b813458"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:7f04c839ed0b6b98b1a7501a002144b76c18fb1c1850c8b98d458ac269e26ed2"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:34d1c8da1e78d2e001f363791c98a272bb734000fcef47a491c1e3b0505657a8"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ff8fa367d09b717b2a17a052544193ad76cd49979c805768879cb63d9ca50561"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-win32.whl", hash = "sha256:aed38f6e4fb3f5d6bf81bfa990a07806be9d83cf7bacef998ab1a9bd660a581f"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-win_amd64.whl", hash = "sha256:b01b88d45a6fcb69667cd6d2f7a9aeb4bf53760d7fc536bf679ec94fe9f3ff3d"}, - {file = "charset_normalizer-3.3.2-py3-none-any.whl", hash = "sha256:3e4d1f6587322d2788836a99c69062fbb091331ec940e02d12d179c1d53e25fc"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:4f9fc98dad6c2eaa32fc3af1417d95b5e3d08aff968df0cd320066def971f9a6"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0de7b687289d3c1b3e8660d0741874abe7888100efe14bd0f9fd7141bcbda92b"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:5ed2e36c3e9b4f21dd9422f6893dec0abf2cca553af509b10cd630f878d3eb99"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:40d3ff7fc90b98c637bda91c89d51264a3dcf210cade3a2c6f838c7268d7a4ca"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1110e22af8ca26b90bd6364fe4c763329b0ebf1ee213ba32b68c73de5752323d"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:86f4e8cca779080f66ff4f191a685ced73d2f72d50216f7112185dc02b90b9b7"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7f683ddc7eedd742e2889d2bfb96d69573fde1d92fcb811979cdb7165bb9c7d3"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:27623ba66c183eca01bf9ff833875b459cad267aeeb044477fedac35e19ba907"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:f606a1881d2663630ea5b8ce2efe2111740df4b687bd78b34a8131baa007f79b"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:0b309d1747110feb25d7ed6b01afdec269c647d382c857ef4663bbe6ad95a912"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:136815f06a3ae311fae551c3df1f998a1ebd01ddd424aa5603a4336997629e95"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:14215b71a762336254351b00ec720a8e85cada43b987da5a042e4ce3e82bd68e"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:79983512b108e4a164b9c8d34de3992f76d48cadc9554c9e60b43f308988aabe"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-win32.whl", hash = "sha256:c94057af19bc953643a33581844649a7fdab902624d2eb739738a30e2b3e60fc"}, + {file = "charset_normalizer-3.4.0-cp310-cp310-win_amd64.whl", hash = "sha256:55f56e2ebd4e3bc50442fbc0888c9d8c94e4e06a933804e2af3e89e2f9c1c749"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:0d99dd8ff461990f12d6e42c7347fd9ab2532fb70e9621ba520f9e8637161d7c"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c57516e58fd17d03ebe67e181a4e4e2ccab1168f8c2976c6a334d4f819fe5944"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:6dba5d19c4dfab08e58d5b36304b3f92f3bd5d42c1a3fa37b5ba5cdf6dfcbcee"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf4475b82be41b07cc5e5ff94810e6a01f276e37c2d55571e3fe175e467a1a1c"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ce031db0408e487fd2775d745ce30a7cd2923667cf3b69d48d219f1d8f5ddeb6"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8ff4e7cdfdb1ab5698e675ca622e72d58a6fa2a8aa58195de0c0061288e6e3ea"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3710a9751938947e6327ea9f3ea6332a09bf0ba0c09cae9cb1f250bd1f1549bc"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:82357d85de703176b5587dbe6ade8ff67f9f69a41c0733cf2425378b49954de5"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:47334db71978b23ebcf3c0f9f5ee98b8d65992b65c9c4f2d34c2eaf5bcaf0594"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:8ce7fd6767a1cc5a92a639b391891bf1c268b03ec7e021c7d6d902285259685c"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:f1a2f519ae173b5b6a2c9d5fa3116ce16e48b3462c8b96dfdded11055e3d6365"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:63bc5c4ae26e4bc6be6469943b8253c0fd4e4186c43ad46e713ea61a0ba49129"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:bcb4f8ea87d03bc51ad04add8ceaf9b0f085ac045ab4d74e73bbc2dc033f0236"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-win32.whl", hash = "sha256:9ae4ef0b3f6b41bad6366fb0ea4fc1d7ed051528e113a60fa2a65a9abb5b1d99"}, + {file = "charset_normalizer-3.4.0-cp311-cp311-win_amd64.whl", hash = "sha256:cee4373f4d3ad28f1ab6290684d8e2ebdb9e7a1b74fdc39e4c211995f77bec27"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:0713f3adb9d03d49d365b70b84775d0a0d18e4ab08d12bc46baa6132ba78aaf6"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:de7376c29d95d6719048c194a9cf1a1b0393fbe8488a22008610b0361d834ecf"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:4a51b48f42d9358460b78725283f04bddaf44a9358197b889657deba38f329db"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b295729485b06c1a0683af02a9e42d2caa9db04a373dc38a6a58cdd1e8abddf1"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ee803480535c44e7f5ad00788526da7d85525cfefaf8acf8ab9a310000be4b03"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3d59d125ffbd6d552765510e3f31ed75ebac2c7470c7274195b9161a32350284"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8cda06946eac330cbe6598f77bb54e690b4ca93f593dee1568ad22b04f347c15"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:07afec21bbbbf8a5cc3651aa96b980afe2526e7f048fdfb7f1014d84acc8b6d8"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:6b40e8d38afe634559e398cc32b1472f376a4099c75fe6299ae607e404c033b2"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:b8dcd239c743aa2f9c22ce674a145e0a25cb1566c495928440a181ca1ccf6719"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:84450ba661fb96e9fd67629b93d2941c871ca86fc38d835d19d4225ff946a631"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:44aeb140295a2f0659e113b31cfe92c9061622cadbc9e2a2f7b8ef6b1e29ef4b"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:1db4e7fefefd0f548d73e2e2e041f9df5c59e178b4c72fbac4cc6f535cfb1565"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-win32.whl", hash = "sha256:5726cf76c982532c1863fb64d8c6dd0e4c90b6ece9feb06c9f202417a31f7dd7"}, + {file = "charset_normalizer-3.4.0-cp312-cp312-win_amd64.whl", hash = "sha256:b197e7094f232959f8f20541ead1d9862ac5ebea1d58e9849c1bf979255dfac9"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:dd4eda173a9fcccb5f2e2bd2a9f423d180194b1bf17cf59e3269899235b2a114"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:e9e3c4c9e1ed40ea53acf11e2a386383c3304212c965773704e4603d589343ed"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:92a7e36b000bf022ef3dbb9c46bfe2d52c047d5e3f3343f43204263c5addc250"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:54b6a92d009cbe2fb11054ba694bc9e284dad30a26757b1e372a1fdddaf21920"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1ffd9493de4c922f2a38c2bf62b831dcec90ac673ed1ca182fe11b4d8e9f2a64"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:35c404d74c2926d0287fbd63ed5d27eb911eb9e4a3bb2c6d294f3cfd4a9e0c23"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4796efc4faf6b53a18e3d46343535caed491776a22af773f366534056c4e1fbc"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e7fdd52961feb4c96507aa649550ec2a0d527c086d284749b2f582f2d40a2e0d"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:92db3c28b5b2a273346bebb24857fda45601aef6ae1c011c0a997106581e8a88"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:ab973df98fc99ab39080bfb0eb3a925181454d7c3ac8a1e695fddfae696d9e90"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:4b67fdab07fdd3c10bb21edab3cbfe8cf5696f453afce75d815d9d7223fbe88b"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:aa41e526a5d4a9dfcfbab0716c7e8a1b215abd3f3df5a45cf18a12721d31cb5d"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:ffc519621dce0c767e96b9c53f09c5d215578e10b02c285809f76509a3931482"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-win32.whl", hash = "sha256:f19c1585933c82098c2a520f8ec1227f20e339e33aca8fa6f956f6691b784e67"}, + {file = "charset_normalizer-3.4.0-cp313-cp313-win_amd64.whl", hash = "sha256:707b82d19e65c9bd28b81dde95249b07bf9f5b90ebe1ef17d9b57473f8a64b7b"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:dbe03226baf438ac4fda9e2d0715022fd579cb641c4cf639fa40d53b2fe6f3e2"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dd9a8bd8900e65504a305bf8ae6fa9fbc66de94178c420791d0293702fce2df7"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b8831399554b92b72af5932cdbbd4ddc55c55f631bb13ff8fe4e6536a06c5c51"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a14969b8691f7998e74663b77b4c36c0337cb1df552da83d5c9004a93afdb574"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dcaf7c1524c0542ee2fc82cc8ec337f7a9f7edee2532421ab200d2b920fc97cf"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:425c5f215d0eecee9a56cdb703203dda90423247421bf0d67125add85d0c4455"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-musllinux_1_2_aarch64.whl", hash = "sha256:d5b054862739d276e09928de37c79ddeec42a6e1bfc55863be96a36ba22926f6"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-musllinux_1_2_i686.whl", hash = "sha256:f3e73a4255342d4eb26ef6df01e3962e73aa29baa3124a8e824c5d3364a65748"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-musllinux_1_2_ppc64le.whl", hash = "sha256:2f6c34da58ea9c1a9515621f4d9ac379871a8f21168ba1b5e09d74250de5ad62"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-musllinux_1_2_s390x.whl", hash = "sha256:f09cb5a7bbe1ecae6e87901a2eb23e0256bb524a79ccc53eb0b7629fbe7677c4"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-musllinux_1_2_x86_64.whl", hash = "sha256:0099d79bdfcf5c1f0c2c72f91516702ebf8b0b8ddd8905f97a8aecf49712c621"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-win32.whl", hash = "sha256:9c98230f5042f4945f957d006edccc2af1e03ed5e37ce7c373f00a5a4daa6149"}, + {file = "charset_normalizer-3.4.0-cp37-cp37m-win_amd64.whl", hash = "sha256:62f60aebecfc7f4b82e3f639a7d1433a20ec32824db2199a11ad4f5e146ef5ee"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:af73657b7a68211996527dbfeffbb0864e043d270580c5aef06dc4b659a4b578"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:cab5d0b79d987c67f3b9e9c53f54a61360422a5a0bc075f43cab5621d530c3b6"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:9289fd5dddcf57bab41d044f1756550f9e7cf0c8e373b8cdf0ce8773dc4bd417"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6b493a043635eb376e50eedf7818f2f322eabbaa974e948bd8bdd29eb7ef2a51"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9fa2566ca27d67c86569e8c85297aaf413ffab85a8960500f12ea34ff98e4c41"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a8e538f46104c815be19c975572d74afb53f29650ea2025bbfaef359d2de2f7f"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6fd30dc99682dc2c603c2b315bded2799019cea829f8bf57dc6b61efde6611c8"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2006769bd1640bdf4d5641c69a3d63b71b81445473cac5ded39740a226fa88ab"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:dc15e99b2d8a656f8e666854404f1ba54765871104e50c8e9813af8a7db07f12"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:ab2e5bef076f5a235c3774b4f4028a680432cded7cad37bba0fd90d64b187d19"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-musllinux_1_2_ppc64le.whl", hash = "sha256:4ec9dd88a5b71abfc74e9df5ebe7921c35cbb3b641181a531ca65cdb5e8e4dea"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-musllinux_1_2_s390x.whl", hash = "sha256:43193c5cda5d612f247172016c4bb71251c784d7a4d9314677186a838ad34858"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:aa693779a8b50cd97570e5a0f343538a8dbd3e496fa5dcb87e29406ad0299654"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-win32.whl", hash = "sha256:7706f5850360ac01d80c89bcef1640683cc12ed87f42579dab6c5d3ed6888613"}, + {file = "charset_normalizer-3.4.0-cp38-cp38-win_amd64.whl", hash = "sha256:c3e446d253bd88f6377260d07c895816ebf33ffffd56c1c792b13bff9c3e1ade"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:980b4f289d1d90ca5efcf07958d3eb38ed9c0b7676bf2831a54d4f66f9c27dfa"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f28f891ccd15c514a0981f3b9db9aa23d62fe1a99997512b0491d2ed323d229a"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a8aacce6e2e1edcb6ac625fb0f8c3a9570ccc7bfba1f63419b3769ccf6a00ed0"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bd7af3717683bea4c87acd8c0d3d5b44d56120b26fd3f8a692bdd2d5260c620a"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5ff2ed8194587faf56555927b3aa10e6fb69d931e33953943bc4f837dfee2242"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e91f541a85298cf35433bf66f3fab2a4a2cff05c127eeca4af174f6d497f0d4b"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:309a7de0a0ff3040acaebb35ec45d18db4b28232f21998851cfa709eeff49d62"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:285e96d9d53422efc0d7a17c60e59f37fbf3dfa942073f666db4ac71e8d726d0"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:5d447056e2ca60382d460a604b6302d8db69476fd2015c81e7c35417cfabe4cd"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:20587d20f557fe189b7947d8e7ec5afa110ccf72a3128d61a2a387c3313f46be"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:130272c698667a982a5d0e626851ceff662565379baf0ff2cc58067b81d4f11d"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:ab22fbd9765e6954bc0bcff24c25ff71dcbfdb185fcdaca49e81bac68fe724d3"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:7782afc9b6b42200f7362858f9e73b1f8316afb276d316336c0ec3bd73312742"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-win32.whl", hash = "sha256:2de62e8801ddfff069cd5c504ce3bc9672b23266597d4e4f50eda28846c322f2"}, + {file = "charset_normalizer-3.4.0-cp39-cp39-win_amd64.whl", hash = "sha256:95c3c157765b031331dd4db3c775e58deaee050a3042fcad72cbc4189d7c8dca"}, + {file = "charset_normalizer-3.4.0-py3-none-any.whl", hash = "sha256:fe9f97feb71aa9896b81973a7bbada8c49501dc73e58a10fcef6663af95e5079"}, + {file = "charset_normalizer-3.4.0.tar.gz", hash = "sha256:223217c3d4f82c3ac5e29032b3f1c2eb0fb591b72161f86d93f5719079dae93e"}, ] [[package]] name = "googletrans" version = "3.1.0a0" description = "Free Google Translate API for Python. Translates totally free of charge." +category = "main" optional = false python-versions = ">=3.6" files = [ @@ -138,6 +157,7 @@ httpx = "0.13.3" name = "h11" version = "0.9.0" description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1" +category = "main" optional = false python-versions = "*" files = [ @@ -149,6 +169,7 @@ files = [ name = "h2" version = "3.2.0" description = "HTTP/2 State-Machine based protocol implementation" +category = "main" optional = false python-versions = "*" files = [ @@ -164,6 +185,7 @@ hyperframe = ">=5.2.0,<6" name = "hpack" version = "3.0.0" description = "Pure-Python HPACK header compression" +category = "main" optional = false python-versions = "*" files = [ @@ -173,19 +195,21 @@ files = [ [[package]] name = "hstspreload" -version = "2024.9.1" +version = "2024.10.1" description = "Chromium HSTS Preload list as a Python package" +category = "main" optional = false python-versions = ">=3.6" files = [ - {file = "hstspreload-2024.9.1-py3-none-any.whl", hash = "sha256:9c1b2d0313899d3ff9dac03ab39d53fed95c32eef9862e7eabee8dc07dfd589c"}, - {file = "hstspreload-2024.9.1.tar.gz", hash = "sha256:2ab4518495a132c4ae430c474afffd12938852c6eec68ce1368c8f7858dc3076"}, + {file = "hstspreload-2024.10.1-py3-none-any.whl", hash = "sha256:3ab481036cbdff095cb411dafe33ee7924492319cf6ddaf4e776a159537541b3"}, + {file = "hstspreload-2024.10.1.tar.gz", hash = "sha256:2859a6b52253743ddddad468d8c9570ba650170ca49ac416336826915ee409b8"}, ] [[package]] name = "httpcore" version = "0.9.1" description = "A minimal low-level HTTP client." +category = "main" optional = false python-versions = ">=3.6" files = [ @@ -195,13 +219,14 @@ files = [ [package.dependencies] h11 = ">=0.8,<0.10" -h2 = "==3.*" -sniffio = "==1.*" +h2 = ">=3.0.0,<4.0.0" +sniffio = ">=1.0.0,<2.0.0" [[package]] name = "httpx" version = "0.13.3" description = "The next generation HTTP client." +category = "main" optional = false python-versions = ">=3.6" files = [ @@ -211,10 +236,10 @@ files = [ [package.dependencies] certifi = "*" -chardet = "==3.*" +chardet = ">=3.0.0,<4.0.0" hstspreload = "*" -httpcore = "==0.9.*" -idna = "==2.*" +httpcore = ">=0.9.0,<0.10.0" +idna = ">=2.0.0,<3.0.0" rfc3986 = ">=1.3,<2" sniffio = "*" @@ -222,6 +247,7 @@ sniffio = "*" name = "hyperframe" version = "5.2.0" description = "HTTP/2 framing layer for Python" +category = "main" optional = false python-versions = "*" files = [ @@ -233,6 +259,7 @@ files = [ name = "idna" version = "2.10" description = "Internationalized Domain Names in Applications (IDNA)" +category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" files = [ @@ -244,6 +271,7 @@ files = [ name = "lxml" version = "5.3.0" description = "Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API." +category = "main" optional = false python-versions = ">=3.6" files = [ @@ -398,6 +426,7 @@ source = ["Cython (>=3.0.11)"] name = "polib" version = "1.1.1" description = "A library to manipulate gettext files (po and mo files)." +category = "main" optional = false python-versions = "*" files = [ @@ -409,6 +438,7 @@ files = [ name = "requests" version = "2.31.0" description = "Python HTTP for Humans." +category = "main" optional = false python-versions = ">=3.7" files = [ @@ -430,6 +460,7 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] name = "rfc3986" version = "1.5.0" description = "Validating URI References per RFC 3986" +category = "main" optional = false python-versions = "*" files = [ @@ -444,6 +475,7 @@ idna2008 = ["idna"] name = "sniffio" version = "1.3.1" description = "Sniff out which async library your code is running under" +category = "main" optional = false python-versions = ">=3.7" files = [ @@ -455,6 +487,7 @@ files = [ name = "translate-toolkit" version = "3.8.1" description = "Tools and API for translation and localization engineering." +category = "main" optional = false python-versions = ">=3.7" files = [ @@ -483,13 +516,14 @@ yaml = ["ruamel.yaml (==0.17.21)"] [[package]] name = "urllib3" -version = "2.2.2" +version = "2.2.3" description = "HTTP library with thread-safe connection pooling, file post, and more." +category = "main" optional = false python-versions = ">=3.8" files = [ - {file = "urllib3-2.2.2-py3-none-any.whl", hash = "sha256:a448b2f64d686155468037e1ace9f2d2199776e17f0a46610480d311f73e3472"}, - {file = "urllib3-2.2.2.tar.gz", hash = "sha256:dd505485549a7a552833da5e6063639d0d177c04f23bc3864e41e5dc5f612168"}, + {file = "urllib3-2.2.3-py3-none-any.whl", hash = "sha256:ca899ca043dcb1bafa3e262d73aa25c465bfb49e0bd9dd5d59f1d0acba2f8fac"}, + {file = "urllib3-2.2.3.tar.gz", hash = "sha256:e7d814a81dad81e6caf2ec9fdedb284ecc9c73076b62654547cc64ccdcae26e9"}, ] [package.extras] diff --git a/.scripts/summarize_progress/main.py b/.scripts/summarize_progress/main.py index 328fbfde6e..f35f7bbd56 100644 --- a/.scripts/summarize_progress/main.py +++ b/.scripts/summarize_progress/main.py @@ -6,27 +6,6 @@ from pathlib import Path -def entry_check(pofile: polib.POFile) -> str: - ''' - Check the po file with how many entries are translated or not. - ''' - - lines_tranlated = len(pofile.translated_entries()) - lines_untranlated = len(pofile.untranslated_entries()) - - if lines_tranlated == 0: - result = "❌" - elif lines_untranlated == 0: - result = "✅" - else: - lines_all = lines_tranlated + lines_untranlated - progress = lines_tranlated / lines_all - progress_percentage = round(progress * 100, 2) - result = f"{progress_percentage} %" - - return result - - def get_open_issues_count() -> int: ''' Fetch GitHub API to get the number of OPEN ISSUES. @@ -89,20 +68,23 @@ def get_github_issues() -> list: def format_line_table_header() -> list: - return [f"|Filename|Progress|Issue|Assignee|\r\n", + return [f"|Filename|Progress (#string)|Issue|Assignee|\r\n", f"|-------:|:-------|:----|:-------|\r\n"] -def format_issue_link(url: str) -> str: - return f"[{url.split('/')[-1]}]({url})" if len(url) > 0 else '' - - -def format_line_file(filename: str, data: dict) -> str: - return f"|`{filename}`|{data['progress']}|{format_issue_link(data['issue'])}|{data['assignee']}|\r\n" +def format_line_po_issue_display(issue_link: str, issue_number: str, progress: float, create_issue_link: str) -> str: + if issue_link: + return f"[{issue_number}]({issue_link})" + if progress != 100.: + return f"[create issue]({create_issue_link})" + return "" -def format_line_directory(dirname: str) -> str: - return f"## {dirname}\r\n" +def format_line_po(filename: str, po_link: str, progress: str, num_entries: str, issue_display: str, assignee: str) -> str: + progress_display = f"{progress} %" + if progress == 100: + progress_display = "✅" + return f"|[`{filename}`]({po_link})|{progress_display} ({num_entries:,})|{issue_display}|{assignee}|\r\n" if __name__ == "__main__": @@ -117,11 +99,17 @@ def format_line_directory(dirname: str) -> str: for filepath in glob.glob(str(BASE_DIR / "**/*.po"), recursive=True): path = Path(filepath) filename = path.name - dirname = path.parent.name if path.parent.name != BASE_DIR.name else '/' + dirname = path.parent.name if path.parent.name != BASE_DIR.name else 'root' po = polib.pofile(filepath) + num_entries = len(list(filter(lambda e: not e.obsolete, po))) + num_translated = len(po.translated_entries()) summary.setdefault(dirname, {})[filename] = { - 'progress': entry_check(po), + 'po_info': { + 'num_entries': num_entries, + 'num_translated': num_translated, + 'progress': round(num_translated / num_entries * 100, 2), + }, 'issue': '', 'assignee': '', } @@ -137,25 +125,47 @@ def format_line_directory(dirname: str) -> str: pass ''' - Adding Space for Formatting Markdown Link - ''' - - ''' - Format the lines that will write into the markdown file, + Format the lines that will be written into the markdown file, also sort the directory name and file name. ''' writeliner = [] summary_sorted = dict(sorted(summary.items())) + total_entries, total_translated = 0, 0 for dirname, filedict in summary_sorted.items(): - writeliner.append(format_line_directory(dirname)) - writeliner.extend(format_line_table_header()) - + dir_total_entries, dir_total_translated = 0, 0 + lines = [] filedict_sorted = dict(sorted(filedict.items())) for filename, filedata in filedict_sorted.items(): - writeliner.append(format_line_file(filename, filedata)) + file_path = f"{dirname}/{filename}" if dirname else filename + po_link = f"https://github.com/python/python-docs-zh-tw/tree/3.13/{file_path}" + issue_link = filedata['issue'] + issue_number = f"#{issue_link.split('/')[-1]}" + create_issue_link = f"https://github.com/python/python-docs-zh-tw/issues/new?title=Translate%20`{file_path}`" + issue_display = format_line_po_issue_display(issue_link, issue_number, filedata['po_info']['progress'], create_issue_link) + line_po = format_line_po( + filename, + po_link, + filedata['po_info']['progress'], + filedata['po_info']['num_entries'], + issue_display, + filedata['assignee'], + ) + lines.append(line_po) + + dir_total_entries += filedata['po_info']['num_entries'] + dir_total_translated += filedata['po_info']['num_translated'] + + dir_progress = round(dir_total_translated / dir_total_entries * 100, 2) + writeliner.append(f"## {dirname} ({dir_progress}%)\r\n") + writeliner.extend(format_line_table_header()) + writeliner.extend(lines) + + total_entries += dir_total_entries + total_translated += dir_total_translated + + overall_progress = round(total_translated / total_entries * 100, 2) + title = f"## Overall Progress: {overall_progress}% ({total_translated:,} / {total_entries:,})\r\n" + writeliner = [title] + writeliner - with open( - f"summarize_progress/result.md", - "w", - ) as file: + with open(f"summarize_progress/result.md", "w") as file: file.writelines(writeliner) diff --git a/Makefile b/Makefile index b1793e0908..c0da35f4af 100644 --- a/Makefile +++ b/Makefile @@ -38,13 +38,13 @@ endef export PRINT_HELP_PYSCRIPT # End of python section CPYTHON_CLONE := ../cpython -VERSION := $(or $(VERSION), 3.12) +VERSION := $(or $(VERSION), 3.13) SPHINX_CONF := $(CPYTHON_CLONE)/Doc/conf.py LANGUAGE := zh_TW LC_MESSAGES := $(CPYTHON_CLONE)/Doc/locales/$(LANGUAGE)/LC_MESSAGES VENV := ~/.venvs/python-docs-i18n/ -MODE := autobuild-dev-html -JOBS := 4 +MODE := $(or $(MODE), autobuild-dev-html) +JOBS := $(or $(JOBS), auto) .PHONY: all all: prepare_deps ## Automatically build an html local version @@ -89,21 +89,21 @@ prepare_cpython: ## Prepare CPython clone at `../cpython/`. $(VENV)/bin/activate: - python3 -m venv $(VENV) + uv venv $(VENV) $(VENV)/bin/sphinx-build: $(VENV)/bin/activate - . $(VENV)/bin/activate; python3 -m pip install sphinx python-docs-theme + . $(VENV)/bin/activate; uv pip install sphinx python-docs-theme $(VENV)/bin/sphinx-lint: $(VENV)/bin/activate - . $(VENV)/bin/activate; python3 -m pip install sphinx-lint + . $(VENV)/bin/activate; uv pip install sphinx-lint $(VENV)/bin/blurb: $(VENV)/bin/activate - . $(VENV)/bin/activate; python3 -m pip install blurb + . $(VENV)/bin/activate; uv pip install blurb .PHONY: upgrade_venv upgrade_venv: $(VENV)/bin/activate ## Upgrade the venv that compiles the doc - @. $(VENV)/bin/activate; python3 -m pip install -q --upgrade sphinx python-docs-theme blurb sphinx-lint + @. $(VENV)/bin/activate; uv pip install -q --upgrade sphinx python-docs-theme blurb sphinx-lint .PHONY: progress @@ -156,6 +156,10 @@ rm_cpython: ## Remove cloned cpython repo lint: $(VENV)/bin/sphinx-lint ## Run sphinx-lint $(VENV)/bin/sphinx-lint --enable default-role +.PHONY: wrap +wrap: ## Run powrap on modified po files + uvx powrap --modified + # This allows us to accept extra arguments (by doing nothing when we get a job that doesn't match, rather than throwing an error) %: @: diff --git a/README.rst b/README.rst index 385d4ee165..0fa98b4abc 100644 --- a/README.rst +++ b/README.rst @@ -6,7 +6,7 @@ Python 官方說明文件臺灣繁體中文翻譯計畫 :target: https://discord.gg/44XheGXhWH :alt: Join Chat on Discord -這是 Python 3.12 官方說明文件的臺灣繁體中文(zh_TW)翻譯。 +這是 Python 3.13 官方說明文件的臺灣繁體中文(zh_TW)翻譯。 翻譯之前,請務必詳讀並同意\ `授權與 License`_。參與方式請參考\ `參與翻譯`_。 @@ -52,7 +52,7 @@ the PSF for inclusion in the documentation. 請注意此予翻譯專案的授權:Python 的說明文件是以全球的志工社群來維護。透過張貼\ 此專案在 Transifex、GitHub 以及其他公眾場合,以及邀請你參與,我們向你提出一個\ 協議:你必須將你對於 Python 說明文件或是 Python 說明文件翻譯的貢獻以 CC0\ -(請參考 https://creativecommons.org/publicdomain/zero/1.0/legalcode/ +(請參考 https://creativecommons.org/publicdomain/zero/1.0/legalcode/ )的方式授權給 PSF 使用。你可以公開地聲明你所貢獻翻譯的部分,並且如果你的翻譯被 PSF 採用,你可以(但並不須要)送出一個修改,其包含在 Misc/ACKS 或是 TRANSLATORS 檔案裡增加合適的注釋。雖然這個說明文件貢獻協議並沒有說明 PSF 有義務納入你的\ @@ -84,6 +84,7 @@ the PSF for inclusion in the documentation. - `安裝好 git `_\ (Windows 上請參考 https://gitforwindows.org/) - 一個 ``.po`` 檔的編輯器。推薦使用 `Poedit `_,若熟悉 po 檔用一般文字編輯器亦可。 +- 參考 `uv Installation `_ 安裝 uv,以便在本機端預覽翻譯成果。 - macOS 的使用者還需要先利用 `homebrew `_ 安裝 gettext,屆時 Sphinx 會使用到。 .. code-block:: bash @@ -132,13 +133,13 @@ the PSF for inclusion in the documentation. 接著在 terminal 裡按照以下步驟: -1. 基於最新版本的 ``upstream/3.12`` 開啟一個 branch,現在假設我們想要翻譯 library/math.po \ +1. 基於最新版本的 ``upstream/3.13`` 開啟一個 branch,現在假設我們想要翻譯 library/math.po \ 所以把這個 branch 叫做 ``library/math``: .. code-block:: bash git fetch upstream - git checkout -b library/math upstream/3.12 + git checkout -b library/math upstream/3.13 2. 接著就可以開始翻譯(翻譯時可參考\ `翻譯守則`_),你可以手動開啟 Poedit 應用程式再選 \ library/math.po 檔案打開 @@ -222,7 +223,7 @@ the PSF for inclusion in the documentation. - 從 upstream(我們的主要 GitHub repo)做 fetch 的動作 - 對 origin(你的 fork)做 push -- 永遠不對 ``3.12`` branch 進行修改,請保持讓這個 branch 唯讀,可以避免掉很多問題。 +- 永遠不對 ``3.13`` branch 進行修改,請保持讓這個 branch 唯讀,可以避免掉很多問題。 要翻譯哪些東西 -------------- @@ -232,7 +233,7 @@ the PSF for inclusion in the documentation. 其中最簡單的貢獻方式就是更新 *fuzzy entries*,讓曾經翻譯的內容保持與最新版本的文件 同步。請參考\ `尋找有翻譯過但需校閱的 fuzzy entries`_ 段落。 -此外,當前的目標為完成 **Tutorial** 的翻譯,因此在 ``tutorial/`` 底下的所有 +此外,目前的目標為完成 **Tutorial** 的翻譯,因此在 ``tutorial/`` 底下的所有 po 檔皆為首要的翻譯對象。你也可以幫忙校對已經翻譯過的內容。 diff --git a/TERMINOLOGY_DICTIONARY.md b/TERMINOLOGY_DICTIONARY.md new file mode 100644 index 0000000000..d06f2f2b44 --- /dev/null +++ b/TERMINOLOGY_DICTIONARY.md @@ -0,0 +1,79 @@ +# Python Documentation Translation Dictionary + +This document describes the terminology dictionaries for maintaining translation consistency across the Python documentation project. + +## Overview + +The translation dictionary project provides curated key terms and their translations to help translators maintain consistent terminology usage across different documents. The dictionaries are maintained using LLM knowledge to identify and categorize important Python terminology. + +## Generated Files + +### terminology_dictionary.csv +The complete terminology dictionary containing important terms identified from Python documentation. Contains: +- **source_term**: The original English term +- **translated_term**: The corresponding Chinese (Traditional) translation +- **frequency**: Number of occurrences across all files +- **files_count**: Number of different files containing this term +- **source_file**: Example file where this term was found +- **directory**: Directory of the source file +- **example_files**: List of up to 5 files containing this term + +Total entries: ~196 essential Python terms + +### focused_terminology_dictionary.csv +A curated subset of ~118 terms focusing on the most important Python terminology. Includes additional columns: +- **priority**: High/Medium priority classification +- **category**: Term classification + +#### Categories: +- **Core Concepts** (7 terms): class, function, method, module, package, object, type +- **Built-in Types** (9 terms): int, str, list, dict, tuple, set, float, bool, complex +- **Keywords/Constants** (25 terms): None, True, False, return, import, def, async, await, and other Python keywords +- **Exceptions** (29 terms): Common *Error and *Exception classes +- **Code Elements** (14 terms): Magic methods like __init__, __str__, etc. +- **Common Terms** (34 terms): Important technical concepts like decorator, generator, iterator + +## Maintenance + +The terminology dictionaries are maintained using LLM knowledge to identify important Python terms and their translations. The dictionaries can be updated as needed to reflect new terminology or improved translations. + +## Integration with Translation Workflow + +### For New Translators +1. Start with `focused_terminology_dictionary.csv` +2. Learn standard translations for core Python concepts +3. Reference high-frequency terms for consistency + +### For Translation Review +1. Check new translations against the dictionary +2. Verify consistent terminology usage +3. Update dictionary when establishing new standard translations + +### For Project Management +1. Track translation progress for key technical terms +2. Identify terminology needing standardization +3. Prioritize translation efforts using frequency data + +### Output Format +CSV files use UTF-8 encoding to properly handle Chinese characters. Compatible with Excel, Google Sheets, and other spreadsheet applications. + +## Maintenance + +### Adding New Terms +New terms can be identified and added based on: +- Frequency of appearance in documentation +- Importance to Python concepts +- Consistency needs across translation files + +### Manual Curation Process +The dictionaries are maintained through careful analysis of: +- Core Python terminology in official documentation +- Existing translation patterns in .po files +- Category-based organization for translator efficiency + +### Quality Assurance +- Regular review of term translations for consistency +- Cross-reference with official Python terminology +- Validation against established translation conventions + +This documentation provides comprehensive guidance for maintaining and using the translation dictionary system to ensure consistent, high-quality Python documentation translation. \ No newline at end of file diff --git a/TRANSLATORS b/TRANSLATORS index 0eac99e39c..772cb45f33 100644 --- a/TRANSLATORS +++ b/TRANSLATORS @@ -18,6 +18,7 @@ Steven Hsu (StevenHsuYL) Taihsiang Ho (tai271828) Tsai, Chia-Wen Wei-Hsiang (Matt) Wang +Weilin Du (LamentXU) Wilson Wang (Josix) Yu Chun Yang Jason (chairco) diff --git a/about.po b/about.po index 4b90148fd5..a95b16de88 100644 --- a/about.po +++ b/about.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -12,9 +11,9 @@ # hsiao yi , 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-08-05 00:19+0000\n" +"POT-Creation-Date: 2025-01-01 00:15+0000\n" "PO-Revision-Date: 2022-05-12 00:11+0800\n" "Last-Translator: hsiao yi \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -27,18 +26,19 @@ msgstr "" "X-Generator: Poedit 3.0.1\n" #: ../../about.rst:3 -msgid "About these documents" -msgstr "關於這些說明文件" +msgid "About this documentation" +msgstr "關於這份說明文件" #: ../../about.rst:6 msgid "" -"These documents are generated from `reStructuredText`_ sources by `Sphinx`_, " -"a document processor specifically written for the Python documentation." +"Python's documentation is generated from `reStructuredText`_ sources using " +"`Sphinx`_, a documentation generator originally created for Python and now " +"maintained as an independent project." msgstr "" -"這些說明文件是透過 `Sphinx`_ (一個專為 Python 說明文件所撰寫的文件處理器)將" -"使用 `reStructuredText`_ 撰寫的原始檔轉換而成。" +"Python 說明文件是透過使用 `Sphinx`_\\ (一個原為 Python 而生的文件產生器、目" +"前是以獨立專案形式來維護)將使用 `reStructuredText`_ 撰寫的原始檔轉換而成。" -#: ../../about.rst:15 +#: ../../about.rst:16 msgid "" "Development of the documentation and its toolchain is an entirely volunteer " "effort, just like Python itself. If you want to contribute, please take a " @@ -49,26 +49,26 @@ msgstr "" "報臭蟲,請見 :ref:`reporting-bugs` 頁面,內含相關資訊。我們永遠歡迎新的自願者" "加入!" -#: ../../about.rst:20 +#: ../../about.rst:21 msgid "Many thanks go to:" msgstr "致謝:" -#: ../../about.rst:22 +#: ../../about.rst:23 msgid "" "Fred L. Drake, Jr., the creator of the original Python documentation toolset " -"and writer of much of the content;" +"and author of much of the content;" msgstr "" "Fred L. Drake, Jr.,原始 Python 文件工具集的創造者以及一大部份內容的作者;" -#: ../../about.rst:24 +#: ../../about.rst:25 msgid "" "the `Docutils `_ project for creating " "reStructuredText and the Docutils suite;" msgstr "" -"創造 reStructuredText 和 Docutils 工具組的 `Docutils `_ 專案;" +"創造 reStructuredText 和 Docutils 工具組的 `Docutils `_ 專案;" -#: ../../about.rst:26 +#: ../../about.rst:27 msgid "" "Fredrik Lundh for his Alternative Python Reference project from which Sphinx " "got many good ideas." @@ -76,11 +76,11 @@ msgstr "" "Fredrik Lundh 先生,Sphinx 從他的 Alternative Python Reference 計劃中獲得許多" "的好主意。" -#: ../../about.rst:31 -msgid "Contributors to the Python Documentation" +#: ../../about.rst:32 +msgid "Contributors to the Python documentation" msgstr "Python 文件的貢獻者們" -#: ../../about.rst:33 +#: ../../about.rst:34 msgid "" "Many people have contributed to the Python language, the Python standard " "library, and the Python documentation. See :source:`Misc/ACKS` in the " @@ -89,7 +89,7 @@ msgstr "" "許多人都曾為 Python 這門語言、Python 標準函式庫和 Python 說明文件貢獻過。" "Python 所發佈的原始碼中含有部份貢獻者的清單,請見 :source:`Misc/ACKS` 。" -#: ../../about.rst:37 +#: ../../about.rst:38 msgid "" "It is only with the input and contributions of the Python community that " "Python has such wonderful documentation -- Thank You!" diff --git a/bugs.po b/bugs.po index b040a99bb9..2837ebfc0a 100644 --- a/bugs.po +++ b/bugs.po @@ -11,7 +11,7 @@ # Steven Hsu , 2021-2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-04-18 19:45+0000\n" "PO-Revision-Date: 2022-08-31 12:34+0800\n" diff --git a/c-api/abstract.po b/c-api/abstract.po index e2ef911a82..87e9a0091e 100644 --- a/c-api/abstract.po +++ b/c-api/abstract.po @@ -8,7 +8,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2021-12-09 21:20+0800\n" diff --git a/c-api/allocation.po b/c-api/allocation.po index f167bb99fa..d1b7524859 100644 --- a/c-api/allocation.po +++ b/c-api/allocation.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -8,9 +7,9 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-08-09 00:03+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2022-10-16 15:35+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -29,16 +28,13 @@ msgstr "在 heap 上分配物件" #: ../../c-api/allocation.rst:17 msgid "" "Initialize a newly allocated object *op* with its type and initial " -"reference. Returns the initialized object. If *type* indicates that the " -"object participates in the cyclic garbage detector, it is added to the " -"detector's set of observed objects. Other fields of the object are not " -"affected." +"reference. Returns the initialized object. Other fields of the object are " +"not affected." msgstr "" -"用它的型別和初始參照來初始化新分配物件 *op*。已初始化的物件會被回傳。如果 " -"*type* 表示了該物件參與迴圈垃圾檢查器,則將其新增到檢查器的觀察物件集合中。物" -"件的其他欄位不受影響。" +"用它的型別和初始參照來初始化新分配物件 *op*。已初始化的物件會被回傳。物件的其" +"他欄位不受影響。" -#: ../../c-api/allocation.rst:26 +#: ../../c-api/allocation.rst:24 msgid "" "This does everything :c:func:`PyObject_Init` does, and also initializes the " "length information for a variable-size object." @@ -46,7 +42,7 @@ msgstr "" "它會做到 :c:func:`PyObject_Init` 的所有功能,並且會初始化一個大小可變物件的長" "度資訊。" -#: ../../c-api/allocation.rst:32 +#: ../../c-api/allocation.rst:30 msgid "" "Allocate a new Python object using the C structure type *TYPE* and the " "Python type object *typeobj* (``PyTypeObject*``). Fields not defined by the " @@ -60,7 +56,16 @@ msgstr "" "化;呼叫者會擁有那個對於物件的唯一參照(物件的參照計數為一)。記憶體分配大小" "由 type 物件的 :c:member:`~PyTypeObject.tp_basicsize` 欄位來指定。" -#: ../../c-api/allocation.rst:43 +#: ../../c-api/allocation.rst:38 +msgid "" +"Note that this function is unsuitable if *typeobj* has :c:macro:" +"`Py_TPFLAGS_HAVE_GC` set. For such objects, use :c:func:`PyObject_GC_New` " +"instead." +msgstr "" +"注意,如果 *typeobj* 有 :c:macro:`Py_TPFLAGS_HAVE_GC` 設定,則此函式不適用。" +"對於這種物件,請改用 :c:func:`PyObject_GC_New`。" + +#: ../../c-api/allocation.rst:45 msgid "" "Allocate a new Python object using the C structure type *TYPE* and the " "Python type object *typeobj* (``PyTypeObject*``). Fields not defined by the " @@ -79,7 +84,16 @@ msgstr "" "於實現如 tuple 這種能夠在建立期間決定自己大小的物件是很實用的。將欄位的陣列嵌" "入到相同的記憶體分配中可以減少記憶體分配的次數,這提高了記憶體管理的效率。" -#: ../../c-api/allocation.rst:57 +#: ../../c-api/allocation.rst:56 +msgid "" +"Note that this function is unsuitable if *typeobj* has :c:macro:" +"`Py_TPFLAGS_HAVE_GC` set. For such objects, use :c:func:`PyObject_GC_NewVar` " +"instead." +msgstr "" +"注意,如果 *typeobj* 有 :c:macro:`Py_TPFLAGS_HAVE_GC` 設定,則此函式不適用。" +"對於這種物件,請改用 :c:func:`PyObject_GC_NewVar`。" + +#: ../../c-api/allocation.rst:63 msgid "" "Releases memory allocated to an object using :c:macro:`PyObject_New` or :c:" "macro:`PyObject_NewVar`. This is normally called from the :c:member:" @@ -92,7 +106,7 @@ msgstr "" "handler 中呼叫。呼叫這個函式以後,物件的各欄位都不可以被存取,因為原本分配的" "記憶體已不再是一個有效的 Python 物件。" -#: ../../c-api/allocation.rst:66 +#: ../../c-api/allocation.rst:72 msgid "" "Object which is visible in Python as ``None``. This should only be accessed " "using the :c:macro:`Py_None` macro, which evaluates to a pointer to this " @@ -101,10 +115,10 @@ msgstr "" "這個物件像是 Python 中的 ``None``。它只應該透過 :c:macro:`Py_None` 巨集來存" "取,該巨集的拿到指向該物件的指標。" -#: ../../c-api/allocation.rst:73 -msgid ":c:func:`PyModule_Create`" -msgstr ":c:func:`PyModule_Create`" +#: ../../c-api/allocation.rst:79 +msgid ":ref:`moduleobjects`" +msgstr ":ref:`moduleobjects`" -#: ../../c-api/allocation.rst:74 +#: ../../c-api/allocation.rst:80 msgid "To allocate and create extension modules." msgstr "分配記憶體和建立擴充模組。" diff --git a/c-api/apiabiversion.po b/c-api/apiabiversion.po index 62558d43f5..8b589303e8 100644 --- a/c-api/apiabiversion.po +++ b/c-api/apiabiversion.po @@ -6,7 +6,7 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-07-29 00:03+0000\n" "PO-Revision-Date: 2022-01-24 22:34+0800\n" diff --git a/c-api/arg.po b/c-api/arg.po index a8487118c9..921b3bae7f 100644 --- a/c-api/arg.po +++ b/c-api/arg.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2025-05-06 05:40+0000\n" "PO-Revision-Date: 2022-10-16 03:21+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -25,7 +24,7 @@ msgstr "剖析引數與建置數值" #: ../../c-api/arg.rst:8 msgid "" -"These functions are useful when creating your own extensions functions and " +"These functions are useful when creating your own extension functions and " "methods. Additional information and examples are available in :ref:" "`extending-index`." msgstr "" @@ -41,7 +40,7 @@ msgstr "" #: ../../c-api/arg.rst:19 msgid "Parsing arguments" -msgstr "" +msgstr "剖析引數" #: ../../c-api/arg.rst:21 msgid "" @@ -55,25 +54,33 @@ msgid "" "brackets is the type of the C variable(s) whose address should be passed." msgstr "" -#: ../../c-api/arg.rst:31 +#: ../../c-api/arg.rst:33 msgid "Strings and buffers" msgstr "" -#: ../../c-api/arg.rst:33 +#: ../../c-api/arg.rst:37 +msgid "" +"On Python 3.12 and older, the macro :c:macro:`!PY_SSIZE_T_CLEAN` must be " +"defined before including :file:`Python.h` to use all ``#`` variants of " +"formats (``s#``, ``y#``, etc.) explained below. This is not necessary on " +"Python 3.13 and later." +msgstr "" + +#: ../../c-api/arg.rst:42 msgid "" "These formats allow accessing an object as a contiguous chunk of memory. You " "don't have to provide raw storage for the returned unicode or bytes area." msgstr "" -#: ../../c-api/arg.rst:37 +#: ../../c-api/arg.rst:46 msgid "Unless otherwise stated, buffers are not NUL-terminated." msgstr "" -#: ../../c-api/arg.rst:39 +#: ../../c-api/arg.rst:48 msgid "There are three ways strings and buffers can be converted to C:" msgstr "" -#: ../../c-api/arg.rst:41 +#: ../../c-api/arg.rst:50 msgid "" "Formats such as ``y*`` and ``s*`` fill a :c:type:`Py_buffer` structure. This " "locks the underlying buffer so that the caller can subsequently use the " @@ -83,14 +90,14 @@ msgid "" "data (or in any early abort case)." msgstr "" -#: ../../c-api/arg.rst:48 +#: ../../c-api/arg.rst:57 msgid "" "The ``es``, ``es#``, ``et`` and ``et#`` formats allocate the result buffer. " "**You have to call** :c:func:`PyMem_Free` after you have finished processing " "the data (or in any early abort case)." msgstr "" -#: ../../c-api/arg.rst:54 +#: ../../c-api/arg.rst:63 msgid "" "Other formats take a :class:`str` or a read-only :term:`bytes-like object`, " "such as :class:`bytes`, and provide a ``const char *`` pointer to its " @@ -99,7 +106,7 @@ msgid "" "won't have to release any memory yourself." msgstr "" -#: ../../c-api/arg.rst:61 +#: ../../c-api/arg.rst:70 msgid "" "To ensure that the underlying buffer may be safely borrowed, the object's :c:" "member:`PyBufferProcs.bf_releasebuffer` field must be ``NULL``. This " @@ -107,22 +114,13 @@ msgid "" "read-only objects such as :class:`memoryview` of :class:`bytes`." msgstr "" -#: ../../c-api/arg.rst:67 +#: ../../c-api/arg.rst:76 msgid "" "Besides this ``bf_releasebuffer`` requirement, there is no check to verify " "whether the input object is immutable (e.g. whether it would honor a request " "for a writable buffer, or whether another thread can mutate the data)." msgstr "" -#: ../../c-api/arg.rst:73 -msgid "" -"For all ``#`` variants of formats (``s#``, ``y#``, etc.), the macro :c:macro:" -"`PY_SSIZE_T_CLEAN` must be defined before including :file:`Python.h`. On " -"Python 3.9 and older, the type of the length argument is :c:type:" -"`Py_ssize_t` if the :c:macro:`PY_SSIZE_T_CLEAN` macro is defined, or int " -"otherwise." -msgstr "" - #: ../../c-api/arg.rst:80 msgid "``s`` (:class:`str`) [const char \\*]" msgstr "``s`` (:class:`str`) [const char \\*]" @@ -153,7 +151,7 @@ msgstr "" #: ../../c-api/arg.rst:100 msgid "``s*`` (:class:`str` or :term:`bytes-like object`) [Py_buffer]" -msgstr "``s*``\\ (:class:`str` 或 :term:`bytes-like object`)[Py_buffer]" +msgstr "``s*`` (:class:`str` 或 :term:`bytes-like object`) [Py_buffer]" #: ../../c-api/arg.rst:101 msgid "" @@ -168,6 +166,8 @@ msgid "" "``s#`` (:class:`str`, read-only :term:`bytes-like object`) [const char \\*, :" "c:type:`Py_ssize_t`]" msgstr "" +"``s#`` (:class:`str`、唯讀的 :term:`bytes-like object`) [const char \\*, :c:" +"type:`Py_ssize_t`]" #: ../../c-api/arg.rst:107 msgid "" @@ -178,9 +178,9 @@ msgid "" "encoding." msgstr "" -#: ../../c-api/arg.rst:113 ../../c-api/arg.rst:546 +#: ../../c-api/arg.rst:113 ../../c-api/arg.rst:593 msgid "``z`` (:class:`str` or ``None``) [const char \\*]" -msgstr "``z``\\ (:class:`str` 或 ``None``)[const char \\*]" +msgstr "``z`` (:class:`str` 或 ``None``) [const char \\*]" #: ../../c-api/arg.rst:114 msgid "" @@ -192,7 +192,7 @@ msgstr "" msgid "" "``z*`` (:class:`str`, :term:`bytes-like object` or ``None``) [Py_buffer]" msgstr "" -"``z*``\\ (:class:`str`、:term:`bytes-like object` 或 ``None``)[Py_buffer]" +"``z*`` (:class:`str`、:term:`bytes-like object` 或 ``None``) [Py_buffer]" #: ../../c-api/arg.rst:118 msgid "" @@ -205,6 +205,8 @@ msgid "" "``z#`` (:class:`str`, read-only :term:`bytes-like object` or ``None``) " "[const char \\*, :c:type:`Py_ssize_t`]" msgstr "" +"``z#`` (:class:`str`、唯讀的 :term:`bytes-like object` 或 ``None``) [const " +"char \\*, :c:type:`Py_ssize_t`]" #: ../../c-api/arg.rst:122 msgid "" @@ -214,7 +216,7 @@ msgstr "" #: ../../c-api/arg.rst:125 msgid "``y`` (read-only :term:`bytes-like object`) [const char \\*]" -msgstr "``y``\\ (唯讀 :term:`bytes-like object`)[const char \\*]" +msgstr "``y`` (唯讀的 :term:`bytes-like object`) [const char \\*]" #: ../../c-api/arg.rst:126 msgid "" @@ -245,6 +247,8 @@ msgid "" "``y#`` (read-only :term:`bytes-like object`) [const char \\*, :c:type:" "`Py_ssize_t`]" msgstr "" +"``y#`` (唯讀的 :term:`bytes-like object`) [const char \\*, :c:type:" +"`Py_ssize_t`]" #: ../../c-api/arg.rst:142 msgid "" @@ -288,7 +292,7 @@ msgstr "" #: ../../c-api/arg.rst:160 msgid "``w*`` (read-write :term:`bytes-like object`) [Py_buffer]" -msgstr "``w*`` (可讀寫 :term:`bytes-like object`) [Py_buffer]" +msgstr "``w*`` (可讀寫 :term:`bytes-like object`) [Py_buffer]" #: ../../c-api/arg.rst:161 msgid "" @@ -332,6 +336,8 @@ msgid "" "``et`` (:class:`str`, :class:`bytes` or :class:`bytearray`) [const char " "\\*encoding, char \\*\\*buffer]" msgstr "" +"``et`` (:class:`str`、:class:`bytes` 或 :class:`bytearray`) [const char " +"\\*encoding, char \\*\\*buffer]" #: ../../c-api/arg.rst:184 msgid "" @@ -345,6 +351,8 @@ msgid "" "``es#`` (:class:`str`) [const char \\*encoding, char \\*\\*buffer, :c:type:" "`Py_ssize_t` \\*buffer_length]" msgstr "" +"``es#`` (:class:`str`) [const char \\*encoding, char \\*\\*buffer, :c:type:" +"`Py_ssize_t` \\*buffer_length]" #: ../../c-api/arg.rst:189 msgid "" @@ -368,7 +376,7 @@ msgstr "" #: ../../c-api/arg.rst:203 msgid "There are two modes of operation:" -msgstr "" +msgstr "有兩個操作模式:" #: ../../c-api/arg.rst:205 msgid "" @@ -418,38 +426,59 @@ msgid "Numbers" msgstr "數字" #: ../../c-api/arg.rst:232 +msgid "" +"These formats allow representing Python numbers or single characters as C " +"numbers. Formats that require :class:`int`, :class:`float` or :class:" +"`complex` can also use the corresponding special methods :meth:`~object." +"__index__`, :meth:`~object.__float__` or :meth:`~object.__complex__` to " +"convert the Python object to the required type." +msgstr "" + +#: ../../c-api/arg.rst:238 +msgid "" +"For signed integer formats, :exc:`OverflowError` is raised if the value is " +"out of range for the C type. For unsigned integer formats, no range checking " +"is done --- the most significant bits are silently truncated when the " +"receiving field is too small to receive the value." +msgstr "" + +#: ../../c-api/arg.rst:244 msgid "``b`` (:class:`int`) [unsigned char]" msgstr "``b`` (:class:`int`) [unsigned char]" -#: ../../c-api/arg.rst:233 +#: ../../c-api/arg.rst:245 msgid "" -"Convert a nonnegative Python integer to an unsigned tiny int, stored in a C :" -"c:expr:`unsigned char`." +"Convert a nonnegative Python integer to an unsigned tiny integer, stored in " +"a C :c:expr:`unsigned char`." msgstr "" +"將一個 Python 非負整數轉換成無符號 tiny integer(小整數),儲存在 C 的 :c:" +"expr:`unsigned`" -#: ../../c-api/arg.rst:236 ../../c-api/arg.rst:580 +#: ../../c-api/arg.rst:248 ../../c-api/arg.rst:627 msgid "``B`` (:class:`int`) [unsigned char]" msgstr "``B`` (:class:`int`) [unsigned char]" -#: ../../c-api/arg.rst:237 +#: ../../c-api/arg.rst:249 msgid "" -"Convert a Python integer to a tiny int without overflow checking, stored in " -"a C :c:expr:`unsigned char`." +"Convert a Python integer to a tiny integer without overflow checking, stored " +"in a C :c:expr:`unsigned char`." msgstr "" +"將一個 Python 整數轉換成 tiny integer,轉換過程無溢位檢查,儲存在 C 的 :c:" +"expr:`unsigned char`。" -#: ../../c-api/arg.rst:240 ../../c-api/arg.rst:574 +#: ../../c-api/arg.rst:252 ../../c-api/arg.rst:621 msgid "``h`` (:class:`int`) [short int]" msgstr "``h`` (:class:`int`) [short int]" -#: ../../c-api/arg.rst:241 +#: ../../c-api/arg.rst:253 msgid "Convert a Python integer to a C :c:expr:`short int`." msgstr "將一個 Python 整數轉換成 C 的 :c:expr:`short int`。" -#: ../../c-api/arg.rst:243 ../../c-api/arg.rst:583 +#: ../../c-api/arg.rst:255 ../../c-api/arg.rst:630 msgid "``H`` (:class:`int`) [unsigned short int]" msgstr "``H`` (:class:`int`) [unsigned short int]" -#: ../../c-api/arg.rst:244 +#: ../../c-api/arg.rst:256 msgid "" "Convert a Python integer to a C :c:expr:`unsigned short int`, without " "overflow checking." @@ -457,57 +486,57 @@ msgstr "" "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned short int`,轉換過程無溢位檢" "查。" -#: ../../c-api/arg.rst:247 ../../c-api/arg.rst:568 +#: ../../c-api/arg.rst:259 ../../c-api/arg.rst:615 msgid "``i`` (:class:`int`) [int]" msgstr "``i`` (:class:`int`) [int]" -#: ../../c-api/arg.rst:248 +#: ../../c-api/arg.rst:260 msgid "Convert a Python integer to a plain C :c:expr:`int`." msgstr "將一個 Python 整數轉換成 C 的 :c:expr:`int`。" -#: ../../c-api/arg.rst:250 ../../c-api/arg.rst:586 +#: ../../c-api/arg.rst:262 ../../c-api/arg.rst:633 msgid "``I`` (:class:`int`) [unsigned int]" msgstr "``I`` (:class:`int`) [unsigned int]" -#: ../../c-api/arg.rst:251 +#: ../../c-api/arg.rst:263 msgid "" "Convert a Python integer to a C :c:expr:`unsigned int`, without overflow " "checking." msgstr "" "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned int`,轉換過程無溢位檢查。" -#: ../../c-api/arg.rst:254 ../../c-api/arg.rst:577 +#: ../../c-api/arg.rst:266 ../../c-api/arg.rst:624 msgid "``l`` (:class:`int`) [long int]" msgstr "``l`` (:class:`int`) [long int]" -#: ../../c-api/arg.rst:255 +#: ../../c-api/arg.rst:267 msgid "Convert a Python integer to a C :c:expr:`long int`." msgstr "將一個 Python 整數轉換成 C 的 :c:expr:`long int`。" -#: ../../c-api/arg.rst:257 ../../c-api/arg.rst:589 +#: ../../c-api/arg.rst:269 ../../c-api/arg.rst:636 msgid "``k`` (:class:`int`) [unsigned long]" msgstr "``k`` (:class:`int`) [unsigned long]" -#: ../../c-api/arg.rst:258 +#: ../../c-api/arg.rst:270 msgid "" "Convert a Python integer to a C :c:expr:`unsigned long` without overflow " "checking." msgstr "" "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned long`,轉換過程無溢位檢查。" -#: ../../c-api/arg.rst:261 ../../c-api/arg.rst:592 +#: ../../c-api/arg.rst:273 ../../c-api/arg.rst:639 msgid "``L`` (:class:`int`) [long long]" msgstr "``L`` (:class:`int`) [long long]" -#: ../../c-api/arg.rst:262 +#: ../../c-api/arg.rst:274 msgid "Convert a Python integer to a C :c:expr:`long long`." msgstr "將一個 Python 整數轉換成 C 的 :c:expr:`long long`。" -#: ../../c-api/arg.rst:264 ../../c-api/arg.rst:595 +#: ../../c-api/arg.rst:276 ../../c-api/arg.rst:644 msgid "``K`` (:class:`int`) [unsigned long long]" msgstr "``K`` (:class:`int`) [unsigned long long]" -#: ../../c-api/arg.rst:265 +#: ../../c-api/arg.rst:277 msgid "" "Convert a Python integer to a C :c:expr:`unsigned long long` without " "overflow checking." @@ -515,71 +544,71 @@ msgstr "" "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned long long`,轉換過程無溢位檢" "查。" -#: ../../c-api/arg.rst:268 ../../c-api/arg.rst:598 +#: ../../c-api/arg.rst:280 ../../c-api/arg.rst:647 msgid "``n`` (:class:`int`) [:c:type:`Py_ssize_t`]" msgstr "``n`` (:class:`int`) [:c:type:`Py_ssize_t`]" -#: ../../c-api/arg.rst:269 +#: ../../c-api/arg.rst:281 msgid "Convert a Python integer to a C :c:type:`Py_ssize_t`." msgstr "將一個 Python 整數轉換成 C 的 :c:type:`Py_ssize_t`。" -#: ../../c-api/arg.rst:271 +#: ../../c-api/arg.rst:283 msgid "``c`` (:class:`bytes` or :class:`bytearray` of length 1) [char]" -msgstr "``c``\\ (:class:`bytes` 或長度為 1 的 :class:`bytearray`)[char]" +msgstr "``c`` (:class:`bytes` 或長度為 1 的 :class:`bytearray`) [char]" -#: ../../c-api/arg.rst:272 +#: ../../c-api/arg.rst:284 msgid "" "Convert a Python byte, represented as a :class:`bytes` or :class:`bytearray` " "object of length 1, to a C :c:expr:`char`." msgstr "" -#: ../../c-api/arg.rst:275 +#: ../../c-api/arg.rst:287 msgid "Allow :class:`bytearray` objects." msgstr "允許 :class:`bytearray` 物件。" -#: ../../c-api/arg.rst:278 ../../c-api/arg.rst:605 +#: ../../c-api/arg.rst:290 ../../c-api/arg.rst:654 msgid "``C`` (:class:`str` of length 1) [int]" -msgstr "``C``\\ (長度為 1 的 :class:`str`)[int]" +msgstr "``C`` (長度為 1 的 :class:`str`) [int]" -#: ../../c-api/arg.rst:279 +#: ../../c-api/arg.rst:291 msgid "" "Convert a Python character, represented as a :class:`str` object of length " "1, to a C :c:expr:`int`." msgstr "" -#: ../../c-api/arg.rst:282 ../../c-api/arg.rst:612 +#: ../../c-api/arg.rst:294 ../../c-api/arg.rst:661 msgid "``f`` (:class:`float`) [float]" msgstr "``f`` (:class:`float`) [float]" -#: ../../c-api/arg.rst:283 +#: ../../c-api/arg.rst:295 msgid "Convert a Python floating-point number to a C :c:expr:`float`." msgstr "將一個 Python 浮點數轉換成 C 的 :c:type::c:expr:`float`。" -#: ../../c-api/arg.rst:285 ../../c-api/arg.rst:609 +#: ../../c-api/arg.rst:297 ../../c-api/arg.rst:658 msgid "``d`` (:class:`float`) [double]" msgstr "``d`` (:class:`float`) [double]" -#: ../../c-api/arg.rst:286 +#: ../../c-api/arg.rst:298 msgid "Convert a Python floating-point number to a C :c:expr:`double`." msgstr "將一個 Python 浮點數轉換成 C 的 :c:type::c:expr:`double`。" -#: ../../c-api/arg.rst:288 +#: ../../c-api/arg.rst:300 msgid "``D`` (:class:`complex`) [Py_complex]" msgstr "``D`` (:class:`complex`) [Py_complex]" -#: ../../c-api/arg.rst:289 +#: ../../c-api/arg.rst:301 msgid "Convert a Python complex number to a C :c:type:`Py_complex` structure." msgstr "將一個 Python 複數轉換成 C 的 :c:type:`Py_complex` 結構。" -#: ../../c-api/arg.rst:292 +#: ../../c-api/arg.rst:304 msgid "Other objects" msgstr "其他物件" -#: ../../c-api/arg.rst:294 ../../c-api/arg.rst:618 +#: ../../c-api/arg.rst:306 ../../c-api/arg.rst:667 msgid "``O`` (object) [PyObject \\*]" -msgstr "``O``\\ (物件)[PyObject \\*]" +msgstr "``O`` (object) [PyObject \\*]" -#: ../../c-api/arg.rst:295 +#: ../../c-api/arg.rst:307 msgid "" "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 :term:" @@ -587,11 +616,11 @@ msgid "" "not increased). The pointer stored is not ``NULL``." msgstr "" -#: ../../c-api/arg.rst:301 +#: ../../c-api/arg.rst:313 msgid "``O!`` (object) [*typeobject*, PyObject \\*]" -msgstr "``O!``\\ (物件)[*typeobject*, PyObject \\*]" +msgstr "``O!`` (object) [*typeobject*, PyObject \\*]" -#: ../../c-api/arg.rst:302 +#: ../../c-api/arg.rst:314 msgid "" "Store a Python object in a C object pointer. This is similar to ``O``, but " "takes two C arguments: the first is the address of a Python type object, the " @@ -600,11 +629,11 @@ msgid "" "required type, :exc:`TypeError` is raised." msgstr "" -#: ../../c-api/arg.rst:310 ../../c-api/arg.rst:636 -msgid "``O&`` (object) [*converter*, *anything*]" -msgstr "``O&``\\ (物件)[*converter*, *anything*]" +#: ../../c-api/arg.rst:322 +msgid "``O&`` (object) [*converter*, *address*]" +msgstr "``O&`` (object) [*converter*, *address*]" -#: ../../c-api/arg.rst:311 +#: ../../c-api/arg.rst:323 msgid "" "Convert a Python object to a C variable through a *converter* function. " "This takes two arguments: the first is a function, the second is the address " @@ -612,11 +641,11 @@ msgid "" "*converter* function in turn is called as follows::" msgstr "" -#: ../../c-api/arg.rst:316 +#: ../../c-api/arg.rst:328 msgid "status = converter(object, address);" msgstr "status = converter(object, address);" -#: ../../c-api/arg.rst:318 +#: ../../c-api/arg.rst:330 msgid "" "where *object* is the Python object to be converted and *address* is the :c:" "expr:`void*` argument that was passed to the ``PyArg_Parse*`` function. The " @@ -626,24 +655,30 @@ msgid "" "unmodified." msgstr "" -#: ../../c-api/arg.rst:324 +#: ../../c-api/arg.rst:339 msgid "" -"If the *converter* returns ``Py_CLEANUP_SUPPORTED``, it may get called a " -"second time if the argument parsing eventually fails, giving the converter a " -"chance to release any memory that it had already allocated. In this second " -"call, the *object* parameter will be ``NULL``; *address* will have the same " -"value as in the original call." +"If the *converter* returns :c:macro:`!Py_CLEANUP_SUPPORTED`, it may get " +"called a second time if the argument parsing eventually fails, giving the " +"converter a chance to release any memory that it had already allocated. In " +"this second call, the *object* parameter will be ``NULL``; *address* will " +"have the same value as in the original call." msgstr "" -#: ../../c-api/arg.rst:330 -msgid "``Py_CLEANUP_SUPPORTED`` was added." -msgstr "加入 ``Py_CLEANUP_SUPPORTED``。" +#: ../../c-api/arg.rst:345 +msgid "" +"Examples of converters: :c:func:`PyUnicode_FSConverter` and :c:func:" +"`PyUnicode_FSDecoder`." +msgstr "" + +#: ../../c-api/arg.rst:348 +msgid ":c:macro:`!Py_CLEANUP_SUPPORTED` was added." +msgstr "新增 :c:macro:`!Py_CLEANUP_SUPPORTED`。" -#: ../../c-api/arg.rst:333 +#: ../../c-api/arg.rst:351 msgid "``p`` (:class:`bool`) [int]" msgstr "``p`` (:class:`bool`) [int]" -#: ../../c-api/arg.rst:334 +#: ../../c-api/arg.rst:352 msgid "" "Tests the value passed in for truth (a boolean **p**\\ redicate) and " "converts the result to its equivalent C true/false integer value. Sets the " @@ -652,37 +687,28 @@ msgid "" "how Python tests values for truth." msgstr "" -#: ../../c-api/arg.rst:342 ../../c-api/arg.rst:642 +#: ../../c-api/arg.rst:360 ../../c-api/arg.rst:691 msgid "``(items)`` (:class:`tuple`) [*matching-items*]" msgstr "``(items)`` (:class:`tuple`) [*matching-items*]" -#: ../../c-api/arg.rst:343 +#: ../../c-api/arg.rst:361 msgid "" "The object must be a Python sequence whose length is the number of format " "units in *items*. The C arguments must correspond to the individual format " "units in *items*. Format units for sequences may be nested." msgstr "" -#: ../../c-api/arg.rst:347 -msgid "" -"It is possible to pass \"long\" integers (integers whose value exceeds the " -"platform's :c:macro:`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)." -msgstr "" - -#: ../../c-api/arg.rst:353 +#: ../../c-api/arg.rst:365 msgid "" "A few other characters have a meaning in a format string. These may not " "occur inside nested parentheses. They are:" msgstr "" -#: ../../c-api/arg.rst:356 +#: ../../c-api/arg.rst:368 msgid "``|``" msgstr "``|``" -#: ../../c-api/arg.rst:357 +#: ../../c-api/arg.rst:369 msgid "" "Indicates that the remaining arguments in the Python argument list are " "optional. The C variables corresponding to optional arguments should be " @@ -691,11 +717,11 @@ msgid "" "corresponding C variable(s)." msgstr "" -#: ../../c-api/arg.rst:363 +#: ../../c-api/arg.rst:375 msgid "``$``" msgstr "``$``" -#: ../../c-api/arg.rst:364 +#: ../../c-api/arg.rst:376 msgid "" ":c:func:`PyArg_ParseTupleAndKeywords` only: Indicates that the remaining " "arguments in the Python argument list are keyword-only. Currently, all " @@ -703,36 +729,36 @@ msgid "" "be specified before ``$`` in the format string." msgstr "" -#: ../../c-api/arg.rst:372 +#: ../../c-api/arg.rst:384 msgid "``:``" msgstr "``:``" -#: ../../c-api/arg.rst:373 +#: ../../c-api/arg.rst:385 msgid "" "The list of format units ends here; the string after the colon is used as " "the function name in error messages (the \"associated value\" of the " "exception that :c:func:`PyArg_ParseTuple` raises)." msgstr "" -#: ../../c-api/arg.rst:377 +#: ../../c-api/arg.rst:389 msgid "``;``" msgstr "``;``" -#: ../../c-api/arg.rst:378 +#: ../../c-api/arg.rst:390 msgid "" "The list of format units ends here; the string after the semicolon is used " "as the error message *instead* of the default error message. ``:`` and ``;" "`` mutually exclude each other." msgstr "" -#: ../../c-api/arg.rst:382 +#: ../../c-api/arg.rst:394 msgid "" "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)!" msgstr "" -#: ../../c-api/arg.rst:386 +#: ../../c-api/arg.rst:398 msgid "" "Additional arguments passed to these functions must be addresses of " "variables whose type is determined by the format string; these are used to " @@ -742,7 +768,7 @@ msgid "" "unit in that case." msgstr "" -#: ../../c-api/arg.rst:392 +#: ../../c-api/arg.rst:404 msgid "" "For the conversion to succeed, the *arg* object must match the format and " "the format must be exhausted. On success, the ``PyArg_Parse*`` functions " @@ -752,63 +778,92 @@ msgid "" "the following format units are left untouched." msgstr "" -#: ../../c-api/arg.rst:401 +#: ../../c-api/arg.rst:413 msgid "API Functions" msgstr "API 函式" -#: ../../c-api/arg.rst:405 +#: ../../c-api/arg.rst:417 msgid "" "Parse the parameters of a function that takes only positional parameters " "into local variables. Returns true on success; on failure, it returns false " "and raises the appropriate exception." msgstr "" -#: ../../c-api/arg.rst:412 +#: ../../c-api/arg.rst:424 msgid "" "Identical to :c:func:`PyArg_ParseTuple`, except that it accepts a va_list " "rather than a variable number of arguments." msgstr "" -#: ../../c-api/arg.rst:418 +#: ../../c-api/arg.rst:430 msgid "" "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. Empty names denote :ref:" -"`positional-only parameters `. Returns true on " -"success; on failure, it returns false and raises the appropriate exception." +"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 :ref:`positional-only " +"parameters `. Returns true on success; on " +"failure, it returns false and raises the appropriate exception." +msgstr "" + +#: ../../c-api/arg.rst:441 +msgid "" +"The *keywords* parameter declaration is :c:expr:`char * const *` in C and :c:" +"expr:`const char * const *` in C++. This can be overridden with the :c:macro:" +"`PY_CXX_CONST` macro." msgstr "" -#: ../../c-api/arg.rst:425 +#: ../../c-api/arg.rst:445 msgid "" "Added support for :ref:`positional-only parameters `." +msgstr "新增對\\ :ref:`僅限位置參數 `\\ 的支援。" + +#: ../../c-api/arg.rst:449 +msgid "" +"The *keywords* parameter has now type :c:expr:`char * const *` in C and :c:" +"expr:`const char * const *` in C++, instead of :c:expr:`char **`. Added " +"support for non-ASCII keyword parameter names." msgstr "" -#: ../../c-api/arg.rst:432 +#: ../../c-api/arg.rst:458 msgid "" "Identical to :c:func:`PyArg_ParseTupleAndKeywords`, except that it accepts a " "va_list rather than a variable number of arguments." msgstr "" -#: ../../c-api/arg.rst:438 +#: ../../c-api/arg.rst:464 msgid "" "Ensure that the keys in the keywords argument dictionary are strings. This " "is only needed if :c:func:`PyArg_ParseTupleAndKeywords` is not used, since " "the latter already does this check." msgstr "" -#: ../../c-api/arg.rst:448 +#: ../../c-api/arg.rst:473 +msgid "" +"Parse the parameter of a function that takes a single positional parameter " +"into a local variable. Returns true on success; on failure, it returns " +"false and raises the appropriate exception." +msgstr "" + +#: ../../c-api/arg.rst:477 +msgid "Example::" +msgstr "舉例來說: ::" + +#: ../../c-api/arg.rst:479 msgid "" -"Function used to deconstruct the argument lists of \"old-style\" functions " -"--- these are functions which use the :const:`METH_OLDARGS` parameter " -"parsing method, which has been removed in Python 3. This is not recommended " -"for use in parameter parsing in new code, and most code in the standard " -"interpreter has been modified to no longer use this for that purpose. It " -"does remain a convenient way to decompose other tuples, however, and may " -"continue to be used for that purpose." +"// Function using METH_O calling convention\n" +"static PyObject*\n" +"my_function(PyObject *module, PyObject *arg)\n" +"{\n" +" int value;\n" +" if (!PyArg_Parse(arg, \"i:my_function\", &value)) {\n" +" return NULL;\n" +" }\n" +" // ... use value ...\n" +"}" msgstr "" -#: ../../c-api/arg.rst:459 +#: ../../c-api/arg.rst:493 msgid "" "A simpler form of parameter retrieval which does not use a format string to " "specify the types of the arguments. Functions which use this method to " @@ -826,13 +881,13 @@ msgid "" "if there was a failure." msgstr "" -#: ../../c-api/arg.rst:474 +#: ../../c-api/arg.rst:508 msgid "" "This is an example of the use of this function, taken from the sources for " "the :mod:`!_weakref` helper module for weak references::" msgstr "" -#: ../../c-api/arg.rst:477 +#: ../../c-api/arg.rst:511 msgid "" "static PyObject *\n" "weakref_ref(PyObject *self, PyObject *args)\n" @@ -860,21 +915,30 @@ msgstr "" " return result;\n" "}" -#: ../../c-api/arg.rst:490 +#: ../../c-api/arg.rst:524 msgid "" "The call to :c:func:`PyArg_UnpackTuple` in this example is entirely " "equivalent to this call to :c:func:`PyArg_ParseTuple`::" msgstr "" -#: ../../c-api/arg.rst:493 +#: ../../c-api/arg.rst:527 msgid "PyArg_ParseTuple(args, \"O|O:ref\", &object, &callback)" msgstr "PyArg_ParseTuple(args, \"O|O:ref\", &object, &callback)" -#: ../../c-api/arg.rst:498 -msgid "Building values" +#: ../../c-api/arg.rst:531 +msgid "" +"The value to be inserted, if any, before :c:expr:`char * const *` in the " +"*keywords* parameter declaration of :c:func:`PyArg_ParseTupleAndKeywords` " +"and :c:func:`PyArg_VaParseTupleAndKeywords`. Default empty for C and " +"``const`` for C++ (:c:expr:`const char * const *`). To override, define it " +"to the desired value before including :file:`Python.h`." msgstr "" -#: ../../c-api/arg.rst:502 +#: ../../c-api/arg.rst:545 +msgid "Building values" +msgstr "建置數值" + +#: ../../c-api/arg.rst:549 msgid "" "Create a new value based on a format string similar to those accepted by the " "``PyArg_Parse*`` family of functions and a sequence of values. Returns the " @@ -882,7 +946,7 @@ msgid "" "``NULL`` is returned." msgstr "" -#: ../../c-api/arg.rst:507 +#: ../../c-api/arg.rst:554 msgid "" ":c:func:`Py_BuildValue` does not always build a tuple. It builds a tuple " "only if its format string contains two or more format units. If the format " @@ -891,7 +955,7 @@ msgid "" "it to return a tuple of size 0 or one, parenthesize the format string." msgstr "" -#: ../../c-api/arg.rst:513 +#: ../../c-api/arg.rst:560 msgid "" "When memory buffers are passed as parameters to supply data to build " "objects, as for the ``s`` and ``s#`` formats, the required data is copied. " @@ -902,7 +966,7 @@ msgid "" "`Py_BuildValue` returns." msgstr "" -#: ../../c-api/arg.rst:521 +#: ../../c-api/arg.rst:568 msgid "" "In the following description, the quoted form is the format unit; the entry " "in (round) parentheses is the Python object type that the format unit will " @@ -910,155 +974,155 @@ msgid "" "be passed." msgstr "" -#: ../../c-api/arg.rst:525 +#: ../../c-api/arg.rst:572 msgid "" "The characters space, tab, colon and comma are ignored in format strings " "(but not within format units such as ``s#``). This can be used to make long " "format strings a tad more readable." msgstr "" -#: ../../c-api/arg.rst:529 +#: ../../c-api/arg.rst:576 msgid "``s`` (:class:`str` or ``None``) [const char \\*]" -msgstr "``s``\\ (:class:`str` 或 ``None``)[const char \\*]" +msgstr "``s`` (:class:`str` 或 ``None``) [const char \\*]" -#: ../../c-api/arg.rst:530 +#: ../../c-api/arg.rst:577 msgid "" "Convert a null-terminated C string to a Python :class:`str` object using " "``'utf-8'`` encoding. If the C string pointer is ``NULL``, ``None`` is used." msgstr "" -#: ../../c-api/arg.rst:533 +#: ../../c-api/arg.rst:580 msgid "" "``s#`` (:class:`str` or ``None``) [const char \\*, :c:type:`Py_ssize_t`]" msgstr "" -"``s#``\\ (:class:`str` 或 ``None``)[const char \\*, :c:type:`Py_ssize_t`]" +"``s#`` (:class:`str` 或 ``None``) [const char \\*, :c:type:`Py_ssize_t`]" -#: ../../c-api/arg.rst:534 +#: ../../c-api/arg.rst:581 msgid "" "Convert a C string and its length to a Python :class:`str` object using " "``'utf-8'`` encoding. If the C string pointer is ``NULL``, the length is " "ignored and ``None`` is returned." msgstr "" -#: ../../c-api/arg.rst:538 +#: ../../c-api/arg.rst:585 msgid "``y`` (:class:`bytes`) [const char \\*]" msgstr "``y`` (:class:`bytes`) [const char \\*]" -#: ../../c-api/arg.rst:539 +#: ../../c-api/arg.rst:586 msgid "" "This converts a C string to a Python :class:`bytes` object. If the C string " "pointer is ``NULL``, ``None`` is returned." msgstr "" -#: ../../c-api/arg.rst:542 +#: ../../c-api/arg.rst:589 msgid "``y#`` (:class:`bytes`) [const char \\*, :c:type:`Py_ssize_t`]" msgstr "``y#`` (:class:`bytes`) [const char \\*, :c:type:`Py_ssize_t`]" -#: ../../c-api/arg.rst:543 +#: ../../c-api/arg.rst:590 msgid "" "This converts a C string and its lengths to a Python object. If the C " "string pointer is ``NULL``, ``None`` is returned." msgstr "" -#: ../../c-api/arg.rst:547 ../../c-api/arg.rst:563 +#: ../../c-api/arg.rst:594 ../../c-api/arg.rst:610 msgid "Same as ``s``." msgstr "和 ``s`` 相同。" -#: ../../c-api/arg.rst:549 +#: ../../c-api/arg.rst:596 msgid "" "``z#`` (:class:`str` or ``None``) [const char \\*, :c:type:`Py_ssize_t`]" msgstr "" -"``z#``\\ (:class:`str` 或 ``None``)[const char \\*, :c:type:`Py_ssize_t`]" +"``z#`` (:class:`str` 或 ``None``) [const char \\*, :c:type:`Py_ssize_t`]" -#: ../../c-api/arg.rst:550 ../../c-api/arg.rst:566 +#: ../../c-api/arg.rst:597 ../../c-api/arg.rst:613 msgid "Same as ``s#``." msgstr "和 ``s#`` 相同。" -#: ../../c-api/arg.rst:552 +#: ../../c-api/arg.rst:599 msgid "``u`` (:class:`str`) [const wchar_t \\*]" msgstr "``u`` (:class:`str`) [const wchar_t \\*]" -#: ../../c-api/arg.rst:553 +#: ../../c-api/arg.rst:600 msgid "" "Convert a null-terminated :c:type:`wchar_t` buffer of Unicode (UTF-16 or " "UCS-4) data to a Python Unicode object. If the Unicode buffer pointer is " "``NULL``, ``None`` is returned." msgstr "" -#: ../../c-api/arg.rst:557 +#: ../../c-api/arg.rst:604 msgid "``u#`` (:class:`str`) [const wchar_t \\*, :c:type:`Py_ssize_t`]" msgstr "``u#`` (:class:`str`) [const wchar_t \\*, :c:type:`Py_ssize_t`]" -#: ../../c-api/arg.rst:558 +#: ../../c-api/arg.rst:605 msgid "" "Convert a Unicode (UTF-16 or UCS-4) data buffer and its length to a Python " "Unicode object. If the Unicode buffer pointer is ``NULL``, the length is " "ignored and ``None`` is returned." msgstr "" -#: ../../c-api/arg.rst:562 +#: ../../c-api/arg.rst:609 msgid "``U`` (:class:`str` or ``None``) [const char \\*]" -msgstr "``U``\\ (:class:`str` 或 ``None``)[const char \\*]" +msgstr "``U`` (:class:`str` 或 ``None``) [const char \\*]" -#: ../../c-api/arg.rst:565 +#: ../../c-api/arg.rst:612 msgid "" "``U#`` (:class:`str` or ``None``) [const char \\*, :c:type:`Py_ssize_t`]" msgstr "" -"``U#``\\ (:class:`str` 或 ``None``)[const char \\*, :c:type:`Py_ssize_t`]" +"``U#`` (:class:`str` 或 ``None``) [const char \\*, :c:type:`Py_ssize_t`]" -#: ../../c-api/arg.rst:569 +#: ../../c-api/arg.rst:616 msgid "Convert a plain C :c:expr:`int` to a Python integer object." msgstr "將一個 C 的 :c:expr:`int` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:571 +#: ../../c-api/arg.rst:618 msgid "``b`` (:class:`int`) [char]" msgstr "``b`` (:class:`int`) [char]" -#: ../../c-api/arg.rst:572 +#: ../../c-api/arg.rst:619 msgid "Convert a plain C :c:expr:`char` to a Python integer object." msgstr "將一個 C 的 :c:expr:`char` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:575 +#: ../../c-api/arg.rst:622 msgid "Convert a plain C :c:expr:`short int` to a Python integer object." msgstr "將一個 C 的 :c:expr:`short int` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:578 +#: ../../c-api/arg.rst:625 msgid "Convert a C :c:expr:`long int` to a Python integer object." msgstr "將一個 C 的 :c:expr:`long int` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:581 +#: ../../c-api/arg.rst:628 msgid "Convert a C :c:expr:`unsigned char` to a Python integer object." msgstr "將一個 C 的 :c:expr:`unsigned char` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:584 +#: ../../c-api/arg.rst:631 msgid "Convert a C :c:expr:`unsigned short int` to a Python integer object." msgstr "將一個 C 的 :c:expr:`unsigned short int` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:587 +#: ../../c-api/arg.rst:634 msgid "Convert a C :c:expr:`unsigned int` to a Python integer object." msgstr "將一個 C 的 :c:expr:`unsigned int` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:590 +#: ../../c-api/arg.rst:637 msgid "Convert a C :c:expr:`unsigned long` to a Python integer object." msgstr "將一個 C 的 :c:expr:`unsigned long` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:593 +#: ../../c-api/arg.rst:640 msgid "Convert a C :c:expr:`long long` to a Python integer object." msgstr "將一個 C 的 :c:expr:`long long` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:596 +#: ../../c-api/arg.rst:645 msgid "Convert a C :c:expr:`unsigned long long` to a Python integer object." msgstr "將一個 C 的 :c:expr:`unsigned long long` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:599 +#: ../../c-api/arg.rst:648 msgid "Convert a C :c:type:`Py_ssize_t` to a Python integer." msgstr "將一個 C 的 :c:type:`Py_ssize_t` 轉換成 Python 整數。" -#: ../../c-api/arg.rst:601 +#: ../../c-api/arg.rst:650 msgid "``c`` (:class:`bytes` of length 1) [char]" -msgstr "``c``\\ (長度為 1 的 :class:`bytes`)[char]" +msgstr "``c`` (長度為 1 的 :class:`bytes`) [char]" -#: ../../c-api/arg.rst:602 +#: ../../c-api/arg.rst:651 msgid "" "Convert a C :c:expr:`int` representing a byte to a Python :class:`bytes` " "object of length 1." @@ -1066,7 +1130,7 @@ msgstr "" "將一個 C 中代表一個位元組的 :c:expr:`int` 轉換成 Python 中長度為一的 :class:" "`bytes`。" -#: ../../c-api/arg.rst:606 +#: ../../c-api/arg.rst:655 msgid "" "Convert a C :c:expr:`int` representing a character to Python :class:`str` " "object of length 1." @@ -1074,23 +1138,23 @@ msgstr "" "將一個 C 中代表一個字元的 :c:expr:`int` 轉換成 Python 中長度為一的 :class:" "`str`。" -#: ../../c-api/arg.rst:610 +#: ../../c-api/arg.rst:659 msgid "Convert a C :c:expr:`double` to a Python floating-point number." msgstr "將一個 C 的 :c:expr:`double` 轉換成 Python 浮點數。" -#: ../../c-api/arg.rst:613 +#: ../../c-api/arg.rst:662 msgid "Convert a C :c:expr:`float` to a Python floating-point number." msgstr "將一個 C 的 :c:expr:`float` 轉換成 Python 浮點數。" -#: ../../c-api/arg.rst:615 +#: ../../c-api/arg.rst:664 msgid "``D`` (:class:`complex`) [Py_complex \\*]" msgstr "``D`` (:class:`complex`) [Py_complex \\*]" -#: ../../c-api/arg.rst:616 +#: ../../c-api/arg.rst:665 msgid "Convert a C :c:type:`Py_complex` structure to a Python complex number." msgstr "將一個 C 的 :c:type:`Py_complex` 結構轉換成 Python 複數。" -#: ../../c-api/arg.rst:619 +#: ../../c-api/arg.rst:668 msgid "" "Pass a Python object untouched but create a new :term:`strong reference` to " "it (i.e. its reference count is incremented by one). If the object passed in " @@ -1100,26 +1164,30 @@ msgid "" "no exception has been raised yet, :exc:`SystemError` is set." msgstr "" -#: ../../c-api/arg.rst:628 +#: ../../c-api/arg.rst:677 msgid "``S`` (object) [PyObject \\*]" -msgstr "``S``\\ (物件)[PyObject \\*]" +msgstr "``S`` (object) [PyObject \\*]" -#: ../../c-api/arg.rst:629 +#: ../../c-api/arg.rst:678 msgid "Same as ``O``." msgstr "和 ``O`` 相同。" -#: ../../c-api/arg.rst:631 +#: ../../c-api/arg.rst:680 msgid "``N`` (object) [PyObject \\*]" -msgstr "``N``\\ (物件)[PyObject \\*]" +msgstr "``N`` (object) [PyObject \\*]" -#: ../../c-api/arg.rst:632 +#: ../../c-api/arg.rst:681 msgid "" "Same as ``O``, except it doesn't create a new :term:`strong reference`. " "Useful when the object is created by a call to an object constructor in the " "argument list." msgstr "" -#: ../../c-api/arg.rst:637 +#: ../../c-api/arg.rst:685 +msgid "``O&`` (object) [*converter*, *anything*]" +msgstr "``O&`` (object) [*converter*, *anything*]" + +#: ../../c-api/arg.rst:686 msgid "" "Convert *anything* to a Python object through a *converter* function. The " "function is called with *anything* (which should be compatible with :c:expr:" @@ -1127,40 +1195,40 @@ msgid "" "``NULL`` if an error occurred." msgstr "" -#: ../../c-api/arg.rst:643 +#: ../../c-api/arg.rst:692 msgid "" "Convert a sequence of C values to a Python tuple with the same number of " "items." msgstr "" -#: ../../c-api/arg.rst:645 +#: ../../c-api/arg.rst:694 msgid "``[items]`` (:class:`list`) [*matching-items*]" msgstr "``[items]`` (:class:`list`) [*matching-items*]" -#: ../../c-api/arg.rst:646 +#: ../../c-api/arg.rst:695 msgid "" "Convert a sequence of C values to a Python list with the same number of " "items." msgstr "" -#: ../../c-api/arg.rst:648 +#: ../../c-api/arg.rst:697 msgid "``{items}`` (:class:`dict`) [*matching-items*]" msgstr "``{items}`` (:class:`dict`) [*matching-items*]" -#: ../../c-api/arg.rst:649 +#: ../../c-api/arg.rst:698 msgid "" "Convert a sequence of C values to a Python dictionary. Each pair of " "consecutive C values adds one item to the dictionary, serving as key and " "value, respectively." msgstr "" -#: ../../c-api/arg.rst:653 +#: ../../c-api/arg.rst:702 msgid "" "If there is an error in the format string, the :exc:`SystemError` exception " "is set and ``NULL`` returned." msgstr "" -#: ../../c-api/arg.rst:658 +#: ../../c-api/arg.rst:707 msgid "" "Identical to :c:func:`Py_BuildValue`, except that it accepts a va_list " "rather than a variable number of arguments." diff --git a/c-api/bool.po b/c-api/bool.po index d90772c4a7..5c1cf65dac 100644 --- a/c-api/bool.po +++ b/c-api/bool.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -8,9 +7,9 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-07-29 10:36+0000\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2021-12-09 20:47+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -42,6 +41,8 @@ msgid "" "This instance of :c:type:`PyTypeObject` represents the Python boolean type; " "it is the same object as :class:`bool` in the Python layer." msgstr "" +"此 :c:type:`PyTypeObject` 實例代表 Python 的布林型別;它與 Python 層級中的 " +":class:`bool` 是同一個物件。" #: ../../c-api/bool.rst:22 msgid "" @@ -52,27 +53,26 @@ msgstr "" #: ../../c-api/bool.rst:28 msgid "" -"The Python ``False`` object. This object has no methods and is `immortal " -"`_." +"The Python ``False`` object. This object has no methods and is :term:" +"`immortal`." msgstr "" -"Python 的 ``False`` 物件。此物件沒有任何方法且為\\ `不滅的 (immortal) " -"`_。" +"Python 的 ``False`` 物件。此物件沒有任何方法且為\\ :term:`不滅的 (immortal) " +"`。" #: ../../c-api/bool.rst:31 -msgid ":c:data:`Py_False` is immortal." -msgstr ":c:data:`Py_False` 為不滅的。" +msgid ":c:data:`Py_False` is :term:`immortal`." +msgstr ":c:data:`Py_False` 為\\ :term:`不滅的 `。" #: ../../c-api/bool.rst:37 msgid "" -"The Python ``True`` object. This object has no methods and is `immortal " -"`_." +"The Python ``True`` object. This object has no methods and is :term:" +"`immortal`." msgstr "" -"Python 的 ``True`` 物件。此物件沒有任何方法且為\\ `不滅的 (immortal) " -"`_。" +"Python 的 ``True`` 物件。此物件沒有任何方法且為\\ :term:`不滅的 `。" #: ../../c-api/bool.rst:40 -msgid ":c:data:`Py_True` is immortal." -msgstr ":c:data:`Py_True` 為不滅的。" +msgid ":c:data:`Py_True` is :term:`immortal`." +msgstr ":c:data:`Py_True` 為\\ :term:`不滅的 `。" #: ../../c-api/bool.rst:46 msgid "Return :c:data:`Py_False` from a function." diff --git a/c-api/buffer.po b/c-api/buffer.po index 7d80cf51b9..5248994757 100644 --- a/c-api/buffer.po +++ b/c-api/buffer.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2025-05-02 00:15+0000\n" "PO-Revision-Date: 2018-05-23 14:30+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -41,24 +41,26 @@ msgstr "" #: ../../c-api/buffer.rst:29 msgid "" -"Python provides such a facility at the C level in the form of the :ref:" -"`buffer protocol `. This protocol has two sides:" +"Python provides such a facility at the C and Python level in the form of " +"the :ref:`buffer protocol `. This protocol has two sides:" msgstr "" #: ../../c-api/buffer.rst:34 msgid "" "on the producer side, a type can export a \"buffer interface\" which allows " "objects of that type to expose information about their underlying buffer. " -"This interface is described in the section :ref:`buffer-structs`;" +"This interface is described in the section :ref:`buffer-structs`; for Python " +"see :ref:`python-buffer-protocol`." msgstr "" -#: ../../c-api/buffer.rst:38 +#: ../../c-api/buffer.rst:39 msgid "" "on the consumer side, several means are available to obtain a pointer to the " -"raw underlying data of an object (for example a method parameter)." +"raw underlying data of an object (for example a method parameter). For " +"Python see :class:`memoryview`." msgstr "" -#: ../../c-api/buffer.rst:41 +#: ../../c-api/buffer.rst:43 msgid "" "Simple objects such as :class:`bytes` and :class:`bytearray` expose their " "underlying buffer in byte-oriented form. Other forms are possible; for " @@ -66,7 +68,7 @@ msgid "" "values." msgstr "" -#: ../../c-api/buffer.rst:45 +#: ../../c-api/buffer.rst:47 msgid "" "An example consumer of the buffer interface is the :meth:`~io.BufferedIOBase." "write` method of file objects: any object that can export a series of bytes " @@ -78,23 +80,23 @@ msgid "" "buffers." msgstr "" -#: ../../c-api/buffer.rst:53 +#: ../../c-api/buffer.rst:55 msgid "" "There are two ways for a consumer of the buffer interface to acquire a " "buffer over a target object:" msgstr "" -#: ../../c-api/buffer.rst:56 +#: ../../c-api/buffer.rst:58 msgid "call :c:func:`PyObject_GetBuffer` with the right parameters;" msgstr "" -#: ../../c-api/buffer.rst:58 +#: ../../c-api/buffer.rst:60 msgid "" "call :c:func:`PyArg_ParseTuple` (or one of its siblings) with one of the " "``y*``, ``w*`` or ``s*`` :ref:`format codes `." msgstr "" -#: ../../c-api/buffer.rst:61 +#: ../../c-api/buffer.rst:63 msgid "" "In both cases, :c:func:`PyBuffer_Release` must be called when the buffer " "isn't needed anymore. Failure to do so could lead to various issues such as " @@ -102,10 +104,16 @@ msgid "" msgstr "" #: ../../c-api/buffer.rst:69 +msgid "" +"The buffer protocol is now accessible in Python, see :ref:`python-buffer-" +"protocol` and :class:`memoryview`." +msgstr "" + +#: ../../c-api/buffer.rst:75 msgid "Buffer structure" msgstr "" -#: ../../c-api/buffer.rst:71 +#: ../../c-api/buffer.rst:77 msgid "" "Buffer structures (or simply \"buffers\") are useful as a way to expose the " "binary data from another object to the Python programmer. They can also be " @@ -117,7 +125,7 @@ msgid "" "in its native, in-memory format." msgstr "" -#: ../../c-api/buffer.rst:80 +#: ../../c-api/buffer.rst:86 msgid "" "Contrary to most data types exposed by the Python interpreter, buffers are " "not :c:type:`PyObject` pointers but rather simple C structures. This allows " @@ -126,14 +134,14 @@ msgid "" "created." msgstr "" -#: ../../c-api/buffer.rst:86 +#: ../../c-api/buffer.rst:92 msgid "" "For short instructions how to write an exporting object, see :ref:`Buffer " "Object Structures `. For obtaining a buffer, see :c:func:" "`PyObject_GetBuffer`." msgstr "" -#: ../../c-api/buffer.rst:94 +#: ../../c-api/buffer.rst:100 msgid "" "A pointer to the start of the logical structure described by the buffer " "fields. This can be any location within the underlying physical memory block " @@ -141,13 +149,13 @@ msgid "" "the value may point to the end of the memory block." msgstr "" -#: ../../c-api/buffer.rst:99 +#: ../../c-api/buffer.rst:105 msgid "" "For :term:`contiguous` arrays, the value points to the beginning of the " "memory block." msgstr "" -#: ../../c-api/buffer.rst:104 +#: ../../c-api/buffer.rst:110 msgid "" "A new reference to the exporting object. The reference is owned by the " "consumer and automatically released (i.e. reference count decremented) and " @@ -155,14 +163,14 @@ msgid "" "of the return value of any standard C-API function." msgstr "" -#: ../../c-api/buffer.rst:111 +#: ../../c-api/buffer.rst:117 msgid "" "As a special case, for *temporary* buffers that are wrapped by :c:func:" "`PyMemoryView_FromBuffer` or :c:func:`PyBuffer_FillInfo` this field is " "``NULL``. In general, exporting objects MUST NOT use this scheme." msgstr "" -#: ../../c-api/buffer.rst:118 +#: ../../c-api/buffer.rst:124 msgid "" "``product(shape) * itemsize``. For contiguous arrays, this is the length of " "the underlying memory block. For non-contiguous arrays, it is the length " @@ -170,7 +178,7 @@ msgid "" "representation." msgstr "" -#: ../../c-api/buffer.rst:123 +#: ../../c-api/buffer.rst:129 msgid "" "Accessing ``((char *)buf)[0] up to ((char *)buf)[len-1]`` is only valid if " "the buffer has been obtained by a request that guarantees contiguity. In " @@ -178,19 +186,19 @@ msgid "" "`PyBUF_WRITABLE`." msgstr "" -#: ../../c-api/buffer.rst:129 +#: ../../c-api/buffer.rst:135 msgid "" "An indicator of whether the buffer is read-only. This field is controlled by " "the :c:macro:`PyBUF_WRITABLE` flag." msgstr "" -#: ../../c-api/buffer.rst:134 +#: ../../c-api/buffer.rst:140 msgid "" "Item size in bytes of a single element. Same as the value of :func:`struct." "calcsize` called on non-``NULL`` :c:member:`~Py_buffer.format` values." msgstr "" -#: ../../c-api/buffer.rst:137 +#: ../../c-api/buffer.rst:143 msgid "" "Important exception: If a consumer requests a buffer without the :c:macro:" "`PyBUF_FORMAT` flag, :c:member:`~Py_buffer.format` will be set to " @@ -198,32 +206,32 @@ msgid "" "original format." msgstr "" -#: ../../c-api/buffer.rst:142 +#: ../../c-api/buffer.rst:148 msgid "" "If :c:member:`~Py_buffer.shape` is present, the equality ``product(shape) * " "itemsize == len`` still holds and the consumer can use :c:member:`~Py_buffer." "itemsize` to navigate the buffer." msgstr "" -#: ../../c-api/buffer.rst:146 +#: ../../c-api/buffer.rst:152 msgid "" "If :c:member:`~Py_buffer.shape` is ``NULL`` as a result of a :c:macro:" "`PyBUF_SIMPLE` or a :c:macro:`PyBUF_WRITABLE` request, the consumer must " "disregard :c:member:`~Py_buffer.itemsize` and assume ``itemsize == 1``." msgstr "" -#: ../../c-api/buffer.rst:152 +#: ../../c-api/buffer.rst:158 msgid "" "A *NULL* terminated string in :mod:`struct` module style syntax describing " "the contents of a single item. If this is ``NULL``, ``\"B\"`` (unsigned " "bytes) is assumed." msgstr "" -#: ../../c-api/buffer.rst:156 +#: ../../c-api/buffer.rst:162 msgid "This field is controlled by the :c:macro:`PyBUF_FORMAT` flag." msgstr "" -#: ../../c-api/buffer.rst:160 +#: ../../c-api/buffer.rst:166 msgid "" "The number of dimensions the memory represents as an n-dimensional array. If " "it is ``0``, :c:member:`~Py_buffer.buf` points to a single item representing " @@ -232,7 +240,7 @@ msgid "" "number of dimensions is given by :c:macro:`PyBUF_MAX_NDIM`." msgstr "" -#: ../../c-api/buffer.rst:168 +#: ../../c-api/buffer.rst:174 msgid "" "An array of :c:type:`Py_ssize_t` of length :c:member:`~Py_buffer.ndim` " "indicating the shape of the memory as an n-dimensional array. Note that " @@ -240,34 +248,34 @@ msgid "" "`~Py_buffer.len`." msgstr "" -#: ../../c-api/buffer.rst:173 +#: ../../c-api/buffer.rst:179 msgid "" "Shape values are restricted to ``shape[n] >= 0``. The case ``shape[n] == 0`` " "requires special attention. See `complex arrays`_ for further information." msgstr "" -#: ../../c-api/buffer.rst:177 +#: ../../c-api/buffer.rst:183 msgid "The shape array is read-only for the consumer." msgstr "" -#: ../../c-api/buffer.rst:181 +#: ../../c-api/buffer.rst:187 msgid "" "An array of :c:type:`Py_ssize_t` of length :c:member:`~Py_buffer.ndim` " "giving the number of bytes to skip to get to a new element in each dimension." msgstr "" -#: ../../c-api/buffer.rst:185 +#: ../../c-api/buffer.rst:191 msgid "" "Stride values can be any integer. For regular arrays, strides are usually " "positive, but a consumer MUST be able to handle the case ``strides[n] <= " "0``. See `complex arrays`_ for further information." msgstr "" -#: ../../c-api/buffer.rst:189 +#: ../../c-api/buffer.rst:195 msgid "The strides array is read-only for the consumer." msgstr "" -#: ../../c-api/buffer.rst:193 +#: ../../c-api/buffer.rst:199 msgid "" "An array of :c:type:`Py_ssize_t` of length :c:member:`~Py_buffer.ndim`. If " "``suboffsets[n] >= 0``, the values stored along the nth dimension are " @@ -276,24 +284,24 @@ msgid "" "that no de-referencing should occur (striding in a contiguous memory block)." msgstr "" -#: ../../c-api/buffer.rst:200 +#: ../../c-api/buffer.rst:206 msgid "" "If all suboffsets are negative (i.e. no de-referencing is needed), then this " "field must be ``NULL`` (the default value)." msgstr "" -#: ../../c-api/buffer.rst:203 +#: ../../c-api/buffer.rst:209 msgid "" "This type of array representation is used by the Python Imaging Library " "(PIL). See `complex arrays`_ for further information how to access elements " "of such an array." msgstr "" -#: ../../c-api/buffer.rst:207 +#: ../../c-api/buffer.rst:213 msgid "The suboffsets array is read-only for the consumer." msgstr "" -#: ../../c-api/buffer.rst:211 +#: ../../c-api/buffer.rst:217 msgid "" "This is for use internally by the exporting object. For example, this might " "be re-cast as an integer by the exporter and used to store flags about " @@ -301,22 +309,22 @@ msgid "" "the buffer is released. The consumer MUST NOT alter this value." msgstr "" -#: ../../c-api/buffer.rst:218 +#: ../../c-api/buffer.rst:224 msgid "Constants:" msgstr "常數:" -#: ../../c-api/buffer.rst:222 +#: ../../c-api/buffer.rst:228 msgid "" "The maximum number of dimensions the memory represents. Exporters MUST " "respect this limit, consumers of multi-dimensional buffers SHOULD be able to " "handle up to :c:macro:`!PyBUF_MAX_NDIM` dimensions. Currently set to 64." msgstr "" -#: ../../c-api/buffer.rst:231 +#: ../../c-api/buffer.rst:237 msgid "Buffer request types" msgstr "" -#: ../../c-api/buffer.rst:233 +#: ../../c-api/buffer.rst:239 msgid "" "Buffers are usually obtained by sending a buffer request to an exporting " "object via :c:func:`PyObject_GetBuffer`. Since the complexity of the logical " @@ -324,16 +332,16 @@ msgid "" "argument to specify the exact buffer type it can handle." msgstr "" -#: ../../c-api/buffer.rst:238 +#: ../../c-api/buffer.rst:244 msgid "" "All :c:type:`Py_buffer` fields are unambiguously defined by the request type." msgstr "" -#: ../../c-api/buffer.rst:242 +#: ../../c-api/buffer.rst:248 msgid "request-independent fields" msgstr "" -#: ../../c-api/buffer.rst:243 +#: ../../c-api/buffer.rst:249 msgid "" "The following fields are not influenced by *flags* and must always be filled " "in with the correct values: :c:member:`~Py_buffer.obj`, :c:member:" @@ -341,25 +349,26 @@ msgid "" "itemsize`, :c:member:`~Py_buffer.ndim`." msgstr "" -#: ../../c-api/buffer.rst:249 +#: ../../c-api/buffer.rst:254 msgid "readonly, format" msgstr "" -#: ../../c-api/buffer.rst:253 +#: ../../c-api/buffer.rst:258 msgid "" "Controls the :c:member:`~Py_buffer.readonly` 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." +"MUST be consistent for all consumers. For example, :c:expr:`PyBUF_SIMPLE | " +"PyBUF_WRITABLE` can be used to request a simple writable buffer." msgstr "" -#: ../../c-api/buffer.rst:260 +#: ../../c-api/buffer.rst:266 msgid "" "Controls the :c:member:`~Py_buffer.format` field. If set, this field MUST be " "filled in correctly. Otherwise, this field MUST be ``NULL``." msgstr "" -#: ../../c-api/buffer.rst:264 +#: ../../c-api/buffer.rst:270 msgid "" ":c:macro:`PyBUF_WRITABLE` can be \\|'d to any of the flags in the next " "section. Since :c:macro:`PyBUF_SIMPLE` is defined as 0, :c:macro:" @@ -367,158 +376,159 @@ msgid "" "writable buffer." msgstr "" -#: ../../c-api/buffer.rst:268 +#: ../../c-api/buffer.rst:274 msgid "" -":c:macro:`PyBUF_FORMAT` can be \\|'d to any of the flags except :c:macro:" -"`PyBUF_SIMPLE`. The latter already implies format ``B`` (unsigned bytes)." +":c:macro:`PyBUF_FORMAT` must be \\|'d to any of the flags except :c:macro:" +"`PyBUF_SIMPLE`, because the latter already implies format ``B`` (unsigned " +"bytes). :c:macro:`!PyBUF_FORMAT` cannot be used on its own." msgstr "" -#: ../../c-api/buffer.rst:273 +#: ../../c-api/buffer.rst:280 msgid "shape, strides, suboffsets" msgstr "" -#: ../../c-api/buffer.rst:275 +#: ../../c-api/buffer.rst:282 msgid "" "The flags that control the logical structure of the memory are listed in " "decreasing order of complexity. Note that each flag contains all bits of the " "flags below it." msgstr "" -#: ../../c-api/buffer.rst:282 ../../c-api/buffer.rst:306 -#: ../../c-api/buffer.rst:331 +#: ../../c-api/buffer.rst:289 ../../c-api/buffer.rst:313 +#: ../../c-api/buffer.rst:338 msgid "Request" msgstr "" -#: ../../c-api/buffer.rst:282 ../../c-api/buffer.rst:306 -#: ../../c-api/buffer.rst:331 +#: ../../c-api/buffer.rst:289 ../../c-api/buffer.rst:313 +#: ../../c-api/buffer.rst:338 msgid "shape" msgstr "" -#: ../../c-api/buffer.rst:282 ../../c-api/buffer.rst:306 -#: ../../c-api/buffer.rst:331 +#: ../../c-api/buffer.rst:289 ../../c-api/buffer.rst:313 +#: ../../c-api/buffer.rst:338 msgid "strides" msgstr "" -#: ../../c-api/buffer.rst:282 ../../c-api/buffer.rst:306 -#: ../../c-api/buffer.rst:331 +#: ../../c-api/buffer.rst:289 ../../c-api/buffer.rst:313 +#: ../../c-api/buffer.rst:338 msgid "suboffsets" msgstr "" -#: ../../c-api/buffer.rst:284 ../../c-api/buffer.rst:286 -#: ../../c-api/buffer.rst:288 ../../c-api/buffer.rst:308 -#: ../../c-api/buffer.rst:310 ../../c-api/buffer.rst:312 -#: ../../c-api/buffer.rst:314 ../../c-api/buffer.rst:333 -#: ../../c-api/buffer.rst:335 ../../c-api/buffer.rst:337 -#: ../../c-api/buffer.rst:339 ../../c-api/buffer.rst:341 -#: ../../c-api/buffer.rst:343 ../../c-api/buffer.rst:345 -#: ../../c-api/buffer.rst:347 +#: ../../c-api/buffer.rst:291 ../../c-api/buffer.rst:293 +#: ../../c-api/buffer.rst:295 ../../c-api/buffer.rst:315 +#: ../../c-api/buffer.rst:317 ../../c-api/buffer.rst:319 +#: ../../c-api/buffer.rst:321 ../../c-api/buffer.rst:340 +#: ../../c-api/buffer.rst:342 ../../c-api/buffer.rst:344 +#: ../../c-api/buffer.rst:346 ../../c-api/buffer.rst:348 +#: ../../c-api/buffer.rst:350 ../../c-api/buffer.rst:352 +#: ../../c-api/buffer.rst:354 msgid "yes" msgstr "" -#: ../../c-api/buffer.rst:284 ../../c-api/buffer.rst:333 -#: ../../c-api/buffer.rst:335 +#: ../../c-api/buffer.rst:291 ../../c-api/buffer.rst:340 +#: ../../c-api/buffer.rst:342 msgid "if needed" msgstr "" -#: ../../c-api/buffer.rst:286 ../../c-api/buffer.rst:288 -#: ../../c-api/buffer.rst:290 ../../c-api/buffer.rst:308 -#: ../../c-api/buffer.rst:310 ../../c-api/buffer.rst:312 -#: ../../c-api/buffer.rst:314 ../../c-api/buffer.rst:337 -#: ../../c-api/buffer.rst:339 ../../c-api/buffer.rst:341 -#: ../../c-api/buffer.rst:343 ../../c-api/buffer.rst:345 -#: ../../c-api/buffer.rst:347 +#: ../../c-api/buffer.rst:293 ../../c-api/buffer.rst:295 +#: ../../c-api/buffer.rst:297 ../../c-api/buffer.rst:315 +#: ../../c-api/buffer.rst:317 ../../c-api/buffer.rst:319 +#: ../../c-api/buffer.rst:321 ../../c-api/buffer.rst:344 +#: ../../c-api/buffer.rst:346 ../../c-api/buffer.rst:348 +#: ../../c-api/buffer.rst:350 ../../c-api/buffer.rst:352 +#: ../../c-api/buffer.rst:354 msgid "NULL" msgstr "NULL" -#: ../../c-api/buffer.rst:297 +#: ../../c-api/buffer.rst:304 msgid "contiguity requests" msgstr "" -#: ../../c-api/buffer.rst:299 +#: ../../c-api/buffer.rst:306 msgid "" "C or Fortran :term:`contiguity ` can be explicitly requested, " "with and without stride information. Without stride information, the buffer " "must be C-contiguous." msgstr "" -#: ../../c-api/buffer.rst:306 ../../c-api/buffer.rst:331 +#: ../../c-api/buffer.rst:313 ../../c-api/buffer.rst:338 msgid "contig" msgstr "" -#: ../../c-api/buffer.rst:308 ../../c-api/buffer.rst:314 -#: ../../c-api/buffer.rst:345 ../../c-api/buffer.rst:347 +#: ../../c-api/buffer.rst:315 ../../c-api/buffer.rst:321 +#: ../../c-api/buffer.rst:352 ../../c-api/buffer.rst:354 msgid "C" msgstr "C" -#: ../../c-api/buffer.rst:310 +#: ../../c-api/buffer.rst:317 msgid "F" msgstr "F" -#: ../../c-api/buffer.rst:312 +#: ../../c-api/buffer.rst:319 msgid "C or F" msgstr "C 或 F" -#: ../../c-api/buffer.rst:314 +#: ../../c-api/buffer.rst:321 msgid ":c:macro:`PyBUF_ND`" msgstr ":c:macro:`PyBUF_ND`" -#: ../../c-api/buffer.rst:319 +#: ../../c-api/buffer.rst:326 msgid "compound requests" msgstr "" -#: ../../c-api/buffer.rst:321 +#: ../../c-api/buffer.rst:328 msgid "" "All possible requests are fully defined by some combination of the flags in " "the previous section. For convenience, the buffer protocol provides " "frequently used combinations as single flags." msgstr "" -#: ../../c-api/buffer.rst:325 +#: ../../c-api/buffer.rst:332 msgid "" "In the following table *U* stands for undefined contiguity. The consumer " "would have to call :c:func:`PyBuffer_IsContiguous` to determine contiguity." msgstr "" -#: ../../c-api/buffer.rst:331 +#: ../../c-api/buffer.rst:338 msgid "readonly" msgstr "" -#: ../../c-api/buffer.rst:331 +#: ../../c-api/buffer.rst:338 msgid "format" msgstr "" -#: ../../c-api/buffer.rst:333 ../../c-api/buffer.rst:335 -#: ../../c-api/buffer.rst:337 ../../c-api/buffer.rst:339 -#: ../../c-api/buffer.rst:341 ../../c-api/buffer.rst:343 +#: ../../c-api/buffer.rst:340 ../../c-api/buffer.rst:342 +#: ../../c-api/buffer.rst:344 ../../c-api/buffer.rst:346 +#: ../../c-api/buffer.rst:348 ../../c-api/buffer.rst:350 msgid "U" msgstr "U" -#: ../../c-api/buffer.rst:333 ../../c-api/buffer.rst:337 -#: ../../c-api/buffer.rst:341 ../../c-api/buffer.rst:345 +#: ../../c-api/buffer.rst:340 ../../c-api/buffer.rst:344 +#: ../../c-api/buffer.rst:348 ../../c-api/buffer.rst:352 msgid "0" msgstr "0" -#: ../../c-api/buffer.rst:335 ../../c-api/buffer.rst:339 -#: ../../c-api/buffer.rst:343 ../../c-api/buffer.rst:347 +#: ../../c-api/buffer.rst:342 ../../c-api/buffer.rst:346 +#: ../../c-api/buffer.rst:350 ../../c-api/buffer.rst:354 msgid "1 or 0" msgstr "1 或 0" -#: ../../c-api/buffer.rst:352 +#: ../../c-api/buffer.rst:359 msgid "Complex arrays" msgstr "" -#: ../../c-api/buffer.rst:355 +#: ../../c-api/buffer.rst:362 msgid "NumPy-style: shape and strides" msgstr "" -#: ../../c-api/buffer.rst:357 +#: ../../c-api/buffer.rst:364 msgid "" "The logical structure of NumPy-style arrays is defined by :c:member:" "`~Py_buffer.itemsize`, :c:member:`~Py_buffer.ndim`, :c:member:`~Py_buffer." "shape` and :c:member:`~Py_buffer.strides`." msgstr "" -#: ../../c-api/buffer.rst:360 +#: ../../c-api/buffer.rst:367 msgid "" "If ``ndim == 0``, the memory location pointed to by :c:member:`~Py_buffer." "buf` is interpreted as a scalar of size :c:member:`~Py_buffer.itemsize`. In " @@ -526,14 +536,14 @@ msgid "" "strides` are ``NULL``." msgstr "" -#: ../../c-api/buffer.rst:364 +#: ../../c-api/buffer.rst:371 msgid "" "If :c:member:`~Py_buffer.strides` is ``NULL``, the array is interpreted as a " "standard n-dimensional C-array. Otherwise, the consumer must access an n-" "dimensional array as follows:" msgstr "" -#: ../../c-api/buffer.rst:368 +#: ../../c-api/buffer.rst:375 msgid "" "ptr = (char *)buf + indices[0] * strides[0] + ... + indices[n-1] * " "strides[n-1];\n" @@ -543,14 +553,14 @@ msgstr "" "strides[n-1];\n" "item = *((typeof(item) *)ptr);" -#: ../../c-api/buffer.rst:374 +#: ../../c-api/buffer.rst:381 msgid "" "As noted above, :c:member:`~Py_buffer.buf` can point to any location within " "the actual memory block. An exporter can check the validity of a buffer with " "this function:" msgstr "" -#: ../../c-api/buffer.rst:378 +#: ../../c-api/buffer.rst:385 msgid "" "def verify_structure(memlen, itemsize, ndim, shape, strides, offset):\n" " \"\"\"Verify that the parameters represent a valid array within\n" @@ -579,11 +589,11 @@ msgid "" " return 0 <= offset+imin and offset+imax+itemsize <= memlen" msgstr "" -#: ../../c-api/buffer.rst:408 +#: ../../c-api/buffer.rst:415 msgid "PIL-style: shape, strides and suboffsets" msgstr "" -#: ../../c-api/buffer.rst:410 +#: ../../c-api/buffer.rst:417 msgid "" "In addition to the regular items, PIL-style arrays can contain pointers that " "must be followed in order to get to the next element in a dimension. For " @@ -594,14 +604,14 @@ msgid "" "x[2][3]`` arrays that can be located anywhere in memory." msgstr "" -#: ../../c-api/buffer.rst:419 +#: ../../c-api/buffer.rst:426 msgid "" "Here is a function that returns a pointer to the element in an N-D array " "pointed to by an N-dimensional index when there are both non-``NULL`` " "strides and suboffsets::" msgstr "" -#: ../../c-api/buffer.rst:423 +#: ../../c-api/buffer.rst:430 msgid "" "void *get_item_pointer(int ndim, void *buf, Py_ssize_t *strides,\n" " Py_ssize_t *suboffsets, Py_ssize_t *indices) {\n" @@ -629,25 +639,25 @@ msgstr "" " return (void*)pointer;\n" "}" -#: ../../c-api/buffer.rst:438 +#: ../../c-api/buffer.rst:445 msgid "Buffer-related functions" msgstr "" -#: ../../c-api/buffer.rst:442 +#: ../../c-api/buffer.rst:449 msgid "" "Return ``1`` if *obj* supports the buffer interface otherwise ``0``. When " "``1`` is returned, it doesn't guarantee that :c:func:`PyObject_GetBuffer` " "will succeed. This function always succeeds." msgstr "" -#: ../../c-api/buffer.rst:449 +#: ../../c-api/buffer.rst:456 msgid "" "Send a request to *exporter* to fill in *view* as specified by *flags*. If " "the exporter cannot provide a buffer of the exact type, it MUST raise :exc:" "`BufferError`, set ``view->obj`` to ``NULL`` and return ``-1``." msgstr "" -#: ../../c-api/buffer.rst:454 +#: ../../c-api/buffer.rst:461 msgid "" "On success, fill in *view*, set ``view->obj`` to a new reference to " "*exporter* and return 0. In the case of chained buffer providers that " @@ -655,7 +665,7 @@ msgid "" "instead of *exporter* (See :ref:`Buffer Object Structures `)." msgstr "" -#: ../../c-api/buffer.rst:459 +#: ../../c-api/buffer.rst:466 msgid "" "Successful calls to :c:func:`PyObject_GetBuffer` must be paired with calls " "to :c:func:`PyBuffer_Release`, similar to :c:func:`malloc` and :c:func:" @@ -663,7 +673,7 @@ msgid "" "`PyBuffer_Release` must be called exactly once." msgstr "" -#: ../../c-api/buffer.rst:467 +#: ../../c-api/buffer.rst:474 msgid "" "Release the buffer *view* and release the :term:`strong reference` (i.e. " "decrement the reference count) to the view's supporting object, ``view-" @@ -671,19 +681,19 @@ msgid "" "used, otherwise reference leaks may occur." msgstr "" -#: ../../c-api/buffer.rst:472 +#: ../../c-api/buffer.rst:479 msgid "" "It is an error to call this function on a buffer that was not obtained via :" "c:func:`PyObject_GetBuffer`." msgstr "" -#: ../../c-api/buffer.rst:478 +#: ../../c-api/buffer.rst:485 msgid "" "Return the implied :c:member:`~Py_buffer.itemsize` from :c:member:" "`~Py_buffer.format`. On error, raise an exception and return -1." msgstr "" -#: ../../c-api/buffer.rst:486 +#: ../../c-api/buffer.rst:493 msgid "" "Return ``1`` if the memory defined by the *view* is C-style (*order* is " "``'C'``) or Fortran-style (*order* is ``'F'``) :term:`contiguous` or either " @@ -691,69 +701,69 @@ msgid "" "succeeds." msgstr "" -#: ../../c-api/buffer.rst:493 +#: ../../c-api/buffer.rst:500 msgid "" "Get the memory area pointed to by the *indices* inside the given *view*. " "*indices* must point to an array of ``view->ndim`` indices." msgstr "" -#: ../../c-api/buffer.rst:499 +#: ../../c-api/buffer.rst:506 msgid "" "Copy contiguous *len* bytes from *buf* to *view*. *fort* can be ``'C'`` or " "``'F'`` (for C-style or Fortran-style ordering). ``0`` is returned on " "success, ``-1`` on error." msgstr "" -#: ../../c-api/buffer.rst:506 +#: ../../c-api/buffer.rst:513 msgid "" "Copy *len* bytes from *src* to its contiguous representation in *buf*. " "*order* can be ``'C'`` or ``'F'`` or ``'A'`` (for C-style or Fortran-style " "ordering or either one). ``0`` is returned on success, ``-1`` on error." msgstr "" -#: ../../c-api/buffer.rst:510 +#: ../../c-api/buffer.rst:517 msgid "This function fails if *len* != *src->len*." msgstr "" -#: ../../c-api/buffer.rst:515 +#: ../../c-api/buffer.rst:522 msgid "" "Copy data from *src* to *dest* buffer. Can convert between C-style and or " "Fortran-style buffers." msgstr "" -#: ../../c-api/buffer.rst:518 +#: ../../c-api/buffer.rst:525 msgid "``0`` is returned on success, ``-1`` on error." msgstr "" -#: ../../c-api/buffer.rst:522 +#: ../../c-api/buffer.rst:529 msgid "" "Fill the *strides* array with byte-strides of a :term:`contiguous` (C-style " "if *order* is ``'C'`` or Fortran-style if *order* is ``'F'``) array of the " "given shape with the given number of bytes per element." msgstr "" -#: ../../c-api/buffer.rst:529 +#: ../../c-api/buffer.rst:536 msgid "" "Handle buffer requests for an exporter that wants to expose *buf* of size " "*len* with writability set according to *readonly*. *buf* is interpreted as " "a sequence of unsigned bytes." msgstr "" -#: ../../c-api/buffer.rst:533 +#: ../../c-api/buffer.rst:540 msgid "" "The *flags* argument indicates the request type. This function always fills " "in *view* as specified by flags, unless *buf* has been designated as read-" "only and :c:macro:`PyBUF_WRITABLE` is set in *flags*." msgstr "" -#: ../../c-api/buffer.rst:537 +#: ../../c-api/buffer.rst:544 msgid "" "On success, set ``view->obj`` to a new reference to *exporter* and return 0. " "Otherwise, raise :exc:`BufferError`, set ``view->obj`` to ``NULL`` and " "return ``-1``;" msgstr "" -#: ../../c-api/buffer.rst:541 +#: ../../c-api/buffer.rst:548 msgid "" "If this function is used as part of a :ref:`getbufferproc `, " "*exporter* MUST be set to the exporting object and *flags* must be passed " @@ -780,14 +790,14 @@ msgstr "buffer object(緩衝物件)" msgid "PyBufferProcs (C type)" msgstr "PyBufferProcs(C 型別)" -#: ../../c-api/buffer.rst:294 +#: ../../c-api/buffer.rst:301 msgid "contiguous" msgstr "contiguous(連續的)" -#: ../../c-api/buffer.rst:294 +#: ../../c-api/buffer.rst:301 msgid "C-contiguous" msgstr "C-contiguous(C 連續的)" -#: ../../c-api/buffer.rst:294 +#: ../../c-api/buffer.rst:301 msgid "Fortran contiguous" msgstr "Fortran contiguous(Fortran 連續的)" diff --git a/c-api/bytearray.po b/c-api/bytearray.po index b99829a933..183f9f7fa0 100644 --- a/c-api/bytearray.po +++ b/c-api/bytearray.po @@ -5,7 +5,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-08-04 00:03+0000\n" "PO-Revision-Date: 2023-08-12 11:42+0800\n" @@ -65,7 +65,7 @@ msgid "" "Return a new bytearray object from any object, *o*, that implements the :ref:" "`buffer protocol `." msgstr "" -"由任意物件 *o* 回傳一個新的位元組陣列物件,並實作了\\ :ref:`緩衝協議 (buffer " +"由任意物件 *o* 回傳一個新的位元組陣列物件,並實作了\\ :ref:`緩衝協定 (buffer " "protocol) `。" #: ../../c-api/bytearray.rst:45 ../../c-api/bytearray.rst:52 diff --git a/c-api/bytes.po b/c-api/bytes.po index e70159eeb0..4cb4ac8545 100644 --- a/c-api/bytes.po +++ b/c-api/bytes.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-12-26 00:03+0000\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2018-05-23 14:04+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -316,16 +316,14 @@ msgstr "" #: ../../c-api/bytes.rst:194 msgid "" -"A way to resize a bytes object even though it is \"immutable\". Only use " -"this to build up a brand new bytes object; don't use this if the bytes may " -"already be known in other parts of the code. It is an error to call this " -"function if the refcount on the input bytes object is not one. 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``, :exc:`MemoryError` " -"is set, and ``-1`` is returned." +"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``, :exc:`MemoryError` is set, and ``-1`` is returned." msgstr "" #: ../../c-api/bytes.rst:11 diff --git a/c-api/call.po b/c-api/call.po index 481a78e876..ada203379c 100644 --- a/c-api/call.po +++ b/c-api/call.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,9 +6,9 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2022-10-16 03:20+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -122,6 +122,11 @@ msgid "" "versions, vectorcall should only be used with :c:macro:`immutable " "` or static types." msgstr "" +"當一個類別的 :py:meth:`~object.__call__` 方法被重新賦值時,:c:macro:" +"`Py_TPFLAGS_HAVE_VECTORCALL` 旗標現在會被移除。(這會在內部設定 :c:member:" +"`~PyTypeObject.tp_call`,因此可能會使它與 vectorcall 函式有不同的行為。)" +"在較早的 Python 版本中,vectorcall 應該只與 :c:macro:" +"`immutable ` 或靜態型別一起使用。" #: ../../c-api/call.rst:69 msgid "" @@ -227,30 +232,11 @@ msgstr "" "要呼叫一個實作了 vectorcall 的物件,請就像其他可呼叫物件一樣使用\\ :ref:`呼" "叫 API` 中的函式。:c:func:`PyObject_Vectorcall` 通常是最有效率的。" -#: ../../c-api/call.rst:120 -msgid "" -"In CPython 3.8, the vectorcall API and related functions were available " -"provisionally under names with a leading underscore: " -"``_PyObject_Vectorcall``, ``_Py_TPFLAGS_HAVE_VECTORCALL``, " -"``_PyObject_VectorcallMethod``, ``_PyVectorcall_Function``, " -"``_PyObject_CallOneArg``, ``_PyObject_CallMethodNoArgs``, " -"``_PyObject_CallMethodOneArg``. Additionally, ``PyObject_VectorcallDict`` " -"was available as ``_PyObject_FastCallDict``. The old names are still defined " -"as aliases of the new, non-underscored names." -msgstr "" -"在 CPython 3.8 中,vectorcall API 和相關函式暫定以帶開頭底線的名稱提供:" -"``_PyObject_Vectorcall``、``_Py_TPFLAGS_HAVE_VECTORCALL``、" -"``_PyObject_VectorcallMethod``、``_PyVectorcall_Function``、" -"``_PyObject_CallOneArg``、``_PyObject_CallMethodNoArgs``、" -"``_PyObject_CallMethodOneArg``。此外,``PyObject_VectorcallDict`` 也以 " -"``_PyObject_FastCallDict`` 名稱提供。這些舊名稱仍有被定義,做為不帶底線的新名" -"稱的別名。" - -#: ../../c-api/call.rst:132 +#: ../../c-api/call.rst:119 msgid "Recursion Control" msgstr "遞迴控制" -#: ../../c-api/call.rst:134 +#: ../../c-api/call.rst:121 msgid "" "When using *tp_call*, callees do not need to worry about :ref:`recursion " "`: CPython uses :c:func:`Py_EnterRecursiveCall` and :c:func:" @@ -260,7 +246,7 @@ msgstr "" "使用 *tp_call* 的呼叫會使用 :c:func:`Py_EnterRecursiveCall` 和 :c:func:" "`Py_LeaveRecursiveCall`。" -#: ../../c-api/call.rst:139 +#: ../../c-api/call.rst:126 msgid "" "For efficiency, this is not the case for calls done using vectorcall: the " "callee should use *Py_EnterRecursiveCall* and *Py_LeaveRecursiveCall* if " @@ -269,27 +255,27 @@ msgstr "" "為保證效率,這不適用於使用 vectorcall 的呼叫:被呼叫方在需要時應當使用 " "*Py_EnterRecursiveCall* 和 *Py_LeaveRecursiveCall*。" -#: ../../c-api/call.rst:145 +#: ../../c-api/call.rst:132 msgid "Vectorcall Support API" msgstr "Vectorcall 支援 API" -#: ../../c-api/call.rst:149 +#: ../../c-api/call.rst:136 msgid "" "Given a vectorcall *nargsf* argument, return the actual number of arguments. " "Currently equivalent to::" msgstr "給定一個 vectorcall *nargsf* 引數,回傳引數的實際數量。目前等同於: ::" -#: ../../c-api/call.rst:153 +#: ../../c-api/call.rst:140 msgid "(Py_ssize_t)(nargsf & ~PY_VECTORCALL_ARGUMENTS_OFFSET)" msgstr "(Py_ssize_t)(nargsf & ~PY_VECTORCALL_ARGUMENTS_OFFSET)" -#: ../../c-api/call.rst:155 +#: ../../c-api/call.rst:142 msgid "" "However, the function ``PyVectorcall_NARGS`` should be used to allow for " "future extensions." msgstr "然而,應使用 ``PyVectorcall_NARGS`` 函式以便將來需要擴充。" -#: ../../c-api/call.rst:162 +#: ../../c-api/call.rst:149 msgid "" "If *op* does not support the vectorcall protocol (either because the type " "does not or because the specific instance does not), return *NULL*. " @@ -300,7 +286,7 @@ msgstr "" "*NULL*。否則,回傳儲存在 *op* 中的 vectorcall 函式指標。這個函式不會引發例" "外。" -#: ../../c-api/call.rst:167 +#: ../../c-api/call.rst:154 msgid "" "This is mostly useful to check whether or not *op* supports vectorcall, " "which can be done by checking ``PyVectorcall_Function(op) != NULL``." @@ -308,7 +294,7 @@ msgstr "" "這大多在檢查 *op* 是否支援 vectorcall 時能派上用場,可以透過檢查 " "``PyVectorcall_Function(op) != NULL`` 來達成。" -#: ../../c-api/call.rst:174 +#: ../../c-api/call.rst:161 msgid "" "Call *callable*'s :c:type:`vectorcallfunc` with positional and keyword " "arguments given in a tuple and dict, respectively." @@ -316,7 +302,7 @@ msgstr "" "呼叫 *callable* 的 :c:type:`vectorcallfunc`,其位置引數和關鍵字引數分別以 " "tuple 和 dict 格式給定。" -#: ../../c-api/call.rst:177 +#: ../../c-api/call.rst:164 msgid "" "This is a specialized function, intended to be put in the :c:member:" "`~PyTypeObject.tp_call` slot or be used in an implementation of ``tp_call``. " @@ -327,11 +313,11 @@ msgstr "" "用於 ``tp_call`` 的實作。它不會檢查 :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` 旗" "標並且它不會退回 (fall back) 使用 ``tp_call``。" -#: ../../c-api/call.rst:188 +#: ../../c-api/call.rst:175 msgid "Object Calling API" msgstr "物件呼叫 API" -#: ../../c-api/call.rst:190 +#: ../../c-api/call.rst:177 msgid "" "Various functions are available for calling a Python object. Each converts " "its arguments to a convention supported by the called object – either " @@ -342,133 +328,133 @@ msgstr "" "的慣用形式 – 可以是 *tp_call* 或 vectorcall。為了儘可能減少轉換的進行,請選擇" "一個適合你所擁有資料格式的函式。" -#: ../../c-api/call.rst:196 +#: ../../c-api/call.rst:183 msgid "" "The following table summarizes the available functions; please see " "individual documentation for details." msgstr "下表總結了可用的函式;請參閱各個說明文件以瞭解詳情。" -#: ../../c-api/call.rst:200 +#: ../../c-api/call.rst:187 msgid "Function" msgstr "函式" -#: ../../c-api/call.rst:200 +#: ../../c-api/call.rst:187 msgid "callable" msgstr "callable" -#: ../../c-api/call.rst:200 +#: ../../c-api/call.rst:187 msgid "args" msgstr "args" -#: ../../c-api/call.rst:200 +#: ../../c-api/call.rst:187 msgid "kwargs" msgstr "kwargs" -#: ../../c-api/call.rst:202 +#: ../../c-api/call.rst:189 msgid ":c:func:`PyObject_Call`" msgstr ":c:func:`PyObject_Call`" -#: ../../c-api/call.rst:202 ../../c-api/call.rst:204 ../../c-api/call.rst:206 -#: ../../c-api/call.rst:208 ../../c-api/call.rst:210 ../../c-api/call.rst:214 -#: ../../c-api/call.rst:222 ../../c-api/call.rst:224 +#: ../../c-api/call.rst:189 ../../c-api/call.rst:191 ../../c-api/call.rst:193 +#: ../../c-api/call.rst:195 ../../c-api/call.rst:197 ../../c-api/call.rst:201 +#: ../../c-api/call.rst:209 ../../c-api/call.rst:211 msgid "``PyObject *``" msgstr "``PyObject *``" -#: ../../c-api/call.rst:202 +#: ../../c-api/call.rst:189 msgid "tuple" msgstr "tuple" -#: ../../c-api/call.rst:202 ../../c-api/call.rst:224 +#: ../../c-api/call.rst:189 ../../c-api/call.rst:211 msgid "dict/``NULL``" msgstr "dict/``NULL``" -#: ../../c-api/call.rst:204 +#: ../../c-api/call.rst:191 msgid ":c:func:`PyObject_CallNoArgs`" msgstr ":c:func:`PyObject_CallNoArgs`" -#: ../../c-api/call.rst:204 ../../c-api/call.rst:206 ../../c-api/call.rst:208 -#: ../../c-api/call.rst:210 ../../c-api/call.rst:212 ../../c-api/call.rst:214 -#: ../../c-api/call.rst:216 ../../c-api/call.rst:218 ../../c-api/call.rst:220 +#: ../../c-api/call.rst:191 ../../c-api/call.rst:193 ../../c-api/call.rst:195 +#: ../../c-api/call.rst:197 ../../c-api/call.rst:199 ../../c-api/call.rst:201 +#: ../../c-api/call.rst:203 ../../c-api/call.rst:205 ../../c-api/call.rst:207 msgid "---" msgstr "---" -#: ../../c-api/call.rst:206 +#: ../../c-api/call.rst:193 msgid ":c:func:`PyObject_CallOneArg`" msgstr ":c:func:`PyObject_CallOneArg`" -#: ../../c-api/call.rst:206 ../../c-api/call.rst:220 +#: ../../c-api/call.rst:193 ../../c-api/call.rst:207 msgid "1 object" msgstr "一個物件" -#: ../../c-api/call.rst:208 +#: ../../c-api/call.rst:195 msgid ":c:func:`PyObject_CallObject`" msgstr ":c:func:`PyObject_CallObject`" -#: ../../c-api/call.rst:208 +#: ../../c-api/call.rst:195 msgid "tuple/``NULL``" msgstr "tuple/``NULL``" -#: ../../c-api/call.rst:210 +#: ../../c-api/call.rst:197 msgid ":c:func:`PyObject_CallFunction`" msgstr ":c:func:`PyObject_CallFunction`" -#: ../../c-api/call.rst:210 ../../c-api/call.rst:212 +#: ../../c-api/call.rst:197 ../../c-api/call.rst:199 msgid "format" msgstr "format" -#: ../../c-api/call.rst:212 +#: ../../c-api/call.rst:199 msgid ":c:func:`PyObject_CallMethod`" msgstr ":c:func:`PyObject_CallMethod`" -#: ../../c-api/call.rst:212 +#: ../../c-api/call.rst:199 msgid "obj + ``char*``" msgstr "物件 + ``char*``" -#: ../../c-api/call.rst:214 +#: ../../c-api/call.rst:201 msgid ":c:func:`PyObject_CallFunctionObjArgs`" msgstr ":c:func:`PyObject_CallFunctionObjArgs`" -#: ../../c-api/call.rst:214 ../../c-api/call.rst:216 +#: ../../c-api/call.rst:201 ../../c-api/call.rst:203 msgid "variadic" msgstr "可變引數" -#: ../../c-api/call.rst:216 +#: ../../c-api/call.rst:203 msgid ":c:func:`PyObject_CallMethodObjArgs`" msgstr ":c:func:`PyObject_CallMethodObjArgs`" -#: ../../c-api/call.rst:216 ../../c-api/call.rst:218 ../../c-api/call.rst:220 +#: ../../c-api/call.rst:203 ../../c-api/call.rst:205 ../../c-api/call.rst:207 msgid "obj + name" msgstr "物件 + 名稱" -#: ../../c-api/call.rst:218 +#: ../../c-api/call.rst:205 msgid ":c:func:`PyObject_CallMethodNoArgs`" msgstr ":c:func:`PyObject_CallMethodNoArgs`" -#: ../../c-api/call.rst:220 +#: ../../c-api/call.rst:207 msgid ":c:func:`PyObject_CallMethodOneArg`" msgstr ":c:func:`PyObject_CallMethodOneArg`" -#: ../../c-api/call.rst:222 +#: ../../c-api/call.rst:209 msgid ":c:func:`PyObject_Vectorcall`" msgstr ":c:func:`PyObject_Vectorcall`" -#: ../../c-api/call.rst:222 ../../c-api/call.rst:224 ../../c-api/call.rst:226 +#: ../../c-api/call.rst:209 ../../c-api/call.rst:211 ../../c-api/call.rst:213 msgid "vectorcall" msgstr "vectorcall" -#: ../../c-api/call.rst:224 +#: ../../c-api/call.rst:211 msgid ":c:func:`PyObject_VectorcallDict`" msgstr ":c:func:`PyObject_VectorcallDict`" -#: ../../c-api/call.rst:226 +#: ../../c-api/call.rst:213 msgid ":c:func:`PyObject_VectorcallMethod`" msgstr ":c:func:`PyObject_VectorcallMethod`" -#: ../../c-api/call.rst:226 +#: ../../c-api/call.rst:213 msgid "arg + name" msgstr "引數 + 名稱" -#: ../../c-api/call.rst:232 +#: ../../c-api/call.rst:219 msgid "" "Call a callable Python object *callable*, with arguments given by the tuple " "*args*, and named arguments given by the dictionary *kwargs*." @@ -476,7 +462,7 @@ msgstr "" "呼叫一個可呼叫的 Python 物件 *callable*,附帶由 tuple *args* 所給定的引數及由" "字典 *kwargs* 所給定的關鍵字引數。" -#: ../../c-api/call.rst:235 +#: ../../c-api/call.rst:222 msgid "" "*args* must not be *NULL*; use an empty tuple if no arguments are needed. If " "no named arguments are needed, *kwargs* can be *NULL*." @@ -484,22 +470,22 @@ msgstr "" "*args* 必須不為 *NULL*;如果不需要引數,請使用一個空 tuple。如果不需要關鍵字" "引數,則 *kwargs* 可以為 *NULL*。" -#: ../../c-api/call.rst:238 ../../c-api/call.rst:250 ../../c-api/call.rst:261 -#: ../../c-api/call.rst:272 ../../c-api/call.rst:284 ../../c-api/call.rst:304 -#: ../../c-api/call.rst:323 ../../c-api/call.rst:337 ../../c-api/call.rst:346 -#: ../../c-api/call.rst:358 ../../c-api/call.rst:371 ../../c-api/call.rst:405 +#: ../../c-api/call.rst:225 ../../c-api/call.rst:237 ../../c-api/call.rst:248 +#: ../../c-api/call.rst:259 ../../c-api/call.rst:271 ../../c-api/call.rst:291 +#: ../../c-api/call.rst:310 ../../c-api/call.rst:324 ../../c-api/call.rst:333 +#: ../../c-api/call.rst:345 ../../c-api/call.rst:358 ../../c-api/call.rst:392 msgid "" "Return the result of the call on success, or raise an exception and return " "*NULL* on failure." msgstr "成功時回傳結果,或在失敗時引發一個例外並回傳 *NULL*。" -#: ../../c-api/call.rst:241 +#: ../../c-api/call.rst:228 msgid "" "This is the equivalent of the Python expression: ``callable(*args, " "**kwargs)``." msgstr "這等價於 Python 運算式 ``callable(*args, **kwargs)``。" -#: ../../c-api/call.rst:247 +#: ../../c-api/call.rst:234 msgid "" "Call a callable Python object *callable* without any arguments. It is the " "most efficient way to call a callable Python object without any argument." @@ -507,7 +493,7 @@ msgstr "" "呼叫一個可呼叫的 Python 物件 *callable* 並不附帶任何引數。這是不帶引數呼叫 " "Python 可呼叫物件的最有效方式。" -#: ../../c-api/call.rst:258 +#: ../../c-api/call.rst:245 msgid "" "Call a callable Python object *callable* with exactly 1 positional argument " "*arg* and no keyword arguments." @@ -515,7 +501,7 @@ msgstr "" "呼叫一個可呼叫的 Python 物件 *callable* 並附帶正好一個位置引數 *arg* 而沒有關" "鍵字引數。" -#: ../../c-api/call.rst:269 +#: ../../c-api/call.rst:256 msgid "" "Call a callable Python object *callable*, with arguments given by the tuple " "*args*. If no arguments are needed, then *args* can be *NULL*." @@ -523,11 +509,11 @@ msgstr "" "呼叫一個可呼叫的 Python 物件 *callable*,附帶由 tuple *args* 所給定的引數。如" "果不需要傳入引數,則 *args* 可以為 *NULL*。" -#: ../../c-api/call.rst:275 ../../c-api/call.rst:287 +#: ../../c-api/call.rst:262 ../../c-api/call.rst:274 msgid "This is the equivalent of the Python expression: ``callable(*args)``." msgstr "這等價於 Python 運算式 ``callable(*args)``。" -#: ../../c-api/call.rst:280 +#: ../../c-api/call.rst:267 msgid "" "Call a callable Python object *callable*, with a variable number of C " "arguments. The C arguments are described using a :c:func:`Py_BuildValue` " @@ -538,7 +524,7 @@ msgstr "" "用 :c:func:`Py_BuildValue` 風格的格式字串來描述。格式可以為 *NULL*,表示沒有" "提供任何引數。" -#: ../../c-api/call.rst:289 +#: ../../c-api/call.rst:276 msgid "" "Note that if you only pass :c:expr:`PyObject *` args, :c:func:" "`PyObject_CallFunctionObjArgs` is a faster alternative." @@ -546,11 +532,11 @@ msgstr "" "注意,如果你只傳入 :c:expr:`PyObject *` 引數,則 :c:func:" "`PyObject_CallFunctionObjArgs` 是另一個更快速的選擇。" -#: ../../c-api/call.rst:292 +#: ../../c-api/call.rst:279 msgid "The type of *format* was changed from ``char *``." msgstr "這個 *format* 的型別已從 ``char *`` 更改。" -#: ../../c-api/call.rst:298 +#: ../../c-api/call.rst:285 msgid "" "Call the method named *name* of object *obj* with a variable number of C " "arguments. The C arguments are described by a :c:func:`Py_BuildValue` " @@ -559,17 +545,17 @@ msgstr "" "呼叫 *obj* 物件中名為 *name* 的 method 並附帶數量可變的 C 引數。這些 C 引數" "由 :c:func:`Py_BuildValue` 格式字串來描述,並應當生成一個 tuple。" -#: ../../c-api/call.rst:302 +#: ../../c-api/call.rst:289 msgid "The format can be *NULL*, indicating that no arguments are provided." msgstr "格式可以為 *NULL*,表示沒有提供任何引數。" -#: ../../c-api/call.rst:307 +#: ../../c-api/call.rst:294 msgid "" "This is the equivalent of the Python expression: ``obj.name(arg1, " "arg2, ...)``." msgstr "這等價於 Python 運算式 ``obj.name(arg1, arg2, ...)``。" -#: ../../c-api/call.rst:310 +#: ../../c-api/call.rst:297 msgid "" "Note that if you only pass :c:expr:`PyObject *` args, :c:func:" "`PyObject_CallMethodObjArgs` is a faster alternative." @@ -577,11 +563,11 @@ msgstr "" "注意,如果你只傳入 :c:expr:`PyObject *` 引數,則 :c:func:" "`PyObject_CallMethodObjArgs` 是另一個更快速的選擇。" -#: ../../c-api/call.rst:313 +#: ../../c-api/call.rst:300 msgid "The types of *name* and *format* were changed from ``char *``." msgstr "*name* 和 *format* 的型別已從 ``char *`` 更改。" -#: ../../c-api/call.rst:319 +#: ../../c-api/call.rst:306 msgid "" "Call a callable Python object *callable*, with a variable number of :c:expr:" "`PyObject *` arguments. The arguments are provided as a variable number of " @@ -590,13 +576,13 @@ msgstr "" "呼叫一個可呼叫的 Python 物件 *callable*,附帶數量可變的 :c:expr:`PyObject *` " "引數。這些引數是以位置在 *NULL* 後面、數量可變的參數來提供。" -#: ../../c-api/call.rst:326 +#: ../../c-api/call.rst:313 msgid "" "This is the equivalent of the Python expression: ``callable(arg1, " "arg2, ...)``." msgstr "這等價於 Python 運算式 ``callable(arg1, arg2, ...)``。" -#: ../../c-api/call.rst:332 +#: ../../c-api/call.rst:319 msgid "" "Call a method of the Python object *obj*, where the name of the method is " "given as a Python string object in *name*. It is called with a variable " @@ -607,7 +593,7 @@ msgstr "" "Python 字串物件給定。被呼叫時會附帶數量可變的 :c:expr:`PyObject *` 引數。這些" "引數是以位置在 *NULL* 後面、且數量可變的參數來提供。" -#: ../../c-api/call.rst:343 +#: ../../c-api/call.rst:330 msgid "" "Call a method of the Python object *obj* without arguments, where the name " "of the method is given as a Python string object in *name*." @@ -615,7 +601,7 @@ msgstr "" "不附帶任何引數地呼叫 Python 物件 *obj* 中的一個 method,其中 method 名稱由 " "*name* 中的 Python 字串物件給定。" -#: ../../c-api/call.rst:354 +#: ../../c-api/call.rst:341 msgid "" "Call a method of the Python object *obj* with a single positional argument " "*arg*, where the name of the method is given as a Python string object in " @@ -624,7 +610,7 @@ msgstr "" "附帶一個位置引數 *arg* 地呼叫 Python 物件 *obj* 中的一個 method,其中 method " "名稱由 *name* 中的 Python 字串物件給定。" -#: ../../c-api/call.rst:366 +#: ../../c-api/call.rst:353 msgid "" "Call a callable Python object *callable*. The arguments are the same as for :" "c:type:`vectorcallfunc`. If *callable* supports vectorcall_, this directly " @@ -634,7 +620,7 @@ msgstr "" "的相同。如果 *callable* 支援 vectorcall_,則它會直接呼叫存放在 *callable* 中" "的 vectorcall 函式。" -#: ../../c-api/call.rst:378 +#: ../../c-api/call.rst:365 msgid "" "Call *callable* with positional arguments passed exactly as in the " "vectorcall_ protocol, but with keyword arguments passed as a dictionary " @@ -643,7 +629,7 @@ msgstr "" "附帶與在 vectorcall_ 協定中傳入的相同位置引數來呼叫 *callable*,但會加上以字" "典 *kwdict* 格式傳入的關鍵字引數。*args* 陣列將只包含位置引數。" -#: ../../c-api/call.rst:382 +#: ../../c-api/call.rst:369 msgid "" "Regardless of which protocol is used internally, a conversion of arguments " "needs to be done. Therefore, this function should only be used if the caller " @@ -653,7 +639,7 @@ msgstr "" "無論內部使用了哪一種協定,都會需要進行引數的轉換。因此,此函式應該只有在呼叫" "方已經擁有一個要作為關鍵字引數的字典、但沒有作為位置引數的 tuple 時才被使用。" -#: ../../c-api/call.rst:392 +#: ../../c-api/call.rst:379 msgid "" "Call a method using the vectorcall calling convention. The name of the " "method is given as a Python string *name*. The object whose method is called " @@ -671,7 +657,7 @@ msgstr "" "加上 :c:macro:`PY_VECTORCALL_ARGUMENTS_OFFSET`。關鍵字引數可以像在 :c:func:" "`PyObject_Vectorcall` 中一樣被傳入。" -#: ../../c-api/call.rst:401 +#: ../../c-api/call.rst:388 msgid "" "If the object has the :c:macro:`Py_TPFLAGS_METHOD_DESCRIPTOR` feature, this " "will call the unbound method object with the full *args* vector as arguments." @@ -679,14 +665,32 @@ msgstr "" "如果物件具有 :c:macro:`Py_TPFLAGS_METHOD_DESCRIPTOR` 特性,這將以完整的 " "*args* 向量作為引數來呼叫 unbound method(未繫結方法)物件。" -#: ../../c-api/call.rst:412 +#: ../../c-api/call.rst:399 msgid "Call Support API" msgstr "呼叫支援 API" -#: ../../c-api/call.rst:416 +#: ../../c-api/call.rst:403 msgid "" "Determine if the object *o* is callable. Return ``1`` if the object is " "callable and ``0`` otherwise. This function always succeeds." msgstr "" "判定物件 *o* 是否為可呼叫的。如果物件是可呼叫物件則回傳 ``1``,其他情況回傳 " "``0``。這個函式不會呼叫失敗。" + +#~ msgid "" +#~ "In CPython 3.8, the vectorcall API and related functions were available " +#~ "provisionally under names with a leading underscore: " +#~ "``_PyObject_Vectorcall``, ``_Py_TPFLAGS_HAVE_VECTORCALL``, " +#~ "``_PyObject_VectorcallMethod``, ``_PyVectorcall_Function``, " +#~ "``_PyObject_CallOneArg``, ``_PyObject_CallMethodNoArgs``, " +#~ "``_PyObject_CallMethodOneArg``. Additionally, ``PyObject_VectorcallDict`` " +#~ "was available as ``_PyObject_FastCallDict``. The old names are still " +#~ "defined as aliases of the new, non-underscored names." +#~ msgstr "" +#~ "在 CPython 3.8 中,vectorcall API 和相關函式暫定以帶開頭底線的名稱提供:" +#~ "``_PyObject_Vectorcall``、``_Py_TPFLAGS_HAVE_VECTORCALL``、" +#~ "``_PyObject_VectorcallMethod``、``_PyVectorcall_Function``、" +#~ "``_PyObject_CallOneArg``、``_PyObject_CallMethodNoArgs``、" +#~ "``_PyObject_CallMethodOneArg``。此外,``PyObject_VectorcallDict`` 也以 " +#~ "``_PyObject_FastCallDict`` 名稱提供。這些舊名稱仍有被定義,做為不帶底線的" +#~ "新名稱的別名。" diff --git a/c-api/capsule.po b/c-api/capsule.po index 7ce4bb7a23..8962dc66fc 100644 --- a/c-api/capsule.po +++ b/c-api/capsule.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2025-06-29 00:17+0000\n" "PO-Revision-Date: 2018-05-23 14:30+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -150,15 +150,29 @@ msgstr "" #: ../../c-api/capsule.rst:108 msgid "" +"This function splits *name* on the ``.`` character, and imports the first " +"element. It then processes further elements using attribute lookups." +msgstr "" + +#: ../../c-api/capsule.rst:111 +msgid "" "Return the capsule's internal *pointer* on success. On failure, set an " "exception and return ``NULL``." msgstr "" -#: ../../c-api/capsule.rst:111 +#: ../../c-api/capsule.rst:116 +msgid "" +"If *name* points to an attribute of some submodule or subpackage, this " +"submodule or subpackage must be previously imported using other means (for " +"example, by using :c:func:`PyImport_ImportModule`) for the attribute lookups " +"to succeed." +msgstr "" + +#: ../../c-api/capsule.rst:121 msgid "*no_block* has no effect anymore." msgstr "" -#: ../../c-api/capsule.rst:117 +#: ../../c-api/capsule.rst:127 msgid "" "Determines whether or not *capsule* is a valid capsule. A valid capsule is " "non-``NULL``, passes :c:func:`PyCapsule_CheckExact`, has a non-``NULL`` " @@ -167,41 +181,41 @@ msgid "" "compared.)" msgstr "" -#: ../../c-api/capsule.rst:123 +#: ../../c-api/capsule.rst:133 msgid "" "In other words, if :c:func:`PyCapsule_IsValid` returns a true value, calls " "to any of the accessors (any function starting with ``PyCapsule_Get``) are " "guaranteed to succeed." msgstr "" -#: ../../c-api/capsule.rst:127 +#: ../../c-api/capsule.rst:137 msgid "" "Return a nonzero value if the object is valid and matches the name passed " "in. Return ``0`` otherwise. This function will not fail." msgstr "" -#: ../../c-api/capsule.rst:133 +#: ../../c-api/capsule.rst:143 msgid "Set the context pointer inside *capsule* to *context*." msgstr "" -#: ../../c-api/capsule.rst:135 ../../c-api/capsule.rst:142 -#: ../../c-api/capsule.rst:151 ../../c-api/capsule.rst:159 +#: ../../c-api/capsule.rst:145 ../../c-api/capsule.rst:152 +#: ../../c-api/capsule.rst:161 ../../c-api/capsule.rst:169 msgid "" "Return ``0`` on success. Return nonzero and set an exception on failure." msgstr "" -#: ../../c-api/capsule.rst:140 +#: ../../c-api/capsule.rst:150 msgid "Set the destructor inside *capsule* to *destructor*." msgstr "" -#: ../../c-api/capsule.rst:147 +#: ../../c-api/capsule.rst:157 msgid "" "Set the name inside *capsule* to *name*. If non-``NULL``, the name must " "outlive the capsule. If the previous *name* stored in the capsule was not " "``NULL``, no attempt is made to free it." msgstr "" -#: ../../c-api/capsule.rst:156 +#: ../../c-api/capsule.rst:166 msgid "" "Set the void pointer inside *capsule* to *pointer*. The pointer may not be " "``NULL``." diff --git a/c-api/cell.po b/c-api/cell.po index 2f91c7b625..1b56cd0661 100644 --- a/c-api/cell.po +++ b/c-api/cell.po @@ -9,7 +9,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-07-10 00:04+0000\n" "PO-Revision-Date: 2022-10-16 15:33+0800\n" @@ -89,7 +89,7 @@ msgid "" "reference to any current content of the cell. *value* may be ``NULL``. " "*cell* must be non-``NULL``." msgstr "" -"將 cell 物件 *cell* 的內容設為 *value*。這將釋放任何對 cell 物件當前內容的參" +"將 cell 物件 *cell* 的內容設為 *value*。這將釋放任何對 cell 物件目前內容的參" "照。*value* 可以為 ``NULL``。*cell* 必須不為 ``NULL``。" #: ../../c-api/cell.rst:58 diff --git a/c-api/code.po b/c-api/code.po index c127f837d6..3ce283f533 100644 --- a/c-api/code.po +++ b/c-api/code.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-18 00:04+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2015-12-09 17:51+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -48,116 +48,127 @@ msgid "" msgstr "" #: ../../c-api/code.rst:35 -msgid "Return the number of free variables in a code object." +msgid "" +"Return the number of :term:`free (closure) variables ` in " +"a code object." msgstr "" -#: ../../c-api/code.rst:39 -msgid "Return the position of the first free variable in a code object." +#: ../../c-api/code.rst:40 +msgid "" +"Return the position of the first :term:`free (closure) variable ` in a code object." msgstr "" -#: ../../c-api/code.rst:43 +#: ../../c-api/code.rst:45 +msgid "" +"Renamed from ``PyCode_GetFirstFree`` as part of :ref:`unstable-c-api`. The " +"old name is deprecated, but will remain available until the signature " +"changes again." +msgstr "" + +#: ../../c-api/code.rst:51 msgid "" "Return a new code object. If you need a dummy code object to create a " "frame, use :c:func:`PyCode_NewEmpty` instead." msgstr "" -#: ../../c-api/code.rst:46 +#: ../../c-api/code.rst:54 msgid "" "Since the definition of the bytecode changes often, calling :c:func:" "`PyUnstable_Code_New` directly can bind you to a precise Python version." msgstr "" -#: ../../c-api/code.rst:49 +#: ../../c-api/code.rst:57 msgid "" "The many arguments of this function are inter-dependent in complex ways, " "meaning that subtle changes to values are likely to result in incorrect " "execution or VM crashes. Use this function only with extreme care." msgstr "" -#: ../../c-api/code.rst:53 +#: ../../c-api/code.rst:61 msgid "Added ``qualname`` and ``exceptiontable`` parameters." msgstr "新增 ``qualname`` 和 ``exceptiontable`` 參數。" -#: ../../c-api/code.rst:60 +#: ../../c-api/code.rst:68 msgid "" "Renamed from ``PyCode_New`` as part of :ref:`unstable-c-api`. The old name " "is deprecated, but will remain available until the signature changes again." msgstr "" -#: ../../c-api/code.rst:66 +#: ../../c-api/code.rst:74 msgid "" "Similar to :c:func:`PyUnstable_Code_New`, but with an extra " "\"posonlyargcount\" for positional-only arguments. The same caveats that " "apply to ``PyUnstable_Code_New`` also apply to this function." msgstr "" -#: ../../c-api/code.rst:71 +#: ../../c-api/code.rst:79 msgid "as ``PyCode_NewWithPosOnlyArgs``" msgstr "" -#: ../../c-api/code.rst:73 +#: ../../c-api/code.rst:81 msgid "Added ``qualname`` and ``exceptiontable`` parameters." msgstr "新增 ``qualname`` 和 ``exceptiontable`` 參數。" -#: ../../c-api/code.rst:78 +#: ../../c-api/code.rst:86 msgid "" "Renamed to ``PyUnstable_Code_NewWithPosOnlyArgs``. The old name is " "deprecated, but will remain available until the signature changes again." msgstr "" -#: ../../c-api/code.rst:84 +#: ../../c-api/code.rst:92 msgid "" "Return a new empty code object with the specified filename, function name, " "and first line number. The resulting code object will raise an ``Exception`` " "if executed." msgstr "" -#: ../../c-api/code.rst:90 +#: ../../c-api/code.rst:98 msgid "" "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 :c:func:`PyFrame_GetLineNumber` instead." msgstr "" -#: ../../c-api/code.rst:93 +#: ../../c-api/code.rst:101 msgid "" "For efficiently iterating over the line numbers in a code object, use :pep:" "`the API described in PEP 626 <0626#out-of-process-debuggers-and-profilers>`." msgstr "" -#: ../../c-api/code.rst:98 +#: ../../c-api/code.rst:106 msgid "" "Sets the passed ``int`` pointers to the source code line and column numbers " "for the instruction at ``byte_offset``. Sets the value to ``0`` when " "information is not available for any particular element." msgstr "" -#: ../../c-api/code.rst:102 +#: ../../c-api/code.rst:110 msgid "Returns ``1`` if the function succeeds and 0 otherwise." msgstr "" -#: ../../c-api/code.rst:108 +#: ../../c-api/code.rst:116 msgid "" "Equivalent to the Python code ``getattr(co, 'co_code')``. Returns a strong " "reference to a :c:type:`PyBytesObject` representing the bytecode in a code " "object. On error, ``NULL`` is returned and an exception is raised." msgstr "" -#: ../../c-api/code.rst:113 +#: ../../c-api/code.rst:121 msgid "" "This ``PyBytesObject`` may be created on-demand by the interpreter and does " "not necessarily represent the bytecode actually executed by CPython. The " "primary use case for this function is debuggers and profilers." msgstr "" -#: ../../c-api/code.rst:121 +#: ../../c-api/code.rst:129 msgid "" "Equivalent to the Python code ``getattr(co, 'co_varnames')``. Returns a new " "reference to a :c:type:`PyTupleObject` containing the names of the local " "variables. On error, ``NULL`` is returned and an exception is raised." msgstr "" -#: ../../c-api/code.rst:130 +#: ../../c-api/code.rst:138 msgid "" "Equivalent to the Python code ``getattr(co, 'co_cellvars')``. Returns a new " "reference to a :c:type:`PyTupleObject` containing the names of the local " @@ -165,14 +176,15 @@ msgid "" "returned and an exception is raised." msgstr "" -#: ../../c-api/code.rst:139 +#: ../../c-api/code.rst:147 msgid "" "Equivalent to the Python code ``getattr(co, 'co_freevars')``. Returns a new " -"reference to a :c:type:`PyTupleObject` containing the names of the free " -"variables. On error, ``NULL`` is returned and an exception is raised." +"reference to a :c:type:`PyTupleObject` containing the names of the :term:" +"`free (closure) variables `. On error, ``NULL`` is " +"returned and an exception is raised." msgstr "" -#: ../../c-api/code.rst:147 +#: ../../c-api/code.rst:156 msgid "" "Register *callback* as a code object watcher for the current interpreter. " "Return an ID which may be passed to :c:func:`PyCode_ClearWatcher`. In case " @@ -180,7 +192,7 @@ msgid "" "exception." msgstr "" -#: ../../c-api/code.rst:156 +#: ../../c-api/code.rst:165 msgid "" "Clear watcher identified by *watcher_id* previously returned from :c:func:" "`PyCode_AddWatcher` for the current interpreter. Return ``0`` on success, or " @@ -188,25 +200,25 @@ msgid "" "never registered.)" msgstr "" -#: ../../c-api/code.rst:165 +#: ../../c-api/code.rst:174 msgid "" "Enumeration of possible code object watcher events: - " "``PY_CODE_EVENT_CREATE`` - ``PY_CODE_EVENT_DESTROY``" msgstr "" -#: ../../c-api/code.rst:173 +#: ../../c-api/code.rst:182 msgid "Type of a code object watcher callback function." msgstr "" -#: ../../c-api/code.rst:175 +#: ../../c-api/code.rst:184 msgid "" "If *event* is ``PY_CODE_EVENT_CREATE``, then the callback is invoked after " -"`co` has been fully initialized. Otherwise, the callback is invoked before " +"*co* has been fully initialized. Otherwise, the callback is invoked before " "the destruction of *co* takes place, so the prior state of *co* can be " "inspected." msgstr "" -#: ../../c-api/code.rst:180 +#: ../../c-api/code.rst:189 msgid "" "If *event* is ``PY_CODE_EVENT_DESTROY``, taking a reference in the callback " "to the about-to-be-destroyed code object will resurrect it and prevent it " @@ -214,7 +226,7 @@ msgid "" "later, any watcher callbacks active at that time will be called again." msgstr "" -#: ../../c-api/code.rst:185 +#: ../../c-api/code.rst:194 msgid "" "Users of this API should not rely on internal runtime implementation " "details. Such details may include, but are not limited to, the exact order " @@ -224,14 +236,14 @@ msgid "" "the Python code being executed." msgstr "" -#: ../../c-api/code.rst:192 +#: ../../c-api/code.rst:201 msgid "" "If the callback sets an exception, it must return ``-1``; this exception " "will be printed as an unraisable exception using :c:func:" "`PyErr_WriteUnraisable`. Otherwise it should return ``0``." msgstr "" -#: ../../c-api/code.rst:196 +#: ../../c-api/code.rst:205 msgid "" "There may already be a pending exception set on entry to the callback. In " "this case, the callback should return ``0`` with the same exception still " @@ -240,85 +252,85 @@ msgid "" "it before returning." msgstr "" -#: ../../c-api/code.rst:206 +#: ../../c-api/code.rst:215 msgid "Extra information" msgstr "" -#: ../../c-api/code.rst:208 +#: ../../c-api/code.rst:217 msgid "" "To support low-level extensions to frame evaluation, such as external just-" "in-time compilers, it is possible to attach arbitrary extra data to code " "objects." msgstr "" -#: ../../c-api/code.rst:212 +#: ../../c-api/code.rst:221 msgid "" "These functions are part of the unstable C API tier: this functionality is a " "CPython implementation detail, and the API may change without deprecation " "warnings." msgstr "" -#: ../../c-api/code.rst:218 +#: ../../c-api/code.rst:227 msgid "Return a new an opaque index value used to adding data to code objects." msgstr "" -#: ../../c-api/code.rst:220 +#: ../../c-api/code.rst:229 msgid "" "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." msgstr "" -#: ../../c-api/code.rst:224 +#: ../../c-api/code.rst:233 msgid "" "If *free* is not ``NULL``: when a code object is deallocated, *free* will be " "called on non-``NULL`` data stored under the new index. Use :c:func:" "`Py_DecRef` when storing :c:type:`PyObject`." msgstr "" -#: ../../c-api/code.rst:230 +#: ../../c-api/code.rst:239 msgid "as ``_PyEval_RequestCodeExtraIndex``" msgstr "" -#: ../../c-api/code.rst:234 +#: ../../c-api/code.rst:243 msgid "" "Renamed to ``PyUnstable_Eval_RequestCodeExtraIndex``. The old private name " "is deprecated, but will be available until the API changes." msgstr "" -#: ../../c-api/code.rst:240 +#: ../../c-api/code.rst:249 msgid "" "Set *extra* to the extra data stored under the given index. Return 0 on " "success. Set an exception and return -1 on failure." msgstr "" -#: ../../c-api/code.rst:243 +#: ../../c-api/code.rst:252 msgid "" "If no data was set under the index, set *extra* to ``NULL`` and return 0 " "without setting an exception." msgstr "" -#: ../../c-api/code.rst:248 +#: ../../c-api/code.rst:257 msgid "as ``_PyCode_GetExtra``" msgstr "" -#: ../../c-api/code.rst:252 +#: ../../c-api/code.rst:261 msgid "" "Renamed to ``PyUnstable_Code_GetExtra``. The old private name is deprecated, " "but will be available until the API changes." msgstr "" -#: ../../c-api/code.rst:258 +#: ../../c-api/code.rst:267 msgid "" "Set the extra data stored under the given index to *extra*. Return 0 on " "success. Set an exception and return -1 on failure." msgstr "" -#: ../../c-api/code.rst:263 +#: ../../c-api/code.rst:272 msgid "as ``_PyCode_SetExtra``" msgstr "" -#: ../../c-api/code.rst:267 +#: ../../c-api/code.rst:276 msgid "" "Renamed to ``PyUnstable_Code_SetExtra``. The old private name is deprecated, " "but will be available until the API changes." @@ -336,22 +348,22 @@ msgstr "code(程式碼)" msgid "code object" msgstr "code object(程式碼物件)" -#: ../../c-api/code.rst:56 +#: ../../c-api/code.rst:64 msgid "PyCode_New (C function)" msgstr "PyCode_New(C 函式)" -#: ../../c-api/code.rst:69 +#: ../../c-api/code.rst:77 msgid "PyCode_NewWithPosOnlyArgs (C function)" msgstr "PyCode_NewWithPosOnlyArgs(C 函式)" -#: ../../c-api/code.rst:228 +#: ../../c-api/code.rst:237 msgid "_PyEval_RequestCodeExtraIndex (C function)" msgstr "_PyEval_RequestCodeExtraIndex(C 函式)" -#: ../../c-api/code.rst:246 +#: ../../c-api/code.rst:255 msgid "_PyCode_GetExtra (C function)" msgstr "_PyCode_GetExtra(C 函式)" -#: ../../c-api/code.rst:261 +#: ../../c-api/code.rst:270 msgid "_PyCode_SetExtra (C function)" msgstr "_PyCode_SetExtra(C 函式)" diff --git a/c-api/codec.po b/c-api/codec.po index 68de1f7702..6fd7c61a7f 100644 --- a/c-api/codec.po +++ b/c-api/codec.po @@ -5,7 +5,7 @@ # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-07-29 00:03+0000\n" "PO-Revision-Date: 2023-07-24 17:51+0000\n" @@ -24,7 +24,7 @@ msgstr "編解碼器註冊表和支援函式" #: ../../c-api/codec.rst:8 msgid "Register a new codec search function." -msgstr "註冊一個新的編解碼器搜索函式。" +msgstr "註冊一個新的編解碼器搜尋函式。" #: ../../c-api/codec.rst:10 msgid "" @@ -32,7 +32,7 @@ msgid "" "done, to make sure that it is always first in the list of search functions." msgstr "" "作為副作用 (side effect),這會嘗試載入 :mod:`!encodings`\\ (如果尚未完成)," -"以確保它始終位於搜索函式列表中的第一個。" +"以確保它始終位於搜尋函式列表中的第一個。" #: ../../c-api/codec.rst:15 msgid "" @@ -40,7 +40,7 @@ msgid "" "search function is not registered, do nothing. Return 0 on success. Raise an " "exception and return -1 on error." msgstr "" -"取消註冊編解碼器搜索函式並清除註冊表 (registry) 的快取。如果搜索函式並未被註" +"取消註冊編解碼器搜尋函式並清除註冊表 (registry) 的快取。如果搜尋函式並未被註" "冊,則不執行任何操作。成功回傳 0,發生錯誤時會引發例外並回傳 -1。" #: ../../c-api/codec.rst:23 diff --git a/c-api/complex.po b/c-api/complex.po index 8d905e1455..a22103f9b4 100644 --- a/c-api/complex.po +++ b/c-api/complex.po @@ -5,9 +5,9 @@ # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2015-12-09 17:51+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -81,14 +81,14 @@ msgstr "以 C 的 :c:type:`Py_complex` 表示形式來回傳兩個複數之和 #: ../../c-api/complex.rst:49 msgid "" -"Return the difference between two complex numbers, using the C :c:type:" -"`Py_complex` representation." +"Return the difference between two complex numbers, using the " +"C :c:type:`Py_complex` representation." msgstr "以 C 的 :c:type:`Py_complex` 表示形式來回傳兩個複數間的差。" #: ../../c-api/complex.rst:55 msgid "" -"Return the negation of the complex number *num*, using the C :c:type:" -"`Py_complex` representation." +"Return the negation of the complex number *num*, using the " +"C :c:type:`Py_complex` representation." msgstr "" "以 C 的 :c:type:`Py_complex` 表示形式來回傳複數 *num* 的相反數 (negation)。" @@ -106,16 +106,16 @@ msgstr "以 C 的 :c:type:`Py_complex` 表示形式來回傳兩個複數的商 #: ../../c-api/complex.rst:70 msgid "" -"If *divisor* is null, this method returns zero and sets :c:data:`errno` to :" -"c:macro:`!EDOM`." +"If *divisor* is null, this method returns zero and sets :c:data:`errno` " +"to :c:macro:`!EDOM`." msgstr "" -"如果 *divisor* 為 null,則此方法會回傳零並將 :c:data:`errno` 設定為 :c:macro:" -"`!EDOM`。" +"如果 *divisor* 為 null,則此方法會回傳零並將 :c:data:`errno` 設定" +"為 :c:macro:`!EDOM`。" #: ../../c-api/complex.rst:76 msgid "" -"Return the exponentiation of *num* by *exp*, using the C :c:type:" -"`Py_complex` representation." +"Return the exponentiation of *num* by *exp*, using the " +"C :c:type:`Py_complex` representation." msgstr "" "以 C 的 :c:type:`Py_complex` 表示形式來回傳 *num* 的 *exp* 次方的結果。" @@ -141,13 +141,13 @@ msgid "" "This instance of :c:type:`PyTypeObject` represents the Python complex number " "type. It is the same object as :class:`complex` in the Python layer." msgstr "" -"這個 :c:type:`PyTypeObject` 的實例代表 Python 複數型別。它與 Python 層中的 :" -"class:`complex` 是同一個物件。" +"這個 :c:type:`PyTypeObject` 的實例代表 Python 複數型別。它與 Python 層中" +"的 :class:`complex` 是同一個物件。" #: ../../c-api/complex.rst:100 msgid "" -"Return true if its argument is a :c:type:`PyComplexObject` or a subtype of :" -"c:type:`PyComplexObject`. This function always succeeds." +"Return true if its argument is a :c:type:`PyComplexObject` or a subtype " +"of :c:type:`PyComplexObject`. This function always succeeds." msgstr "" "如果其引數是一個 :c:type:`PyComplexObject` 或者是 :c:type:`PyComplexObject` " "的子型別,則會回傳 true。這個函式不會失敗。" @@ -182,43 +182,71 @@ msgstr "以 C 的 :c:expr:`double` 形式回傳 *op* 的實部。" #: ../../c-api/complex.rst:126 msgid "" +"If *op* is not a Python complex number object but has " +"a :meth:`~object.__complex__` method, this method will first be called to " +"convert *op* to a Python complex number object. If :meth:`!__complex__` is " +"not defined then it falls back to call :c:func:`PyFloat_AsDouble` and " +"returns its result." +msgstr "" +"如果 *op* 不是 Python 複數物件,但有一個 :meth:`~object.__complex__` 方法,則" +"首先會呼叫該方法將 *op* 轉換為 Python 複數物件。如果 :meth:`!__complex__` 並" +"未定義,那麼它會回退到呼叫 :func:`PyFloat_AsDouble` 並回傳其結果。" + +#: ../../c-api/complex.rst:132 ../../c-api/complex.rst:148 +msgid "" "Upon failure, this method returns ``-1.0`` with an exception set, so one " "should call :c:func:`PyErr_Occurred` to check for errors." msgstr "" -"失敗時,此方法回傳 ``-1.0`` 並設定例外,因此應該呼叫 :c:func:" -"`PyErr_Occurred` 來檢查錯誤。" +"失敗時,此方法回傳 ``-1.0`` 並設定例外,因此應該呼" +"叫 :c:func:`PyErr_Occurred` 來檢查錯誤。" + +#: ../../c-api/complex.rst:135 ../../c-api/complex.rst:151 +msgid "Use :meth:`~object.__complex__` if available." +msgstr "如果可用則使用 :meth:`~object.__complex__`。" -#: ../../c-api/complex.rst:132 +#: ../../c-api/complex.rst:140 msgid "Return the imaginary part of *op* as a C :c:expr:`double`." msgstr "將 *op* 的虛部作為 C 的 :c:expr:`double` 回傳。" -#: ../../c-api/complex.rst:137 +#: ../../c-api/complex.rst:142 +msgid "" +"If *op* is not a Python complex number object but has " +"a :meth:`~object.__complex__` method, this method will first be called to " +"convert *op* to a Python complex number object. If :meth:`!__complex__` is " +"not defined then it falls back to call :c:func:`PyFloat_AsDouble` and " +"returns ``0.0`` on success." +msgstr "" +"如果 *op* 不是 Python 複數物件,但有一個 :meth:`~object.__complex__` 方法,則" +"首先會呼叫該方法將 *op* 轉換為 Python 複數物件。如果 :meth:`!__complex__` 並" +"未定義,那麼它會回退到呼叫 :func:`PyFloat_AsDouble` 並於成功時回傳 ``0.0``。" + +#: ../../c-api/complex.rst:156 msgid "Return the :c:type:`Py_complex` value of the complex number *op*." msgstr "回傳複數 *op* 的 :c:type:`Py_complex` 值。" -#: ../../c-api/complex.rst:139 +#: ../../c-api/complex.rst:158 msgid "" -"If *op* is not a Python complex number object but has a :meth:`~object." -"__complex__` method, this method will first be called to convert *op* to a " -"Python complex number object. If :meth:`!__complex__` is not defined then " -"it falls back to :meth:`~object.__float__`. If :meth:`!__float__` is not " -"defined then it falls back to :meth:`~object.__index__`." +"If *op* is not a Python complex number object but has " +"a :meth:`~object.__complex__` method, this method will first be called to " +"convert *op* to a Python complex number object. If :meth:`!__complex__` is " +"not defined then it falls back to :meth:`~object.__float__`. If :meth:`!" +"__float__` is not defined then it falls back to :meth:`~object.__index__`." msgstr "" "如果 *op* 不是 Python 複數物件,但有一個 :meth:`~object.__complex__` 方法,則" "首先會呼叫該方法將 *op* 轉換為 Python 複數物件。如果 :meth:`!__complex__` 並" "未定義,那麼它會回退到 :meth:`~object.__float__`。如果 :meth:`!__float__` 未" "定義,則它將繼續回退為 :meth:`~object.__index__`。" -#: ../../c-api/complex.rst:145 +#: ../../c-api/complex.rst:164 msgid "" -"Upon failure, this method returns :c:type:`Py_complex` with :c:member:" -"`~Py_complex.real` set to ``-1.0`` and with an exception set, so one should " -"call :c:func:`PyErr_Occurred` to check for errors." +"Upon failure, this method returns :c:type:`Py_complex` " +"with :c:member:`~Py_complex.real` set to ``-1.0`` and with an exception set, " +"so one should call :c:func:`PyErr_Occurred` to check for errors." msgstr "" "失敗時,此方法回傳 :c:type:`Py_complex` 並將 :c:member:`~Py_complex.real` 設" "為 ``-1.0``,並設定例外,因此應該呼叫 :c:func:`PyErr_Occurred` 來檢查錯誤。" -#: ../../c-api/complex.rst:149 +#: ../../c-api/complex.rst:168 msgid "Use :meth:`~object.__index__` if available." msgstr "如果可用則使用 :meth:`~object.__index__`。" diff --git a/c-api/concrete.po b/c-api/concrete.po index 4db03592ba..cafd42eadc 100644 --- a/c-api/concrete.po +++ b/c-api/concrete.po @@ -6,7 +6,7 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-05-09 00:15+0000\n" "PO-Revision-Date: 2022-11-13 20:37+0800\n" diff --git a/c-api/contextvars.po b/c-api/contextvars.po index 1f5674b054..07a22f1e5f 100644 --- a/c-api/contextvars.po +++ b/c-api/contextvars.po @@ -3,10 +3,10 @@ # This file is distributed under the same license as the Python package. msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-01 22:24+0800\n" -"PO-Revision-Date: 2018-07-15 18:56+0800\n" +"PO-Revision-Date: 2025-06-27 00:11+0800\n" "Last-Translator: \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -14,10 +14,11 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 3.6\n" #: ../../c-api/contextvars.rst:6 msgid "Context Variables Objects" -msgstr "情境變數物件" +msgstr "情境變數物件(Context Variables Objects)" #: ../../c-api/contextvars.rst:15 msgid "" @@ -25,6 +26,9 @@ msgid "" "**changed** to use :c:type:`PyObject` pointers instead of :c:type:" "`PyContext`, :c:type:`PyContextVar`, and :c:type:`PyContextToken`, e.g.::" msgstr "" +"在 Python 3.7.1 中所有情境變數 C API 的簽名都被\\ **改為**\\ 使用 :c:type:" +"`PyObject` 指標,而不是 :c:type:`PyContext`、:c:type:`PyContextVar` 或 :c:" +"type:`PyContextToken`,例如:" #: ../../c-api/contextvars.rst:20 msgid "" @@ -34,6 +38,11 @@ msgid "" "// in 3.7.1+:\n" "PyObject *PyContext_New(void);" msgstr "" +"// 在 3.7.0:\n" +"PyContext *PyContext_New(void);\n" +"\n" +"// 在 3.7.1+:\n" +"PyObject *PyContext_New(void);" #: ../../c-api/contextvars.rst:26 msgid "See :issue:`34762` for more details." @@ -42,83 +51,90 @@ msgstr "更多細節請見 :issue:`34762`。" #: ../../c-api/contextvars.rst:29 msgid "" "This section details the public C API for the :mod:`contextvars` module." -msgstr "" +msgstr "本節詳述 :mod:`contextvars` 模組的公開 C API。" #: ../../c-api/contextvars.rst:33 msgid "" "The C structure used to represent a :class:`contextvars.Context` object." -msgstr "" +msgstr "用來代表 :class:`contextvars.Context` 物件的 C 結構。" #: ../../c-api/contextvars.rst:38 msgid "" "The C structure used to represent a :class:`contextvars.ContextVar` object." -msgstr "" +msgstr "用來代表 :class:`contextvars.ContextVar` 物件的 C 結構。" #: ../../c-api/contextvars.rst:43 msgid "The C structure used to represent a :class:`contextvars.Token` object." -msgstr "" +msgstr "用來代表 :class:`contextvars.Token` 物件的 C 結構。" #: ../../c-api/contextvars.rst:47 msgid "The type object representing the *context* type." -msgstr "" +msgstr "代表 *context* 型別的型別物件。" #: ../../c-api/contextvars.rst:51 msgid "The type object representing the *context variable* type." -msgstr "" +msgstr "代表 *情境變數* 型別的型別物件。" #: ../../c-api/contextvars.rst:55 msgid "The type object representing the *context variable token* type." -msgstr "" +msgstr "代表 *情境變數 token* 型別的型別物件。" #: ../../c-api/contextvars.rst:58 msgid "Type-check macros:" -msgstr "" +msgstr "型別檢查巨集:" #: ../../c-api/contextvars.rst:62 msgid "" "Return true if *o* is of type :c:data:`PyContext_Type`. *o* must not be " "``NULL``. This function always succeeds." msgstr "" +"如果 *o* 的型別為 :c:data:`PyContext_Type` 則回傳 true。*o* 不得為 ``NULL``。" +"此函式一定會成功回傳。" #: ../../c-api/contextvars.rst:67 msgid "" "Return true if *o* is of type :c:data:`PyContextVar_Type`. *o* must not be " "``NULL``. This function always succeeds." msgstr "" +"如果 *o* 的類型為 :c:data:`PyContextVar_Type` 則回傳 true。*o* 不得為 " +"``NULL``。此函式一定會成功回傳。" #: ../../c-api/contextvars.rst:72 msgid "" "Return true if *o* is of type :c:data:`PyContextToken_Type`. *o* must not be " "``NULL``. This function always succeeds." msgstr "" +"如果 *o* 的類型為 :c:data:`PyContextToken_Type` 則回傳 true。 *o* 不得為 " +"``NULL``。此函式一定會成功回傳。" #: ../../c-api/contextvars.rst:76 msgid "Context object management functions:" -msgstr "" +msgstr "情境物件管理函式:" #: ../../c-api/contextvars.rst:80 msgid "" "Create a new empty context object. Returns ``NULL`` if an error has " "occurred." -msgstr "" +msgstr "建立一個新的空的情境物件。 如果發生錯誤,則回傳 ``NULL``。" #: ../../c-api/contextvars.rst:85 msgid "" "Create a shallow copy of the passed *ctx* context object. Returns ``NULL`` " "if an error has occurred." -msgstr "" +msgstr "建立傳入的 *ctx* 情境物件的淺層複製 (shallow copy)。如果發生錯誤,則回傳 ``NULL``。" #: ../../c-api/contextvars.rst:90 msgid "" "Create a shallow copy of the current thread context. Returns ``NULL`` if an " "error has occurred." -msgstr "" +msgstr "建立目前執行緒上的情境的淺層複製。如果發生錯誤,則回傳 ``NULL``。" #: ../../c-api/contextvars.rst:95 msgid "" "Set *ctx* as the current context for the current thread. Returns ``0`` on " "success, and ``-1`` on error." msgstr "" +"設定 *ctx* 為目前執行緒上的目前情境。成功時回傳 ``0``,錯誤時回傳 ``-1``。" #: ../../c-api/contextvars.rst:100 msgid "" @@ -126,10 +142,12 @@ msgid "" "context for the current thread. Returns ``0`` on success, and ``-1`` on " "error." msgstr "" +"關閉 *ctx* 情境,並將目前執行緒的目前情境設回之前的情境。 成功時回傳 ``0``," +"錯誤時回傳 ``-1``。" #: ../../c-api/contextvars.rst:105 msgid "Context variable functions:" -msgstr "" +msgstr "情境變數函式:" #: ../../c-api/contextvars.rst:109 msgid "" @@ -138,6 +156,9 @@ msgid "" "value for the context variable, or ``NULL`` for no default. If an error has " "occurred, this function returns ``NULL``." msgstr "" +"建立一個新的 ``ContextVar`` 物件。*name* 參數用於自我檢查(introspection)和" +"除錯目的。*def* 參數指定情境變數的預設值,亦可用 ``NULL`` 表示沒有預設值。 如" +"果發生錯誤,此函式會回傳 ``NULL``。" #: ../../c-api/contextvars.rst:116 msgid "" @@ -145,20 +166,24 @@ msgid "" "occurred during lookup, and ``0`` if no error occurred, whether or not a " "value was found." msgstr "" +"取得情境變數的值。如果在查找過程中發生錯誤則回傳 ``-1``,如果沒有發生錯誤則無" +"論是否找到值都會回傳 ``0``。" #: ../../c-api/contextvars.rst:120 msgid "" "If the context variable was found, *value* will be a pointer to it. If the " "context variable was *not* found, *value* will point to:" msgstr "" +"如果找到情境變數,*value* 將會是指向它的指標。如果 *沒有* 找到情境變數," +"*value* 將會指到:" #: ../../c-api/contextvars.rst:123 msgid "*default_value*, if not ``NULL``;" -msgstr "" +msgstr "*default_value* 預設值,但前提是預設值不是 ``NULL``;" #: ../../c-api/contextvars.rst:124 msgid "the default value of *var*, if not ``NULL``;" -msgstr "" +msgstr "*var* 的預設值,但前提是預設值不是 ``NULL``;" #: ../../c-api/contextvars.rst:125 msgid "``NULL``" @@ -166,13 +191,15 @@ msgstr "``NULL``" #: ../../c-api/contextvars.rst:127 msgid "Except for ``NULL``, the function returns a new reference." -msgstr "" +msgstr "除了 ``NULL`` 之外,此函式會回傳一個新的參照(reference)。" #: ../../c-api/contextvars.rst:131 msgid "" "Set the value of *var* to *value* in the current context. Returns a new " "token object for this change, or ``NULL`` if an error has occurred." msgstr "" +"在目前的情境中將 *var* 的值設為 *value*。會回傳一個用來代表此變更的新 token " +"物件,如果發生錯誤則回傳 ``NULL``。" #: ../../c-api/contextvars.rst:136 msgid "" @@ -180,3 +207,6 @@ msgid "" "func:`PyContextVar_Set` that returned the *token* was called. This function " "returns ``0`` on success and ``-1`` on error." msgstr "" +"將 *var* 情境變數的狀態設回之前的狀態,亦即上一次回傳 token 的 :c:func:" +"`PyContextVar_Set` 被呼叫前的狀態。此函式在成功時回傳 ``0``,錯誤時回傳 " +"``-1``。" diff --git a/c-api/conversion.po b/c-api/conversion.po index d7c2b52620..a8c2e00699 100644 --- a/c-api/conversion.po +++ b/c-api/conversion.po @@ -7,7 +7,7 @@ # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-01-27 00:03+0000\n" "PO-Revision-Date: 2023-12-11 18:26+0000\n" diff --git a/c-api/coro.po b/c-api/coro.po index 5d375aa714..1a5f027a6d 100644 --- a/c-api/coro.po +++ b/c-api/coro.po @@ -8,7 +8,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-09-13 00:11+0000\n" "PO-Revision-Date: 2021-12-09 21:15+0800\n" diff --git a/c-api/datetime.po b/c-api/datetime.po index e2e8158f5d..60f4918fdc 100644 --- a/c-api/datetime.po +++ b/c-api/datetime.po @@ -8,7 +8,7 @@ # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-08-22 00:03+0000\n" "PO-Revision-Date: 2023-07-01 04:14+0800\n" @@ -38,7 +38,7 @@ msgid "" msgstr "" ":mod:`datetime` 模組提供各種日期和時間物件。在使用任何這些函式之前,必須將標" "頭檔 :file:`datetime.h` 引入於原始碼中(請注意,:file:`Python.h` 並無引入該標" -"頭檔),且巨集 :c:macro:`!PyDateTime_IMPORT` 必須被調用,而這通常作為模組初始" +"頭檔),且巨集 :c:macro:`!PyDateTime_IMPORT` 必須被叫用,而這通常作為模組初始" "化函式的一部分。該巨集將指向 C 結構的指標放入靜態變數 :c:data:`!" "PyDateTimeAPI` 中,該變數會被以下巨集使用。" diff --git a/c-api/descriptor.po b/c-api/descriptor.po index 4a8d94a8d2..314623827e 100644 --- a/c-api/descriptor.po +++ b/c-api/descriptor.po @@ -8,7 +8,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-10-26 16:47+0000\n" "PO-Revision-Date: 2021-12-09 20:56+0800\n" diff --git a/c-api/dict.po b/c-api/dict.po index e696336c09..b11b75f775 100644 --- a/c-api/dict.po +++ b/c-api/dict.po @@ -7,9 +7,9 @@ # Liang-Bo Wang , 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2025-02-21 00:13+0000\n" "PO-Revision-Date: 2017-09-22 18:26+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -34,8 +34,8 @@ msgid "" "This instance of :c:type:`PyTypeObject` represents the Python dictionary " "type. This is the same object as :class:`dict` in the Python layer." msgstr "" -":c:type:`PyTypeObject` 實例代表一個 Python 字典型態。此與 Python 層中的 :" -"class:`dict` 為同一個物件。" +":c:type:`PyTypeObject` 實例代表一個 Python 字典型態。此與 Python 層中" +"的 :class:`dict` 為同一個物件。" #: ../../c-api/dict.rst:24 msgid "" @@ -66,7 +66,7 @@ msgstr "" #: ../../c-api/dict.rst:48 msgid "Empty an existing dictionary of all key-value pairs." -msgstr "" +msgstr "清空現有字典中的所有鍵值對。" #: ../../c-api/dict.rst:53 msgid "" @@ -76,81 +76,121 @@ msgid "" msgstr "" #: ../../c-api/dict.rst:60 +msgid "" +"This is the same as :c:func:`PyDict_Contains`, but *key* is specified as " +"a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." +msgstr "" + +#: ../../c-api/dict.rst:69 msgid "Return a new dictionary that contains the same key-value pairs as *p*." msgstr "" -#: ../../c-api/dict.rst:65 +#: ../../c-api/dict.rst:74 msgid "" -"Insert *val* into the dictionary *p* with a key of *key*. *key* must be :" -"term:`hashable`; if it isn't, :exc:`TypeError` will be raised. Return ``0`` " -"on success or ``-1`` on failure. This function *does not* steal a reference " -"to *val*." +"Insert *val* into the dictionary *p* with a key of *key*. *key* must " +"be :term:`hashable`; if it isn't, :exc:`TypeError` will be raised. Return " +"``0`` on success or ``-1`` on failure. This function *does not* steal a " +"reference to *val*." msgstr "" -#: ../../c-api/dict.rst:73 +#: ../../c-api/dict.rst:82 msgid "" -"This is the same as :c:func:`PyDict_SetItem`, but *key* is specified as a :c:" -"expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" -"`PyObject*`." +"This is the same as :c:func:`PyDict_SetItem`, but *key* is specified as " +"a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." msgstr "" -#: ../../c-api/dict.rst:80 +#: ../../c-api/dict.rst:89 msgid "" -"Remove the entry in dictionary *p* with key *key*. *key* must be :term:" -"`hashable`; if it isn't, :exc:`TypeError` is raised. If *key* is not in the " -"dictionary, :exc:`KeyError` is raised. Return ``0`` on success or ``-1`` on " -"failure." +"Remove the entry in dictionary *p* with key *key*. *key* must " +"be :term:`hashable`; if it isn't, :exc:`TypeError` is raised. If *key* is " +"not in the dictionary, :exc:`KeyError` is raised. Return ``0`` on success or " +"``-1`` on failure." msgstr "" -#: ../../c-api/dict.rst:88 +#: ../../c-api/dict.rst:97 msgid "" -"This is the same as :c:func:`PyDict_DelItem`, but *key* is specified as a :c:" -"expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" -"`PyObject*`." +"This is the same as :c:func:`PyDict_DelItem`, but *key* is specified as " +"a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." msgstr "" -#: ../../c-api/dict.rst:95 +#: ../../c-api/dict.rst:104 msgid "" -"Return the object from dictionary *p* which has a key *key*. Return " -"``NULL`` if the key *key* is not present, but *without* setting an exception." +"Return a new :term:`strong reference` to the object from dictionary *p* " +"which has a key *key*:" msgstr "" -#: ../../c-api/dict.rst:100 +#: ../../c-api/dict.rst:107 msgid "" -"Exceptions that occur while this calls :meth:`~object.__hash__` and :meth:" -"`~object.__eq__` methods are silently ignored. Prefer the :c:func:" -"`PyDict_GetItemWithError` function instead." +"If the key is present, set *\\*result* to a new :term:`strong reference` to " +"the value and return ``1``." msgstr "" -#: ../../c-api/dict.rst:104 +#: ../../c-api/dict.rst:109 +msgid "If the key is missing, set *\\*result* to ``NULL`` and return ``0``." +msgstr "" + +#: ../../c-api/dict.rst:110 ../../c-api/dict.rst:207 +msgid "On error, raise an exception and return ``-1``." +msgstr "錯誤發生時,引發一個例外並回傳 ``-1``。" + +#: ../../c-api/dict.rst:114 +msgid "See also the :c:func:`PyObject_GetItem` function." +msgstr "另見 :c:func:`PyObject_GetItem` 函式。" + +#: ../../c-api/dict.rst:119 +msgid "" +"Return a :term:`borrowed reference` to the object from dictionary *p* which " +"has a key *key*. Return ``NULL`` if the key *key* is missing *without* " +"setting an exception." +msgstr "" + +#: ../../c-api/dict.rst:125 +msgid "" +"Exceptions that occur while this calls :meth:`~object.__hash__` " +"and :meth:`~object.__eq__` methods are silently ignored. Prefer " +"the :c:func:`PyDict_GetItemWithError` function instead." +msgstr "" + +#: ../../c-api/dict.rst:129 msgid "" "Calling this API without :term:`GIL` held had been allowed for historical " "reason. It is no longer allowed." msgstr "" -#: ../../c-api/dict.rst:111 +#: ../../c-api/dict.rst:136 msgid "" "Variant of :c:func:`PyDict_GetItem` that does not suppress exceptions. " "Return ``NULL`` **with** an exception set if an exception occurred. Return " "``NULL`` **without** an exception set if the key wasn't present." msgstr "" -#: ../../c-api/dict.rst:119 +#: ../../c-api/dict.rst:144 msgid "" -"This is the same as :c:func:`PyDict_GetItem`, but *key* is specified as a :c:" -"expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" -"`PyObject*`." +"This is the same as :c:func:`PyDict_GetItem`, but *key* is specified as " +"a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." msgstr "" -#: ../../c-api/dict.rst:125 +#: ../../c-api/dict.rst:150 msgid "" -"Exceptions that occur while this calls :meth:`~object.__hash__` and :meth:" -"`~object.__eq__` methods or while creating the temporary :class:`str` object " -"are silently ignored. Prefer using the :c:func:`PyDict_GetItemWithError` " -"function with your own :c:func:`PyUnicode_FromString` *key* instead." +"Exceptions that occur while this calls :meth:`~object.__hash__` " +"and :meth:`~object.__eq__` methods or while creating the " +"temporary :class:`str` object are silently ignored. Prefer using " +"the :c:func:`PyDict_GetItemWithError` function with your " +"own :c:func:`PyUnicode_FromString` *key* instead." msgstr "" -#: ../../c-api/dict.rst:134 +#: ../../c-api/dict.rst:159 +msgid "" +"Similar to :c:func:`PyDict_GetItemRef`, but *key* is specified as " +"a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." +msgstr "" + +#: ../../c-api/dict.rst:168 msgid "" "This is the same as the Python-level :meth:`dict.setdefault`. If present, " "it returns the value corresponding to *key* from the dictionary *p*. If the " @@ -160,47 +200,97 @@ msgid "" "the insertion." msgstr "" -#: ../../c-api/dict.rst:144 +#: ../../c-api/dict.rst:179 msgid "" -"Return a :c:type:`PyListObject` containing all the items from the dictionary." +"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 :term:`strong reference` 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``." msgstr "" -#: ../../c-api/dict.rst:149 +#: ../../c-api/dict.rst:189 msgid "" -"Return a :c:type:`PyListObject` containing all the keys from the dictionary." +"For clarity: if you have a strong reference to *default_value* before " +"calling this function, then after it returns, you hold a strong reference to " +"both *default_value* and *\\*result* (if it's not ``NULL``). These may refer " +"to the same object: in that case you hold two separate references to it." +msgstr "" + +#: ../../c-api/dict.rst:200 +msgid "" +"Remove *key* from dictionary *p* and optionally return the removed value. Do " +"not raise :exc:`KeyError` if the key missing." +msgstr "" + +#: ../../c-api/dict.rst:203 +msgid "" +"If the key is present, set *\\*result* to a new reference to the removed " +"value if *result* is not ``NULL``, and return ``1``." +msgstr "" + +#: ../../c-api/dict.rst:205 +msgid "" +"If the key is missing, set *\\*result* to ``NULL`` if *result* is not " +"``NULL``, and return ``0``." msgstr "" -#: ../../c-api/dict.rst:154 +#: ../../c-api/dict.rst:209 +msgid "" +"Similar to :meth:`dict.pop`, but without the default value and not " +"raising :exc:`KeyError` if the key missing." +msgstr "" + +#: ../../c-api/dict.rst:217 +msgid "" +"Similar to :c:func:`PyDict_Pop`, but *key* is specified as a :c:expr:`const " +"char*` UTF-8 encoded bytes string, rather than a :c:expr:`PyObject*`." +msgstr "" + +#: ../../c-api/dict.rst:226 +msgid "" +"Return a :c:type:`PyListObject` containing all the items from the dictionary." +msgstr "回傳一個包含字典中所有項目的 :c:type:`PyListObject`。" + +#: ../../c-api/dict.rst:231 +msgid "" +"Return a :c:type:`PyListObject` containing all the keys from the dictionary." +msgstr "回傳一個包含字典中所有鍵的 :c:type:`PyListObject`。" + +#: ../../c-api/dict.rst:236 msgid "" "Return a :c:type:`PyListObject` containing all the values from the " "dictionary *p*." -msgstr "" +msgstr "回傳一個包含字典 *p* 中所有值的 :c:type:`PyListObject`。" -#: ../../c-api/dict.rst:162 +#: ../../c-api/dict.rst:244 msgid "" "Return the number of items in the dictionary. This is equivalent to " "``len(p)`` on a dictionary." -msgstr "" +msgstr "回傳字典中項目的數量。此與於字典呼叫 ``len(p)`` 等效。" -#: ../../c-api/dict.rst:168 +#: ../../c-api/dict.rst:250 msgid "" -"Iterate over all key-value pairs in the dictionary *p*. The :c:type:" -"`Py_ssize_t` referred to by *ppos* must be initialized to ``0`` prior to the " -"first call to this function to start the iteration; the function returns " -"true for each pair in the dictionary, and false once all pairs have been " -"reported. The parameters *pkey* and *pvalue* should either point to :c:expr:" -"`PyObject*` variables that will be filled in with each key and value, " -"respectively, or may be ``NULL``. Any references returned through them are " -"borrowed. *ppos* should not be altered during iteration. Its value " -"represents offsets within the internal dictionary structure, and since the " -"structure is sparse, the offsets are not consecutive." +"Iterate over all key-value pairs in the dictionary *p*. " +"The :c:type:`Py_ssize_t` referred to by *ppos* must be initialized to ``0`` " +"prior to the first call to this function to start the iteration; the " +"function returns true for each pair in the dictionary, and false once all " +"pairs have been reported. The parameters *pkey* and *pvalue* should either " +"point to :c:expr:`PyObject*` variables that will be filled in with each key " +"and value, respectively, or may be ``NULL``. Any references returned " +"through them are borrowed. *ppos* should not be altered during iteration. " +"Its value represents offsets within the internal dictionary structure, and " +"since the structure is sparse, the offsets are not consecutive." msgstr "" -#: ../../c-api/dict.rst:179 +#: ../../c-api/dict.rst:261 msgid "For example::" msgstr "舉例來說: ::" -#: ../../c-api/dict.rst:181 +#: ../../c-api/dict.rst:263 msgid "" "PyObject *key, *value;\n" "Py_ssize_t pos = 0;\n" @@ -211,14 +301,14 @@ msgid "" "}" msgstr "" -#: ../../c-api/dict.rst:189 +#: ../../c-api/dict.rst:271 msgid "" "The dictionary *p* should not be mutated during iteration. It is safe to " "modify the values of the keys as you iterate over the dictionary, but only " "so long as the set of keys does not change. For example::" msgstr "" -#: ../../c-api/dict.rst:193 +#: ../../c-api/dict.rst:275 msgid "" "PyObject *key, *value;\n" "Py_ssize_t pos = 0;\n" @@ -256,7 +346,29 @@ msgstr "" " Py_DECREF(o);\n" "}" -#: ../../c-api/dict.rst:214 +#: ../../c-api/dict.rst:293 +msgid "" +"The function is not thread-safe in the :term:`free-threaded ` build without external synchronization. You can " +"use :c:macro:`Py_BEGIN_CRITICAL_SECTION` to lock the dictionary while " +"iterating over it::" +msgstr "" + +#: ../../c-api/dict.rst:298 +msgid "" +"Py_BEGIN_CRITICAL_SECTION(self->dict);\n" +"while (PyDict_Next(self->dict, &pos, &key, &value)) {\n" +" ...\n" +"}\n" +"Py_END_CRITICAL_SECTION();" +msgstr "" +"Py_BEGIN_CRITICAL_SECTION(self->dict);\n" +"while (PyDict_Next(self->dict, &pos, &key, &value)) {\n" +" ...\n" +"}\n" +"Py_END_CRITICAL_SECTION();" + +#: ../../c-api/dict.rst:307 msgid "" "Iterate over mapping object *b* adding key-value pairs to dictionary *a*. " "*b* may be a dictionary, or any object supporting :c:func:`PyMapping_Keys` " @@ -266,16 +378,16 @@ msgid "" "or ``-1`` if an exception was raised." msgstr "" -#: ../../c-api/dict.rst:224 +#: ../../c-api/dict.rst:317 msgid "" -"This is the same as ``PyDict_Merge(a, b, 1)`` in C, and is similar to ``a." -"update(b)`` in Python except that :c:func:`PyDict_Update` doesn't fall back " -"to the iterating over a sequence of key value pairs if the second argument " -"has no \"keys\" attribute. Return ``0`` on success or ``-1`` if an " +"This is the same as ``PyDict_Merge(a, b, 1)`` in C, and is similar to " +"``a.update(b)`` in Python except that :c:func:`PyDict_Update` doesn't fall " +"back to the iterating over a sequence of key value pairs if the second " +"argument has no \"keys\" attribute. Return ``0`` on success or ``-1`` if an " "exception was raised." msgstr "" -#: ../../c-api/dict.rst:233 +#: ../../c-api/dict.rst:326 msgid "" "Update or merge into dictionary *a*, from the key-value pairs in *seq2*. " "*seq2* must be an iterable object producing iterable objects of length 2, " @@ -284,7 +396,7 @@ msgid "" "if an exception was raised. Equivalent Python (except for the return value)::" msgstr "" -#: ../../c-api/dict.rst:240 +#: ../../c-api/dict.rst:333 msgid "" "def PyDict_MergeFromSeq2(a, seq2, override):\n" " for key, value in seq2:\n" @@ -296,7 +408,7 @@ msgstr "" " if override or key not in a:\n" " a[key] = value" -#: ../../c-api/dict.rst:247 +#: ../../c-api/dict.rst:340 msgid "" "Register *callback* as a dictionary watcher. Return a non-negative integer " "id which must be passed to future calls to :c:func:`PyDict_Watch`. In case " @@ -304,21 +416,21 @@ msgid "" "exception." msgstr "" -#: ../../c-api/dict.rst:256 +#: ../../c-api/dict.rst:349 msgid "" -"Clear watcher identified by *watcher_id* previously returned from :c:func:" -"`PyDict_AddWatcher`. Return ``0`` on success, ``-1`` on error (e.g. if the " -"given *watcher_id* was never registered.)" +"Clear watcher identified by *watcher_id* previously returned " +"from :c:func:`PyDict_AddWatcher`. Return ``0`` on success, ``-1`` on error " +"(e.g. if the given *watcher_id* was never registered.)" msgstr "" -#: ../../c-api/dict.rst:264 +#: ../../c-api/dict.rst:357 msgid "" -"Mark dictionary *dict* as watched. The callback granted *watcher_id* by :c:" -"func:`PyDict_AddWatcher` will be called when *dict* is modified or " +"Mark dictionary *dict* as watched. The callback granted *watcher_id* " +"by :c:func:`PyDict_AddWatcher` will be called when *dict* is modified or " "deallocated. Return ``0`` on success or ``-1`` on error." msgstr "" -#: ../../c-api/dict.rst:272 +#: ../../c-api/dict.rst:365 msgid "" "Mark dictionary *dict* as no longer watched. The callback granted " "*watcher_id* by :c:func:`PyDict_AddWatcher` will no longer be called when " @@ -326,7 +438,7 @@ msgid "" "watched by this watcher. Return ``0`` on success or ``-1`` on error." msgstr "" -#: ../../c-api/dict.rst:281 +#: ../../c-api/dict.rst:374 msgid "" "Enumeration of possible dictionary watcher events: ``PyDict_EVENT_ADDED``, " "``PyDict_EVENT_MODIFIED``, ``PyDict_EVENT_DELETED``, " @@ -334,11 +446,11 @@ msgid "" "``PyDict_EVENT_DEALLOCATED``." msgstr "" -#: ../../c-api/dict.rst:289 +#: ../../c-api/dict.rst:382 msgid "Type of a dict watcher callback function." msgstr "" -#: ../../c-api/dict.rst:291 +#: ../../c-api/dict.rst:384 msgid "" "If *event* is ``PyDict_EVENT_CLEARED`` or ``PyDict_EVENT_DEALLOCATED``, both " "*key* and *new_value* will be ``NULL``. If *event* is ``PyDict_EVENT_ADDED`` " @@ -347,7 +459,7 @@ msgid "" "dictionary and *new_value* will be ``NULL``." msgstr "" -#: ../../c-api/dict.rst:297 +#: ../../c-api/dict.rst:390 msgid "" "``PyDict_EVENT_CLONED`` occurs when *dict* was previously empty and another " "dict is merged into it. To maintain efficiency of this operation, per-key " @@ -355,14 +467,14 @@ msgid "" "``PyDict_EVENT_CLONED`` is issued, and *key* will be the source dictionary." msgstr "" -#: ../../c-api/dict.rst:303 +#: ../../c-api/dict.rst:396 msgid "" "The callback may inspect but must not modify *dict*; doing so could have " "unpredictable effects, including infinite recursion. Do not trigger Python " "code execution in the callback, as it could modify the dict as a side effect." msgstr "" -#: ../../c-api/dict.rst:307 +#: ../../c-api/dict.rst:400 msgid "" "If *event* is ``PyDict_EVENT_DEALLOCATED``, taking a new reference in the " "callback to the about-to-be-destroyed dictionary will resurrect it and " @@ -371,20 +483,20 @@ msgid "" "again." msgstr "" -#: ../../c-api/dict.rst:313 +#: ../../c-api/dict.rst:406 msgid "" "Callbacks occur before the notified modification to *dict* takes place, so " "the prior state of *dict* can be inspected." msgstr "" -#: ../../c-api/dict.rst:316 +#: ../../c-api/dict.rst:409 msgid "" "If the callback sets an exception, it must return ``-1``; this exception " -"will be printed as an unraisable exception using :c:func:" -"`PyErr_WriteUnraisable`. Otherwise it should return ``0``." +"will be printed as an unraisable exception " +"using :c:func:`PyErr_WriteUnraisable`. Otherwise it should return ``0``." msgstr "" -#: ../../c-api/dict.rst:320 +#: ../../c-api/dict.rst:413 msgid "" "There may already be a pending exception set on entry to the callback. In " "this case, the callback should return ``0`` with the same exception still " @@ -401,11 +513,11 @@ msgstr "object(物件)" msgid "dictionary" msgstr "dictionary(字典)" -#: ../../c-api/dict.rst:160 +#: ../../c-api/dict.rst:242 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../c-api/dict.rst:160 +#: ../../c-api/dict.rst:242 msgid "len" msgstr "len" diff --git a/c-api/exceptions.po b/c-api/exceptions.po index 9c9a07f5a1..4dd9f8c915 100644 --- a/c-api/exceptions.po +++ b/c-api/exceptions.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Ching-Lung Chuang, 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2025-07-11 00:17+0000\n" "PO-Revision-Date: 2018-05-23 14:05+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -101,7 +100,7 @@ msgstr "" #: ../../c-api/exceptions.rst:69 msgid "The setting of :data:`sys.last_exc` was added." -msgstr "" +msgstr "新增 :data:`sys.last_exc` 設定。" #: ../../c-api/exceptions.rst:75 msgid "Alias for ``PyErr_PrintEx(1)``." @@ -143,22 +142,31 @@ msgstr "使用 :func:`sys.unraisablehook`。" #: ../../c-api/exceptions.rst:104 msgid "" +"Similar to :c:func:`PyErr_WriteUnraisable`, but the *format* and subsequent " +"parameters help format the warning message; they have the same meaning and " +"values as in :c:func:`PyUnicode_FromFormat`. ``PyErr_WriteUnraisable(obj)`` " +"is roughly equivalent to ``PyErr_FormatUnraisable(\"Exception ignored in: " +"%R\", obj)``. If *format* is ``NULL``, only the traceback is printed." +msgstr "" + +#: ../../c-api/exceptions.rst:116 +msgid "" "Print the standard traceback display of ``exc`` to ``sys.stderr``, including " "chained exceptions and notes." msgstr "" -#: ../../c-api/exceptions.rst:110 +#: ../../c-api/exceptions.rst:123 msgid "Raising exceptions" msgstr "" -#: ../../c-api/exceptions.rst:112 +#: ../../c-api/exceptions.rst:125 msgid "" "These functions help you set the current thread's error indicator. For " "convenience, some of these functions will always return a ``NULL`` pointer " "for use in a ``return`` statement." msgstr "" -#: ../../c-api/exceptions.rst:119 +#: ../../c-api/exceptions.rst:132 msgid "" "This is the most common way to set the error indicator. The first argument " "specifies the exception type; it is normally one of the standard exceptions, " @@ -167,13 +175,13 @@ msgid "" "error message; it is decoded from ``'utf-8'``." msgstr "" -#: ../../c-api/exceptions.rst:128 +#: ../../c-api/exceptions.rst:141 msgid "" "This function is similar to :c:func:`PyErr_SetString` but lets you specify " "an arbitrary Python object for the \"value\" of the exception." msgstr "" -#: ../../c-api/exceptions.rst:134 +#: ../../c-api/exceptions.rst:147 msgid "" "This function sets the error indicator and returns ``NULL``. *exception* " "should be a Python exception class. The *format* and subsequent parameters " @@ -181,31 +189,31 @@ msgid "" "c:func:`PyUnicode_FromFormat`. *format* is an ASCII-encoded string." msgstr "" -#: ../../c-api/exceptions.rst:143 +#: ../../c-api/exceptions.rst:156 msgid "" "Same as :c:func:`PyErr_Format`, but taking a :c:type:`va_list` argument " "rather than a variable number of arguments." msgstr "" -#: ../../c-api/exceptions.rst:151 +#: ../../c-api/exceptions.rst:164 msgid "This is a shorthand for ``PyErr_SetObject(type, Py_None)``." msgstr "" -#: ../../c-api/exceptions.rst:156 +#: ../../c-api/exceptions.rst:169 msgid "" "This is a shorthand for ``PyErr_SetString(PyExc_TypeError, message)``, where " "*message* indicates that a built-in operation was invoked with an illegal " "argument. It is mostly for internal use." msgstr "" -#: ../../c-api/exceptions.rst:163 +#: ../../c-api/exceptions.rst:176 msgid "" "This is a shorthand for ``PyErr_SetNone(PyExc_MemoryError)``; it returns " "``NULL`` so an object allocation function can write ``return " "PyErr_NoMemory();`` when it runs out of memory." msgstr "" -#: ../../c-api/exceptions.rst:172 +#: ../../c-api/exceptions.rst:185 msgid "" "This is a convenience function to raise an exception when a C library " "function has returned an error and set the C variable :c:data:`errno`. It " @@ -219,7 +227,7 @@ msgid "" "``return PyErr_SetFromErrno(type);`` when the system call returns an error." msgstr "" -#: ../../c-api/exceptions.rst:186 +#: ../../c-api/exceptions.rst:199 msgid "" "Similar to :c:func:`PyErr_SetFromErrno`, with the additional behavior that " "if *filenameObject* is not ``NULL``, it is passed to the constructor of " @@ -227,21 +235,21 @@ msgid "" "is used to define the :attr:`!filename` attribute of the exception instance." msgstr "" -#: ../../c-api/exceptions.rst:195 +#: ../../c-api/exceptions.rst:208 msgid "" "Similar to :c:func:`PyErr_SetFromErrnoWithFilenameObject`, but takes a " "second filename object, for raising errors when a function that takes two " "filenames fails." msgstr "" -#: ../../c-api/exceptions.rst:204 +#: ../../c-api/exceptions.rst:217 msgid "" "Similar to :c:func:`PyErr_SetFromErrnoWithFilenameObject`, but the filename " "is given as a C string. *filename* is decoded from the :term:`filesystem " "encoding and error handler`." msgstr "" -#: ../../c-api/exceptions.rst:211 +#: ../../c-api/exceptions.rst:224 msgid "" "This is a convenience function to raise :exc:`OSError`. If called with " "*ierr* of ``0``, the error code returned by a call to :c:func:`!" @@ -255,19 +263,19 @@ msgid "" "``NULL``." msgstr "" -#: ../../c-api/exceptions.rst:221 ../../c-api/exceptions.rst:229 -#: ../../c-api/exceptions.rst:240 ../../c-api/exceptions.rst:250 -#: ../../c-api/exceptions.rst:258 ../../c-api/exceptions.rst:268 -msgid ":ref:`Availability `: Windows." -msgstr ":ref:`適用 `:Windows。" +#: ../../c-api/exceptions.rst:234 ../../c-api/exceptions.rst:242 +#: ../../c-api/exceptions.rst:253 ../../c-api/exceptions.rst:263 +#: ../../c-api/exceptions.rst:271 ../../c-api/exceptions.rst:281 +msgid "Availability" +msgstr "可用性" -#: ../../c-api/exceptions.rst:226 +#: ../../c-api/exceptions.rst:239 msgid "" "Similar to :c:func:`PyErr_SetFromWindowsErr`, with an additional parameter " "specifying the exception type to be raised." msgstr "" -#: ../../c-api/exceptions.rst:234 +#: ../../c-api/exceptions.rst:247 msgid "" "Similar to :c:func:`PyErr_SetFromWindowsErr`, with the additional behavior " "that if *filename* is not ``NULL``, it is decoded from the filesystem " @@ -276,7 +284,7 @@ msgid "" "attribute of the exception instance." msgstr "" -#: ../../c-api/exceptions.rst:245 +#: ../../c-api/exceptions.rst:258 msgid "" "Similar to :c:func:`PyErr_SetExcFromWindowsErr`, with the additional " "behavior that if *filename* is not ``NULL``, it is passed to the constructor " @@ -284,19 +292,19 @@ msgid "" "filename` attribute of the exception instance." msgstr "" -#: ../../c-api/exceptions.rst:255 +#: ../../c-api/exceptions.rst:268 msgid "" "Similar to :c:func:`PyErr_SetExcFromWindowsErrWithFilenameObject`, but " "accepts a second filename object." msgstr "" -#: ../../c-api/exceptions.rst:265 +#: ../../c-api/exceptions.rst:278 msgid "" "Similar to :c:func:`PyErr_SetFromWindowsErrWithFilename`, with an additional " "parameter specifying the exception type to be raised." msgstr "" -#: ../../c-api/exceptions.rst:273 +#: ../../c-api/exceptions.rst:286 msgid "" "This is a convenience function to raise :exc:`ImportError`. *msg* will be " "set as the exception's message string. *name* and *path*, both of which can " @@ -304,13 +312,13 @@ msgid "" "``path`` attributes." msgstr "" -#: ../../c-api/exceptions.rst:283 +#: ../../c-api/exceptions.rst:296 msgid "" "Much like :c:func:`PyErr_SetImportError` but this function allows for " "specifying a subclass of :exc:`ImportError` to raise." msgstr "" -#: ../../c-api/exceptions.rst:291 +#: ../../c-api/exceptions.rst:304 msgid "" "Set file, line, and offset information for the current exception. If the " "current exception is not a :exc:`SyntaxError`, then it sets additional " @@ -318,19 +326,19 @@ msgid "" "is a :exc:`SyntaxError`." msgstr "" -#: ../../c-api/exceptions.rst:301 +#: ../../c-api/exceptions.rst:314 msgid "" "Like :c:func:`PyErr_SyntaxLocationObject`, but *filename* is a byte string " "decoded from the :term:`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/exceptions.rst:309 +#: ../../c-api/exceptions.rst:322 msgid "" "Like :c:func:`PyErr_SyntaxLocationEx`, but the *col_offset* parameter is " "omitted." msgstr "" -#: ../../c-api/exceptions.rst:315 +#: ../../c-api/exceptions.rst:328 msgid "" "This is a shorthand for ``PyErr_SetString(PyExc_SystemError, message)``, " "where *message* indicates that an internal operation (e.g. a Python/C API " @@ -338,11 +346,11 @@ msgid "" "use." msgstr "" -#: ../../c-api/exceptions.rst:322 +#: ../../c-api/exceptions.rst:335 msgid "Issuing warnings" msgstr "" -#: ../../c-api/exceptions.rst:324 +#: ../../c-api/exceptions.rst:337 msgid "" "Use these functions to issue warnings from C code. They mirror similar " "functions exported by the Python :mod:`warnings` module. They normally " @@ -358,7 +366,7 @@ msgid "" "return an error value)." msgstr "" -#: ../../c-api/exceptions.rst:339 +#: ../../c-api/exceptions.rst:352 msgid "" "Issue a warning message. The *category* argument is a warning category (see " "below) or ``NULL``; the *message* argument is a UTF-8 encoded string. " @@ -368,7 +376,7 @@ msgid "" "`PyErr_WarnEx`, 2 is the function above that, and so forth." msgstr "" -#: ../../c-api/exceptions.rst:346 +#: ../../c-api/exceptions.rst:359 msgid "" "Warning categories must be subclasses of :c:data:`PyExc_Warning`; :c:data:" "`PyExc_Warning` is a subclass of :c:data:`PyExc_Exception`; the default " @@ -377,14 +385,14 @@ msgid "" "enumerated at :ref:`standardwarningcategories`." msgstr "" -#: ../../c-api/exceptions.rst:352 +#: ../../c-api/exceptions.rst:365 msgid "" "For information about warning control, see the documentation for the :mod:" "`warnings` module and the :option:`-W` option in the command line " "documentation. There is no C API for warning control." msgstr "" -#: ../../c-api/exceptions.rst:359 +#: ../../c-api/exceptions.rst:372 msgid "" "Issue a warning message with explicit control over all warning attributes. " "This is a straightforward wrapper around the Python function :func:`warnings." @@ -392,32 +400,32 @@ msgid "" "arguments may be set to ``NULL`` to get the default effect described there." msgstr "" -#: ../../c-api/exceptions.rst:370 +#: ../../c-api/exceptions.rst:383 msgid "" "Similar to :c:func:`PyErr_WarnExplicitObject` except that *message* and " "*module* are UTF-8 encoded strings, and *filename* is decoded from the :term:" "`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/exceptions.rst:377 +#: ../../c-api/exceptions.rst:390 msgid "" "Function similar to :c:func:`PyErr_WarnEx`, but use :c:func:" "`PyUnicode_FromFormat` to format the warning message. *format* is an ASCII-" "encoded string." msgstr "" -#: ../../c-api/exceptions.rst:386 +#: ../../c-api/exceptions.rst:399 msgid "" "Function similar to :c:func:`PyErr_WarnFormat`, but *category* is :exc:" "`ResourceWarning` and it passes *source* to :class:`!warnings." "WarningMessage`." msgstr "" -#: ../../c-api/exceptions.rst:393 +#: ../../c-api/exceptions.rst:406 msgid "Querying the error indicator" msgstr "" -#: ../../c-api/exceptions.rst:397 +#: ../../c-api/exceptions.rst:410 msgid "" "Test whether the error indicator is set. If set, return the exception " "*type* (the first argument to the last call to one of the ``PyErr_Set*`` " @@ -426,11 +434,11 @@ msgid "" "`Py_DECREF` it." msgstr "" -#: ../../c-api/exceptions.rst:403 +#: ../../c-api/exceptions.rst:416 msgid "The caller must hold the GIL." -msgstr "" +msgstr "呼叫者必須持有 GIL。" -#: ../../c-api/exceptions.rst:407 +#: ../../c-api/exceptions.rst:420 msgid "" "Do not compare the return value to a specific exception; use :c:func:" "`PyErr_ExceptionMatches` instead, shown below. (The comparison could easily " @@ -438,14 +446,14 @@ msgid "" "of a class exception, or it may be a subclass of the expected exception.)" msgstr "" -#: ../../c-api/exceptions.rst:415 +#: ../../c-api/exceptions.rst:428 msgid "" "Equivalent to ``PyErr_GivenExceptionMatches(PyErr_Occurred(), exc)``. This " "should only be called when an exception is actually set; a memory access " "violation will occur if no exception has been raised." msgstr "" -#: ../../c-api/exceptions.rst:422 +#: ../../c-api/exceptions.rst:435 msgid "" "Return true if the *given* exception matches the exception type in *exc*. " "If *exc* is a class object, this also returns true when *given* is an " @@ -453,23 +461,23 @@ msgid "" "tuple (and recursively in subtuples) are searched for a match." msgstr "" -#: ../../c-api/exceptions.rst:430 +#: ../../c-api/exceptions.rst:443 msgid "" "Return the exception currently being raised, clearing the error indicator at " "the same time. Return ``NULL`` if the error indicator is not set." msgstr "" -#: ../../c-api/exceptions.rst:433 +#: ../../c-api/exceptions.rst:446 msgid "" "This function is used by code that needs to catch exceptions, or code that " "needs to save and restore the error indicator temporarily." msgstr "" -#: ../../c-api/exceptions.rst:436 ../../c-api/exceptions.rst:480 +#: ../../c-api/exceptions.rst:449 ../../c-api/exceptions.rst:493 msgid "For example::" msgstr "舉例來說: ::" -#: ../../c-api/exceptions.rst:438 +#: ../../c-api/exceptions.rst:451 msgid "" "{\n" " PyObject *exc = PyErr_GetRaisedException();\n" @@ -479,28 +487,35 @@ msgid "" " PyErr_SetRaisedException(exc);\n" "}" msgstr "" +"{\n" +" PyObject *exc = PyErr_GetRaisedException();\n" +"\n" +" /* ... 可能會產生其他錯誤的程式碼 ... */\n" +"\n" +" PyErr_SetRaisedException(exc);\n" +"}" -#: ../../c-api/exceptions.rst:446 +#: ../../c-api/exceptions.rst:459 msgid "" ":c:func:`PyErr_GetHandledException`, to save the exception currently being " "handled." msgstr "" -#: ../../c-api/exceptions.rst:454 +#: ../../c-api/exceptions.rst:467 msgid "" "Set *exc* as the exception currently being raised, clearing the existing " "exception if one is set." msgstr "" -#: ../../c-api/exceptions.rst:459 +#: ../../c-api/exceptions.rst:472 msgid "This call steals a reference to *exc*, which must be a valid exception." msgstr "" -#: ../../c-api/exceptions.rst:468 +#: ../../c-api/exceptions.rst:481 msgid "Use :c:func:`PyErr_GetRaisedException` instead." -msgstr "" +msgstr "請改用 :c:func:`PyErr_GetRaisedException`。" -#: ../../c-api/exceptions.rst:470 +#: ../../c-api/exceptions.rst:483 msgid "" "Retrieve the error indicator into three variables whose addresses are " "passed. If the error indicator is not set, set all three variables to " @@ -509,13 +524,13 @@ msgid "" "the type object is not." msgstr "" -#: ../../c-api/exceptions.rst:477 +#: ../../c-api/exceptions.rst:490 msgid "" "This function is normally only used by legacy code that needs to catch " "exceptions or save and restore the error indicator temporarily." msgstr "" -#: ../../c-api/exceptions.rst:482 +#: ../../c-api/exceptions.rst:495 msgid "" "{\n" " PyObject *type, *value, *traceback;\n" @@ -526,12 +541,20 @@ msgid "" " PyErr_Restore(type, value, traceback);\n" "}" msgstr "" +"{\n" +" PyObject *type, *value, *traceback;\n" +" PyErr_Fetch(&type, &value, &traceback);\n" +"\n" +" /* ... 可能會產生其他錯誤的程式碼 ... */\n" +"\n" +" PyErr_Restore(type, value, traceback);\n" +"}" -#: ../../c-api/exceptions.rst:496 +#: ../../c-api/exceptions.rst:509 msgid "Use :c:func:`PyErr_SetRaisedException` instead." -msgstr "" +msgstr "請改用 :c:func:`PyErr_SetRaisedException`。" -#: ../../c-api/exceptions.rst:498 +#: ../../c-api/exceptions.rst:511 msgid "" "Set the error indicator from the three objects, *type*, *value*, and " "*traceback*, clearing the existing exception if one is set. If the objects " @@ -544,20 +567,20 @@ msgid "" "don't use this function. I warned you.)" msgstr "" -#: ../../c-api/exceptions.rst:512 +#: ../../c-api/exceptions.rst:525 msgid "" "This function is normally only used by legacy code that needs to save and " "restore the error indicator temporarily. Use :c:func:`PyErr_Fetch` to save " "the current error indicator." msgstr "" -#: ../../c-api/exceptions.rst:521 +#: ../../c-api/exceptions.rst:534 msgid "" "Use :c:func:`PyErr_GetRaisedException` instead, to avoid any possible de-" "normalization." msgstr "" -#: ../../c-api/exceptions.rst:524 +#: ../../c-api/exceptions.rst:537 msgid "" "Under certain circumstances, the values returned by :c:func:`PyErr_Fetch` " "below can be \"unnormalized\", meaning that ``*exc`` is a class object but " @@ -567,14 +590,14 @@ msgid "" "improve performance." msgstr "" -#: ../../c-api/exceptions.rst:532 +#: ../../c-api/exceptions.rst:545 msgid "" "This function *does not* implicitly set the :attr:`~BaseException." "__traceback__` attribute on the exception value. If setting the traceback " "appropriately is desired, the following additional snippet is needed::" msgstr "" -#: ../../c-api/exceptions.rst:537 +#: ../../c-api/exceptions.rst:550 msgid "" "if (tb != NULL) {\n" " PyException_SetTraceback(val, tb);\n" @@ -584,7 +607,7 @@ msgstr "" " PyException_SetTraceback(val, tb);\n" "}" -#: ../../c-api/exceptions.rst:544 +#: ../../c-api/exceptions.rst:557 msgid "" "Retrieve the active exception instance, as would be returned by :func:`sys." "exception`. This refers to an exception that was *already caught*, not to an " @@ -592,7 +615,7 @@ msgid "" "or ``NULL``. Does not modify the interpreter's exception state." msgstr "" -#: ../../c-api/exceptions.rst:551 +#: ../../c-api/exceptions.rst:564 msgid "" "This function is not normally used by code that wants to handle exceptions. " "Rather, it can be used when code needs to save and restore the exception " @@ -600,14 +623,14 @@ msgid "" "clear the exception state." msgstr "" -#: ../../c-api/exceptions.rst:560 +#: ../../c-api/exceptions.rst:573 msgid "" "Set the active exception, as known from ``sys.exception()``. This refers to " "an exception that was *already caught*, not to an exception that was freshly " "raised. To clear the exception state, pass ``NULL``." msgstr "" -#: ../../c-api/exceptions.rst:567 +#: ../../c-api/exceptions.rst:580 msgid "" "This function is not normally used by code that wants to handle exceptions. " "Rather, it can be used when code needs to save and restore the exception " @@ -615,7 +638,7 @@ msgid "" "exception state." msgstr "" -#: ../../c-api/exceptions.rst:576 +#: ../../c-api/exceptions.rst:589 msgid "" "Retrieve the old-style representation of the exception info, as known from :" "func:`sys.exc_info`. This refers to an exception that was *already caught*, " @@ -625,7 +648,7 @@ msgid "" "using :c:func:`PyErr_GetHandledException`." msgstr "" -#: ../../c-api/exceptions.rst:585 +#: ../../c-api/exceptions.rst:598 msgid "" "This function is not normally used by code that wants to handle exceptions. " "Rather, it can be used when code needs to save and restore the exception " @@ -633,7 +656,7 @@ msgid "" "exception state." msgstr "" -#: ../../c-api/exceptions.rst:595 +#: ../../c-api/exceptions.rst:608 msgid "" "Set the exception info, as known from ``sys.exc_info()``. This refers to an " "exception that was *already caught*, not to an exception that was freshly " @@ -643,7 +666,7 @@ msgid "" "`PyErr_SetHandledException`." msgstr "" -#: ../../c-api/exceptions.rst:604 +#: ../../c-api/exceptions.rst:617 msgid "" "This function is not normally used by code that wants to handle exceptions. " "Rather, it can be used when code needs to save and restore the exception " @@ -651,22 +674,22 @@ msgid "" "state." msgstr "" -#: ../../c-api/exceptions.rst:611 +#: ../../c-api/exceptions.rst:624 msgid "" "The ``type`` and ``traceback`` arguments are no longer used and can be NULL. " "The interpreter now derives them from the exception instance (the ``value`` " "argument). The function still steals references of all three arguments." msgstr "" -#: ../../c-api/exceptions.rst:619 +#: ../../c-api/exceptions.rst:632 msgid "Signal Handling" -msgstr "" +msgstr "訊號處理" -#: ../../c-api/exceptions.rst:629 +#: ../../c-api/exceptions.rst:642 msgid "This function interacts with Python's signal handling." msgstr "" -#: ../../c-api/exceptions.rst:631 +#: ../../c-api/exceptions.rst:644 msgid "" "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 " @@ -674,7 +697,7 @@ msgid "" "module is supported, this can invoke a signal handler written in Python." msgstr "" -#: ../../c-api/exceptions.rst:636 +#: ../../c-api/exceptions.rst:649 msgid "" "The function attempts to handle all pending signals, and then returns ``0``. " "However, if a Python signal handler raises an exception, the error indicator " @@ -683,44 +706,44 @@ msgid "" "`PyErr_CheckSignals()` invocation)." msgstr "" -#: ../../c-api/exceptions.rst:642 +#: ../../c-api/exceptions.rst:655 msgid "" "If the function is called from a non-main thread, or under a non-main Python " "interpreter, it does nothing and returns ``0``." msgstr "" -#: ../../c-api/exceptions.rst:645 +#: ../../c-api/exceptions.rst:658 msgid "" "This function can be called by long-running C code that wants to be " "interruptible by user requests (such as by pressing Ctrl-C)." msgstr "" -#: ../../c-api/exceptions.rst:649 +#: ../../c-api/exceptions.rst:662 msgid "" "The default Python signal handler for :c:macro:`!SIGINT` raises the :exc:" "`KeyboardInterrupt` exception." msgstr "" -#: ../../c-api/exceptions.rst:660 +#: ../../c-api/exceptions.rst:673 msgid "" "Simulate the effect of a :c:macro:`!SIGINT` signal arriving. This is " "equivalent to ``PyErr_SetInterruptEx(SIGINT)``." msgstr "" -#: ../../c-api/exceptions.rst:664 ../../c-api/exceptions.rst:691 +#: ../../c-api/exceptions.rst:677 ../../c-api/exceptions.rst:704 msgid "" "This function is async-signal-safe. It can be called without the :term:" "`GIL` and from a C signal handler." msgstr "" -#: ../../c-api/exceptions.rst:674 +#: ../../c-api/exceptions.rst:687 msgid "" "Simulate the effect of a signal arriving. The next time :c:func:" "`PyErr_CheckSignals` is called, the Python signal handler for the given " "signal number will be called." msgstr "" -#: ../../c-api/exceptions.rst:678 +#: ../../c-api/exceptions.rst:691 msgid "" "This function can be called by C code that sets up its own signal handling " "and wants Python signal handlers to be invoked as expected when an " @@ -728,27 +751,27 @@ msgid "" "interrupt an operation)." msgstr "" -#: ../../c-api/exceptions.rst:683 +#: ../../c-api/exceptions.rst:696 msgid "" "If the given signal isn't handled by Python (it was set to :py:const:`signal." "SIG_DFL` or :py:const:`signal.SIG_IGN`), it will be ignored." msgstr "" -#: ../../c-api/exceptions.rst:686 +#: ../../c-api/exceptions.rst:699 msgid "" "If *signum* is outside of the allowed range of signal numbers, ``-1`` is " "returned. Otherwise, ``0`` is returned. The error indicator is never " "changed by this function." msgstr "" -#: ../../c-api/exceptions.rst:699 +#: ../../c-api/exceptions.rst:712 msgid "" "This utility function specifies a file descriptor to which the signal number " "is written as a single byte whenever a signal is received. *fd* must be non-" "blocking. It returns the previous such file descriptor." msgstr "" -#: ../../c-api/exceptions.rst:703 +#: ../../c-api/exceptions.rst:716 msgid "" "The value ``-1`` disables the feature; this is the initial state. This is " "equivalent to :func:`signal.set_wakeup_fd` in Python, but without any error " @@ -756,15 +779,15 @@ msgid "" "be called from the main thread." msgstr "" -#: ../../c-api/exceptions.rst:708 +#: ../../c-api/exceptions.rst:721 msgid "On Windows, the function now also supports socket handles." msgstr "" -#: ../../c-api/exceptions.rst:713 +#: ../../c-api/exceptions.rst:726 msgid "Exception Classes" msgstr "例外類別" -#: ../../c-api/exceptions.rst:717 +#: ../../c-api/exceptions.rst:730 msgid "" "This utility function creates and returns a new exception class. The *name* " "argument must be the name of the new exception, a C string of the form " @@ -773,41 +796,51 @@ msgid "" "(accessible in C as :c:data:`PyExc_Exception`)." msgstr "" -#: ../../c-api/exceptions.rst:723 +#: ../../c-api/exceptions.rst:736 msgid "" -"The :attr:`!__module__` attribute of the new class is set to the first part " -"(up to the last dot) of the *name* argument, and the class name is set to " -"the last part (after the last dot). The *base* argument can be used to " +"The :attr:`~type.__module__` attribute of the new class is set to the first " +"part (up to the last dot) of the *name* argument, and the class name is set " +"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." msgstr "" -#: ../../c-api/exceptions.rst:732 +#: ../../c-api/exceptions.rst:745 msgid "" "Same as :c:func:`PyErr_NewException`, except that the new exception class " "can easily be given a docstring: If *doc* is non-``NULL``, it will be used " "as the docstring for the exception class." msgstr "" -#: ../../c-api/exceptions.rst:740 +#: ../../c-api/exceptions.rst:754 +msgid "" +"Return non-zero if *ob* is an exception class, zero otherwise. This function " +"always succeeds." +msgstr "" + +#: ../../c-api/exceptions.rst:759 +msgid "Return :c:member:`~PyTypeObject.tp_name` of the exception class *ob*." +msgstr "回傳例外類別 *ob* 的 :c:member:`~PyTypeObject.tp_name`。" + +#: ../../c-api/exceptions.rst:763 msgid "Exception Objects" msgstr "例外物件" -#: ../../c-api/exceptions.rst:744 +#: ../../c-api/exceptions.rst:767 msgid "" "Return the traceback associated with the exception as a new reference, as " "accessible from Python through the :attr:`~BaseException.__traceback__` " "attribute. If there is no traceback associated, this returns ``NULL``." msgstr "" -#: ../../c-api/exceptions.rst:752 +#: ../../c-api/exceptions.rst:775 msgid "" "Set the traceback associated with the exception to *tb*. Use ``Py_None`` to " "clear it." msgstr "" -#: ../../c-api/exceptions.rst:758 +#: ../../c-api/exceptions.rst:781 msgid "" "Return the context (another exception instance during whose handling *ex* " "was raised) associated with the exception as a new reference, as accessible " @@ -815,14 +848,14 @@ msgid "" "there is no context associated, this returns ``NULL``." msgstr "" -#: ../../c-api/exceptions.rst:766 +#: ../../c-api/exceptions.rst:789 msgid "" "Set the context associated with the exception to *ctx*. Use ``NULL`` to " "clear it. There is no type check to make sure that *ctx* is an exception " "instance. This steals a reference to *ctx*." msgstr "" -#: ../../c-api/exceptions.rst:773 +#: ../../c-api/exceptions.rst:796 msgid "" "Return the cause (either an exception instance, or ``None``, set by " "``raise ... from ...``) associated with the exception as a new reference, as " @@ -830,28 +863,28 @@ msgid "" "attribute." msgstr "" -#: ../../c-api/exceptions.rst:781 +#: ../../c-api/exceptions.rst:804 msgid "" "Set the cause associated with the exception to *cause*. Use ``NULL`` to " "clear it. There is no type check to make sure that *cause* is either an " "exception instance or ``None``. This steals a reference to *cause*." msgstr "" -#: ../../c-api/exceptions.rst:785 +#: ../../c-api/exceptions.rst:808 msgid "" "The :attr:`~BaseException.__suppress_context__` attribute is implicitly set " "to ``True`` by this function." msgstr "" -#: ../../c-api/exceptions.rst:791 +#: ../../c-api/exceptions.rst:814 msgid "Return :attr:`~BaseException.args` of exception *ex*." -msgstr "" +msgstr "回傳例外 *ex* 的 :attr:`~BaseException.args`。" -#: ../../c-api/exceptions.rst:796 +#: ../../c-api/exceptions.rst:819 msgid "Set :attr:`~BaseException.args` of exception *ex* to *args*." -msgstr "" +msgstr "設定例外 *ex* 的 :attr:`~BaseException.args` 為 *args*。" -#: ../../c-api/exceptions.rst:800 +#: ../../c-api/exceptions.rst:823 msgid "" "Implement part of the interpreter's implementation of :keyword:`!except*`. " "*orig* is the original exception that was caught, and *excs* is the list of " @@ -863,72 +896,72 @@ msgid "" "if there is nothing to reraise." msgstr "" -#: ../../c-api/exceptions.rst:814 +#: ../../c-api/exceptions.rst:837 msgid "Unicode Exception Objects" -msgstr "" +msgstr "Unicode 例外物件" -#: ../../c-api/exceptions.rst:816 +#: ../../c-api/exceptions.rst:839 msgid "" "The following functions are used to create and modify Unicode exceptions " "from C." msgstr "" -#: ../../c-api/exceptions.rst:820 +#: ../../c-api/exceptions.rst:843 msgid "" "Create a :class:`UnicodeDecodeError` object with the attributes *encoding*, " "*object*, *length*, *start*, *end* and *reason*. *encoding* and *reason* are " "UTF-8 encoded strings." msgstr "" -#: ../../c-api/exceptions.rst:827 +#: ../../c-api/exceptions.rst:850 msgid "Return the *encoding* attribute of the given exception object." msgstr "" -#: ../../c-api/exceptions.rst:833 +#: ../../c-api/exceptions.rst:856 msgid "Return the *object* attribute of the given exception object." msgstr "" -#: ../../c-api/exceptions.rst:839 +#: ../../c-api/exceptions.rst:862 msgid "" "Get the *start* attribute of the given exception object and place it into " "*\\*start*. *start* must not be ``NULL``. Return ``0`` on success, ``-1`` " "on failure." msgstr "" -#: ../../c-api/exceptions.rst:847 +#: ../../c-api/exceptions.rst:870 msgid "" "Set the *start* attribute of the given exception object to *start*. Return " "``0`` on success, ``-1`` on failure." msgstr "" -#: ../../c-api/exceptions.rst:854 +#: ../../c-api/exceptions.rst:877 msgid "" "Get the *end* attribute of the given exception object and place it into " "*\\*end*. *end* must not be ``NULL``. Return ``0`` on success, ``-1`` on " "failure." msgstr "" -#: ../../c-api/exceptions.rst:862 +#: ../../c-api/exceptions.rst:885 msgid "" "Set the *end* attribute of the given exception object to *end*. Return " "``0`` on success, ``-1`` on failure." msgstr "" -#: ../../c-api/exceptions.rst:869 +#: ../../c-api/exceptions.rst:892 msgid "Return the *reason* attribute of the given exception object." -msgstr "" +msgstr "回傳給定例外物件的 *reason* 屬性。" -#: ../../c-api/exceptions.rst:875 +#: ../../c-api/exceptions.rst:898 msgid "" "Set the *reason* attribute of the given exception object to *reason*. " "Return ``0`` on success, ``-1`` on failure." msgstr "" -#: ../../c-api/exceptions.rst:882 +#: ../../c-api/exceptions.rst:905 msgid "Recursion Control" -msgstr "" +msgstr "遞迴控制" -#: ../../c-api/exceptions.rst:884 +#: ../../c-api/exceptions.rst:907 msgid "" "These two functions provide a way to perform safe recursive calls at the C " "level, both in the core and in extension modules. They are needed if the " @@ -938,44 +971,44 @@ msgid "" "recursion handling." msgstr "" -#: ../../c-api/exceptions.rst:893 +#: ../../c-api/exceptions.rst:916 msgid "Marks a point where a recursive C-level call is about to be performed." msgstr "" -#: ../../c-api/exceptions.rst:895 +#: ../../c-api/exceptions.rst:918 msgid "" "If :c:macro:`!USE_STACKCHECK` is defined, this function checks if the OS " "stack overflowed using :c:func:`PyOS_CheckStack`. If this is the case, it " "sets a :exc:`MemoryError` and returns a nonzero value." msgstr "" -#: ../../c-api/exceptions.rst:899 +#: ../../c-api/exceptions.rst:922 msgid "" "The function then checks if the recursion limit is reached. If this is the " "case, a :exc:`RecursionError` is set and a nonzero value is returned. " "Otherwise, zero is returned." msgstr "" -#: ../../c-api/exceptions.rst:903 +#: ../../c-api/exceptions.rst:926 msgid "" "*where* should be a UTF-8 encoded string such as ``\" in instance check\"`` " "to be concatenated to the :exc:`RecursionError` message caused by the " "recursion depth limit." msgstr "" -#: ../../c-api/exceptions.rst:907 ../../c-api/exceptions.rst:915 +#: ../../c-api/exceptions.rst:930 ../../c-api/exceptions.rst:938 msgid "" "This function is now also available in the :ref:`limited API `." msgstr "" -#: ../../c-api/exceptions.rst:912 +#: ../../c-api/exceptions.rst:935 msgid "" "Ends a :c:func:`Py_EnterRecursiveCall`. Must be called once for each " "*successful* invocation of :c:func:`Py_EnterRecursiveCall`." msgstr "" -#: ../../c-api/exceptions.rst:918 +#: ../../c-api/exceptions.rst:941 msgid "" "Properly implementing :c:member:`~PyTypeObject.tp_repr` for container types " "requires special recursion handling. In addition to protecting the stack, :" @@ -984,13 +1017,13 @@ msgid "" "Effectively, these are the C equivalent to :func:`reprlib.recursive_repr`." msgstr "" -#: ../../c-api/exceptions.rst:926 +#: ../../c-api/exceptions.rst:949 msgid "" "Called at the beginning of the :c:member:`~PyTypeObject.tp_repr` " "implementation to detect cycles." msgstr "" -#: ../../c-api/exceptions.rst:929 +#: ../../c-api/exceptions.rst:952 msgid "" "If the object has already been processed, the function returns a positive " "integer. In that case the :c:member:`~PyTypeObject.tp_repr` implementation " @@ -998,482 +1031,276 @@ msgid "" "`dict` objects return ``{...}`` and :class:`list` objects return ``[...]``." msgstr "" -#: ../../c-api/exceptions.rst:935 +#: ../../c-api/exceptions.rst:958 msgid "" "The function will return a negative integer if the recursion limit is " "reached. In that case the :c:member:`~PyTypeObject.tp_repr` implementation " "should typically return ``NULL``." msgstr "" -#: ../../c-api/exceptions.rst:939 +#: ../../c-api/exceptions.rst:962 msgid "" "Otherwise, the function returns zero and the :c:member:`~PyTypeObject." "tp_repr` implementation can continue normally." msgstr "" -#: ../../c-api/exceptions.rst:944 +#: ../../c-api/exceptions.rst:967 msgid "" "Ends a :c:func:`Py_ReprEnter`. Must be called once for each invocation of :" "c:func:`Py_ReprEnter` that returns zero." msgstr "" -#: ../../c-api/exceptions.rst:951 -msgid "Standard Exceptions" -msgstr "" +#: ../../c-api/exceptions.rst:974 +msgid "Exception and warning types" +msgstr "例外和警告型別" -#: ../../c-api/exceptions.rst:953 +#: ../../c-api/exceptions.rst:976 msgid "" -"All standard Python exceptions are available as global variables whose names " -"are ``PyExc_`` followed by the Python exception name. These have the type :" -"c:expr:`PyObject*`; they are all class objects. For completeness, here are " -"all the variables:" +"All standard Python exceptions and warning categories are available as " +"global variables whose names are ``PyExc_`` followed by the Python exception " +"name. These have the type :c:expr:`PyObject*`; they are all class objects." msgstr "" -#: ../../c-api/exceptions.rst:1014 ../../c-api/exceptions.rst:1147 -#: ../../c-api/exceptions.rst:1192 -msgid "C Name" -msgstr "C 名稱" +#: ../../c-api/exceptions.rst:980 +msgid "For completeness, here are all the variables:" +msgstr "" -#: ../../c-api/exceptions.rst:1014 ../../c-api/exceptions.rst:1192 -msgid "Python Name" -msgstr "Python 名稱" +#: ../../c-api/exceptions.rst:983 +msgid "Exception types" +msgstr "例外型別" -#: ../../c-api/exceptions.rst:1014 ../../c-api/exceptions.rst:1147 -#: ../../c-api/exceptions.rst:1192 -msgid "Notes" -msgstr "註解" +#: ../../c-api/exceptions.rst:990 ../../c-api/exceptions.rst:1136 +#: ../../c-api/exceptions.rst:1166 +msgid "C name" +msgstr "C 名稱" -#: ../../c-api/exceptions.rst:1016 -msgid ":c:data:`PyExc_BaseException`" -msgstr ":c:data:`PyExc_BaseException`" +#: ../../c-api/exceptions.rst:991 ../../c-api/exceptions.rst:1137 +#: ../../c-api/exceptions.rst:1167 +msgid "Python name" +msgstr "Python 名稱" -#: ../../c-api/exceptions.rst:1016 +#: ../../c-api/exceptions.rst:993 msgid ":exc:`BaseException`" msgstr ":exc:`BaseException`" -#: ../../c-api/exceptions.rst:1016 ../../c-api/exceptions.rst:1018 -#: ../../c-api/exceptions.rst:1020 ../../c-api/exceptions.rst:1066 -#: ../../c-api/exceptions.rst:1078 -msgid "[1]_" -msgstr "[1]_" - -#: ../../c-api/exceptions.rst:1018 -msgid ":c:data:`PyExc_Exception`" -msgstr ":c:data:`PyExc_Exception`" +#: ../../c-api/exceptions.rst:995 +msgid ":exc:`BaseExceptionGroup`" +msgstr ":exc:`BaseExceptionGroup`" -#: ../../c-api/exceptions.rst:1018 +#: ../../c-api/exceptions.rst:997 msgid ":exc:`Exception`" msgstr ":exc:`Exception`" -#: ../../c-api/exceptions.rst:1020 -msgid ":c:data:`PyExc_ArithmeticError`" -msgstr ":c:data:`PyExc_ArithmeticError`" - -#: ../../c-api/exceptions.rst:1020 +#: ../../c-api/exceptions.rst:999 msgid ":exc:`ArithmeticError`" msgstr ":exc:`ArithmeticError`" -#: ../../c-api/exceptions.rst:1022 -msgid ":c:data:`PyExc_AssertionError`" -msgstr ":c:data:`PyExc_AssertionError`" - -#: ../../c-api/exceptions.rst:1022 +#: ../../c-api/exceptions.rst:1001 msgid ":exc:`AssertionError`" msgstr ":exc:`AssertionError`" -#: ../../c-api/exceptions.rst:1024 -msgid ":c:data:`PyExc_AttributeError`" -msgstr ":c:data:`PyExc_AttributeError`" - -#: ../../c-api/exceptions.rst:1024 +#: ../../c-api/exceptions.rst:1003 msgid ":exc:`AttributeError`" msgstr ":exc:`AttributeError`" -#: ../../c-api/exceptions.rst:1026 -msgid ":c:data:`PyExc_BlockingIOError`" -msgstr ":c:data:`PyExc_BlockingIOError`" - -#: ../../c-api/exceptions.rst:1026 +#: ../../c-api/exceptions.rst:1005 msgid ":exc:`BlockingIOError`" msgstr ":exc:`BlockingIOError`" -#: ../../c-api/exceptions.rst:1028 -msgid ":c:data:`PyExc_BrokenPipeError`" -msgstr ":c:data:`PyExc_BrokenPipeError`" - -#: ../../c-api/exceptions.rst:1028 +#: ../../c-api/exceptions.rst:1007 msgid ":exc:`BrokenPipeError`" msgstr ":exc:`BrokenPipeError`" -#: ../../c-api/exceptions.rst:1030 -msgid ":c:data:`PyExc_BufferError`" -msgstr ":c:data:`PyExc_BufferError`" - -#: ../../c-api/exceptions.rst:1030 +#: ../../c-api/exceptions.rst:1009 msgid ":exc:`BufferError`" msgstr ":exc:`BufferError`" -#: ../../c-api/exceptions.rst:1032 -msgid ":c:data:`PyExc_ChildProcessError`" -msgstr ":c:data:`PyExc_ChildProcessError`" - -#: ../../c-api/exceptions.rst:1032 +#: ../../c-api/exceptions.rst:1011 msgid ":exc:`ChildProcessError`" msgstr ":exc:`ChildProcessError`" -#: ../../c-api/exceptions.rst:1034 -msgid ":c:data:`PyExc_ConnectionAbortedError`" -msgstr ":c:data:`PyExc_ConnectionAbortedError`" - -#: ../../c-api/exceptions.rst:1034 +#: ../../c-api/exceptions.rst:1013 msgid ":exc:`ConnectionAbortedError`" msgstr ":exc:`ConnectionAbortedError`" -#: ../../c-api/exceptions.rst:1036 -msgid ":c:data:`PyExc_ConnectionError`" -msgstr ":c:data:`PyExc_ConnectionError`" - -#: ../../c-api/exceptions.rst:1036 +#: ../../c-api/exceptions.rst:1015 msgid ":exc:`ConnectionError`" msgstr ":exc:`ConnectionError`" -#: ../../c-api/exceptions.rst:1038 -msgid ":c:data:`PyExc_ConnectionRefusedError`" -msgstr ":c:data:`PyExc_ConnectionRefusedError`" - -#: ../../c-api/exceptions.rst:1038 +#: ../../c-api/exceptions.rst:1017 msgid ":exc:`ConnectionRefusedError`" msgstr ":exc:`ConnectionRefusedError`" -#: ../../c-api/exceptions.rst:1040 -msgid ":c:data:`PyExc_ConnectionResetError`" -msgstr ":c:data:`PyExc_ConnectionResetError`" - -#: ../../c-api/exceptions.rst:1040 +#: ../../c-api/exceptions.rst:1019 msgid ":exc:`ConnectionResetError`" msgstr ":exc:`ConnectionResetError`" -#: ../../c-api/exceptions.rst:1042 -msgid ":c:data:`PyExc_EOFError`" -msgstr ":c:data:`PyExc_EOFError`" - -#: ../../c-api/exceptions.rst:1042 +#: ../../c-api/exceptions.rst:1021 msgid ":exc:`EOFError`" msgstr ":exc:`EOFError`" -#: ../../c-api/exceptions.rst:1044 -msgid ":c:data:`PyExc_FileExistsError`" -msgstr ":c:data:`PyExc_FileExistsError`" - -#: ../../c-api/exceptions.rst:1044 +#: ../../c-api/exceptions.rst:1023 msgid ":exc:`FileExistsError`" msgstr ":exc:`FileExistsError`" -#: ../../c-api/exceptions.rst:1046 -msgid ":c:data:`PyExc_FileNotFoundError`" -msgstr ":c:data:`PyExc_FileNotFoundError`" - -#: ../../c-api/exceptions.rst:1046 +#: ../../c-api/exceptions.rst:1025 msgid ":exc:`FileNotFoundError`" msgstr ":exc:`FileNotFoundError`" -#: ../../c-api/exceptions.rst:1048 -msgid ":c:data:`PyExc_FloatingPointError`" -msgstr ":c:data:`PyExc_FloatingPointError`" - -#: ../../c-api/exceptions.rst:1048 +#: ../../c-api/exceptions.rst:1027 msgid ":exc:`FloatingPointError`" msgstr ":exc:`FloatingPointError`" -#: ../../c-api/exceptions.rst:1050 -msgid ":c:data:`PyExc_GeneratorExit`" -msgstr ":c:data:`PyExc_GeneratorExit`" - -#: ../../c-api/exceptions.rst:1050 +#: ../../c-api/exceptions.rst:1029 msgid ":exc:`GeneratorExit`" msgstr ":exc:`GeneratorExit`" -#: ../../c-api/exceptions.rst:1052 -msgid ":c:data:`PyExc_ImportError`" -msgstr ":c:data:`PyExc_ImportError`" - -#: ../../c-api/exceptions.rst:1052 +#: ../../c-api/exceptions.rst:1031 msgid ":exc:`ImportError`" msgstr ":exc:`ImportError`" -#: ../../c-api/exceptions.rst:1054 -msgid ":c:data:`PyExc_IndentationError`" -msgstr ":c:data:`PyExc_IndentationError`" - -#: ../../c-api/exceptions.rst:1054 +#: ../../c-api/exceptions.rst:1033 msgid ":exc:`IndentationError`" msgstr ":exc:`IndentationError`" -#: ../../c-api/exceptions.rst:1056 -msgid ":c:data:`PyExc_IndexError`" -msgstr ":c:data:`PyExc_IndexError`" - -#: ../../c-api/exceptions.rst:1056 +#: ../../c-api/exceptions.rst:1035 msgid ":exc:`IndexError`" msgstr ":exc:`IndexError`" -#: ../../c-api/exceptions.rst:1058 -msgid ":c:data:`PyExc_InterruptedError`" -msgstr ":c:data:`PyExc_InterruptedError`" - -#: ../../c-api/exceptions.rst:1058 +#: ../../c-api/exceptions.rst:1037 msgid ":exc:`InterruptedError`" msgstr ":exc:`InterruptedError`" -#: ../../c-api/exceptions.rst:1060 -msgid ":c:data:`PyExc_IsADirectoryError`" -msgstr ":c:data:`PyExc_IsADirectoryError`" - -#: ../../c-api/exceptions.rst:1060 +#: ../../c-api/exceptions.rst:1039 msgid ":exc:`IsADirectoryError`" msgstr ":exc:`IsADirectoryError`" -#: ../../c-api/exceptions.rst:1062 -msgid ":c:data:`PyExc_KeyError`" -msgstr ":c:data:`PyExc_KeyError`" - -#: ../../c-api/exceptions.rst:1062 +#: ../../c-api/exceptions.rst:1041 msgid ":exc:`KeyError`" msgstr ":exc:`KeyError`" -#: ../../c-api/exceptions.rst:1064 -msgid ":c:data:`PyExc_KeyboardInterrupt`" -msgstr ":c:data:`PyExc_KeyboardInterrupt`" - -#: ../../c-api/exceptions.rst:1064 +#: ../../c-api/exceptions.rst:1043 msgid ":exc:`KeyboardInterrupt`" msgstr ":exc:`KeyboardInterrupt`" -#: ../../c-api/exceptions.rst:1066 -msgid ":c:data:`PyExc_LookupError`" -msgstr ":c:data:`PyExc_LookupError`" - -#: ../../c-api/exceptions.rst:1066 +#: ../../c-api/exceptions.rst:1045 msgid ":exc:`LookupError`" msgstr ":exc:`LookupError`" -#: ../../c-api/exceptions.rst:1068 -msgid ":c:data:`PyExc_MemoryError`" -msgstr ":c:data:`PyExc_MemoryError`" - -#: ../../c-api/exceptions.rst:1068 +#: ../../c-api/exceptions.rst:1047 msgid ":exc:`MemoryError`" msgstr ":exc:`MemoryError`" -#: ../../c-api/exceptions.rst:1070 -msgid ":c:data:`PyExc_ModuleNotFoundError`" -msgstr ":c:data:`PyExc_ModuleNotFoundError`" - -#: ../../c-api/exceptions.rst:1070 +#: ../../c-api/exceptions.rst:1049 msgid ":exc:`ModuleNotFoundError`" msgstr ":exc:`ModuleNotFoundError`" -#: ../../c-api/exceptions.rst:1072 -msgid ":c:data:`PyExc_NameError`" -msgstr ":c:data:`PyExc_NameError`" - -#: ../../c-api/exceptions.rst:1072 +#: ../../c-api/exceptions.rst:1051 msgid ":exc:`NameError`" msgstr ":exc:`NameError`" -#: ../../c-api/exceptions.rst:1074 -msgid ":c:data:`PyExc_NotADirectoryError`" -msgstr ":c:data:`PyExc_NotADirectoryError`" - -#: ../../c-api/exceptions.rst:1074 +#: ../../c-api/exceptions.rst:1053 msgid ":exc:`NotADirectoryError`" msgstr ":exc:`NotADirectoryError`" -#: ../../c-api/exceptions.rst:1076 -msgid ":c:data:`PyExc_NotImplementedError`" -msgstr ":c:data:`PyExc_NotImplementedError`" - -#: ../../c-api/exceptions.rst:1076 +#: ../../c-api/exceptions.rst:1055 msgid ":exc:`NotImplementedError`" msgstr ":exc:`NotImplementedError`" -#: ../../c-api/exceptions.rst:1078 -msgid ":c:data:`PyExc_OSError`" -msgstr ":c:data:`PyExc_OSError`" - -#: ../../c-api/exceptions.rst:1078 +#: ../../c-api/exceptions.rst:1057 ../../c-api/exceptions.rst:1140 +#: ../../c-api/exceptions.rst:1143 ../../c-api/exceptions.rst:1146 msgid ":exc:`OSError`" msgstr ":exc:`OSError`" -#: ../../c-api/exceptions.rst:1080 -msgid ":c:data:`PyExc_OverflowError`" -msgstr ":c:data:`PyExc_OverflowError`" - -#: ../../c-api/exceptions.rst:1080 +#: ../../c-api/exceptions.rst:1059 msgid ":exc:`OverflowError`" msgstr ":exc:`OverflowError`" -#: ../../c-api/exceptions.rst:1082 -msgid ":c:data:`PyExc_PermissionError`" -msgstr ":c:data:`PyExc_PermissionError`" - -#: ../../c-api/exceptions.rst:1082 +#: ../../c-api/exceptions.rst:1061 msgid ":exc:`PermissionError`" msgstr ":exc:`PermissionError`" -#: ../../c-api/exceptions.rst:1084 -msgid ":c:data:`PyExc_ProcessLookupError`" -msgstr ":c:data:`PyExc_ProcessLookupError`" - -#: ../../c-api/exceptions.rst:1084 +#: ../../c-api/exceptions.rst:1063 msgid ":exc:`ProcessLookupError`" msgstr ":exc:`ProcessLookupError`" -#: ../../c-api/exceptions.rst:1086 -msgid ":c:data:`PyExc_RecursionError`" -msgstr ":c:data:`PyExc_RecursionError`" +#: ../../c-api/exceptions.rst:1065 +msgid ":exc:`PythonFinalizationError`" +msgstr ":exc:`PythonFinalizationError`" -#: ../../c-api/exceptions.rst:1086 +#: ../../c-api/exceptions.rst:1067 msgid ":exc:`RecursionError`" msgstr ":exc:`RecursionError`" -#: ../../c-api/exceptions.rst:1088 -msgid ":c:data:`PyExc_ReferenceError`" -msgstr ":c:data:`PyExc_ReferenceError`" - -#: ../../c-api/exceptions.rst:1088 +#: ../../c-api/exceptions.rst:1069 msgid ":exc:`ReferenceError`" msgstr ":exc:`ReferenceError`" -#: ../../c-api/exceptions.rst:1090 -msgid ":c:data:`PyExc_RuntimeError`" -msgstr ":c:data:`PyExc_RuntimeError`" - -#: ../../c-api/exceptions.rst:1090 +#: ../../c-api/exceptions.rst:1071 msgid ":exc:`RuntimeError`" msgstr ":exc:`RuntimeError`" -#: ../../c-api/exceptions.rst:1092 -msgid ":c:data:`PyExc_StopAsyncIteration`" -msgstr ":c:data:`PyExc_StopAsyncIteration`" - -#: ../../c-api/exceptions.rst:1092 +#: ../../c-api/exceptions.rst:1073 msgid ":exc:`StopAsyncIteration`" msgstr ":exc:`StopAsyncIteration`" -#: ../../c-api/exceptions.rst:1094 -msgid ":c:data:`PyExc_StopIteration`" -msgstr ":c:data:`PyExc_StopIteration`" - -#: ../../c-api/exceptions.rst:1094 +#: ../../c-api/exceptions.rst:1075 msgid ":exc:`StopIteration`" msgstr ":exc:`StopIteration`" -#: ../../c-api/exceptions.rst:1096 -msgid ":c:data:`PyExc_SyntaxError`" -msgstr ":c:data:`PyExc_SyntaxError`" - -#: ../../c-api/exceptions.rst:1096 +#: ../../c-api/exceptions.rst:1077 msgid ":exc:`SyntaxError`" msgstr ":exc:`SyntaxError`" -#: ../../c-api/exceptions.rst:1098 -msgid ":c:data:`PyExc_SystemError`" -msgstr ":c:data:`PyExc_SystemError`" - -#: ../../c-api/exceptions.rst:1098 +#: ../../c-api/exceptions.rst:1079 msgid ":exc:`SystemError`" msgstr ":exc:`SystemError`" -#: ../../c-api/exceptions.rst:1100 -msgid ":c:data:`PyExc_SystemExit`" -msgstr ":c:data:`PyExc_SystemExit`" - -#: ../../c-api/exceptions.rst:1100 +#: ../../c-api/exceptions.rst:1081 msgid ":exc:`SystemExit`" msgstr ":exc:`SystemExit`" -#: ../../c-api/exceptions.rst:1102 -msgid ":c:data:`PyExc_TabError`" -msgstr ":c:data:`PyExc_TabError`" - -#: ../../c-api/exceptions.rst:1102 +#: ../../c-api/exceptions.rst:1083 msgid ":exc:`TabError`" msgstr ":exc:`TabError`" -#: ../../c-api/exceptions.rst:1104 -msgid ":c:data:`PyExc_TimeoutError`" -msgstr ":c:data:`PyExc_TimeoutError`" - -#: ../../c-api/exceptions.rst:1104 +#: ../../c-api/exceptions.rst:1085 msgid ":exc:`TimeoutError`" msgstr ":exc:`TimeoutError`" -#: ../../c-api/exceptions.rst:1106 -msgid ":c:data:`PyExc_TypeError`" -msgstr ":c:data:`PyExc_TypeError`" - -#: ../../c-api/exceptions.rst:1106 +#: ../../c-api/exceptions.rst:1087 msgid ":exc:`TypeError`" msgstr ":exc:`TypeError`" -#: ../../c-api/exceptions.rst:1108 -msgid ":c:data:`PyExc_UnboundLocalError`" -msgstr ":c:data:`PyExc_UnboundLocalError`" - -#: ../../c-api/exceptions.rst:1108 +#: ../../c-api/exceptions.rst:1089 msgid ":exc:`UnboundLocalError`" msgstr ":exc:`UnboundLocalError`" -#: ../../c-api/exceptions.rst:1110 -msgid ":c:data:`PyExc_UnicodeDecodeError`" -msgstr ":c:data:`PyExc_UnicodeDecodeError`" - -#: ../../c-api/exceptions.rst:1110 +#: ../../c-api/exceptions.rst:1091 msgid ":exc:`UnicodeDecodeError`" msgstr ":exc:`UnicodeDecodeError`" -#: ../../c-api/exceptions.rst:1112 -msgid ":c:data:`PyExc_UnicodeEncodeError`" -msgstr ":c:data:`PyExc_UnicodeEncodeError`" - -#: ../../c-api/exceptions.rst:1112 +#: ../../c-api/exceptions.rst:1093 msgid ":exc:`UnicodeEncodeError`" msgstr ":exc:`UnicodeEncodeError`" -#: ../../c-api/exceptions.rst:1114 -msgid ":c:data:`PyExc_UnicodeError`" -msgstr ":c:data:`PyExc_UnicodeError`" - -#: ../../c-api/exceptions.rst:1114 +#: ../../c-api/exceptions.rst:1095 msgid ":exc:`UnicodeError`" msgstr ":exc:`UnicodeError`" -#: ../../c-api/exceptions.rst:1116 -msgid ":c:data:`PyExc_UnicodeTranslateError`" -msgstr ":c:data:`PyExc_UnicodeTranslateError`" - -#: ../../c-api/exceptions.rst:1116 +#: ../../c-api/exceptions.rst:1097 msgid ":exc:`UnicodeTranslateError`" msgstr ":exc:`UnicodeTranslateError`" -#: ../../c-api/exceptions.rst:1118 -msgid ":c:data:`PyExc_ValueError`" -msgstr ":c:data:`PyExc_ValueError`" - -#: ../../c-api/exceptions.rst:1118 +#: ../../c-api/exceptions.rst:1099 msgid ":exc:`ValueError`" msgstr ":exc:`ValueError`" -#: ../../c-api/exceptions.rst:1120 -msgid ":c:data:`PyExc_ZeroDivisionError`" -msgstr ":c:data:`PyExc_ZeroDivisionError`" - -#: ../../c-api/exceptions.rst:1120 +#: ../../c-api/exceptions.rst:1101 msgid ":exc:`ZeroDivisionError`" msgstr ":exc:`ZeroDivisionError`" -#: ../../c-api/exceptions.rst:1123 +#: ../../c-api/exceptions.rst:1103 msgid "" ":c:data:`PyExc_BlockingIOError`, :c:data:`PyExc_BrokenPipeError`, :c:data:" "`PyExc_ChildProcessError`, :c:data:`PyExc_ConnectionError`, :c:data:" @@ -1493,451 +1320,127 @@ msgstr "" "`PyExc_PermissionError`, :c:data:`PyExc_ProcessLookupError` 和 :c:data:" "`PyExc_TimeoutError` 是在 :pep:`3151` 被引入。" -#: ../../c-api/exceptions.rst:1133 +#: ../../c-api/exceptions.rst:1113 msgid ":c:data:`PyExc_StopAsyncIteration` and :c:data:`PyExc_RecursionError`." msgstr ":c:data:`PyExc_StopAsyncIteration` 和 :c:data:`PyExc_RecursionError`。" -#: ../../c-api/exceptions.rst:1136 +#: ../../c-api/exceptions.rst:1116 msgid ":c:data:`PyExc_ModuleNotFoundError`." msgstr ":c:data:`PyExc_ModuleNotFoundError`。" -#: ../../c-api/exceptions.rst:1139 -msgid "These are compatibility aliases to :c:data:`PyExc_OSError`:" -msgstr "" +#: ../../c-api/exceptions.rst:1119 +msgid ":c:data:`PyExc_BaseExceptionGroup`." +msgstr ":c:data:`PyExc_BaseExceptionGroup`" -#: ../../c-api/exceptions.rst:1149 -msgid ":c:data:`!PyExc_EnvironmentError`" -msgstr ":c:data:`!PyExc_EnvironmentError`" - -#: ../../c-api/exceptions.rst:1151 -msgid ":c:data:`!PyExc_IOError`" -msgstr ":c:data:`!PyExc_IOError`" +#: ../../c-api/exceptions.rst:1124 +msgid "OSError aliases" +msgstr "OSError 別名" -#: ../../c-api/exceptions.rst:1153 -msgid ":c:data:`!PyExc_WindowsError`" -msgstr ":c:data:`!PyExc_WindowsError`" - -#: ../../c-api/exceptions.rst:1153 -msgid "[2]_" -msgstr "[2]_" +#: ../../c-api/exceptions.rst:1126 +msgid "The following are a compatibility aliases to :c:data:`PyExc_OSError`." +msgstr "" -#: ../../c-api/exceptions.rst:1156 +#: ../../c-api/exceptions.rst:1128 msgid "These aliases used to be separate exception types." msgstr "" -#: ../../c-api/exceptions.rst:1159 ../../c-api/exceptions.rst:1220 -msgid "Notes:" -msgstr "註解:" - -#: ../../c-api/exceptions.rst:1162 -msgid "This is a base class for other standard exceptions." -msgstr "" +#: ../../c-api/exceptions.rst:1138 +msgid "Notes" +msgstr "註解" -#: ../../c-api/exceptions.rst:1165 -msgid "" -"Only defined on Windows; protect code that uses this by testing that the " -"preprocessor macro ``MS_WINDOWS`` is defined." -msgstr "" +#: ../../c-api/exceptions.rst:1147 +msgid "[win]_" +msgstr "[win]_" -#: ../../c-api/exceptions.rst:1171 -msgid "Standard Warning Categories" -msgstr "" +#: ../../c-api/exceptions.rst:1149 +msgid "Notes:" +msgstr "註解:" -#: ../../c-api/exceptions.rst:1173 +#: ../../c-api/exceptions.rst:1152 msgid "" -"All standard Python warning categories are available as global variables " -"whose names are ``PyExc_`` followed by the Python exception name. These have " -"the type :c:expr:`PyObject*`; they are all class objects. For completeness, " -"here are all the variables:" +":c:var:`!PyExc_WindowsError` is only defined on Windows; protect code that " +"uses this by testing that the preprocessor macro ``MS_WINDOWS`` is defined." msgstr "" -#: ../../c-api/exceptions.rst:1194 -msgid ":c:data:`PyExc_Warning`" -msgstr ":c:data:`PyExc_Warning`" +#: ../../c-api/exceptions.rst:1159 +msgid "Warning types" +msgstr "警告型別" -#: ../../c-api/exceptions.rst:1194 +#: ../../c-api/exceptions.rst:1169 msgid ":exc:`Warning`" msgstr ":exc:`Warning`" -#: ../../c-api/exceptions.rst:1194 -msgid "[3]_" -msgstr "[3]_" - -#: ../../c-api/exceptions.rst:1196 -msgid ":c:data:`PyExc_BytesWarning`" -msgstr ":c:data:`PyExc_BytesWarning`" - -#: ../../c-api/exceptions.rst:1196 +#: ../../c-api/exceptions.rst:1171 msgid ":exc:`BytesWarning`" msgstr ":exc:`BytesWarning`" -#: ../../c-api/exceptions.rst:1198 -msgid ":c:data:`PyExc_DeprecationWarning`" -msgstr ":c:data:`PyExc_DeprecationWarning`" - -#: ../../c-api/exceptions.rst:1198 +#: ../../c-api/exceptions.rst:1173 msgid ":exc:`DeprecationWarning`" msgstr ":exc:`DeprecationWarning`" -#: ../../c-api/exceptions.rst:1200 -msgid ":c:data:`PyExc_FutureWarning`" -msgstr ":c:data:`PyExc_FutureWarning`" +#: ../../c-api/exceptions.rst:1175 +msgid ":exc:`EncodingWarning`" +msgstr ":exc:`EncodingWarning`" -#: ../../c-api/exceptions.rst:1200 +#: ../../c-api/exceptions.rst:1177 msgid ":exc:`FutureWarning`" msgstr ":exc:`FutureWarning`" -#: ../../c-api/exceptions.rst:1202 -msgid ":c:data:`PyExc_ImportWarning`" -msgstr ":c:data:`PyExc_ImportWarning`" - -#: ../../c-api/exceptions.rst:1202 +#: ../../c-api/exceptions.rst:1179 msgid ":exc:`ImportWarning`" msgstr ":exc:`ImportWarning`" -#: ../../c-api/exceptions.rst:1204 -msgid ":c:data:`PyExc_PendingDeprecationWarning`" -msgstr ":c:data:`PyExc_PendingDeprecationWarning`" - -#: ../../c-api/exceptions.rst:1204 +#: ../../c-api/exceptions.rst:1181 msgid ":exc:`PendingDeprecationWarning`" msgstr ":exc:`PendingDeprecationWarning`" -#: ../../c-api/exceptions.rst:1206 -msgid ":c:data:`PyExc_ResourceWarning`" -msgstr ":c:data:`PyExc_ResourceWarning`" - -#: ../../c-api/exceptions.rst:1206 +#: ../../c-api/exceptions.rst:1183 msgid ":exc:`ResourceWarning`" msgstr ":exc:`ResourceWarning`" -#: ../../c-api/exceptions.rst:1208 -msgid ":c:data:`PyExc_RuntimeWarning`" -msgstr ":c:data:`PyExc_RuntimeWarning`" - -#: ../../c-api/exceptions.rst:1208 +#: ../../c-api/exceptions.rst:1185 msgid ":exc:`RuntimeWarning`" msgstr ":exc:`RuntimeWarning`" -#: ../../c-api/exceptions.rst:1210 -msgid ":c:data:`PyExc_SyntaxWarning`" -msgstr ":c:data:`PyExc_SyntaxWarning`" - -#: ../../c-api/exceptions.rst:1210 +#: ../../c-api/exceptions.rst:1187 msgid ":exc:`SyntaxWarning`" msgstr ":exc:`SyntaxWarning`" -#: ../../c-api/exceptions.rst:1212 -msgid ":c:data:`PyExc_UnicodeWarning`" -msgstr ":c:data:`PyExc_UnicodeWarning`" - -#: ../../c-api/exceptions.rst:1212 +#: ../../c-api/exceptions.rst:1189 msgid ":exc:`UnicodeWarning`" msgstr ":exc:`UnicodeWarning`" -#: ../../c-api/exceptions.rst:1214 -msgid ":c:data:`PyExc_UserWarning`" -msgstr ":c:data:`PyExc_UserWarning`" - -#: ../../c-api/exceptions.rst:1214 +#: ../../c-api/exceptions.rst:1191 msgid ":exc:`UserWarning`" msgstr ":exc:`UserWarning`" -#: ../../c-api/exceptions.rst:1217 +#: ../../c-api/exceptions.rst:1193 msgid ":c:data:`PyExc_ResourceWarning`." -msgstr ":c:data:`PyExc_ResourceWarning`." +msgstr ":c:data:`PyExc_ResourceWarning`。" -#: ../../c-api/exceptions.rst:1223 -msgid "This is a base class for other standard warning categories." -msgstr "" +#: ../../c-api/exceptions.rst:1196 +msgid ":c:data:`PyExc_EncodingWarning`." +msgstr ":c:data:`PyExc_EncodingWarning`。" -#: ../../c-api/exceptions.rst:170 +#: ../../c-api/exceptions.rst:183 msgid "strerror (C function)" msgstr "strerror(C 函式)" -#: ../../c-api/exceptions.rst:624 ../../c-api/exceptions.rst:655 -#: ../../c-api/exceptions.rst:670 +#: ../../c-api/exceptions.rst:637 ../../c-api/exceptions.rst:668 +#: ../../c-api/exceptions.rst:683 msgid "module" msgstr "module(模組)" -#: ../../c-api/exceptions.rst:624 ../../c-api/exceptions.rst:655 -#: ../../c-api/exceptions.rst:670 +#: ../../c-api/exceptions.rst:637 ../../c-api/exceptions.rst:668 +#: ../../c-api/exceptions.rst:683 msgid "signal" msgstr "signal(訊號)" -#: ../../c-api/exceptions.rst:624 ../../c-api/exceptions.rst:655 +#: ../../c-api/exceptions.rst:637 ../../c-api/exceptions.rst:668 msgid "SIGINT (C macro)" msgstr "SIGINT(C 巨集)" -#: ../../c-api/exceptions.rst:624 ../../c-api/exceptions.rst:655 -#: ../../c-api/exceptions.rst:670 +#: ../../c-api/exceptions.rst:637 ../../c-api/exceptions.rst:668 +#: ../../c-api/exceptions.rst:683 msgid "KeyboardInterrupt (built-in exception)" msgstr "KeyboardInterrupt(內建例外)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_BaseException (C var)" -msgstr "PyExc_BaseException(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_Exception (C var)" -msgstr "PyExc_Exception(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_ArithmeticError (C var)" -msgstr "PyExc_ArithmeticError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_AssertionError (C var)" -msgstr "PyExc_AssertionError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_AttributeError (C var)" -msgstr "PyExc_AttributeError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_BlockingIOError (C var)" -msgstr "PyExc_BlockingIOError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_BrokenPipeError (C var)" -msgstr "PyExc_BrokenPipeError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_BufferError (C var)" -msgstr "PyExc_BufferError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_ChildProcessError (C var)" -msgstr "PyExc_ChildProcessError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_ConnectionAbortedError (C var)" -msgstr "PyExc_ConnectionAbortedError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_ConnectionError (C var)" -msgstr "PyExc_ConnectionError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_ConnectionRefusedError (C var)" -msgstr "PyExc_ConnectionRefusedError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_ConnectionResetError (C var)" -msgstr "PyExc_ConnectionResetError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_EOFError (C var)" -msgstr "PyExc_EOFError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_FileExistsError (C var)" -msgstr "PyExc_FileExistsError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_FileNotFoundError (C var)" -msgstr "PyExc_FileNotFoundError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_FloatingPointError (C var)" -msgstr "PyExc_FloatingPointError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_GeneratorExit (C var)" -msgstr "PyExc_GeneratorExit(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_ImportError (C var)" -msgstr "PyExc_ImportError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_IndentationError (C var)" -msgstr "PyExc_IndentationError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_IndexError (C var)" -msgstr "PyExc_IndexError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_InterruptedError (C var)" -msgstr "PyExc_InterruptedError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_IsADirectoryError (C var)" -msgstr "PyExc_IsADirectoryError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_KeyError (C var)" -msgstr "PyExc_KeyError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_KeyboardInterrupt (C var)" -msgstr "PyExc_KeyboardInterrupt(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_LookupError (C var)" -msgstr "PyExc_LookupError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_MemoryError (C var)" -msgstr "PyExc_MemoryError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_ModuleNotFoundError (C var)" -msgstr "PyExc_ModuleNotFoundError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_NameError (C var)" -msgstr "PyExc_NameError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_NotADirectoryError (C var)" -msgstr "PyExc_NotADirectoryError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_NotImplementedError (C var)" -msgstr "PyExc_NotImplementedError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_OSError (C var)" -msgstr "PyExc_OSError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_OverflowError (C var)" -msgstr "PyExc_OverflowError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_PermissionError (C var)" -msgstr "PyExc_PermissionError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_ProcessLookupError (C var)" -msgstr "PyExc_ProcessLookupError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_RecursionError (C var)" -msgstr "PyExc_RecursionError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_ReferenceError (C var)" -msgstr "PyExc_ReferenceError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_RuntimeError (C var)" -msgstr "PyExc_RuntimeError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_StopAsyncIteration (C var)" -msgstr "PyExc_StopAsyncIteration(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_StopIteration (C var)" -msgstr "PyExc_StopIteration(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_SyntaxError (C var)" -msgstr "PyExc_SyntaxError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_SystemError (C var)" -msgstr "PyExc_SystemError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_SystemExit (C var)" -msgstr "PyExc_SystemExit(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_TabError (C var)" -msgstr "PyExc_TabError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_TimeoutError (C var)" -msgstr "PyExc_TimeoutError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_TypeError (C var)" -msgstr "PyExc_TypeError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_UnboundLocalError (C var)" -msgstr "PyExc_UnboundLocalError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_UnicodeDecodeError (C var)" -msgstr "PyExc_UnicodeDecodeError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_UnicodeEncodeError (C var)" -msgstr "PyExc_UnicodeEncodeError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_UnicodeError (C var)" -msgstr "PyExc_UnicodeError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_UnicodeTranslateError (C var)" -msgstr "PyExc_UnicodeTranslateError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_ValueError (C var)" -msgstr "PyExc_ValueError(C 變數)" - -#: ../../c-api/exceptions.rst:958 -msgid "PyExc_ZeroDivisionError (C var)" -msgstr "PyExc_ZeroDivisionError(C 變數)" - -#: ../../c-api/exceptions.rst:1141 -msgid "PyExc_EnvironmentError (C var)" -msgstr "PyExc_EnvironmentError(C 變數)" - -#: ../../c-api/exceptions.rst:1141 -msgid "PyExc_IOError (C var)" -msgstr "PyExc_IOError(C 變數)" - -#: ../../c-api/exceptions.rst:1141 -msgid "PyExc_WindowsError (C var)" -msgstr "PyExc_WindowsError(C 變數)" - -#: ../../c-api/exceptions.rst:1178 -msgid "PyExc_Warning (C var)" -msgstr "PyExc_Warning(C 變數)" - -#: ../../c-api/exceptions.rst:1178 -msgid "PyExc_BytesWarning (C var)" -msgstr "PyExc_BytesWarning(C 變數)" - -#: ../../c-api/exceptions.rst:1178 -msgid "PyExc_DeprecationWarning (C var)" -msgstr "PyExc_DeprecationWarning(C 變數)" - -#: ../../c-api/exceptions.rst:1178 -msgid "PyExc_FutureWarning (C var)" -msgstr "PyExc_FutureWarning(C 變數)" - -#: ../../c-api/exceptions.rst:1178 -msgid "PyExc_ImportWarning (C var)" -msgstr "PyExc_ImportWarning(C 變數)" - -#: ../../c-api/exceptions.rst:1178 -msgid "PyExc_PendingDeprecationWarning (C var)" -msgstr "PyExc_PendingDeprecationWarning(C 變數)" - -#: ../../c-api/exceptions.rst:1178 -msgid "PyExc_ResourceWarning (C var)" -msgstr "PyExc_ResourceWarning(C 變數)" - -#: ../../c-api/exceptions.rst:1178 -msgid "PyExc_RuntimeWarning (C var)" -msgstr "PyExc_RuntimeWarning(C 變數)" - -#: ../../c-api/exceptions.rst:1178 -msgid "PyExc_SyntaxWarning (C var)" -msgstr "PyExc_SyntaxWarning(C 變數)" - -#: ../../c-api/exceptions.rst:1178 -msgid "PyExc_UnicodeWarning (C var)" -msgstr "PyExc_UnicodeWarning(C 變數)" - -#: ../../c-api/exceptions.rst:1178 -msgid "PyExc_UserWarning (C var)" -msgstr "PyExc_UserWarning(C 變數)" diff --git a/c-api/file.po b/c-api/file.po index 4a1d1c1e24..cb40f45c72 100644 --- a/c-api/file.po +++ b/c-api/file.po @@ -7,9 +7,9 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-04 00:03+0000\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2023-04-24 20:38+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -38,7 +38,7 @@ msgid "" msgstr "" "這些 API 是用於內建檔案物件的 Python 2 C API 的最小模擬 (minimal emulation)," "它過去依賴於 C 標準函式庫對於緩衝 I/O (:c:expr:`FILE*`) 的支援。在 Python 3 " -"中,檔案和串流使用新的 :mod:`io` 模組,它在操作系統的低階無緩衝 I/O 上定義了" +"中,檔案和串流使用新的 :mod:`io` 模組,它在作業系統的低階無緩衝 I/O 上定義了" "多個層級。下面描述的函式是這些新 API 的便捷 C 包裝器,主要用於直譯器中的內部" "錯誤報告;建議第三方程式碼改為存取 :mod:`io` API。" @@ -55,7 +55,7 @@ msgstr "" "從已打開檔案 *fd* 的檔案描述器建立一個 Python 檔案物件。引數 *name*、" "*encoding*、*errors* 和 *newline* 可以為 ``NULL`` 以使用預設值; *buffering* " "可以是 *-1* 以使用預設值。 *name* 被忽略並保留以實作向後相容性。失敗時回傳 " -"``NULL``。有關引數的更全面描述,請參閱 :func:`io.open` 函式文檔。" +"``NULL``。有關引數的更全面描述,請參閱 :func:`io.open` 函式文件。" #: ../../c-api/file.rst:31 msgid "" @@ -63,7 +63,7 @@ msgid "" "level file descriptors can produce various issues (such as unexpected " "ordering of data)." msgstr "" -"由於 Python 串流有自己的緩衝層,將它們與操作系統層級檔案描述器混合使用會產生" +"由於 Python 串流有自己的緩衝層,將它們與作業系統層級檔案描述器混合使用會產生" "各種問題(例如資料的排序不符合預期)。" #: ../../c-api/file.rst:35 @@ -111,10 +111,10 @@ msgstr "" "數。" #: ../../c-api/file.rst:68 -msgid "The handler is a function of type:" +msgid "The *handler* is a function of type:" msgstr "" -#: ../../c-api/file.rst:72 +#: ../../c-api/file.rst:73 #, fuzzy msgid "" "Equivalent of :c:expr:`PyObject *(\\*)(PyObject *path, void *userData)`, " @@ -123,7 +123,7 @@ msgstr "" "處理程式是 :c:expr:`PyObject *(\\*)(PyObject *path, void *userData)` 型別的函" "式,其中 *path* 保證為 :c:type:`PyUnicodeObject`。" -#: ../../c-api/file.rst:76 +#: ../../c-api/file.rst:77 msgid "" "The *userData* pointer is passed into the hook function. Since hook " "functions may be called from different runtimes, this pointer should not " @@ -132,7 +132,7 @@ msgstr "" "*userData* 指標被傳遞到掛鉤函式 (hook function) 中。由於可能會從不同的執行環" "境 (runtime) 呼叫掛鉤函式,因此該指標不應直接指向 Python 狀態。" -#: ../../c-api/file.rst:80 +#: ../../c-api/file.rst:81 msgid "" "As this hook is intentionally used during import, avoid importing new " "modules during its execution unless they are known to be frozen or available " @@ -141,7 +141,7 @@ msgstr "" "由於此掛鉤函式是在導入期間有意使用的,因此請避免在其執行期間導入新模組,除非" "它們已知有被凍結或在 ``sys.modules`` 中可用。" -#: ../../c-api/file.rst:84 +#: ../../c-api/file.rst:85 #, fuzzy msgid "" "Once a hook has been set, it cannot be removed or replaced, and later calls " @@ -152,11 +152,11 @@ msgstr "" "`PyFile_SetOpenCodeHook` 將失敗。失敗時,函式回傳 -1 並在直譯器已初始化時設定" "例外。" -#: ../../c-api/file.rst:88 +#: ../../c-api/file.rst:89 msgid "This function is safe to call before :c:func:`Py_Initialize`." msgstr "在 :c:func:`Py_Initialize` 之前呼叫此函式是安全的。" -#: ../../c-api/file.rst:90 +#: ../../c-api/file.rst:91 msgid "" "Raises an :ref:`auditing event ` ``setopencodehook`` with no " "arguments." @@ -164,7 +164,7 @@ msgstr "" "不帶引數地引發一個\\ :ref:`稽核事件 (auditing event) ` " "``setopencodehook``。" -#: ../../c-api/file.rst:100 +#: ../../c-api/file.rst:101 msgid "" "Write object *obj* to file object *p*. The only supported flag for *flags* " "is :c:macro:`Py_PRINT_RAW`; if given, the :func:`str` of the object is " @@ -175,7 +175,7 @@ msgstr "" "`Py_PRINT_RAW`;如果有給定,則寫入物件的 :func:`str` 而不是 :func:`repr`。在" "成功回傳 ``0`` 或在失敗回傳 ``-1``;將設定適當的例外。" -#: ../../c-api/file.rst:108 +#: ../../c-api/file.rst:109 msgid "" "Write string *s* to file object *p*. Return ``0`` on success or ``-1`` on " "failure; the appropriate exception will be set." @@ -195,6 +195,6 @@ msgstr "file(檔案)" msgid "EOFError (built-in exception)" msgstr "EOFError(內建例外)" -#: ../../c-api/file.rst:98 +#: ../../c-api/file.rst:99 msgid "Py_PRINT_RAW (C macro)" msgstr "Py_PRINT_RAW(C 巨集)" diff --git a/c-api/float.po b/c-api/float.po index df086b405b..3c2eff7ff2 100644 --- a/c-api/float.po +++ b/c-api/float.po @@ -7,7 +7,7 @@ # Liang-Bo Wang , 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-07-20 00:03+0000\n" "PO-Revision-Date: 2017-09-22 18:26+0000\n" @@ -159,7 +159,7 @@ msgstr "" #: ../../c-api/float.rst:122 msgid "``-0.0`` and ``+0.0`` produce the same bytes string." -msgstr "" +msgstr "``-0.0`` 和 ``+0.0`` 會產生同樣的位元組字串。" #: ../../c-api/float.rst:126 msgid "Pack a C double as the IEEE 754 binary16 half-precision format." diff --git a/c-api/frame.po b/c-api/frame.po index c7c3384f27..1bbe0b32c7 100644 --- a/c-api/frame.po +++ b/c-api/frame.po @@ -1,17 +1,16 @@ -# SOME DESCRIPTIVE TITLE. # Copyright (C) 2001-2022, Python Software Foundation # This file is distributed under the same license as the Python package. -# FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-12-06 00:03+0000\n" +"POT-Creation-Date: 2024-12-12 00:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -43,7 +42,7 @@ msgstr "" #: ../../c-api/frame.rst:20 msgid "See also :ref:`Reflection `." -msgstr "" +msgstr "另請參閱 :ref:`Reflection `。" #: ../../c-api/frame.rst:24 msgid "" @@ -87,7 +86,7 @@ msgstr "回傳 :term:`strong reference`。結果不能為 ``NULL``。" msgid "Get the *frame* code." msgstr "" -#: ../../c-api/frame.rst:64 ../../c-api/frame.rst:125 +#: ../../c-api/frame.rst:64 ../../c-api/frame.rst:130 msgid "Return a :term:`strong reference`." msgstr "回傳 :term:`strong reference`。" @@ -146,34 +145,70 @@ msgid "" msgstr "" #: ../../c-api/frame.rst:123 -msgid "Get the *frame*'s :attr:`~frame.f_locals` attribute (:class:`dict`)." +msgid "" +"Get the *frame*'s :attr:`~frame.f_locals` attribute. If the frame refers to " +"an :term:`optimized scope`, this returns a write-through proxy object that " +"allows modifying the locals. In all other cases (classes, modules, :func:" +"`exec`, :func:`eval`) it returns the mapping representing the frame locals " +"directly (as described for :func:`locals`)." +msgstr "" + +#: ../../c-api/frame.rst:134 +msgid "" +"As part of :pep:`667`, return an instance of :c:var:" +"`PyFrameLocalsProxy_Type`." msgstr "" -#: ../../c-api/frame.rst:132 +#: ../../c-api/frame.rst:140 msgid "Return the line number that *frame* is currently executing." msgstr "" -#: ../../c-api/frame.rst:137 +#: ../../c-api/frame.rst:144 +msgid "Frame Locals Proxies" +msgstr "" + +#: ../../c-api/frame.rst:148 +msgid "" +"The :attr:`~frame.f_locals` attribute on a :ref:`frame object ` is an instance of a \"frame-locals proxy\". The proxy object " +"exposes a write-through view of the underlying locals dictionary for the " +"frame. This ensures that the variables exposed by ``f_locals`` are always up " +"to date with the live local variables in the frame itself." +msgstr "" + +#: ../../c-api/frame.rst:154 +msgid "See :pep:`667` for more information." +msgstr "" + +#: ../../c-api/frame.rst:158 +msgid "The type of frame :func:`locals` proxy objects." +msgstr "" + +#: ../../c-api/frame.rst:162 +msgid "Return non-zero if *obj* is a frame :func:`locals` proxy." +msgstr "" + +#: ../../c-api/frame.rst:165 msgid "Internal Frames" msgstr "" -#: ../../c-api/frame.rst:139 +#: ../../c-api/frame.rst:167 msgid "Unless using :pep:`523`, you will not need this." msgstr "" -#: ../../c-api/frame.rst:143 +#: ../../c-api/frame.rst:171 msgid "The interpreter's internal frame representation." msgstr "" -#: ../../c-api/frame.rst:149 +#: ../../c-api/frame.rst:177 msgid "Return a :term:`strong reference` to the code object for the frame." msgstr "" -#: ../../c-api/frame.rst:156 +#: ../../c-api/frame.rst:184 msgid "Return the byte offset into the last executed instruction." msgstr "" -#: ../../c-api/frame.rst:163 +#: ../../c-api/frame.rst:191 msgid "" "Return the currently executing line number, or -1 if there is no line number." msgstr "" diff --git a/c-api/function.po b/c-api/function.po index fd946abcb3..9328805cc2 100644 --- a/c-api/function.po +++ b/c-api/function.po @@ -8,9 +8,9 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-12-13 00:03+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2022-11-12 15:45+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -126,8 +126,8 @@ msgid "" msgstr "" "設定函式物件 *op* 的引數預設值。*defaults* 必須是 ``Py_None`` 或一個 tuple。" -#: ../../c-api/function.rst:86 ../../c-api/function.rst:109 -#: ../../c-api/function.rst:123 +#: ../../c-api/function.rst:86 ../../c-api/function.rst:116 +#: ../../c-api/function.rst:130 msgid "Raises :exc:`SystemError` and returns ``-1`` on failure." msgstr "引發 :exc:`SystemError` 且在失敗時回傳 ``-1``。" @@ -139,9 +139,17 @@ msgstr "為一個給定的函式物件 *func* 設定 vectorcall 欄位。" msgid "" "Warning: extensions using this API must preserve the behavior of the " "unaltered (default) vectorcall function!" +msgstr "警告:使用此 API 的擴充套件必須保留未更改(預設)vectorcall 函式的行為!" + +#: ../../c-api/function.rst:101 +msgid "" +"Return the keyword-only argument default values of the function object *op*. " +"This can be a dictionary of arguments or ``NULL``." msgstr "" +"回傳函式物件 *op* 的僅限關鍵字引數預設值,這可以是一個含有多個引數的字典或 " +"``NULL``。" -#: ../../c-api/function.rst:100 +#: ../../c-api/function.rst:107 msgid "" "Return the closure associated with the function object *op*. This can be " "``NULL`` or a tuple of cell objects." @@ -149,7 +157,7 @@ msgstr "" "回傳與函式物件 *op* 相關聯的閉包,這可以是個 ``NULL`` 或是一個包含 cell 物件" "的 tuple。" -#: ../../c-api/function.rst:106 +#: ../../c-api/function.rst:113 msgid "" "Set the closure associated with the function object *op*. *closure* must be " "``Py_None`` or a tuple of cell objects." @@ -157,20 +165,27 @@ msgstr "" "設定與函式物件 *op* 相關聯的閉包,*closure* 必須是 ``Py_None`` 或是一個包含 " "cell 物件的 tuple。" -#: ../../c-api/function.rst:114 +#: ../../c-api/function.rst:121 msgid "" "Return the annotations of the function object *op*. This can be a mutable " "dictionary or ``NULL``." msgstr "" "回傳函式物件 *op* 的標註,這可以是一個可變動的 (mutable) 字典或 ``NULL``。" -#: ../../c-api/function.rst:120 +#: ../../c-api/function.rst:127 msgid "" "Set the annotations for the function object *op*. *annotations* must be a " "dictionary or ``Py_None``." msgstr "設定函式物件 *op* 的標註,*annotations* 必須是一個字典或 ``Py_None``。" -#: ../../c-api/function.rst:128 +#: ../../c-api/function.rst:141 +msgid "" +"These functions are similar to their ``PyFunction_Get*`` counterparts, but " +"do not do type checking. Passing anything other than an instance of :c:data:" +"`PyFunction_Type` is undefined behavior." +msgstr "" + +#: ../../c-api/function.rst:148 msgid "" "Register *callback* as a function watcher for the current interpreter. " "Return an ID which may be passed to :c:func:`PyFunction_ClearWatcher`. In " @@ -178,7 +193,7 @@ msgid "" "exception." msgstr "" -#: ../../c-api/function.rst:138 +#: ../../c-api/function.rst:158 msgid "" "Clear watcher identified by *watcher_id* previously returned from :c:func:" "`PyFunction_AddWatcher` for the current interpreter. Return ``0`` on " @@ -186,19 +201,35 @@ msgid "" "*watcher_id* was never registered.)" msgstr "" -#: ../../c-api/function.rst:148 -msgid "" -"Enumeration of possible function watcher events: - " -"``PyFunction_EVENT_CREATE`` - ``PyFunction_EVENT_DESTROY`` - " -"``PyFunction_EVENT_MODIFY_CODE`` - ``PyFunction_EVENT_MODIFY_DEFAULTS`` - " -"``PyFunction_EVENT_MODIFY_KWDEFAULTS``" +#: ../../c-api/function.rst:168 +msgid "Enumeration of possible function watcher events:" msgstr "" -#: ../../c-api/function.rst:160 +#: ../../c-api/function.rst:170 +msgid "``PyFunction_EVENT_CREATE``" +msgstr "``PyFunction_EVENT_CREATE``" + +#: ../../c-api/function.rst:171 +msgid "``PyFunction_EVENT_DESTROY``" +msgstr "``PyFunction_EVENT_DESTROY``" + +#: ../../c-api/function.rst:172 +msgid "``PyFunction_EVENT_MODIFY_CODE``" +msgstr "``PyFunction_EVENT_MODIFY_CODE``" + +#: ../../c-api/function.rst:173 +msgid "``PyFunction_EVENT_MODIFY_DEFAULTS``" +msgstr "``PyFunction_EVENT_MODIFY_DEFAULTS``" + +#: ../../c-api/function.rst:174 +msgid "``PyFunction_EVENT_MODIFY_KWDEFAULTS``" +msgstr "``PyFunction_EVENT_MODIFY_KWDEFAULTS``" + +#: ../../c-api/function.rst:181 msgid "Type of a function watcher callback function." msgstr "" -#: ../../c-api/function.rst:162 +#: ../../c-api/function.rst:183 msgid "" "If *event* is ``PyFunction_EVENT_CREATE`` or ``PyFunction_EVENT_DESTROY`` " "then *new_value* will be ``NULL``. Otherwise, *new_value* will hold a :term:" @@ -206,16 +237,16 @@ msgid "" "for the attribute that is being modified." msgstr "" -#: ../../c-api/function.rst:167 +#: ../../c-api/function.rst:188 msgid "" "The callback may inspect but must not modify *func*; doing so could have " "unpredictable effects, including infinite recursion." msgstr "" -#: ../../c-api/function.rst:170 +#: ../../c-api/function.rst:191 msgid "" "If *event* is ``PyFunction_EVENT_CREATE``, then the callback is invoked " -"after `func` has been fully initialized. Otherwise, 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. " @@ -224,7 +255,7 @@ msgid "" "semantics of the Python code being executed." msgstr "" -#: ../../c-api/function.rst:179 +#: ../../c-api/function.rst:200 msgid "" "If *event* is ``PyFunction_EVENT_DESTROY``, Taking a reference in the " "callback to the about-to-be-destroyed function will resurrect it, preventing " @@ -232,14 +263,14 @@ msgid "" "later, any watcher callbacks active at that time will be called again." msgstr "" -#: ../../c-api/function.rst:184 +#: ../../c-api/function.rst:205 msgid "" "If the callback sets an exception, it must return ``-1``; this exception " "will be printed as an unraisable exception using :c:func:" "`PyErr_WriteUnraisable`. Otherwise it should return ``0``." msgstr "" -#: ../../c-api/function.rst:188 +#: ../../c-api/function.rst:209 msgid "" "There may already be a pending exception set on entry to the callback. In " "this case, the callback should return ``0`` with the same exception still " diff --git a/c-api/gcsupport.po b/c-api/gcsupport.po index e52f8c9b5d..8ad9b1c6a1 100644 --- a/c-api/gcsupport.po +++ b/c-api/gcsupport.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 14:31+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -255,9 +255,10 @@ msgstr "" #: ../../c-api/gcsupport.rst:185 msgid "" -"If *o* is not ``NULL``, call the *visit* callback, with arguments *o* and " -"*arg*. If *visit* returns a non-zero value, then return it. Using this " -"macro, :c:member:`~PyTypeObject.tp_traverse` handlers look like::" +"If the :c:expr:`PyObject *` *o* is not ``NULL``, call the *visit* callback, " +"with arguments *o* and *arg*. If *visit* returns a non-zero value, then " +"return it. Using this macro, :c:member:`~PyTypeObject.tp_traverse` handlers " +"look like::" msgstr "" #: ../../c-api/gcsupport.rst:190 @@ -369,7 +370,7 @@ msgstr "" msgid "" "Type of the visitor function to be passed to :c:func:" "`PyUnstable_GC_VisitObjects`. *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 " +"``PyUnstable_GC_VisitObjects``. Return ``1`` to continue iteration, return " +"``0`` to stop iteration. Other return values are reserved for now so " "behavior on returning anything else is undefined." msgstr "" diff --git a/c-api/gen.po b/c-api/gen.po index 400aa9f691..a1d498d11c 100644 --- a/c-api/gen.po +++ b/c-api/gen.po @@ -8,7 +8,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-09-13 00:11+0000\n" "PO-Revision-Date: 2022-10-16 15:33+0800\n" diff --git a/c-api/hash.po b/c-api/hash.po index 543ff1d4b4..dcb8889a1b 100644 --- a/c-api/hash.po +++ b/c-api/hash.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-02-18 00:03+0000\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2024-04-30 00:20+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,8 +22,9 @@ msgid "PyHash API" msgstr "PyHash API" #: ../../c-api/hash.rst:6 -msgid "See also the :c:member:`PyTypeObject.tp_hash` member." -msgstr "另請參閱 :c:member:`PyTypeObject.tp_hash` 成員。" +msgid "" +"See also the :c:member:`PyTypeObject.tp_hash` member and :ref:`numeric-hash`." +msgstr "另請參閱 :c:member:`PyTypeObject.tp_hash` 成員和 :ref:`numeric-hash`。" #: ../../c-api/hash.rst:10 msgid "Hash value type: signed integer." @@ -33,28 +34,76 @@ msgstr "雜湊值型別:有符號整數。" msgid "Hash value type: unsigned integer." msgstr "雜湊值型別:無符號整數。" -#: ../../c-api/hash.rst:23 +#: ../../c-api/hash.rst:22 +msgid "" +"The `Mersenne prime `_ ``P = " +"2**n -1``, used for numeric hash scheme." +msgstr "" +"用於數值雜湊方案的\\ `梅森質數 (Mersenne prime) `_ ``P = 2**n -1``。" + +#: ../../c-api/hash.rst:28 +msgid "The exponent ``n`` of ``P`` in :c:macro:`PyHASH_MODULUS`." +msgstr ":c:macro:`PyHASH_MODULUS` 中 ``P`` 的指數 ``n``。" + +#: ../../c-api/hash.rst:34 +msgid "Prime multiplier used in string and various other hashes." +msgstr "用於字串和其他各種雜湊的質數乘數 (prime multiplier)。" + +#: ../../c-api/hash.rst:40 +msgid "The hash value returned for a positive infinity." +msgstr "正無窮大回傳的雜湊值。" + +#: ../../c-api/hash.rst:46 +msgid "The multiplier used for the imaginary part of a complex number." +msgstr "用於複數虛數部分的乘數。" + +#: ../../c-api/hash.rst:52 msgid "Hash function definition used by :c:func:`PyHash_GetFuncDef`." msgstr ":c:func:`PyHash_GetFuncDef` 所使用的雜湊函式定義。" -#: ../../c-api/hash.rst:31 +#: ../../c-api/hash.rst:60 msgid "Hash function name (UTF-8 encoded string)." msgstr "雜湊函式名稱(UTF-8 編碼字串)。" -#: ../../c-api/hash.rst:35 +#: ../../c-api/hash.rst:64 msgid "Internal size of the hash value in bits." msgstr "雜湊值的內部大小(以位元為單位)。" -#: ../../c-api/hash.rst:39 +#: ../../c-api/hash.rst:68 msgid "Size of seed input in bits." msgstr "Seed 輸入的大小(以位元為單位)。" -#: ../../c-api/hash.rst:46 +#: ../../c-api/hash.rst:75 msgid "Get the hash function definition." msgstr "取得雜湊函式定義。" -#: ../../c-api/hash.rst:49 +#: ../../c-api/hash.rst:78 msgid ":pep:`456` \"Secure and interchangeable hash algorithm\"." msgstr "" ":pep:`456`\\ 「安全且可交替使用的雜湊演算法 (Secure and interchangeable hash " "algorithm)」。" + +#: ../../c-api/hash.rst:85 +msgid "" +"Hash a pointer value: process the pointer value as an integer (cast it to " +"``uintptr_t`` internally). The pointer is not dereferenced." +msgstr "" +"雜湊指標值:將指標值作為整數處理(在內部轉型為 ``uintptr_t``)。指標不會被取" +"值 (dereference)。" + +#: ../../c-api/hash.rst:88 +msgid "The function cannot fail: it cannot return ``-1``." +msgstr "此函式不會失敗:它不會回傳 ``-1``。" + +#: ../../c-api/hash.rst:94 +msgid "" +"Generic hashing function that is meant to be put into a type object's " +"``tp_hash`` slot. Its result only depends on the object's identity." +msgstr "" +"泛用雜湊函式,旨在放入型別物件的 ``tp_hash`` 插槽中。其結果僅取決於物件的識別" +"性。" + +#: ../../c-api/hash.rst:99 +msgid "In CPython, it is equivalent to :c:func:`Py_HashPointer`." +msgstr "在 CPython 中,它等價於 :c:func:`Py_HashPointer`。" diff --git a/c-api/import.po b/c-api/import.po index 340d9ccd66..8f830d9e96 100644 --- a/c-api/import.po +++ b/c-api/import.po @@ -6,9 +6,9 @@ # Ching-Lung Chuang, 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2024-10-10 00:13+0000\n" "PO-Revision-Date: 2018-05-23 14:06+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -41,13 +41,17 @@ msgid "" "needed anymore." msgstr "" -#: ../../c-api/import.rst:34 +#: ../../c-api/import.rst:29 +msgid "Use :c:func:`PyImport_ImportModule` instead." +msgstr "請改用 :c:func:`PyImport_ImportModule`。" + +#: ../../c-api/import.rst:37 msgid "" "Import a module. This is best described by referring to the built-in Python " "function :func:`__import__`." msgstr "" -#: ../../c-api/import.rst:37 ../../c-api/import.rst:53 +#: ../../c-api/import.rst:40 ../../c-api/import.rst:56 msgid "" "The return value is a new reference to the imported module or top-level " "package, or ``NULL`` with an exception set on failure. Like for :func:" @@ -55,30 +59,30 @@ msgid "" "is normally the top-level package, unless a non-empty *fromlist* was given." msgstr "" -#: ../../c-api/import.rst:43 +#: ../../c-api/import.rst:46 msgid "" "Failing imports remove incomplete module objects, like with :c:func:" "`PyImport_ImportModule`." msgstr "" -#: ../../c-api/import.rst:49 +#: ../../c-api/import.rst:52 msgid "" "Import a module. This is best described by referring to the built-in Python " "function :func:`__import__`, as the standard :func:`__import__` function " "calls this function directly." msgstr "" -#: ../../c-api/import.rst:63 +#: ../../c-api/import.rst:66 msgid "" "Similar to :c:func:`PyImport_ImportModuleLevelObject`, but the name is a " "UTF-8 encoded string instead of a Unicode object." msgstr "" -#: ../../c-api/import.rst:66 +#: ../../c-api/import.rst:69 msgid "Negative values for *level* are no longer accepted." msgstr "" -#: ../../c-api/import.rst:71 +#: ../../c-api/import.rst:74 msgid "" "This is a higher-level interface that calls the current \"import hook " "function\" (with an explicit *level* of 0, meaning absolute import). It " @@ -87,40 +91,59 @@ msgid "" "hooks are installed in the current environment." msgstr "" -#: ../../c-api/import.rst:77 +#: ../../c-api/import.rst:80 msgid "This function always uses absolute imports." msgstr "" -#: ../../c-api/import.rst:82 +#: ../../c-api/import.rst:85 msgid "" "Reload a module. Return a new reference to the reloaded module, or ``NULL`` " "with an exception set on failure (the module still exists in this case)." msgstr "" -#: ../../c-api/import.rst:88 +#: ../../c-api/import.rst:91 +msgid "Return the module object corresponding to a module name." +msgstr "" + +#: ../../c-api/import.rst:93 +msgid "" +"The *name* argument may be of the form ``package.module``. First check the " +"modules dictionary if there's one there, and if not, create a new one and " +"insert it in the modules dictionary." +msgstr "" + +#: ../../c-api/import.rst:97 msgid "" -"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 ``NULL`` with an exception set on failure." +"Return a :term:`strong reference` to the module on success. Return ``NULL`` " +"with an exception set on failure." +msgstr "" + +#: ../../c-api/import.rst:100 +msgid "The module name *name* is decoded from UTF-8." msgstr "" -#: ../../c-api/import.rst:95 +#: ../../c-api/import.rst:102 msgid "" "This function does not load or import the module; if the module wasn't " "already loaded, you will get an empty module object. Use :c:func:" -"`PyImport_ImportModule` or one of its variants to import a module. Package " +"`PyImport_ImportModule` 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." msgstr "" -#: ../../c-api/import.rst:105 +#: ../../c-api/import.rst:113 msgid "" -"Similar to :c:func:`PyImport_AddModuleObject`, but the name is a UTF-8 " -"encoded string instead of a Unicode object." +"Similar to :c:func:`PyImport_AddModuleRef`, but return a :term:`borrowed " +"reference` and *name* is a Python :class:`str` object." msgstr "" -#: ../../c-api/import.rst:113 +#: ../../c-api/import.rst:121 +msgid "" +"Similar to :c:func:`PyImport_AddModuleRef`, but return a :term:`borrowed " +"reference`." +msgstr "" + +#: ../../c-api/import.rst:129 msgid "" "Given a module name (possibly of the form ``package.module``) and a code " "object read from a Python bytecode file or obtained from the built-in " @@ -134,69 +157,69 @@ msgid "" "to the module author's intents) state." msgstr "" -#: ../../c-api/import.rst:123 +#: ../../c-api/import.rst:139 msgid "" -"The module's :attr:`__spec__` and :attr:`__loader__` 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 :class:`~importlib." -"machinery.SourceFileLoader` otherwise." +"The module's :attr:`~module.__spec__` and :attr:`~module.__loader__` will be " +"set, if not set already, with the appropriate values. The spec's loader " +"will be set to the module's :attr:`!__loader__` (if set) and to an instance " +"of :class:`~importlib.machinery.SourceFileLoader` otherwise." msgstr "" -#: ../../c-api/import.rst:128 +#: ../../c-api/import.rst:144 msgid "" -"The module's :attr:`__file__` attribute will be set to the code object's :" -"attr:`~codeobject.co_filename`. If applicable, :attr:`__cached__` will also " -"be set." +"The module's :attr:`~module.__file__` attribute will be set to the code " +"object's :attr:`~codeobject.co_filename`. If applicable, :attr:`~module." +"__cached__` will also be set." msgstr "" -#: ../../c-api/import.rst:132 +#: ../../c-api/import.rst:148 msgid "" "This function will reload the module if it was already imported. See :c:" "func:`PyImport_ReloadModule` for the intended way to reload a module." msgstr "" -#: ../../c-api/import.rst:135 +#: ../../c-api/import.rst:151 msgid "" "If *name* points to a dotted name of the form ``package.module``, any " "package structures not already created will still not be created." msgstr "" -#: ../../c-api/import.rst:138 +#: ../../c-api/import.rst:154 msgid "" "See also :c:func:`PyImport_ExecCodeModuleEx` and :c:func:" "`PyImport_ExecCodeModuleWithPathnames`." msgstr "" -#: ../../c-api/import.rst:141 +#: ../../c-api/import.rst:157 msgid "" -"The setting of :attr:`__cached__` and :attr:`__loader__` is deprecated. See :" -"class:`~importlib.machinery.ModuleSpec` for alternatives." +"The setting of :attr:`~module.__cached__` and :attr:`~module.__loader__` is " +"deprecated. See :class:`~importlib.machinery.ModuleSpec` for alternatives." msgstr "" -#: ../../c-api/import.rst:149 +#: ../../c-api/import.rst:165 msgid "" -"Like :c:func:`PyImport_ExecCodeModule`, but the :attr:`__file__` attribute " -"of the module object is set to *pathname* if it is non-``NULL``." +"Like :c:func:`PyImport_ExecCodeModule`, but the :attr:`~module.__file__` " +"attribute of the module object is set to *pathname* if it is non-``NULL``." msgstr "" -#: ../../c-api/import.rst:152 +#: ../../c-api/import.rst:168 msgid "See also :c:func:`PyImport_ExecCodeModuleWithPathnames`." msgstr "也請見 :c:func:`PyImport_ExecCodeModuleWithPathnames`。" -#: ../../c-api/import.rst:157 +#: ../../c-api/import.rst:173 msgid "" -"Like :c:func:`PyImport_ExecCodeModuleEx`, but the :attr:`__cached__` " +"Like :c:func:`PyImport_ExecCodeModuleEx`, but the :attr:`~module.__cached__` " "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." msgstr "" -#: ../../c-api/import.rst:163 +#: ../../c-api/import.rst:179 msgid "" -"Setting :attr:`__cached__` is deprecated. See :class:`~importlib.machinery." -"ModuleSpec` for alternatives." +"Setting :attr:`~module.__cached__` is deprecated. See :class:`~importlib." +"machinery.ModuleSpec` for alternatives." msgstr "" -#: ../../c-api/import.rst:170 +#: ../../c-api/import.rst:186 msgid "" "Like :c:func:`PyImport_ExecCodeModuleObject`, but *name*, *pathname* and " "*cpathname* are UTF-8 encoded strings. Attempts are also made to figure out " @@ -204,48 +227,48 @@ msgid "" "set to ``NULL``." msgstr "" -#: ../../c-api/import.rst:176 +#: ../../c-api/import.rst:192 msgid "" "Uses :func:`!imp.source_from_cache` in calculating the source path if only " "the bytecode path is provided." msgstr "" -#: ../../c-api/import.rst:179 +#: ../../c-api/import.rst:195 msgid "No longer uses the removed :mod:`!imp` module." msgstr "不再使用已被移除的 :mod:`!imp` 模組。" -#: ../../c-api/import.rst:185 +#: ../../c-api/import.rst:201 msgid "" "Return the magic number for Python bytecode files (a.k.a. :file:`.pyc` " "file). The magic number should be present in the first four bytes of the " "bytecode file, in little-endian byte order. Returns ``-1`` on error." msgstr "" -#: ../../c-api/import.rst:189 +#: ../../c-api/import.rst:205 msgid "Return value of ``-1`` upon failure." msgstr "當失敗時回傳 ``-1``。" -#: ../../c-api/import.rst:195 +#: ../../c-api/import.rst:211 msgid "" "Return the magic tag string for :pep:`3147` format Python bytecode file " "names. Keep in mind that the value at ``sys.implementation.cache_tag`` is " "authoritative and should be used instead of this function." msgstr "" -#: ../../c-api/import.rst:203 +#: ../../c-api/import.rst:219 msgid "" "Return the dictionary used for the module administration (a.k.a. ``sys." "modules``). Note that this is a per-interpreter variable." msgstr "" -#: ../../c-api/import.rst:208 +#: ../../c-api/import.rst:224 msgid "" "Return the already imported module with the given name. If the module has " "not been imported yet then returns ``NULL`` but does not set an error. " "Returns ``NULL`` and sets an error if the lookup failed." msgstr "" -#: ../../c-api/import.rst:216 +#: ../../c-api/import.rst:232 msgid "" "Return a finder object for a :data:`sys.path`/:attr:`!pkg.__path__` item " "*path*, possibly by fetching it from the :data:`sys.path_importer_cache` " @@ -256,7 +279,7 @@ msgid "" "path_importer_cache`. Return a new reference to the finder object." msgstr "" -#: ../../c-api/import.rst:227 +#: ../../c-api/import.rst:243 msgid "" "Load a frozen module named *name*. Return ``1`` for success, ``0`` if the " "module is not found, and ``-1`` with an exception set if the initialization " @@ -265,17 +288,17 @@ msgid "" "the module if it was already imported.)" msgstr "" -#: ../../c-api/import.rst:235 +#: ../../c-api/import.rst:251 msgid "The ``__file__`` attribute is no longer set on the module." msgstr "" -#: ../../c-api/import.rst:241 +#: ../../c-api/import.rst:257 msgid "" "Similar to :c:func:`PyImport_ImportFrozenModuleObject`, but the name is a " "UTF-8 encoded string instead of a Unicode object." msgstr "" -#: ../../c-api/import.rst:249 +#: ../../c-api/import.rst:265 msgid "" "This is the structure type definition for frozen module descriptors, as " "generated by the :program:`freeze` utility (see :file:`Tools/freeze/` in the " @@ -283,7 +306,7 @@ msgid "" "h`, is::" msgstr "" -#: ../../c-api/import.rst:254 +#: ../../c-api/import.rst:270 msgid "" "struct _frozen {\n" " const char *name;\n" @@ -299,13 +322,13 @@ msgstr "" " bool is_package;\n" "};" -#: ../../c-api/import.rst:261 +#: ../../c-api/import.rst:277 msgid "" "The new ``is_package`` field indicates whether the module is a package or " "not. This replaces setting the ``size`` field to a negative value." msgstr "" -#: ../../c-api/import.rst:267 +#: ../../c-api/import.rst:283 msgid "" "This pointer is initialized to point to an array of :c:struct:`_frozen` " "records, terminated by one whose members are all ``NULL`` or zero. When a " @@ -314,7 +337,7 @@ msgid "" "frozen modules." msgstr "" -#: ../../c-api/import.rst:275 +#: ../../c-api/import.rst:291 msgid "" "Add a single module to the existing table of built-in modules. This is a " "convenience wrapper around :c:func:`PyImport_ExtendInittab`, returning " @@ -324,7 +347,7 @@ msgid "" "before :c:func:`Py_Initialize`." msgstr "" -#: ../../c-api/import.rst:285 +#: ../../c-api/import.rst:301 msgid "" "Structure describing a single entry in the list of built-in modules. " "Programs which embed Python may use an array of these structures in " @@ -332,15 +355,15 @@ msgid "" "built-in modules. The structure consists of two members:" msgstr "" -#: ../../c-api/import.rst:293 +#: ../../c-api/import.rst:309 msgid "The module name, as an ASCII encoded string." msgstr "" -#: ../../c-api/import.rst:297 +#: ../../c-api/import.rst:313 msgid "Initialization function for a module built into the interpreter." msgstr "" -#: ../../c-api/import.rst:302 +#: ../../c-api/import.rst:318 msgid "" "Add a collection of modules to the table of built-in modules. The *newtab* " "array must end with a sentinel entry which contains ``NULL`` for the :c:" @@ -351,7 +374,7 @@ msgid "" "before :c:func:`Py_Initialize`." msgstr "" -#: ../../c-api/import.rst:309 +#: ../../c-api/import.rst:325 msgid "" "If Python is initialized multiple times, :c:func:`PyImport_AppendInittab` " "or :c:func:`PyImport_ExtendInittab` must be called before each Python " @@ -374,18 +397,18 @@ msgstr "__all__(套件變數)" msgid "modules (in module sys)" msgstr "modules(sys 模組中)" -#: ../../c-api/import.rst:32 ../../c-api/import.rst:111 +#: ../../c-api/import.rst:35 ../../c-api/import.rst:127 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../c-api/import.rst:32 +#: ../../c-api/import.rst:35 msgid "__import__" msgstr "__import__" -#: ../../c-api/import.rst:111 +#: ../../c-api/import.rst:127 msgid "compile" msgstr "compile(編譯)" -#: ../../c-api/import.rst:247 +#: ../../c-api/import.rst:263 msgid "freeze utility" msgstr "freeze utility(凍結工具)" diff --git a/c-api/index.po b/c-api/index.po index d1aa91e806..7e0a7df309 100644 --- a/c-api/index.po +++ b/c-api/index.po @@ -8,7 +8,7 @@ # Steven Hsu , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2021-07-05 21:11+0800\n" diff --git a/c-api/init.po b/c-api/init.po index 8f5da7b89d..e003fd46a4 100644 --- a/c-api/init.po +++ b/c-api/init.po @@ -1,4 +1,3 @@ -# SOME DESCRIPTIVE TITLE. # Copyright (C) 2001-2022, Python Software Foundation # This file is distributed under the same license as the Python package. # @@ -6,9 +5,9 @@ # Adrian Liaw , 2018 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2023-04-24 20:49+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -25,14 +24,18 @@ msgid "Initialization, Finalization, and Threads" msgstr "" #: ../../c-api/init.rst:10 -msgid "See also :ref:`Python Initialization Configuration `." -msgstr "也請參見 :ref:`Python 初始化設定 `。" +msgid "" +"See :ref:`Python Initialization Configuration ` for details on " +"how to configure the interpreter prior to initialization." +msgstr "" +"關於如何在初始化之前設定直譯器的細節,請參見 :ref:`Python 初始化設定 `。" -#: ../../c-api/init.rst:15 +#: ../../c-api/init.rst:16 msgid "Before Python Initialization" msgstr "Python 初始化之前" -#: ../../c-api/init.rst:17 +#: ../../c-api/init.rst:18 msgid "" "In an application embedding Python, the :c:func:`Py_Initialize` function " "must be called before using any other Python/C API functions; with the " @@ -40,152 +43,186 @@ msgid "" "`." msgstr "" -#: ../../c-api/init.rst:22 +#: ../../c-api/init.rst:23 msgid "" "The following functions can be safely called before Python is initialized:" msgstr "" -#: ../../c-api/init.rst:24 +#: ../../c-api/init.rst:25 +msgid "Functions that initialize the interpreter:" +msgstr "" + +#: ../../c-api/init.rst:27 +msgid ":c:func:`Py_Initialize`" +msgstr ":c:func:`Py_Initialize`" + +#: ../../c-api/init.rst:28 +msgid ":c:func:`Py_InitializeEx`" +msgstr ":c:func:`Py_InitializeEx`" + +#: ../../c-api/init.rst:29 +msgid ":c:func:`Py_InitializeFromConfig`" +msgstr ":c:func:`Py_InitializeFromConfig`" + +#: ../../c-api/init.rst:30 +msgid ":c:func:`Py_BytesMain`" +msgstr ":c:func:`Py_BytesMain`" + +#: ../../c-api/init.rst:31 +msgid ":c:func:`Py_Main`" +msgstr ":c:func:`Py_Main`" + +#: ../../c-api/init.rst:32 +msgid "the runtime pre-initialization functions covered in :ref:`init-config`" +msgstr "" + +#: ../../c-api/init.rst:34 msgid "Configuration functions:" msgstr "" -#: ../../c-api/init.rst:26 +#: ../../c-api/init.rst:36 msgid ":c:func:`PyImport_AppendInittab`" msgstr ":c:func:`PyImport_AppendInittab`" -#: ../../c-api/init.rst:27 +#: ../../c-api/init.rst:37 msgid ":c:func:`PyImport_ExtendInittab`" msgstr ":c:func:`PyImport_ExtendInittab`" -#: ../../c-api/init.rst:28 +#: ../../c-api/init.rst:38 msgid ":c:func:`!PyInitFrozenExtensions`" msgstr ":c:func:`!PyInitFrozenExtensions`" -#: ../../c-api/init.rst:29 +#: ../../c-api/init.rst:39 msgid ":c:func:`PyMem_SetAllocator`" msgstr ":c:func:`PyMem_SetAllocator`" -#: ../../c-api/init.rst:30 +#: ../../c-api/init.rst:40 msgid ":c:func:`PyMem_SetupDebugHooks`" msgstr ":c:func:`PyMem_SetupDebugHooks`" -#: ../../c-api/init.rst:31 +#: ../../c-api/init.rst:41 msgid ":c:func:`PyObject_SetArenaAllocator`" msgstr ":c:func:`PyObject_SetArenaAllocator`" -#: ../../c-api/init.rst:32 -msgid ":c:func:`Py_SetPath`" -msgstr ":c:func:`Py_SetPath`" - -#: ../../c-api/init.rst:33 +#: ../../c-api/init.rst:42 msgid ":c:func:`Py_SetProgramName`" msgstr ":c:func:`Py_SetProgramName`" -#: ../../c-api/init.rst:34 +#: ../../c-api/init.rst:43 msgid ":c:func:`Py_SetPythonHome`" msgstr ":c:func:`Py_SetPythonHome`" -#: ../../c-api/init.rst:35 -msgid ":c:func:`Py_SetStandardStreamEncoding`" -msgstr ":c:func:`Py_SetStandardStreamEncoding`" - -#: ../../c-api/init.rst:36 -msgid ":c:func:`PySys_AddWarnOption`" -msgstr ":c:func:`PySys_AddWarnOption`" - -#: ../../c-api/init.rst:37 -msgid ":c:func:`PySys_AddXOption`" -msgstr ":c:func:`PySys_AddXOption`" - -#: ../../c-api/init.rst:38 +#: ../../c-api/init.rst:44 msgid ":c:func:`PySys_ResetWarnOptions`" msgstr ":c:func:`PySys_ResetWarnOptions`" -#: ../../c-api/init.rst:40 +#: ../../c-api/init.rst:45 +msgid "the configuration functions covered in :ref:`init-config`" +msgstr "" + +#: ../../c-api/init.rst:47 msgid "Informative functions:" msgstr "" -#: ../../c-api/init.rst:42 +#: ../../c-api/init.rst:49 ../../c-api/init.rst:57 msgid ":c:func:`Py_IsInitialized`" msgstr ":c:func:`Py_IsInitialized`" -#: ../../c-api/init.rst:43 +#: ../../c-api/init.rst:50 msgid ":c:func:`PyMem_GetAllocator`" msgstr ":c:func:`PyMem_GetAllocator`" -#: ../../c-api/init.rst:44 +#: ../../c-api/init.rst:51 msgid ":c:func:`PyObject_GetArenaAllocator`" msgstr ":c:func:`PyObject_GetArenaAllocator`" -#: ../../c-api/init.rst:45 +#: ../../c-api/init.rst:52 msgid ":c:func:`Py_GetBuildInfo`" msgstr ":c:func:`Py_GetBuildInfo`" -#: ../../c-api/init.rst:46 +#: ../../c-api/init.rst:53 msgid ":c:func:`Py_GetCompiler`" msgstr ":c:func:`Py_GetCompiler`" -#: ../../c-api/init.rst:47 +#: ../../c-api/init.rst:54 msgid ":c:func:`Py_GetCopyright`" msgstr ":c:func:`Py_GetCopyright`" -#: ../../c-api/init.rst:48 +#: ../../c-api/init.rst:55 msgid ":c:func:`Py_GetPlatform`" msgstr ":c:func:`Py_GetPlatform`" -#: ../../c-api/init.rst:49 +#: ../../c-api/init.rst:56 msgid ":c:func:`Py_GetVersion`" msgstr ":c:func:`Py_GetVersion`" -#: ../../c-api/init.rst:51 +#: ../../c-api/init.rst:59 msgid "Utilities:" msgstr "" -#: ../../c-api/init.rst:53 +#: ../../c-api/init.rst:61 msgid ":c:func:`Py_DecodeLocale`" msgstr ":c:func:`Py_DecodeLocale`" -#: ../../c-api/init.rst:55 +#: ../../c-api/init.rst:62 +msgid "" +"the status reporting and utility functions covered in :ref:`init-config`" +msgstr "" + +#: ../../c-api/init.rst:64 msgid "Memory allocators:" msgstr "" -#: ../../c-api/init.rst:57 +#: ../../c-api/init.rst:66 msgid ":c:func:`PyMem_RawMalloc`" msgstr ":c:func:`PyMem_RawMalloc`" -#: ../../c-api/init.rst:58 +#: ../../c-api/init.rst:67 msgid ":c:func:`PyMem_RawRealloc`" msgstr ":c:func:`PyMem_RawRealloc`" -#: ../../c-api/init.rst:59 +#: ../../c-api/init.rst:68 msgid ":c:func:`PyMem_RawCalloc`" msgstr ":c:func:`PyMem_RawCalloc`" -#: ../../c-api/init.rst:60 +#: ../../c-api/init.rst:69 msgid ":c:func:`PyMem_RawFree`" msgstr ":c:func:`PyMem_RawFree`" -#: ../../c-api/init.rst:64 +#: ../../c-api/init.rst:71 +msgid "Synchronization:" +msgstr "" + +#: ../../c-api/init.rst:73 +msgid ":c:func:`PyMutex_Lock`" +msgstr ":c:func:`PyMutex_Lock`" + +#: ../../c-api/init.rst:74 +msgid ":c:func:`PyMutex_Unlock`" +msgstr ":c:func:`PyMutex_Unlock`" + +#: ../../c-api/init.rst:78 msgid "" -"The following functions **should not be called** before :c:func:" -"`Py_Initialize`: :c:func:`Py_EncodeLocale`, :c:func:`Py_GetPath`, :c:func:" +"Despite their apparent similarity to some of the functions listed above, the " +"following functions **should not be called** before the interpreter has been " +"initialized: :c:func:`Py_EncodeLocale`, :c:func:`Py_GetPath`, :c:func:" "`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, :c:func:" "`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome`, :c:func:" -"`Py_GetProgramName` and :c:func:`PyEval_InitThreads`." +"`Py_GetProgramName`, :c:func:`PyEval_InitThreads`, and :c:func:`Py_RunMain`." msgstr "" -#: ../../c-api/init.rst:74 +#: ../../c-api/init.rst:90 msgid "Global configuration variables" msgstr "" -#: ../../c-api/init.rst:76 +#: ../../c-api/init.rst:92 msgid "" "Python has variables for the global configuration to control different " "features and options. By default, these flags are controlled by :ref:" "`command line options `." msgstr "" -#: ../../c-api/init.rst:80 +#: ../../c-api/init.rst:96 msgid "" "When a flag is set by an option, the value of the flag is the number of " "times that the option was set. For example, ``-b`` sets :c:data:" @@ -193,108 +230,108 @@ msgid "" "2." msgstr "" -#: ../../c-api/init.rst:86 +#: ../../c-api/init.rst:102 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "bytes_warning` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:90 +#: ../../c-api/init.rst:106 msgid "" "Issue a warning when comparing :class:`bytes` or :class:`bytearray` with :" "class:`str` or :class:`bytes` with :class:`int`. Issue an error if greater " "or equal to ``2``." msgstr "" -#: ../../c-api/init.rst:94 +#: ../../c-api/init.rst:110 msgid "Set by the :option:`-b` option." msgstr "由 :option:`-b` 選項設定。" -#: ../../c-api/init.rst:100 +#: ../../c-api/init.rst:116 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "parser_debug` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:104 +#: ../../c-api/init.rst:120 msgid "" "Turn on parser debugging output (for expert only, depending on compilation " "options)." msgstr "" -#: ../../c-api/init.rst:107 +#: ../../c-api/init.rst:123 msgid "" "Set by the :option:`-d` option and the :envvar:`PYTHONDEBUG` environment " "variable." msgstr "由 :option:`-d` 選項與 :envvar:`PYTHONDEBUG` 環境變數設定。" -#: ../../c-api/init.rst:114 +#: ../../c-api/init.rst:130 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "write_bytecode` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:118 +#: ../../c-api/init.rst:134 msgid "" "If set to non-zero, Python won't try to write ``.pyc`` files on the import " "of source modules." msgstr "" -#: ../../c-api/init.rst:121 +#: ../../c-api/init.rst:137 msgid "" "Set by the :option:`-B` option and the :envvar:`PYTHONDONTWRITEBYTECODE` " "environment variable." msgstr "" "由 :option:`-B` 選項與 :envvar:`PYTHONDONTWRITEBYTECODE` 環境變數設定。" -#: ../../c-api/init.rst:128 +#: ../../c-api/init.rst:144 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "pathconfig_warnings` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:132 +#: ../../c-api/init.rst:148 msgid "" "Suppress error messages when calculating the module search path in :c:func:" "`Py_GetPath`." msgstr "" -#: ../../c-api/init.rst:135 +#: ../../c-api/init.rst:151 msgid "Private flag used by ``_freeze_module`` and ``frozenmain`` programs." msgstr "" -#: ../../c-api/init.rst:141 +#: ../../c-api/init.rst:157 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "hash_seed` and :c:member:`PyConfig.use_hash_seed` should be used instead, " "see :ref:`Python Initialization Configuration `." msgstr "" -#: ../../c-api/init.rst:146 +#: ../../c-api/init.rst:162 msgid "" "Set to ``1`` if the :envvar:`PYTHONHASHSEED` environment variable is set to " "a non-empty string." msgstr "" "如果環境變數 :envvar:`PYTHONHASHSEED` 被設定為一個非空字串則設為 ``1``。" -#: ../../c-api/init.rst:149 +#: ../../c-api/init.rst:165 msgid "" "If the flag is non-zero, read the :envvar:`PYTHONHASHSEED` environment " "variable to initialize the secret hash seed." msgstr "" -#: ../../c-api/init.rst:156 +#: ../../c-api/init.rst:172 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "use_environment` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:160 +#: ../../c-api/init.rst:176 msgid "" "Ignore all :envvar:`!PYTHON*` environment variables, e.g. :envvar:" "`PYTHONPATH` and :envvar:`PYTHONHOME`, that might be set." @@ -302,73 +339,73 @@ msgstr "" "忽略所有可能被設定的 :envvar:`!PYTHON*` 環境變數,例如 :envvar:`PYTHONPATH` " "與 :envvar:`PYTHONHOME`。" -#: ../../c-api/init.rst:163 +#: ../../c-api/init.rst:179 msgid "Set by the :option:`-E` and :option:`-I` options." msgstr "由 :option:`-E` 與 :option:`-I` 選項設定。" -#: ../../c-api/init.rst:169 +#: ../../c-api/init.rst:185 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "inspect` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:173 +#: ../../c-api/init.rst:189 msgid "" "When a script is passed as first argument or the :option:`-c` option is " "used, enter interactive mode after executing the script or the command, even " "when :data:`sys.stdin` does not appear to be a terminal." msgstr "" -#: ../../c-api/init.rst:177 +#: ../../c-api/init.rst:193 msgid "" "Set by the :option:`-i` option and the :envvar:`PYTHONINSPECT` environment " "variable." msgstr "由 :option:`-i` 選項與 :envvar:`PYTHONINSPECT` 環境變數設定。" -#: ../../c-api/init.rst:184 +#: ../../c-api/init.rst:200 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "interactive` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:188 +#: ../../c-api/init.rst:204 msgid "Set by the :option:`-i` option." msgstr "由 :option:`-i` 選項設定。" -#: ../../c-api/init.rst:194 +#: ../../c-api/init.rst:210 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "isolated` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:198 +#: ../../c-api/init.rst:214 msgid "" "Run Python in isolated mode. In isolated mode :data:`sys.path` contains " "neither the script's directory nor the user's site-packages directory." msgstr "" -#: ../../c-api/init.rst:201 +#: ../../c-api/init.rst:217 msgid "Set by the :option:`-I` option." msgstr "由 :option:`-i` 選項設定。" -#: ../../c-api/init.rst:209 +#: ../../c-api/init.rst:225 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyPreConfig." "legacy_windows_fs_encoding` should be used instead, see :ref:`Python " "Initialization Configuration `." msgstr "" -#: ../../c-api/init.rst:213 +#: ../../c-api/init.rst:229 msgid "" "If the flag is non-zero, use the ``mbcs`` encoding with ``replace`` error " "handler, instead of the UTF-8 encoding with ``surrogatepass`` error handler, " "for the :term:`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/init.rst:217 +#: ../../c-api/init.rst:233 msgid "" "Set to ``1`` if the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment " "variable is set to a non-empty string." @@ -376,45 +413,45 @@ msgstr "" "如果環境變數 :envvar:`PYTHONLEGACYWINDOWSFSENCODING` 被設定為一個非空字串則設" "為 ``1``。" -#: ../../c-api/init.rst:220 +#: ../../c-api/init.rst:236 msgid "See :pep:`529` for more details." msgstr "更多詳情請見 :pep:`529`。" -#: ../../c-api/init.rst:222 ../../c-api/init.rst:240 -msgid ":ref:`Availability `: Windows." -msgstr ":ref:`適用 `:Windows。" +#: ../../c-api/init.rst:238 ../../c-api/init.rst:256 +msgid "Availability" +msgstr "可用性" -#: ../../c-api/init.rst:228 +#: ../../c-api/init.rst:244 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "legacy_windows_stdio` should be used instead, see :ref:`Python " "Initialization Configuration `." msgstr "" -#: ../../c-api/init.rst:232 +#: ../../c-api/init.rst:248 msgid "" "If the flag is non-zero, use :class:`io.FileIO` instead of :class:`!io." "_WindowsConsoleIO` for :mod:`sys` standard streams." msgstr "" -#: ../../c-api/init.rst:235 +#: ../../c-api/init.rst:251 msgid "" "Set to ``1`` if the :envvar:`PYTHONLEGACYWINDOWSSTDIO` environment variable " "is set to a non-empty string." msgstr "" -#: ../../c-api/init.rst:238 +#: ../../c-api/init.rst:254 msgid "See :pep:`528` for more details." msgstr "更多詳情請見 :pep:`528`。" -#: ../../c-api/init.rst:246 +#: ../../c-api/init.rst:262 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "site_import` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:250 +#: ../../c-api/init.rst:266 msgid "" "Disable the import of the module :mod:`site` and the site-dependent " "manipulations of :data:`sys.path` that it entails. Also disable these " @@ -422,24 +459,24 @@ msgid "" "main` if you want them to be triggered)." msgstr "" -#: ../../c-api/init.rst:255 +#: ../../c-api/init.rst:271 msgid "Set by the :option:`-S` option." msgstr "由 :option:`-S` 選項設定。" -#: ../../c-api/init.rst:261 +#: ../../c-api/init.rst:277 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "user_site_directory` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:265 +#: ../../c-api/init.rst:281 msgid "" "Don't add the :data:`user site-packages directory ` to :data:" "`sys.path`." msgstr "" -#: ../../c-api/init.rst:268 +#: ../../c-api/init.rst:284 msgid "" "Set by the :option:`-s` and :option:`-I` options, and the :envvar:" "`PYTHONNOUSERSITE` environment variable." @@ -447,60 +484,60 @@ msgstr "" "由 :option:`-s` 選項、:option:`-I` 選項與 :envvar:`PYTHONNOUSERSITE` 環境變數" "設定。" -#: ../../c-api/init.rst:275 +#: ../../c-api/init.rst:291 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "optimization_level` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:279 +#: ../../c-api/init.rst:295 msgid "" "Set by the :option:`-O` option and the :envvar:`PYTHONOPTIMIZE` environment " "variable." msgstr "由 :option:`-O` 選項與 :envvar:`PYTHONOPTIMIZE` 環境變數設定。" -#: ../../c-api/init.rst:286 +#: ../../c-api/init.rst:302 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "quiet` should be used instead, see :ref:`Python Initialization Configuration " "`." msgstr "" -#: ../../c-api/init.rst:290 +#: ../../c-api/init.rst:306 msgid "" "Don't display the copyright and version messages even in interactive mode." msgstr "" -#: ../../c-api/init.rst:292 +#: ../../c-api/init.rst:308 msgid "Set by the :option:`-q` option." msgstr "由 :option:`-q` 選項設定。" -#: ../../c-api/init.rst:300 +#: ../../c-api/init.rst:316 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "buffered_stdio` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:304 +#: ../../c-api/init.rst:320 msgid "Force the stdout and stderr streams to be unbuffered." msgstr "" -#: ../../c-api/init.rst:306 +#: ../../c-api/init.rst:322 msgid "" "Set by the :option:`-u` option and the :envvar:`PYTHONUNBUFFERED` " "environment variable." msgstr "由 :option:`-u` 選項與 :envvar:`PYTHONUNBUFFERED` 環境變數設定。" -#: ../../c-api/init.rst:313 +#: ../../c-api/init.rst:329 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "verbose` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:317 +#: ../../c-api/init.rst:333 msgid "" "Print a message each time a module is initialized, showing the place " "(filename or built-in module) from which it is loaded. If greater or equal " @@ -508,60 +545,81 @@ msgid "" "for a module. Also provides information on module cleanup at exit." msgstr "" -#: ../../c-api/init.rst:322 +#: ../../c-api/init.rst:338 msgid "" "Set by the :option:`-v` option and the :envvar:`PYTHONVERBOSE` environment " "variable." msgstr "由 :option:`-v` 選項與 :envvar:`PYTHONVERBOSE` 環境變數設定。" -#: ../../c-api/init.rst:329 +#: ../../c-api/init.rst:345 msgid "Initializing and finalizing the interpreter" msgstr "" -#: ../../c-api/init.rst:347 +#: ../../c-api/init.rst:360 msgid "" "Initialize the Python interpreter. In an application embedding Python, " "this should be called before using any other Python/C API functions; see :" "ref:`Before Python Initialization ` for the few exceptions." msgstr "" -#: ../../c-api/init.rst:351 +#: ../../c-api/init.rst:364 msgid "" "This initializes the table of loaded modules (``sys.modules``), and creates " -"the fundamental modules :mod:`builtins`, :mod:`__main__` and :mod:`sys`. It " +"the fundamental modules :mod:`builtins`, :mod:`__main__` and :mod:`sys`. It " "also initializes the module search path (``sys.path``). It does not set " -"``sys.argv``; use :c:func:`PySys_SetArgvEx` for that. This is a no-op when " -"called for a second time (without calling :c:func:`Py_FinalizeEx` first). " -"There is no return value; it is a fatal error if the initialization fails." +"``sys.argv``; use the :ref:`Python Initialization Configuration ` API for that. This is a no-op when called for a second time " +"(without calling :c:func:`Py_FinalizeEx` first). There is no return value; " +"it is a fatal error if the initialization fails." msgstr "" -#: ../../c-api/init.rst:359 ../../c-api/init.rst:373 +#: ../../c-api/init.rst:372 ../../c-api/init.rst:386 msgid "" -"Use the :c:func:`Py_InitializeFromConfig` function to customize the :ref:" -"`Python Initialization Configuration `." +"Use :c:func:`Py_InitializeFromConfig` to customize the :ref:`Python " +"Initialization Configuration `." msgstr "" -#: ../../c-api/init.rst:363 +#: ../../c-api/init.rst:376 msgid "" "On Windows, changes the console mode from ``O_TEXT`` to ``O_BINARY``, which " "will also affect non-Python uses of the console using the C Runtime." msgstr "" -#: ../../c-api/init.rst:369 +#: ../../c-api/init.rst:382 msgid "" "This function works like :c:func:`Py_Initialize` if *initsigs* is ``1``. If " "*initsigs* is ``0``, it skips initialization registration of signal " -"handlers, which might be useful when Python is embedded." +"handlers, which may be useful when CPython is embedded as part of a larger " +"application." +msgstr "" + +#: ../../c-api/init.rst:392 +msgid "" +"Initialize Python from *config* configuration, as described in :ref:`init-" +"from-config`." +msgstr "" + +#: ../../c-api/init.rst:395 +msgid "" +"See the :ref:`init-config` section for details on pre-initializing the " +"interpreter, populating the runtime configuration structure, and querying " +"the returned status structure." msgstr "" -#: ../../c-api/init.rst:379 +#: ../../c-api/init.rst:402 msgid "" "Return true (nonzero) when the Python interpreter has been initialized, " "false (zero) if not. After :c:func:`Py_FinalizeEx` is called, this returns " "false until :c:func:`Py_Initialize` is called again." msgstr "" -#: ../../c-api/init.rst:386 +#: ../../c-api/init.rst:409 +msgid "" +"Return true (non-zero) if the main Python interpreter is :term:`shutting " +"down `. Return false (zero) otherwise." +msgstr "" + +#: ../../c-api/init.rst:417 msgid "" "Undo all initializations made by :c:func:`Py_Initialize` and subsequent use " "of Python/C API functions, and destroy all sub-interpreters (see :c:func:" @@ -571,7 +629,7 @@ msgid "" "second time (without calling :c:func:`Py_Initialize` again first)." msgstr "" -#: ../../c-api/init.rst:393 +#: ../../c-api/init.rst:424 msgid "" "Since this is the reverse of :c:func:`Py_Initialize`, it should be called in " "the same thread with the same interpreter active. That means the main " @@ -579,13 +637,13 @@ msgid "" "`Py_RunMain` is running." msgstr "" -#: ../../c-api/init.rst:398 +#: ../../c-api/init.rst:429 msgid "" "Normally the return value is ``0``. If there were errors during finalization " "(flushing buffered data), ``-1`` is returned." msgstr "" -#: ../../c-api/init.rst:402 +#: ../../c-api/init.rst:433 msgid "" "This function is provided for a number of reasons. An embedding application " "might want to restart Python without having to restart the application " @@ -596,7 +654,7 @@ msgid "" "Python before exiting from the application." msgstr "" -#: ../../c-api/init.rst:410 +#: ../../c-api/init.rst:441 msgid "" "**Bugs and caveats:** The destruction of modules and objects in modules is " "done in random order; this may cause destructors (:meth:`~object.__del__` " @@ -611,7 +669,7 @@ msgid "" "more than once." msgstr "" -#: ../../c-api/init.rst:421 +#: ../../c-api/init.rst:452 msgid "" "Raises an :ref:`auditing event ` ``cpython." "_PySys_ClearAuditHooks`` with no arguments." @@ -619,68 +677,149 @@ msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``cpython." "_PySys_ClearAuditHooks``。" -#: ../../c-api/init.rst:427 +#: ../../c-api/init.rst:459 msgid "" "This is a backwards-compatible version of :c:func:`Py_FinalizeEx` that " "disregards the return value." msgstr "" -#: ../../c-api/init.rst:432 -msgid "Process-wide parameters" +#: ../../c-api/init.rst:465 +msgid "" +"Similar to :c:func:`Py_Main` but *argv* is an array of bytes strings, " +"allowing the calling application to delegate the text decoding step to the " +"CPython runtime." msgstr "" -#: ../../c-api/init.rst:442 +#: ../../c-api/init.rst:474 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"stdio_encoding` and :c:member:`PyConfig.stdio_errors` should be used " -"instead, see :ref:`Python Initialization Configuration `." +"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 :ref:`using-on-" +"cmdline`." +msgstr "" + +#: ../../c-api/init.rst:480 +msgid "" +"This is made available for programs which wish to support the full CPython " +"command line interface, rather than just embedding a Python runtime in a " +"larger application." msgstr "" -#: ../../c-api/init.rst:447 +#: ../../c-api/init.rst:484 msgid "" -"This function should be called before :c:func:`Py_Initialize`, if it is " -"called at all. It specifies which encoding and error handling to use with " -"standard IO, with the same meanings as in :func:`str.encode`." +"The *argc* and *argv* parameters are similar to those which are passed to a " +"C program's :c:func:`main` function, except that the *argv* entries are " +"first converted to ``wchar_t`` using :c:func:`Py_DecodeLocale`. 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)." msgstr "" -#: ../../c-api/init.rst:451 +#: ../../c-api/init.rst:491 msgid "" -"It overrides :envvar:`PYTHONIOENCODING` values, and allows embedding code to " -"control IO encoding when the environment variable does not work." +"The return value is ``2`` if the argument list does not represent a valid " +"Python command line, and otherwise the same as :c:func:`Py_RunMain`." msgstr "" -#: ../../c-api/init.rst:454 +#: ../../c-api/init.rst:494 +msgid "" +"In terms of the CPython runtime configuration APIs documented in the :ref:" +"`runtime configuration ` section (and without accounting for " +"error handling), ``Py_Main`` is approximately equivalent to::" +msgstr "" + +#: ../../c-api/init.rst:498 +msgid "" +"PyConfig config;\n" +"PyConfig_InitPythonConfig(&config);\n" +"PyConfig_SetArgv(&config, argc, argv);\n" +"Py_InitializeFromConfig(&config);\n" +"PyConfig_Clear(&config);\n" +"\n" +"Py_RunMain();" +msgstr "" + +#: ../../c-api/init.rst:506 +msgid "" +"In normal usage, an embedding application will call this function *instead* " +"of calling :c:func:`Py_Initialize`, :c:func:`Py_InitializeEx` or :c:func:" +"`Py_InitializeFromConfig` 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)." +msgstr "" + +#: ../../c-api/init.rst:519 +msgid "Executes the main module in a fully configured CPython runtime." +msgstr "" + +#: ../../c-api/init.rst:521 msgid "" -"*encoding* and/or *errors* may be ``NULL`` to use :envvar:`PYTHONIOENCODING` " -"and/or default values (depending on other settings)." +"Executes the command (:c:member:`PyConfig.run_command`), the script (:c:" +"member:`PyConfig.run_filename`) or the module (:c:member:`PyConfig." +"run_module`) 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." msgstr "" -#: ../../c-api/init.rst:458 +#: ../../c-api/init.rst:527 msgid "" -"Note that :data:`sys.stderr` always uses the \"backslashreplace\" error " -"handler, regardless of this (or any other) setting." +"If :c:member:`PyConfig.inspect` is not set (the default), the return value " +"will be ``0`` if the interpreter exits normally (that is, without raising an " +"exception), the exit status of an unhandled :exc:`SystemExit`, or ``1`` for " +"any other unhandled exception." msgstr "" -#: ../../c-api/init.rst:461 +#: ../../c-api/init.rst:532 msgid "" -"If :c:func:`Py_FinalizeEx` is called, this function will need to be called " -"again in order to affect subsequent calls to :c:func:`Py_Initialize`." +"If :c:member:`PyConfig.inspect` is set (such as when the :option:`-i` 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: ``0``, ``1``, or the " +"status of a :exc:`SystemExit`, as specified above." msgstr "" -#: ../../c-api/init.rst:464 +#: ../../c-api/init.rst:540 msgid "" -"Returns ``0`` if successful, a nonzero value on error (e.g. calling after " -"the interpreter has already been initialized)." +"This function always finalizes the Python interpreter before it returns." +msgstr "" + +#: ../../c-api/init.rst:542 +msgid "" +"See :ref:`Python Configuration ` for an example of a " +"customized Python that always runs in isolated mode using :c:func:" +"`Py_RunMain`." +msgstr "" + +#: ../../c-api/init.rst:548 +msgid "" +"Register an :mod:`atexit` callback for the target interpreter *interp*. This " +"is similar to :c:func:`Py_AtExit`, but takes an explicit interpreter and " +"data pointer for the callback." +msgstr "" + +#: ../../c-api/init.rst:552 +msgid "The :term:`GIL` must be held for *interp*." +msgstr "" + +#: ../../c-api/init.rst:557 +msgid "Process-wide parameters" msgstr "" -#: ../../c-api/init.rst:479 +#: ../../c-api/init.rst:567 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "program_name` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:483 +#: ../../c-api/init.rst:571 msgid "" "This function should be called before :c:func:`Py_Initialize` is called for " "the first time, if it is called at all. It tells the interpreter the value " @@ -694,60 +833,71 @@ msgid "" "this storage." msgstr "" -#: ../../c-api/init.rst:494 +#: ../../c-api/init.rst:582 ../../c-api/init.rst:824 ../../c-api/init.rst:860 +#: ../../c-api/init.rst:886 msgid "" "Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a :c:expr:" -"`wchar_t *` string." +"`wchar_t*` string." msgstr "" -#: ../../c-api/init.rst:504 +#: ../../c-api/init.rst:590 msgid "" -"Return the program name set with :c:func:`Py_SetProgramName`, or the " +"Return the program name set with :c:member:`PyConfig.program_name`, or the " "default. The returned string points into static storage; the caller should " "not modify its value." msgstr "" -#: ../../c-api/init.rst:508 ../../c-api/init.rst:527 ../../c-api/init.rst:568 -#: ../../c-api/init.rst:587 ../../c-api/init.rst:611 ../../c-api/init.rst:834 +#: ../../c-api/init.rst:594 ../../c-api/init.rst:616 ../../c-api/init.rst:662 +#: ../../c-api/init.rst:684 ../../c-api/init.rst:710 ../../c-api/init.rst:898 msgid "" "This function should not be called before :c:func:`Py_Initialize`, otherwise " "it returns ``NULL``." msgstr "此函式不應該在 :c:func:`Py_Initialize` 之前呼叫,否則會回傳 ``NULL``。" -#: ../../c-api/init.rst:511 ../../c-api/init.rst:530 ../../c-api/init.rst:571 -#: ../../c-api/init.rst:590 ../../c-api/init.rst:616 ../../c-api/init.rst:837 +#: ../../c-api/init.rst:597 ../../c-api/init.rst:619 ../../c-api/init.rst:665 +#: ../../c-api/init.rst:687 ../../c-api/init.rst:715 ../../c-api/init.rst:901 msgid "It now returns ``NULL`` if called before :c:func:`Py_Initialize`." msgstr "如果在 :c:func:`Py_Initialize` 之前呼叫,現在會回傳 ``NULL``。" -#: ../../c-api/init.rst:517 +#: ../../c-api/init.rst:600 ../../c-api/init.rst:690 +msgid "Get :data:`sys.executable` instead." +msgstr "" + +#: ../../c-api/init.rst:606 msgid "" "Return the *prefix* for installed platform-independent files. This is " "derived through a number of complicated rules from the program name set " -"with :c:func:`Py_SetProgramName` and some environment variables; for " +"with :c:member:`PyConfig.program_name` 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 :makevar:`prefix` " "variable in the top-level :file:`Makefile` and the :option:`--prefix` " "argument to the :program:`configure` script at build time. The value is " -"available to Python code as ``sys.prefix``. It is only useful on Unix. See " -"also the next function." +"available to Python code as ``sys.base_prefix``. It is only useful on Unix. " +"See also the next function." +msgstr "" + +#: ../../c-api/init.rst:622 +msgid "" +"Get :data:`sys.base_prefix` instead, or :data:`sys.prefix` if :ref:`virtual " +"environments ` need to be handled." msgstr "" -#: ../../c-api/init.rst:536 +#: ../../c-api/init.rst:629 msgid "" "Return the *exec-prefix* for installed platform-*dependent* files. This is " "derived through a number of complicated rules from the program name set " -"with :c:func:`Py_SetProgramName` and some environment variables; for " +"with :c:member:`PyConfig.program_name` 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 :makevar:" "`exec_prefix` variable in the top-level :file:`Makefile` and the ``--exec-" "prefix`` argument to the :program:`configure` script at build time. The " -"value is available to Python code as ``sys.exec_prefix``. It is only useful " -"on Unix." +"value is available to Python code as ``sys.base_exec_prefix``. It is only " +"useful on Unix." msgstr "" -#: ../../c-api/init.rst:546 +#: ../../c-api/init.rst:640 msgid "" "Background: The exec-prefix differs from the prefix when platform dependent " "files (such as executables and shared libraries) are installed in a " @@ -756,7 +906,7 @@ msgid "" "independent may be installed in :file:`/usr/local`." msgstr "" -#: ../../c-api/init.rst:552 +#: ../../c-api/init.rst:646 msgid "" "Generally speaking, a platform is a combination of hardware and software " "families, e.g. Sparc machines running the Solaris 2.x operating system are " @@ -770,7 +920,7 @@ msgid "" "independent from the Python version by which they were compiled!)." msgstr "" -#: ../../c-api/init.rst:563 +#: ../../c-api/init.rst:657 msgid "" "System administrators will know how to configure the :program:`mount` or :" "program:`automount` programs to share :file:`/usr/local` between platforms " @@ -778,19 +928,25 @@ msgid "" "platform." msgstr "" -#: ../../c-api/init.rst:581 +#: ../../c-api/init.rst:668 +msgid "" +"Get :data:`sys.base_exec_prefix` instead, or :data:`sys.exec_prefix` if :ref:" +"`virtual environments ` need to be handled." +msgstr "" + +#: ../../c-api/init.rst:678 msgid "" "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 :c:func:`Py_SetProgramName` above). The returned string points " +"name (set by :c:member:`PyConfig.program_name`). The returned string points " "into static storage; the caller should not modify its value. The value is " "available to Python code as ``sys.executable``." msgstr "" -#: ../../c-api/init.rst:601 +#: ../../c-api/init.rst:700 msgid "" "Return the default module search path; this is computed from the program " -"name (set by :c:func:`Py_SetProgramName` above) and some environment " +"name (set by :c:member:`PyConfig.program_name`) 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 " @@ -800,63 +956,21 @@ msgid "" "for loading modules." msgstr "" -#: ../../c-api/init.rst:627 -msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"module_search_paths` and :c:member:`PyConfig.module_search_paths_set` should " -"be used instead, see :ref:`Python Initialization Configuration `." -msgstr "" - -#: ../../c-api/init.rst:632 -msgid "" -"Set the default module search path. If this function is called before :c:" -"func:`Py_Initialize`, then :c:func:`Py_GetPath` won't attempt to compute a " -"default search path but uses the one provided instead. This is useful if " -"Python is embedded by an application that has full knowledge of the location " -"of all modules. The path components should be separated by the platform " -"dependent delimiter character, which is ``':'`` on Unix and macOS, ``';'`` " -"on Windows." -msgstr "" - -#: ../../c-api/init.rst:640 -msgid "" -"This also causes :data:`sys.executable` to be set to the program full path " -"(see :c:func:`Py_GetProgramFullPath`) and for :data:`sys.prefix` and :data:" -"`sys.exec_prefix` to be empty. It is up to the caller to modify these if " -"required after calling :c:func:`Py_Initialize`." +#: ../../c-api/init.rst:718 +msgid "Get :data:`sys.path` instead." msgstr "" -#: ../../c-api/init.rst:645 ../../c-api/init.rst:760 ../../c-api/init.rst:796 -#: ../../c-api/init.rst:822 -msgid "" -"Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a :c:expr:" -"`wchar_*` string." -msgstr "" - -#: ../../c-api/init.rst:648 -msgid "" -"The path argument is copied internally, so the caller may free it after the " -"call completes." -msgstr "" - -#: ../../c-api/init.rst:651 -msgid "" -"The program full path is now used for :data:`sys.executable`, instead of the " -"program name." -msgstr "" - -#: ../../c-api/init.rst:660 +#: ../../c-api/init.rst:724 msgid "" "Return the version of this Python interpreter. This is a string that looks " "something like ::" msgstr "" -#: ../../c-api/init.rst:663 +#: ../../c-api/init.rst:727 msgid "\"3.0a5+ (py3k:63103M, May 12 2008, 00:53:55) \\n[GCC 4.2.3]\"" msgstr "\"3.0a5+ (py3k:63103M, May 12 2008, 00:53:55) \\n[GCC 4.2.3]\"" -#: ../../c-api/init.rst:667 +#: ../../c-api/init.rst:731 msgid "" "The first word (up to the first space character) is the current Python " "version; the first characters are the major and minor version separated by a " @@ -865,11 +979,11 @@ msgid "" "version`." msgstr "" -#: ../../c-api/init.rst:672 +#: ../../c-api/init.rst:736 msgid "See also the :c:var:`Py_Version` constant." -msgstr "" +msgstr "另請參閱 :c:var:`Py_Version` 常數。" -#: ../../c-api/init.rst:679 +#: ../../c-api/init.rst:743 msgid "" "Return the platform identifier for the current platform. On Unix, this is " "formed from the \"official\" name of the operating system, converted to " @@ -880,50 +994,50 @@ msgid "" "available to Python code as ``sys.platform``." msgstr "" -#: ../../c-api/init.rst:690 +#: ../../c-api/init.rst:754 msgid "" "Return the official copyright string for the current Python version, for " "example" msgstr "" -#: ../../c-api/init.rst:692 +#: ../../c-api/init.rst:756 msgid "``'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'``" msgstr "``'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'``" -#: ../../c-api/init.rst:696 +#: ../../c-api/init.rst:760 msgid "" "The returned string points into static storage; the caller should not modify " "its value. The value is available to Python code as ``sys.copyright``." msgstr "" -#: ../../c-api/init.rst:702 +#: ../../c-api/init.rst:766 msgid "" "Return an indication of the compiler used to build the current Python " "version, in square brackets, for example::" msgstr "" -#: ../../c-api/init.rst:705 +#: ../../c-api/init.rst:769 msgid "\"[GCC 2.7.2.2]\"" msgstr "\"[GCC 2.7.2.2]\"" -#: ../../c-api/init.rst:709 ../../c-api/init.rst:723 +#: ../../c-api/init.rst:773 ../../c-api/init.rst:787 msgid "" "The returned string points into static storage; the caller should not modify " "its value. The value is available to Python code as part of the variable " "``sys.version``." msgstr "" -#: ../../c-api/init.rst:716 +#: ../../c-api/init.rst:780 msgid "" "Return information about the sequence number and build date and time of the " "current Python interpreter instance, for example ::" msgstr "" -#: ../../c-api/init.rst:719 +#: ../../c-api/init.rst:783 msgid "\"#67, Aug 1 1997, 22:34:28\"" msgstr "\"#67, Aug 1 1997, 22:34:28\"" -#: ../../c-api/init.rst:735 +#: ../../c-api/init.rst:799 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "argv`, :c:member:`PyConfig.parse_argv` and :c:member:`PyConfig.safe_path` " @@ -931,7 +1045,7 @@ msgid "" "config>`." msgstr "" -#: ../../c-api/init.rst:740 +#: ../../c-api/init.rst:804 msgid "" "Set :data:`sys.argv` based on *argc* and *argv*. These parameters are " "similar to those passed to the program's :c:func:`main` function with the " @@ -942,84 +1056,84 @@ msgid "" "fatal condition is signalled using :c:func:`Py_FatalError`." msgstr "" -#: ../../c-api/init.rst:748 +#: ../../c-api/init.rst:812 msgid "" "If *updatepath* is zero, this is all the function does. If *updatepath* is " "non-zero, the function also modifies :data:`sys.path` according to the " "following algorithm:" msgstr "" -#: ../../c-api/init.rst:752 +#: ../../c-api/init.rst:816 msgid "" "If the name of an existing script is passed in ``argv[0]``, the absolute " "path of the directory where the script is located is prepended to :data:`sys." "path`." msgstr "" -#: ../../c-api/init.rst:755 +#: ../../c-api/init.rst:819 msgid "" "Otherwise (that is, if *argc* is ``0`` or ``argv[0]`` doesn't point to an " "existing file name), an empty string is prepended to :data:`sys.path`, which " "is the same as prepending the current working directory (``\".\"``)." msgstr "" -#: ../../c-api/init.rst:763 ../../c-api/init.rst:799 +#: ../../c-api/init.rst:827 ../../c-api/init.rst:863 msgid "" "See also :c:member:`PyConfig.orig_argv` and :c:member:`PyConfig.argv` " "members of the :ref:`Python Initialization Configuration `." msgstr "" -#: ../../c-api/init.rst:767 +#: ../../c-api/init.rst:831 msgid "" "It is recommended that applications embedding the Python interpreter for " "purposes other than executing a single script pass ``0`` as *updatepath*, " "and update :data:`sys.path` themselves if desired. See :cve:`2008-5983`." msgstr "" -#: ../../c-api/init.rst:772 +#: ../../c-api/init.rst:836 msgid "" "On versions before 3.1.3, you can achieve the same effect by manually " "popping the first :data:`sys.path` element after having called :c:func:" "`PySys_SetArgv`, for example using::" msgstr "" -#: ../../c-api/init.rst:776 +#: ../../c-api/init.rst:840 msgid "PyRun_SimpleString(\"import sys; sys.path.pop(0)\\n\");" msgstr "PyRun_SimpleString(\"import sys; sys.path.pop(0)\\n\");" -#: ../../c-api/init.rst:788 +#: ../../c-api/init.rst:852 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "argv` and :c:member:`PyConfig.parse_argv` should be used instead, see :ref:" "`Python Initialization Configuration `." msgstr "" -#: ../../c-api/init.rst:792 +#: ../../c-api/init.rst:856 msgid "" "This function works like :c:func:`PySys_SetArgvEx` with *updatepath* set to " "``1`` unless the :program:`python` interpreter was started with the :option:" "`-I`." msgstr "" -#: ../../c-api/init.rst:802 +#: ../../c-api/init.rst:866 msgid "The *updatepath* value depends on :option:`-I`." msgstr "" -#: ../../c-api/init.rst:809 +#: ../../c-api/init.rst:873 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "home` should be used instead, see :ref:`Python Initialization Configuration " "`." msgstr "" -#: ../../c-api/init.rst:813 +#: ../../c-api/init.rst:877 msgid "" "Set the default \"home\" directory, that is, the location of the standard " "Python libraries. See :envvar:`PYTHONHOME` for the meaning of the argument " "string." msgstr "" -#: ../../c-api/init.rst:817 +#: ../../c-api/init.rst:881 msgid "" "The argument should point to a zero-terminated character string in static " "storage whose contents will not change for the duration of the program's " @@ -1027,18 +1141,24 @@ msgid "" "this storage." msgstr "" -#: ../../c-api/init.rst:830 +#: ../../c-api/init.rst:894 msgid "" -"Return the default \"home\", that is, the value set by a previous call to :c:" -"func:`Py_SetPythonHome`, or the value of the :envvar:`PYTHONHOME` " -"environment variable if it is set." +"Return the default \"home\", that is, the value set by :c:member:`PyConfig." +"home`, or the value of the :envvar:`PYTHONHOME` environment variable if it " +"is set." msgstr "" -#: ../../c-api/init.rst:844 +#: ../../c-api/init.rst:904 +msgid "" +"Get :c:member:`PyConfig.home` or :envvar:`PYTHONHOME` environment variable " +"instead." +msgstr "改為取得 :c:member:`PyConfig.home` 或 :envvar:`PYTHONHOME` 環境變數。" + +#: ../../c-api/init.rst:912 msgid "Thread State and the Global Interpreter Lock" msgstr "" -#: ../../c-api/init.rst:851 +#: ../../c-api/init.rst:919 msgid "" "The Python interpreter is not fully thread-safe. In order to support multi-" "threaded Python programs, there's a global lock, called the :term:`global " @@ -1050,7 +1170,7 @@ msgid "" "once instead of twice." msgstr "" -#: ../../c-api/init.rst:861 +#: ../../c-api/init.rst:929 msgid "" "Therefore, the rule exists that only the thread that has acquired the :term:" "`GIL` may operate on Python objects or call Python/C API functions. In order " @@ -1060,7 +1180,7 @@ msgid "" "a file, so that other Python threads can run in the meantime." msgstr "" -#: ../../c-api/init.rst:871 +#: ../../c-api/init.rst:939 msgid "" "The Python interpreter keeps some thread-specific bookkeeping information " "inside a data structure called :c:type:`PyThreadState`. There's also one " @@ -1068,17 +1188,17 @@ msgid "" "retrieved using :c:func:`PyThreadState_Get`." msgstr "" -#: ../../c-api/init.rst:877 +#: ../../c-api/init.rst:945 msgid "Releasing the GIL from extension code" msgstr "" -#: ../../c-api/init.rst:879 +#: ../../c-api/init.rst:947 msgid "" "Most extension code manipulating the :term:`GIL` has the following simple " "structure::" msgstr "" -#: ../../c-api/init.rst:882 +#: ../../c-api/init.rst:950 msgid "" "Save the thread state in a local variable.\n" "Release the global interpreter lock.\n" @@ -1087,29 +1207,29 @@ msgid "" "Restore the thread state from the local variable." msgstr "" -#: ../../c-api/init.rst:888 +#: ../../c-api/init.rst:956 msgid "This is so common that a pair of macros exists to simplify it::" msgstr "" -#: ../../c-api/init.rst:890 +#: ../../c-api/init.rst:958 msgid "" "Py_BEGIN_ALLOW_THREADS\n" "... Do some blocking I/O operation ...\n" "Py_END_ALLOW_THREADS" msgstr "" -#: ../../c-api/init.rst:898 +#: ../../c-api/init.rst:966 msgid "" "The :c:macro:`Py_BEGIN_ALLOW_THREADS` macro opens a new block and declares a " "hidden local variable; the :c:macro:`Py_END_ALLOW_THREADS` macro closes the " "block." msgstr "" -#: ../../c-api/init.rst:902 +#: ../../c-api/init.rst:970 msgid "The block above expands to the following code::" msgstr "" -#: ../../c-api/init.rst:904 +#: ../../c-api/init.rst:972 msgid "" "PyThreadState *_save;\n" "\n" @@ -1118,7 +1238,7 @@ msgid "" "PyEval_RestoreThread(_save);" msgstr "" -#: ../../c-api/init.rst:914 +#: ../../c-api/init.rst:982 msgid "" "Here is how these functions work: the global interpreter lock is used to " "protect the pointer to the current thread state. When releasing the lock " @@ -1129,7 +1249,7 @@ msgid "" "state, the lock must be acquired before storing the thread state pointer." msgstr "" -#: ../../c-api/init.rst:923 +#: ../../c-api/init.rst:991 msgid "" "Calling system I/O functions is the most common use case for releasing the " "GIL, but it can also be useful before calling long-running computations " @@ -1139,11 +1259,11 @@ msgid "" "compressing or hashing data." msgstr "" -#: ../../c-api/init.rst:934 +#: ../../c-api/init.rst:1002 msgid "Non-Python created threads" msgstr "" -#: ../../c-api/init.rst:936 +#: ../../c-api/init.rst:1004 msgid "" "When threads are created using the dedicated Python APIs (such as the :mod:" "`threading` module), a thread state is automatically associated to them and " @@ -1153,7 +1273,7 @@ msgid "" "for them." msgstr "" -#: ../../c-api/init.rst:943 +#: ../../c-api/init.rst:1011 msgid "" "If you need to call Python code from these threads (often this will be part " "of a callback API provided by the aforementioned third-party library), you " @@ -1164,14 +1284,14 @@ msgid "" "finally free the thread state data structure." msgstr "" -#: ../../c-api/init.rst:951 +#: ../../c-api/init.rst:1019 msgid "" "The :c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release` functions " "do all of the above automatically. The typical idiom for calling into " "Python from a C thread is::" msgstr "" -#: ../../c-api/init.rst:955 +#: ../../c-api/init.rst:1023 msgid "" "PyGILState_STATE gstate;\n" "gstate = PyGILState_Ensure();\n" @@ -1184,7 +1304,7 @@ msgid "" "PyGILState_Release(gstate);" msgstr "" -#: ../../c-api/init.rst:965 +#: ../../c-api/init.rst:1033 msgid "" "Note that the ``PyGILState_*`` functions assume there is only one global " "interpreter (created automatically by :c:func:`Py_Initialize`). Python " @@ -1193,11 +1313,11 @@ msgid "" "``PyGILState_*`` API is unsupported." msgstr "" -#: ../../c-api/init.rst:975 +#: ../../c-api/init.rst:1043 msgid "Cautions about fork()" msgstr "" -#: ../../c-api/init.rst:977 +#: ../../c-api/init.rst:1045 msgid "" "Another important thing to note about threads is their behaviour in the face " "of the C :c:func:`fork` call. On most systems with :c:func:`fork`, after a " @@ -1206,7 +1326,7 @@ msgid "" "CPython's runtime." msgstr "" -#: ../../c-api/init.rst:983 +#: ../../c-api/init.rst:1051 msgid "" "The fact that only the \"current\" thread remains means any locks held by " "other threads will never be released. Python solves this for :func:`os.fork` " @@ -1223,7 +1343,7 @@ msgid "" "locks, but is not always able to." msgstr "" -#: ../../c-api/init.rst:998 +#: ../../c-api/init.rst:1066 msgid "" "The fact that all other threads go away also means that CPython's runtime " "state there must be cleaned up properly, which :func:`os.fork` does. This " @@ -1236,17 +1356,17 @@ msgid "" "called immediately after." msgstr "" -#: ../../c-api/init.rst:1011 +#: ../../c-api/init.rst:1079 msgid "High-level API" msgstr "高階 API" -#: ../../c-api/init.rst:1013 +#: ../../c-api/init.rst:1081 msgid "" "These are the most commonly used types and functions when writing C " "extension code, or when embedding the Python interpreter:" msgstr "" -#: ../../c-api/init.rst:1018 +#: ../../c-api/init.rst:1086 msgid "" "This data structure represents the state shared by a number of cooperating " "threads. Threads belonging to the same interpreter share their module " @@ -1254,7 +1374,7 @@ msgid "" "in this structure." msgstr "" -#: ../../c-api/init.rst:1023 +#: ../../c-api/init.rst:1091 msgid "" "Threads belonging to different interpreters initially share nothing, except " "process state like available memory, open file descriptors and such. The " @@ -1262,52 +1382,41 @@ msgid "" "which interpreter they belong." msgstr "" -#: ../../c-api/init.rst:1031 +#: ../../c-api/init.rst:1099 msgid "" "This data structure represents the state of a single thread. The only " "public data member is:" msgstr "" -#: ../../c-api/init.rst:1036 +#: ../../c-api/init.rst:1104 msgid "This thread's interpreter state." msgstr "" -#: ../../c-api/init.rst:1047 +#: ../../c-api/init.rst:1115 msgid "Deprecated function which does nothing." msgstr "" -#: ../../c-api/init.rst:1049 +#: ../../c-api/init.rst:1117 msgid "" "In Python 3.6 and older, this function created the GIL if it didn't exist." msgstr "" -#: ../../c-api/init.rst:1051 +#: ../../c-api/init.rst:1119 msgid "The function now does nothing." msgstr "此函式現在不會做任何事情。" -#: ../../c-api/init.rst:1054 +#: ../../c-api/init.rst:1122 msgid "" "This function is now called by :c:func:`Py_Initialize()`, so you don't have " "to call it yourself anymore." msgstr "" -#: ../../c-api/init.rst:1058 +#: ../../c-api/init.rst:1126 msgid "" "This function cannot be called before :c:func:`Py_Initialize()` anymore." msgstr "" -#: ../../c-api/init.rst:1068 -msgid "" -"Returns a non-zero value if :c:func:`PyEval_InitThreads` has been called. " -"This function can be called without holding the GIL, and therefore can be " -"used to avoid calls to the locking API when running single-threaded." -msgstr "" - -#: ../../c-api/init.rst:1072 -msgid "The :term:`GIL` is now initialized by :c:func:`Py_Initialize()`." -msgstr "" - -#: ../../c-api/init.rst:1080 +#: ../../c-api/init.rst:1136 msgid "" "Release the global interpreter lock (if it has been created) and reset the " "thread state to ``NULL``, returning the previous thread state (which is not " @@ -1315,7 +1424,7 @@ msgid "" "acquired it." msgstr "" -#: ../../c-api/init.rst:1088 +#: ../../c-api/init.rst:1144 msgid "" "Acquire the global interpreter lock (if it has been created) and set the " "thread state to *tstate*, which must not be ``NULL``. If the lock has been " @@ -1323,37 +1432,59 @@ msgid "" "ensues." msgstr "" -#: ../../c-api/init.rst:1094 ../../c-api/init.rst:1140 -#: ../../c-api/init.rst:1422 +#: ../../c-api/init.rst:1150 ../../c-api/init.rst:1210 +#: ../../c-api/init.rst:1506 msgid "" "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 :c:func:`!_Py_IsFinalizing` or :func:`sys.is_finalizing` to check if the " +"use :c:func:`Py_IsFinalizing` or :func:`sys.is_finalizing` to check if the " "interpreter is in process of being finalized before calling this function to " "avoid unwanted termination." msgstr "" -#: ../../c-api/init.rst:1102 +#: ../../c-api/init.rst:1158 msgid "" "Return the current thread state. The global interpreter lock must be held. " "When the current thread state is ``NULL``, this issues a fatal error (so " "that the caller needn't check for ``NULL``)." msgstr "" -#: ../../c-api/init.rst:1109 +#: ../../c-api/init.rst:1162 +msgid "See also :c:func:`PyThreadState_GetUnchecked`." +msgstr "也請見 :c:func:`PyThreadState_GetUnchecked`。" + +#: ../../c-api/init.rst:1167 +msgid "" +"Similar to :c:func:`PyThreadState_Get`, but don't kill the process with a " +"fatal error if it is NULL. The caller is responsible to check if the result " +"is NULL." +msgstr "" + +#: ../../c-api/init.rst:1171 +msgid "" +"In Python 3.5 to 3.12, the function was private and known as " +"``_PyThreadState_UncheckedGet()``." +msgstr "" + +#: ../../c-api/init.rst:1178 msgid "" "Swap the current thread state with the thread state given by the argument " -"*tstate*, which may be ``NULL``. The global interpreter lock must be held " -"and is not released." +"*tstate*, which may be ``NULL``." +msgstr "" + +#: ../../c-api/init.rst:1181 +msgid "" +"The :term:`GIL` does not need to be held, but will be held upon returning if " +"*tstate* is non-``NULL``." msgstr "" -#: ../../c-api/init.rst:1114 +#: ../../c-api/init.rst:1184 msgid "" "The following functions use thread-local storage, and are not compatible " "with sub-interpreters:" msgstr "" -#: ../../c-api/init.rst:1119 +#: ../../c-api/init.rst:1189 msgid "" "Ensure that the current thread is ready to call the Python C API regardless " "of the current state of Python, or of the global interpreter lock. This may " @@ -1366,7 +1497,7 @@ msgid "" "is acceptable." msgstr "" -#: ../../c-api/init.rst:1129 +#: ../../c-api/init.rst:1199 msgid "" "The return value is an opaque \"handle\" to the thread state when :c:func:" "`PyGILState_Ensure` was called, and must be passed to :c:func:" @@ -1376,13 +1507,13 @@ msgid "" "func:`PyGILState_Release`." msgstr "" -#: ../../c-api/init.rst:1136 +#: ../../c-api/init.rst:1206 msgid "" "When the function returns, the current thread will hold the GIL and be able " "to call arbitrary Python code. Failure is a fatal error." msgstr "" -#: ../../c-api/init.rst:1148 +#: ../../c-api/init.rst:1218 msgid "" "Release any resources previously acquired. After this call, Python's state " "will be the same as it was prior to the corresponding :c:func:" @@ -1390,13 +1521,13 @@ msgid "" "caller, hence the use of the GILState API)." msgstr "" -#: ../../c-api/init.rst:1153 +#: ../../c-api/init.rst:1223 msgid "" "Every call to :c:func:`PyGILState_Ensure` must be matched by a call to :c:" "func:`PyGILState_Release` on the same thread." msgstr "" -#: ../../c-api/init.rst:1159 +#: ../../c-api/init.rst:1229 msgid "" "Get the current thread state for this thread. May return ``NULL`` if no " "GILState API has been used on the current thread. Note that the main thread " @@ -1404,7 +1535,7 @@ msgid "" "made on the main thread. This is mainly a helper/diagnostic function." msgstr "" -#: ../../c-api/init.rst:1167 +#: ../../c-api/init.rst:1237 msgid "" "Return ``1`` if the current thread is holding the GIL and ``0`` otherwise. " "This function can be called from any thread at any time. Only if it has had " @@ -1415,13 +1546,13 @@ msgid "" "otherwise behave differently." msgstr "" -#: ../../c-api/init.rst:1179 +#: ../../c-api/init.rst:1249 msgid "" "The following macros are normally used without a trailing semicolon; look " "for example usage in the Python source distribution." msgstr "" -#: ../../c-api/init.rst:1185 +#: ../../c-api/init.rst:1255 msgid "" "This macro expands to ``{ PyThreadState *_save; _save = PyEval_SaveThread();" "``. Note that it contains an opening brace; it must be matched with a " @@ -1429,7 +1560,7 @@ msgid "" "discussion of this macro." msgstr "" -#: ../../c-api/init.rst:1193 +#: ../../c-api/init.rst:1263 msgid "" "This macro expands to ``PyEval_RestoreThread(_save); }``. Note that it " "contains a closing brace; it must be matched with an earlier :c:macro:" @@ -1437,40 +1568,40 @@ msgid "" "macro." msgstr "" -#: ../../c-api/init.rst:1201 +#: ../../c-api/init.rst:1271 msgid "" "This macro expands to ``PyEval_RestoreThread(_save);``: it is equivalent to :" "c:macro:`Py_END_ALLOW_THREADS` without the closing brace." msgstr "" -#: ../../c-api/init.rst:1207 +#: ../../c-api/init.rst:1277 msgid "" "This macro expands to ``_save = PyEval_SaveThread();``: it is equivalent to :" "c:macro:`Py_BEGIN_ALLOW_THREADS` without the opening brace and variable " "declaration." msgstr "" -#: ../../c-api/init.rst:1213 +#: ../../c-api/init.rst:1283 msgid "Low-level API" msgstr "低階 API" -#: ../../c-api/init.rst:1215 +#: ../../c-api/init.rst:1285 msgid "" "All of the following functions must be called after :c:func:`Py_Initialize`." msgstr "" -#: ../../c-api/init.rst:1217 +#: ../../c-api/init.rst:1287 msgid ":c:func:`Py_Initialize()` now initializes the :term:`GIL`." msgstr "" -#: ../../c-api/init.rst:1223 +#: ../../c-api/init.rst:1293 msgid "" "Create a new interpreter state object. The global interpreter lock need not " "be held, but may be held if it is necessary to serialize calls to this " "function." msgstr "" -#: ../../c-api/init.rst:1227 +#: ../../c-api/init.rst:1297 msgid "" "Raises an :ref:`auditing event ` ``cpython." "PyInterpreterState_New`` with no arguments." @@ -1478,13 +1609,13 @@ msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``cpython." "PyInterpreterState_New``。" -#: ../../c-api/init.rst:1232 +#: ../../c-api/init.rst:1302 msgid "" "Reset all information in an interpreter state object. The global " "interpreter lock must be held." msgstr "" -#: ../../c-api/init.rst:1235 +#: ../../c-api/init.rst:1305 msgid "" "Raises an :ref:`auditing event ` ``cpython." "PyInterpreterState_Clear`` with no arguments." @@ -1492,160 +1623,171 @@ msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``cpython." "PyInterpreterState_Clear``。" -#: ../../c-api/init.rst:1240 +#: ../../c-api/init.rst:1310 msgid "" "Destroy an interpreter state object. The global interpreter lock need not " "be held. The interpreter state must have been reset with a previous call " "to :c:func:`PyInterpreterState_Clear`." msgstr "" -#: ../../c-api/init.rst:1247 +#: ../../c-api/init.rst:1317 msgid "" "Create a new thread state object belonging to the given interpreter object. " "The global interpreter lock need not be held, but may be held if it is " "necessary to serialize calls to this function." msgstr "" -#: ../../c-api/init.rst:1254 +#: ../../c-api/init.rst:1324 msgid "" "Reset all information in a thread state object. The global interpreter lock " "must be held." msgstr "" -#: ../../c-api/init.rst:1257 +#: ../../c-api/init.rst:1327 msgid "" "This function now calls the :c:member:`PyThreadState.on_delete` callback. " "Previously, that happened in :c:func:`PyThreadState_Delete`." msgstr "" -#: ../../c-api/init.rst:1264 +#: ../../c-api/init.rst:1331 +msgid "The :c:member:`PyThreadState.on_delete` callback was removed." +msgstr ":c:member:`PyThreadState.on_delete` 回呼已被移除。" + +#: ../../c-api/init.rst:1337 msgid "" "Destroy a thread state object. The global interpreter lock need not be " "held. The thread state must have been reset with a previous call to :c:func:" "`PyThreadState_Clear`." msgstr "" -#: ../../c-api/init.rst:1271 +#: ../../c-api/init.rst:1344 msgid "" "Destroy the current thread state and release the global interpreter lock. " -"Like :c:func:`PyThreadState_Delete`, the global interpreter lock need not be " +"Like :c:func:`PyThreadState_Delete`, the global interpreter lock must be " "held. The thread state must have been reset with a previous call to :c:func:" "`PyThreadState_Clear`." msgstr "" -#: ../../c-api/init.rst:1279 +#: ../../c-api/init.rst:1352 msgid "Get the current frame of the Python thread state *tstate*." msgstr "" -#: ../../c-api/init.rst:1281 +#: ../../c-api/init.rst:1354 msgid "" "Return a :term:`strong reference`. Return ``NULL`` if no frame is currently " "executing." msgstr "" -#: ../../c-api/init.rst:1284 +#: ../../c-api/init.rst:1357 msgid "See also :c:func:`PyEval_GetFrame`." msgstr "也請見 :c:func:`PyEval_GetFrame`。" -#: ../../c-api/init.rst:1286 ../../c-api/init.rst:1295 -#: ../../c-api/init.rst:1304 +#: ../../c-api/init.rst:1359 ../../c-api/init.rst:1368 +#: ../../c-api/init.rst:1377 msgid "*tstate* must not be ``NULL``." msgstr "*tstate* 不可為 ``NULL``。" -#: ../../c-api/init.rst:1293 +#: ../../c-api/init.rst:1366 msgid "" "Get the unique thread state identifier of the Python thread state *tstate*." msgstr "" -#: ../../c-api/init.rst:1302 +#: ../../c-api/init.rst:1375 msgid "Get the interpreter of the Python thread state *tstate*." msgstr "" -#: ../../c-api/init.rst:1311 +#: ../../c-api/init.rst:1384 msgid "Suspend tracing and profiling in the Python thread state *tstate*." msgstr "" -#: ../../c-api/init.rst:1313 +#: ../../c-api/init.rst:1386 msgid "Resume them using the :c:func:`PyThreadState_LeaveTracing` function." msgstr "" -#: ../../c-api/init.rst:1320 +#: ../../c-api/init.rst:1393 msgid "" "Resume tracing and profiling in the Python thread state *tstate* suspended " "by the :c:func:`PyThreadState_EnterTracing` function." msgstr "" -#: ../../c-api/init.rst:1323 +#: ../../c-api/init.rst:1396 msgid "" "See also :c:func:`PyEval_SetTrace` and :c:func:`PyEval_SetProfile` functions." msgstr "" -#: ../../c-api/init.rst:1331 +#: ../../c-api/init.rst:1404 msgid "Get the current interpreter." msgstr "" -#: ../../c-api/init.rst:1333 +#: ../../c-api/init.rst:1406 msgid "" "Issue a fatal error if there no current Python thread state or no current " "interpreter. It cannot return NULL." msgstr "" -#: ../../c-api/init.rst:1336 ../../c-api/init.rst:1346 +#: ../../c-api/init.rst:1409 ../../c-api/init.rst:1419 +#: ../../c-api/init.rst:1441 msgid "The caller must hold the GIL." msgstr "" -#: ../../c-api/init.rst:1343 +#: ../../c-api/init.rst:1416 msgid "" "Return the interpreter's unique ID. If there was any error in doing so then " "``-1`` is returned and an error is set." msgstr "" -#: ../../c-api/init.rst:1353 +#: ../../c-api/init.rst:1426 msgid "" "Return a dictionary in which interpreter-specific data may be stored. If " "this function returns ``NULL`` then no exception has been raised and the " "caller should assume no interpreter-specific dict is available." msgstr "" -#: ../../c-api/init.rst:1357 +#: ../../c-api/init.rst:1430 msgid "" "This is not a replacement for :c:func:`PyModule_GetState()`, which " "extensions should use to store interpreter-specific state information." msgstr "" -#: ../../c-api/init.rst:1364 +#: ../../c-api/init.rst:1438 +msgid "" +"Return a :term:`strong reference` to the ``__main__`` :ref:`module object " +"` for the given interpreter." +msgstr "" + +#: ../../c-api/init.rst:1448 msgid "Type of a frame evaluation function." msgstr "" -#: ../../c-api/init.rst:1366 +#: ../../c-api/init.rst:1450 msgid "" "The *throwflag* parameter is used by the ``throw()`` method of generators: " "if non-zero, handle the current exception." msgstr "" -#: ../../c-api/init.rst:1369 +#: ../../c-api/init.rst:1453 msgid "The function now takes a *tstate* parameter." msgstr "" -#: ../../c-api/init.rst:1372 +#: ../../c-api/init.rst:1456 msgid "" "The *frame* parameter changed from ``PyFrameObject*`` to " "``_PyInterpreterFrame*``." msgstr "" -#: ../../c-api/init.rst:1377 +#: ../../c-api/init.rst:1461 msgid "Get the frame evaluation function." msgstr "" -#: ../../c-api/init.rst:1379 ../../c-api/init.rst:1387 +#: ../../c-api/init.rst:1463 ../../c-api/init.rst:1471 msgid "See the :pep:`523` \"Adding a frame evaluation API to CPython\"." msgstr "" -#: ../../c-api/init.rst:1385 +#: ../../c-api/init.rst:1469 msgid "Set the frame evaluation function." msgstr "" -#: ../../c-api/init.rst:1394 +#: ../../c-api/init.rst:1478 msgid "" "Return a dictionary in which extensions can store thread-specific state " "information. Each extension should use a unique key to use to store state " @@ -1654,7 +1796,7 @@ msgid "" "raised and the caller should assume no current thread state is available." msgstr "" -#: ../../c-api/init.rst:1403 +#: ../../c-api/init.rst:1487 msgid "" "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. " @@ -1666,33 +1808,33 @@ msgid "" "raises no exceptions." msgstr "" -#: ../../c-api/init.rst:1411 +#: ../../c-api/init.rst:1495 msgid "" "The type of the *id* parameter changed from :c:expr:`long` to :c:expr:" "`unsigned long`." msgstr "" -#: ../../c-api/init.rst:1417 +#: ../../c-api/init.rst:1501 msgid "" "Acquire the global interpreter lock and set the current thread state to " "*tstate*, which must not be ``NULL``. The lock must have been created " "earlier. If this thread already has the lock, deadlock ensues." msgstr "" -#: ../../c-api/init.rst:1428 ../../c-api/init.rst:1466 +#: ../../c-api/init.rst:1512 msgid "" "Updated to be consistent with :c:func:`PyEval_RestoreThread`, :c:func:" "`Py_END_ALLOW_THREADS`, and :c:func:`PyGILState_Ensure`, and terminate the " "current thread if called while the interpreter is finalizing." msgstr "" -#: ../../c-api/init.rst:1433 +#: ../../c-api/init.rst:1517 msgid "" ":c:func:`PyEval_RestoreThread` is a higher-level function which is always " "available (even when threads have not been initialized)." msgstr "" -#: ../../c-api/init.rst:1439 +#: ../../c-api/init.rst:1523 msgid "" "Reset the current thread state to ``NULL`` and release the global " "interpreter lock. The lock must have been created earlier and must be held " @@ -1701,50 +1843,17 @@ msgid "" "isn't, a fatal error is reported." msgstr "" -#: ../../c-api/init.rst:1445 +#: ../../c-api/init.rst:1529 msgid "" ":c:func:`PyEval_SaveThread` is a higher-level function which is always " "available (even when threads have not been initialized)." msgstr "" -#: ../../c-api/init.rst:1451 -msgid "" -"Acquire the global interpreter lock. The lock must have been created " -"earlier. If this thread already has the lock, a deadlock ensues." -msgstr "" - -#: ../../c-api/init.rst:1454 -msgid "" -"This function does not update the current thread state. Please use :c:func:" -"`PyEval_RestoreThread` or :c:func:`PyEval_AcquireThread` instead." -msgstr "" - -#: ../../c-api/init.rst:1460 -msgid "" -"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 :c:func:`_Py_IsFinalizing` or :func:`sys.is_finalizing` to check if the " -"interpreter is in process of being finalized before calling this function to " -"avoid unwanted termination." -msgstr "" - -#: ../../c-api/init.rst:1474 -msgid "" -"Release the global interpreter lock. The lock must have been created " -"earlier." -msgstr "" - -#: ../../c-api/init.rst:1476 -msgid "" -"This function does not update the current thread state. Please use :c:func:" -"`PyEval_SaveThread` or :c:func:`PyEval_ReleaseThread` instead." -msgstr "" - -#: ../../c-api/init.rst:1485 +#: ../../c-api/init.rst:1536 msgid "Sub-interpreter support" msgstr "" -#: ../../c-api/init.rst:1487 +#: ../../c-api/init.rst:1538 msgid "" "While in most uses, you will only embed a single Python interpreter, there " "are cases where you need to create several independent interpreters in the " @@ -1752,7 +1861,7 @@ msgid "" "to do that." msgstr "" -#: ../../c-api/init.rst:1492 +#: ../../c-api/init.rst:1543 msgid "" "The \"main\" interpreter is the first one created when the runtime " "initializes. It is usually the only Python interpreter in a process. Unlike " @@ -1763,31 +1872,31 @@ msgid "" "returns a pointer to its state." msgstr "" -#: ../../c-api/init.rst:1499 +#: ../../c-api/init.rst:1550 msgid "" "You can switch between sub-interpreters using the :c:func:" "`PyThreadState_Swap` function. You can create and destroy them using the " "following functions:" msgstr "" -#: ../../c-api/init.rst:1505 +#: ../../c-api/init.rst:1556 msgid "" "Structure containing most parameters to configure a sub-interpreter. Its " "values are used only in :c:func:`Py_NewInterpreterFromConfig` and never " "modified by the runtime." msgstr "" -#: ../../c-api/init.rst:1511 +#: ../../c-api/init.rst:1562 msgid "Structure fields:" msgstr "" -#: ../../c-api/init.rst:1515 +#: ../../c-api/init.rst:1566 msgid "" "If this is ``0`` then the sub-interpreter will use its own \"object\" " "allocator state. Otherwise it will use (share) the main interpreter's." msgstr "" -#: ../../c-api/init.rst:1519 +#: ../../c-api/init.rst:1570 msgid "" "If this is ``0`` then :c:member:`~PyInterpreterConfig." "check_multi_interp_extensions` must be ``1`` (non-zero). If this is ``1`` " @@ -1795,44 +1904,44 @@ msgid "" "`PyInterpreterConfig_OWN_GIL`." msgstr "" -#: ../../c-api/init.rst:1527 +#: ../../c-api/init.rst:1578 msgid "" "If this is ``0`` then the runtime will not support forking the process in " "any thread where the sub-interpreter is currently active. Otherwise fork is " "unrestricted." msgstr "" -#: ../../c-api/init.rst:1531 +#: ../../c-api/init.rst:1582 msgid "" "Note that the :mod:`subprocess` module still works when fork is disallowed." msgstr "" -#: ../../c-api/init.rst:1536 +#: ../../c-api/init.rst:1587 msgid "" "If this is ``0`` then the runtime will not support replacing the current " "process via exec (e.g. :func:`os.execv`) in any thread where the sub-" "interpreter is currently active. Otherwise exec is unrestricted." msgstr "" -#: ../../c-api/init.rst:1541 +#: ../../c-api/init.rst:1592 msgid "" "Note that the :mod:`subprocess` module still works when exec is disallowed." msgstr "" -#: ../../c-api/init.rst:1546 +#: ../../c-api/init.rst:1597 msgid "" "If this is ``0`` then the sub-interpreter's :mod:`threading` module won't " "create threads. Otherwise threads are allowed." msgstr "" -#: ../../c-api/init.rst:1552 +#: ../../c-api/init.rst:1603 msgid "" "If this is ``0`` then the sub-interpreter's :mod:`threading` module won't " "create daemon threads. Otherwise daemon threads are allowed (as long as :c:" "member:`~PyInterpreterConfig.allow_threads` is non-zero)." msgstr "" -#: ../../c-api/init.rst:1559 +#: ../../c-api/init.rst:1610 msgid "" "If this is ``0`` then all extension modules may be imported, including " "legacy (single-phase init) modules, in any thread where the sub-interpreter " @@ -1841,37 +1950,37 @@ msgid "" "`Py_mod_multiple_interpreters`.)" msgstr "" -#: ../../c-api/init.rst:1566 +#: ../../c-api/init.rst:1617 msgid "" "This must be ``1`` (non-zero) if :c:member:`~PyInterpreterConfig." "use_main_obmalloc` is ``0``." msgstr "" -#: ../../c-api/init.rst:1571 +#: ../../c-api/init.rst:1622 msgid "" "This determines the operation of the GIL for the sub-interpreter. It may be " "one of the following:" msgstr "" -#: ../../c-api/init.rst:1578 +#: ../../c-api/init.rst:1629 msgid "Use the default selection (:c:macro:`PyInterpreterConfig_SHARED_GIL`)." msgstr "" -#: ../../c-api/init.rst:1582 +#: ../../c-api/init.rst:1633 msgid "Use (share) the main interpreter's GIL." msgstr "" -#: ../../c-api/init.rst:1586 +#: ../../c-api/init.rst:1637 msgid "Use the sub-interpreter's own GIL." msgstr "" -#: ../../c-api/init.rst:1588 +#: ../../c-api/init.rst:1639 msgid "" "If this is :c:macro:`PyInterpreterConfig_OWN_GIL` then :c:member:" "`PyInterpreterConfig.use_main_obmalloc` must be ``0``." msgstr "" -#: ../../c-api/init.rst:1602 +#: ../../c-api/init.rst:1653 msgid "" "Create a new sub-interpreter. This is an (almost) totally separate " "environment for the execution of Python code. In particular, the new " @@ -1884,13 +1993,13 @@ msgid "" "underlying file descriptors)." msgstr "" -#: ../../c-api/init.rst:1612 +#: ../../c-api/init.rst:1663 msgid "" "The given *config* controls the options with which the interpreter is " "initialized." msgstr "" -#: ../../c-api/init.rst:1615 +#: ../../c-api/init.rst:1666 msgid "" "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 " @@ -1901,7 +2010,7 @@ msgid "" "state." msgstr "" -#: ../../c-api/init.rst:1624 +#: ../../c-api/init.rst:1675 msgid "" "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. " @@ -1913,13 +2022,13 @@ msgid "" "released here." msgstr "" -#: ../../c-api/init.rst:1635 +#: ../../c-api/init.rst:1686 msgid "" "Sub-interpreters are most effective when isolated from each other, with " "certain functionality restricted::" msgstr "" -#: ../../c-api/init.rst:1638 +#: ../../c-api/init.rst:1689 msgid "" "PyInterpreterConfig config = {\n" " .use_main_obmalloc = 0,\n" @@ -1930,7 +2039,11 @@ msgid "" " .check_multi_interp_extensions = 1,\n" " .gil = PyInterpreterConfig_OWN_GIL,\n" "};\n" -"PyThreadState *tstate = Py_NewInterpreterFromConfig(&config);" +"PyThreadState *tstate = NULL;\n" +"PyStatus status = Py_NewInterpreterFromConfig(&tstate, &config);\n" +"if (PyStatus_Exception(status)) {\n" +" Py_ExitStatusException(status);\n" +"}" msgstr "" "PyInterpreterConfig config = {\n" " .use_main_obmalloc = 0,\n" @@ -1941,9 +2054,13 @@ msgstr "" " .check_multi_interp_extensions = 1,\n" " .gil = PyInterpreterConfig_OWN_GIL,\n" "};\n" -"PyThreadState *tstate = Py_NewInterpreterFromConfig(&config);" +"PyThreadState *tstate = NULL;\n" +"PyStatus status = Py_NewInterpreterFromConfig(&tstate, &config);\n" +"if (PyStatus_Exception(status)) {\n" +" Py_ExitStatusException(status);\n" +"}" -#: ../../c-api/init.rst:1649 +#: ../../c-api/init.rst:1704 msgid "" "Note that the config is used only briefly and does not get modified. During " "initialization the config's values are converted into various :c:type:" @@ -1951,11 +2068,11 @@ msgid "" "internally on the :c:type:`PyInterpreterState`." msgstr "" -#: ../../c-api/init.rst:1658 +#: ../../c-api/init.rst:1713 msgid "Extension modules are shared between (sub-)interpreters as follows:" msgstr "" -#: ../../c-api/init.rst:1660 +#: ../../c-api/init.rst:1715 msgid "" "For modules using multi-phase initialization, e.g. :c:func:" "`PyModule_FromDefAndSpec`, a separate module object is created and " @@ -1963,7 +2080,7 @@ msgid "" "are shared between these module objects." msgstr "" -#: ../../c-api/init.rst:1666 +#: ../../c-api/init.rst:1721 msgid "" "For modules using single-phase initialization, e.g. :c:func:" "`PyModule_Create`, the first time a particular extension is imported, it is " @@ -1975,7 +2092,7 @@ msgid "" "might cause unwanted behavior (see `Bugs and caveats`_ below)." msgstr "" -#: ../../c-api/init.rst:1677 +#: ../../c-api/init.rst:1732 msgid "" "Note that this is different from what happens when an extension is imported " "after the interpreter has been completely re-initialized by calling :c:func:" @@ -1985,7 +2102,7 @@ msgid "" "shared between these modules." msgstr "" -#: ../../c-api/init.rst:1697 +#: ../../c-api/init.rst:1752 msgid "" "Create a new sub-interpreter. This is essentially just a wrapper around :c:" "func:`Py_NewInterpreterFromConfig` with a config that preserves the existing " @@ -1994,7 +2111,7 @@ msgid "" "single-phase init modules." msgstr "" -#: ../../c-api/init.rst:1709 +#: ../../c-api/init.rst:1764 msgid "" "Destroy the (sub-)interpreter represented by the given thread state. The " "given thread state must be the current thread state. See the discussion of " @@ -2004,17 +2121,17 @@ msgid "" "be held before calling this function. No GIL is held when it returns." msgstr "" -#: ../../c-api/init.rst:1717 +#: ../../c-api/init.rst:1772 msgid "" ":c:func:`Py_FinalizeEx` will destroy all sub-interpreters that haven't been " "explicitly destroyed at that point." msgstr "" -#: ../../c-api/init.rst:1722 +#: ../../c-api/init.rst:1777 msgid "A Per-Interpreter GIL" -msgstr "" +msgstr "直譯器各別持有的 GIL" -#: ../../c-api/init.rst:1724 +#: ../../c-api/init.rst:1779 msgid "" "Using :c:func:`Py_NewInterpreterFromConfig` you can create a sub-interpreter " "that is completely isolated from other interpreters, including having its " @@ -2026,7 +2143,7 @@ msgid "" "just using threads. (See :pep:`554`.)" msgstr "" -#: ../../c-api/init.rst:1734 +#: ../../c-api/init.rst:1789 msgid "" "Using an isolated interpreter requires vigilance in preserving that " "isolation. That especially means not sharing any objects or mutable state " @@ -2035,12 +2152,12 @@ msgid "" "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 \"immortal\". In fact, this has been " -"done for the builtin singletons, small integers, and a number of other " +"spite of their refcounts by making them :term:`immortal`. In fact, this has " +"been done for the builtin singletons, small integers, and a number of other " "builtin objects." msgstr "" -#: ../../c-api/init.rst:1745 +#: ../../c-api/init.rst:1800 msgid "" "If you preserve isolation then you will have access to proper multi-core " "computing without the complications that come with free-threading. Failure " @@ -2048,7 +2165,7 @@ msgid "" "threading, including races and hard-to-debug crashes." msgstr "" -#: ../../c-api/init.rst:1750 +#: ../../c-api/init.rst:1805 msgid "" "Aside from that, one of the main challenges of using multiple isolated " "interpreters is how to communicate between them safely (not break isolation) " @@ -2058,11 +2175,11 @@ msgid "" "sharing) data between interpreters." msgstr "" -#: ../../c-api/init.rst:1761 +#: ../../c-api/init.rst:1816 msgid "Bugs and caveats" msgstr "" -#: ../../c-api/init.rst:1763 +#: ../../c-api/init.rst:1818 msgid "" "Because sub-interpreters (and the main interpreter) are part of the same " "process, the insulation between them isn't perfect --- for example, using " @@ -2075,7 +2192,7 @@ msgid "" "should be avoided if possible." msgstr "" -#: ../../c-api/init.rst:1773 +#: ../../c-api/init.rst:1828 msgid "" "Special care should be taken to avoid sharing user-defined functions, " "methods, instances or classes between sub-interpreters, since import " @@ -2084,7 +2201,7 @@ msgid "" "objects from which the above are reachable." msgstr "" -#: ../../c-api/init.rst:1779 +#: ../../c-api/init.rst:1834 msgid "" "Also note that combining this functionality with ``PyGILState_*`` APIs is " "delicate, because these APIs assume a bijection between Python thread states " @@ -2096,25 +2213,25 @@ msgid "" "created threads will probably be broken when using sub-interpreters." msgstr "" -#: ../../c-api/init.rst:1790 +#: ../../c-api/init.rst:1845 msgid "Asynchronous Notifications" msgstr "" -#: ../../c-api/init.rst:1792 +#: ../../c-api/init.rst:1847 msgid "" "A mechanism is provided to make asynchronous notifications to the main " "interpreter thread. These notifications take the form of a function pointer " "and a void pointer argument." msgstr "" -#: ../../c-api/init.rst:1799 +#: ../../c-api/init.rst:1854 msgid "" "Schedule a function to be called from the main interpreter thread. On " "success, ``0`` is returned and *func* is queued for being called in the main " "thread. On failure, ``-1`` is returned without setting any exception." msgstr "" -#: ../../c-api/init.rst:1803 +#: ../../c-api/init.rst:1858 msgid "" "When successfully queued, *func* will be *eventually* called from the main " "interpreter thread with the argument *arg*. It will be called " @@ -2122,17 +2239,17 @@ msgid "" "these conditions met:" msgstr "" -#: ../../c-api/init.rst:1808 +#: ../../c-api/init.rst:1863 msgid "on a :term:`bytecode` boundary;" msgstr "" -#: ../../c-api/init.rst:1809 +#: ../../c-api/init.rst:1864 msgid "" "with the main thread holding the :term:`global interpreter lock` (*func* can " "therefore use the full C API)." msgstr "" -#: ../../c-api/init.rst:1812 +#: ../../c-api/init.rst:1867 msgid "" "*func* must return ``0`` on success, or ``-1`` on failure with an exception " "set. *func* won't be interrupted to perform another asynchronous " @@ -2140,20 +2257,20 @@ msgid "" "if the global interpreter lock is released." msgstr "" -#: ../../c-api/init.rst:1817 +#: ../../c-api/init.rst:1872 msgid "" "This function doesn't need a current thread state to run, and it doesn't " "need the global interpreter lock." msgstr "" -#: ../../c-api/init.rst:1820 +#: ../../c-api/init.rst:1875 msgid "" "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." msgstr "" -#: ../../c-api/init.rst:1825 +#: ../../c-api/init.rst:1880 msgid "" "This is a low-level function, only useful for very special cases. There is " "no guarantee that *func* will be called as quick as possible. If the main " @@ -2163,7 +2280,7 @@ msgid "" "`PyGILState API`." msgstr "" -#: ../../c-api/init.rst:1834 +#: ../../c-api/init.rst:1889 msgid "" "If this function is called in a subinterpreter, the function *func* is now " "scheduled to be called from the subinterpreter, rather than being called " @@ -2171,18 +2288,18 @@ msgid "" "scheduled calls." msgstr "" -#: ../../c-api/init.rst:1843 +#: ../../c-api/init.rst:1898 msgid "Profiling and Tracing" msgstr "" -#: ../../c-api/init.rst:1848 +#: ../../c-api/init.rst:1903 msgid "" "The Python interpreter provides some low-level support for attaching " "profiling and execution tracing facilities. These are used for profiling, " "debugging, and coverage analysis tools." msgstr "" -#: ../../c-api/init.rst:1852 +#: ../../c-api/init.rst:1907 msgid "" "This C interface allows the profiling or tracing code to avoid the overhead " "of calling through Python-level callable objects, making a direct C function " @@ -2192,7 +2309,7 @@ msgid "" "reported to the Python-level trace functions in previous versions." msgstr "" -#: ../../c-api/init.rst:1862 +#: ../../c-api/init.rst:1917 msgid "" "The type of the trace function registered using :c:func:`PyEval_SetProfile` " "and :c:func:`PyEval_SetTrace`. The first parameter is the object passed to " @@ -2204,66 +2321,66 @@ msgid "" "value of *what*:" msgstr "" -#: ../../c-api/init.rst:1871 +#: ../../c-api/init.rst:1926 msgid "Value of *what*" msgstr "" -#: ../../c-api/init.rst:1871 +#: ../../c-api/init.rst:1926 msgid "Meaning of *arg*" msgstr "*arg* 的含義" -#: ../../c-api/init.rst:1873 +#: ../../c-api/init.rst:1928 msgid ":c:data:`PyTrace_CALL`" msgstr ":c:data:`PyTrace_CALL`" -#: ../../c-api/init.rst:1873 ../../c-api/init.rst:1878 -#: ../../c-api/init.rst:1889 +#: ../../c-api/init.rst:1928 ../../c-api/init.rst:1933 +#: ../../c-api/init.rst:1944 msgid "Always :c:data:`Py_None`." msgstr "" -#: ../../c-api/init.rst:1875 +#: ../../c-api/init.rst:1930 msgid ":c:data:`PyTrace_EXCEPTION`" msgstr ":c:data:`PyTrace_EXCEPTION`" -#: ../../c-api/init.rst:1875 +#: ../../c-api/init.rst:1930 msgid "Exception information as returned by :func:`sys.exc_info`." msgstr "" -#: ../../c-api/init.rst:1878 +#: ../../c-api/init.rst:1933 msgid ":c:data:`PyTrace_LINE`" msgstr ":c:data:`PyTrace_LINE`" -#: ../../c-api/init.rst:1880 +#: ../../c-api/init.rst:1935 msgid ":c:data:`PyTrace_RETURN`" msgstr ":c:data:`PyTrace_RETURN`" -#: ../../c-api/init.rst:1880 +#: ../../c-api/init.rst:1935 msgid "" "Value being returned to the caller, or ``NULL`` if caused by an exception." msgstr "" -#: ../../c-api/init.rst:1883 +#: ../../c-api/init.rst:1938 msgid ":c:data:`PyTrace_C_CALL`" msgstr ":c:data:`PyTrace_C_CALL`" -#: ../../c-api/init.rst:1883 ../../c-api/init.rst:1885 -#: ../../c-api/init.rst:1887 +#: ../../c-api/init.rst:1938 ../../c-api/init.rst:1940 +#: ../../c-api/init.rst:1942 msgid "Function object being called." msgstr "被呼叫的函式物件。" -#: ../../c-api/init.rst:1885 +#: ../../c-api/init.rst:1940 msgid ":c:data:`PyTrace_C_EXCEPTION`" msgstr ":c:data:`PyTrace_C_EXCEPTION`" -#: ../../c-api/init.rst:1887 +#: ../../c-api/init.rst:1942 msgid ":c:data:`PyTrace_C_RETURN`" msgstr ":c:data:`PyTrace_C_RETURN`" -#: ../../c-api/init.rst:1889 +#: ../../c-api/init.rst:1944 msgid ":c:data:`PyTrace_OPCODE`" msgstr ":c:data:`PyTrace_OPCODE`" -#: ../../c-api/init.rst:1894 +#: ../../c-api/init.rst:1949 msgid "" "The value of the *what* parameter to a :c:type:`Py_tracefunc` function when " "a new call to a function or method is being reported, or a new entry into a " @@ -2272,7 +2389,7 @@ msgid "" "the corresponding frame." msgstr "" -#: ../../c-api/init.rst:1903 +#: ../../c-api/init.rst:1958 msgid "" "The value of the *what* parameter to a :c:type:`Py_tracefunc` function when " "an exception has been raised. The callback function is called with this " @@ -2284,7 +2401,7 @@ msgid "" "profiler." msgstr "" -#: ../../c-api/init.rst:1914 +#: ../../c-api/init.rst:1969 msgid "" "The value passed as the *what* parameter to a :c:type:`Py_tracefunc` " "function (but not a profiling function) when a line-number event is being " @@ -2292,31 +2409,31 @@ msgid "" "f_trace_lines` to *0* on that frame." msgstr "" -#: ../../c-api/init.rst:1922 +#: ../../c-api/init.rst:1977 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions when " "a call is about to return." msgstr "" -#: ../../c-api/init.rst:1928 +#: ../../c-api/init.rst:1983 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions when " "a C function is about to be called." msgstr "" -#: ../../c-api/init.rst:1934 +#: ../../c-api/init.rst:1989 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions when " "a C function has raised an exception." msgstr "" -#: ../../c-api/init.rst:1940 +#: ../../c-api/init.rst:1995 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions when " "a C function has returned." msgstr "" -#: ../../c-api/init.rst:1946 +#: ../../c-api/init.rst:2001 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions (but " "not profiling functions) when a new opcode is about to be executed. This " @@ -2324,7 +2441,7 @@ msgid "" "attr:`~frame.f_trace_opcodes` to *1* on the frame." msgstr "" -#: ../../c-api/init.rst:1954 +#: ../../c-api/init.rst:2009 msgid "" "Set the profiler function to *func*. The *obj* parameter is passed to the " "function as its first parameter, and may be any Python object, or ``NULL``. " @@ -2334,29 +2451,29 @@ msgid "" "`PyTrace_LINE` :c:data:`PyTrace_OPCODE` and :c:data:`PyTrace_EXCEPTION`." msgstr "" -#: ../../c-api/init.rst:1961 +#: ../../c-api/init.rst:2016 msgid "See also the :func:`sys.setprofile` function." -msgstr "" +msgstr "另請參閱 :func:`sys.setprofile` 函式。" -#: ../../c-api/init.rst:1963 ../../c-api/init.rst:1970 -#: ../../c-api/init.rst:1989 ../../c-api/init.rst:1996 +#: ../../c-api/init.rst:2018 ../../c-api/init.rst:2025 +#: ../../c-api/init.rst:2044 ../../c-api/init.rst:2051 msgid "The caller must hold the :term:`GIL`." msgstr "呼叫者必須持有 :term:`GIL`。" -#: ../../c-api/init.rst:1967 +#: ../../c-api/init.rst:2022 msgid "" "Like :c:func:`PyEval_SetProfile` but sets the profile function in all " "running threads belonging to the current interpreter instead of the setting " "it only on the current thread." msgstr "" -#: ../../c-api/init.rst:1972 +#: ../../c-api/init.rst:2027 msgid "" "As :c:func:`PyEval_SetProfile`, this function ignores any exceptions raised " "while setting the profile functions in all threads." msgstr "" -#: ../../c-api/init.rst:1980 +#: ../../c-api/init.rst:2035 msgid "" "Set the tracing function to *func*. This is similar to :c:func:" "`PyEval_SetProfile`, except the tracing function does receive line-number " @@ -2367,65 +2484,120 @@ msgid "" "*what* parameter." msgstr "" -#: ../../c-api/init.rst:1987 +#: ../../c-api/init.rst:2042 msgid "See also the :func:`sys.settrace` function." msgstr "也請見 :func:`sys.settrace` 函式。" -#: ../../c-api/init.rst:1993 +#: ../../c-api/init.rst:2048 msgid "" "Like :c:func:`PyEval_SetTrace` but sets the tracing function in all running " "threads belonging to the current interpreter instead of the setting it only " "on the current thread." msgstr "" -#: ../../c-api/init.rst:1998 +#: ../../c-api/init.rst:2053 msgid "" "As :c:func:`PyEval_SetTrace`, this function ignores any exceptions raised " "while setting the trace functions in all threads." msgstr "" -#: ../../c-api/init.rst:2007 +#: ../../c-api/init.rst:2059 +msgid "Reference tracing" +msgstr "" + +#: ../../c-api/init.rst:2065 +msgid "" +"The type of the trace function registered using :c:func:" +"`PyRefTracer_SetTracer`. The first parameter is a Python object that has " +"been just created (when **event** is set to :c:data:`PyRefTracer_CREATE`) or " +"about to be destroyed (when **event** is set to :c:data:" +"`PyRefTracer_DESTROY`). The **data** argument is the opaque pointer that was " +"provided when :c:func:`PyRefTracer_SetTracer` was called." +msgstr "" + +#: ../../c-api/init.rst:2075 +msgid "" +"The value for the *event* parameter to :c:type:`PyRefTracer` functions when " +"a Python object has been created." +msgstr "" + +#: ../../c-api/init.rst:2080 +msgid "" +"The value for the *event* parameter to :c:type:`PyRefTracer` functions when " +"a Python object has been destroyed." +msgstr "" + +#: ../../c-api/init.rst:2085 +msgid "" +"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." +msgstr "" + +#: ../../c-api/init.rst:2091 +msgid "" +"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." +msgstr "" + +#: ../../c-api/init.rst:2096 ../../c-api/init.rst:2107 +msgid "The GIL must be held when calling this function." +msgstr "" + +#: ../../c-api/init.rst:2102 +msgid "" +"Get the registered reference tracer function and the value of the opaque " +"data pointer that was registered when :c:func:`PyRefTracer_SetTracer` was " +"called. If no tracer was registered this function will return NULL and will " +"set the **data** pointer to NULL." +msgstr "" + +#: ../../c-api/init.rst:2114 msgid "Advanced Debugger Support" msgstr "" -#: ../../c-api/init.rst:2012 +#: ../../c-api/init.rst:2119 msgid "" "These functions are only intended to be used by advanced debugging tools." msgstr "" -#: ../../c-api/init.rst:2017 +#: ../../c-api/init.rst:2124 msgid "" "Return the interpreter state object at the head of the list of all such " "objects." msgstr "" -#: ../../c-api/init.rst:2022 +#: ../../c-api/init.rst:2129 msgid "Return the main interpreter state object." msgstr "" -#: ../../c-api/init.rst:2027 +#: ../../c-api/init.rst:2134 msgid "" "Return the next interpreter state object after *interp* from the list of all " "such objects." msgstr "" -#: ../../c-api/init.rst:2033 +#: ../../c-api/init.rst:2140 msgid "" "Return the pointer to the first :c:type:`PyThreadState` object in the list " "of threads associated with the interpreter *interp*." msgstr "" -#: ../../c-api/init.rst:2039 +#: ../../c-api/init.rst:2146 msgid "" "Return the next thread state object after *tstate* from the list of all such " "objects belonging to the same :c:type:`PyInterpreterState` object." msgstr "" -#: ../../c-api/init.rst:2046 +#: ../../c-api/init.rst:2153 msgid "Thread Local Storage Support" msgstr "" -#: ../../c-api/init.rst:2050 +#: ../../c-api/init.rst:2157 msgid "" "The Python interpreter provides low-level support for thread-local storage " "(TLS) which wraps the underlying native TLS implementation to support the " @@ -2435,19 +2607,19 @@ msgid "" "thread." msgstr "" -#: ../../c-api/init.rst:2057 +#: ../../c-api/init.rst:2164 msgid "" "The GIL does *not* need to be held when calling these functions; they supply " "their own locking." msgstr "" -#: ../../c-api/init.rst:2060 +#: ../../c-api/init.rst:2167 msgid "" "Note that :file:`Python.h` does not include the declaration of the TLS APIs, " "you need to include :file:`pythread.h` to use thread-local storage." msgstr "" -#: ../../c-api/init.rst:2064 +#: ../../c-api/init.rst:2171 msgid "" "None of these API functions handle memory management on behalf of the :c:" "expr:`void*` values. You need to allocate and deallocate them yourself. If " @@ -2455,22 +2627,22 @@ msgid "" "don't do refcount operations on them either." msgstr "" -#: ../../c-api/init.rst:2072 +#: ../../c-api/init.rst:2179 msgid "Thread Specific Storage (TSS) API" msgstr "" -#: ../../c-api/init.rst:2074 +#: ../../c-api/init.rst:2181 msgid "" "TSS API is introduced to supersede the use of the existing TLS API within " "the CPython interpreter. This API uses a new type :c:type:`Py_tss_t` " "instead of :c:expr:`int` to represent thread keys." msgstr "" -#: ../../c-api/init.rst:2080 +#: ../../c-api/init.rst:2187 msgid "\"A New C-API for Thread-Local Storage in CPython\" (:pep:`539`)" msgstr "" -#: ../../c-api/init.rst:2085 +#: ../../c-api/init.rst:2192 msgid "" "This data structure represents the state of a thread key, the definition of " "which may depend on the underlying TLS implementation, and it has an " @@ -2478,52 +2650,52 @@ msgid "" "public members in this structure." msgstr "" -#: ../../c-api/init.rst:2090 +#: ../../c-api/init.rst:2197 msgid "" "When :ref:`Py_LIMITED_API ` is not defined, static allocation of " "this type by :c:macro:`Py_tss_NEEDS_INIT` is allowed." msgstr "" -#: ../../c-api/init.rst:2096 +#: ../../c-api/init.rst:2203 msgid "" "This macro expands to the initializer for :c:type:`Py_tss_t` variables. Note " "that this macro won't be defined with :ref:`Py_LIMITED_API `." msgstr "" -#: ../../c-api/init.rst:2101 +#: ../../c-api/init.rst:2208 msgid "Dynamic Allocation" msgstr "" -#: ../../c-api/init.rst:2103 +#: ../../c-api/init.rst:2210 msgid "" "Dynamic allocation of the :c:type:`Py_tss_t`, required in extension modules " "built with :ref:`Py_LIMITED_API `, where static allocation of this " "type is not possible due to its implementation being opaque at build time." msgstr "" -#: ../../c-api/init.rst:2110 +#: ../../c-api/init.rst:2217 msgid "" "Return a value which is the same state as a value initialized with :c:macro:" "`Py_tss_NEEDS_INIT`, or ``NULL`` in the case of dynamic allocation failure." msgstr "" -#: ../../c-api/init.rst:2117 +#: ../../c-api/init.rst:2224 msgid "" "Free the given *key* allocated by :c:func:`PyThread_tss_alloc`, after first " "calling :c:func:`PyThread_tss_delete` to ensure any associated thread locals " "have been unassigned. This is a no-op if the *key* argument is ``NULL``." msgstr "" -#: ../../c-api/init.rst:2123 +#: ../../c-api/init.rst:2230 msgid "" "A freed key becomes a dangling pointer. You should reset the key to ``NULL``." msgstr "" -#: ../../c-api/init.rst:2128 +#: ../../c-api/init.rst:2235 msgid "Methods" msgstr "方法" -#: ../../c-api/init.rst:2130 +#: ../../c-api/init.rst:2237 msgid "" "The parameter *key* of these functions must not be ``NULL``. Moreover, the " "behaviors of :c:func:`PyThread_tss_set` and :c:func:`PyThread_tss_get` are " @@ -2531,13 +2703,13 @@ msgid "" "func:`PyThread_tss_create`." msgstr "" -#: ../../c-api/init.rst:2138 +#: ../../c-api/init.rst:2245 msgid "" "Return a non-zero value if the given :c:type:`Py_tss_t` has been initialized " "by :c:func:`PyThread_tss_create`." msgstr "" -#: ../../c-api/init.rst:2144 +#: ../../c-api/init.rst:2251 msgid "" "Return a zero value on successful initialization of a TSS key. The behavior " "is undefined if the value pointed to by the *key* argument is not " @@ -2546,7 +2718,7 @@ msgid "" "no-op and immediately returns success." msgstr "" -#: ../../c-api/init.rst:2153 +#: ../../c-api/init.rst:2260 msgid "" "Destroy a TSS key to forget the values associated with the key across all " "threads, and change the key's initialization state to uninitialized. A " @@ -2555,31 +2727,31 @@ msgid "" "key -- calling it on an already destroyed key is a no-op." msgstr "" -#: ../../c-api/init.rst:2162 +#: ../../c-api/init.rst:2269 msgid "" "Return a zero value to indicate successfully associating a :c:expr:`void*` " "value with a TSS key in the current thread. Each thread has a distinct " "mapping of the key to a :c:expr:`void*` value." msgstr "" -#: ../../c-api/init.rst:2169 +#: ../../c-api/init.rst:2276 msgid "" "Return the :c:expr:`void*` value associated with a TSS key in the current " "thread. This returns ``NULL`` if no value is associated with the key in the " "current thread." msgstr "" -#: ../../c-api/init.rst:2177 +#: ../../c-api/init.rst:2284 msgid "Thread Local Storage (TLS) API" msgstr "執行緒局部儲存 (Thread Local Storage, TLS) API:" -#: ../../c-api/init.rst:2179 +#: ../../c-api/init.rst:2286 msgid "" "This API is superseded by :ref:`Thread Specific Storage (TSS) API `." msgstr "" -#: ../../c-api/init.rst:2184 +#: ../../c-api/init.rst:2291 msgid "" "This version of the API does not support platforms where the native TLS key " "is defined in a way that cannot be safely cast to ``int``. On such " @@ -2588,190 +2760,331 @@ msgid "" "platforms." msgstr "" -#: ../../c-api/init.rst:2189 +#: ../../c-api/init.rst:2296 msgid "" "Due to the compatibility problem noted above, this version of the API should " "not be used in new code." msgstr "" -#: ../../c-api/init.rst:334 ../../c-api/init.rst:502 ../../c-api/init.rst:577 -msgid "Py_SetProgramName()" -msgstr "Py_SetProgramName()" +#: ../../c-api/init.rst:2307 +msgid "Synchronization Primitives" +msgstr "" + +#: ../../c-api/init.rst:2309 +msgid "The C-API provides a basic mutual exclusion lock." +msgstr "" + +#: ../../c-api/init.rst:2313 +msgid "" +"A mutual exclusion lock. The :c:type:`!PyMutex` should be initialized to " +"zero to represent the unlocked state. For example::" +msgstr "" + +#: ../../c-api/init.rst:2316 +msgid "PyMutex mutex = {0};" +msgstr "" + +#: ../../c-api/init.rst:2318 +msgid "" +"Instances of :c:type:`!PyMutex` should not be copied or moved. Both the " +"contents and address of a :c:type:`!PyMutex` are meaningful, and it must " +"remain at a fixed, writable location in memory." +msgstr "" + +#: ../../c-api/init.rst:2324 +msgid "" +"A :c:type:`!PyMutex` currently occupies one byte, but the size should be " +"considered unstable. The size may change in future Python releases without " +"a deprecation period." +msgstr "" + +#: ../../c-api/init.rst:2332 +msgid "" +"Lock mutex *m*. If another thread has already locked it, the calling thread " +"will block until the mutex is unlocked. While blocked, the thread will " +"temporarily release the :term:`GIL` if it is held." +msgstr "" + +#: ../../c-api/init.rst:2340 +msgid "" +"Unlock mutex *m*. The mutex must be locked --- otherwise, the function will " +"issue a fatal error." +msgstr "" + +#: ../../c-api/init.rst:2348 +msgid "Python Critical Section API" +msgstr "" + +#: ../../c-api/init.rst:2350 +msgid "" +"The critical section API provides a deadlock avoidance layer on top of per-" +"object locks for :term:`free-threaded ` CPython. They are " +"intended to replace reliance on the :term:`global interpreter lock`, and are " +"no-ops in versions of Python with the global interpreter lock." +msgstr "" + +#: ../../c-api/init.rst:2355 +msgid "" +"Critical sections avoid deadlocks by implicitly suspending active critical " +"sections and releasing the locks during calls to :c:func:" +"`PyEval_SaveThread`. When :c:func:`PyEval_RestoreThread` 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 :term:`GIL`." +msgstr "" + +#: ../../c-api/init.rst:2362 +msgid "" +"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." +msgstr "" + +#: ../../c-api/init.rst:2369 +msgid "" +"Operations that need to lock two objects at once must use :c:macro:" +"`Py_BEGIN_CRITICAL_SECTION2`. You *cannot* use nested critical sections to " +"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." +msgstr "" + +#: ../../c-api/init.rst:2375 +msgid "Example usage::" +msgstr "" + +#: ../../c-api/init.rst:2377 +msgid "" +"static PyObject *\n" +"set_field(MyObject *self, PyObject *value)\n" +"{\n" +" Py_BEGIN_CRITICAL_SECTION(self);\n" +" Py_SETREF(self->field, Py_XNewRef(value));\n" +" Py_END_CRITICAL_SECTION();\n" +" Py_RETURN_NONE;\n" +"}" +msgstr "" + +#: ../../c-api/init.rst:2386 +msgid "" +"In the above example, :c:macro:`Py_SETREF` calls :c:macro:`Py_DECREF`, which " +"can call arbitrary code through an object's deallocation function. The " +"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 :c:func:" +"`PyEval_SaveThread`." +msgstr "" + +#: ../../c-api/init.rst:2394 +msgid "" +"Acquires the per-object lock for the object *op* and begins a critical " +"section." +msgstr "" + +#: ../../c-api/init.rst:2397 ../../c-api/init.rst:2411 +#: ../../c-api/init.rst:2426 ../../c-api/init.rst:2440 +msgid "In the free-threaded build, this macro expands to::" +msgstr "" + +#: ../../c-api/init.rst:2399 +msgid "" +"{\n" +" PyCriticalSection _py_cs;\n" +" PyCriticalSection_Begin(&_py_cs, (PyObject*)(op))" +msgstr "" + +#: ../../c-api/init.rst:2403 ../../c-api/init.rst:2432 +msgid "In the default build, this macro expands to ``{``." +msgstr "" + +#: ../../c-api/init.rst:2409 +msgid "Ends the critical section and releases the per-object lock." +msgstr "" + +#: ../../c-api/init.rst:2413 +msgid "" +" PyCriticalSection_End(&_py_cs);\n" +"}" +msgstr "" + +#: ../../c-api/init.rst:2416 ../../c-api/init.rst:2445 +msgid "In the default build, this macro expands to ``}``." +msgstr "" + +#: ../../c-api/init.rst:2422 +msgid "" +"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." +msgstr "" + +#: ../../c-api/init.rst:2428 +msgid "" +"{\n" +" PyCriticalSection2 _py_cs2;\n" +" PyCriticalSection2_Begin(&_py_cs2, (PyObject*)(a), (PyObject*)(b))" +msgstr "" + +#: ../../c-api/init.rst:2438 +msgid "Ends the critical section and releases the per-object locks." +msgstr "" + +#: ../../c-api/init.rst:2442 +msgid "" +" PyCriticalSection2_End(&_py_cs2);\n" +"}" +msgstr "" -#: ../../c-api/init.rst:334 +#: ../../c-api/init.rst:350 msgid "PyEval_InitThreads()" msgstr "PyEval_InitThreads()" -#: ../../c-api/init.rst:334 +#: ../../c-api/init.rst:350 msgid "modules (in module sys)" msgstr "modules(sys 模組中)" -#: ../../c-api/init.rst:334 ../../c-api/init.rst:596 ../../c-api/init.rst:622 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:696 msgid "path (in module sys)" msgstr "path(sys 模組中)" -#: ../../c-api/init.rst:334 ../../c-api/init.rst:596 ../../c-api/init.rst:622 -#: ../../c-api/init.rst:1063 ../../c-api/init.rst:1594 -#: ../../c-api/init.rst:1689 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:696 ../../c-api/init.rst:1131 +#: ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 msgid "module" msgstr "模組" -#: ../../c-api/init.rst:334 ../../c-api/init.rst:1594 ../../c-api/init.rst:1689 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 msgid "builtins" msgstr "builtins(內建)" -#: ../../c-api/init.rst:334 ../../c-api/init.rst:1594 ../../c-api/init.rst:1689 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 msgid "__main__" msgstr "__main__" -#: ../../c-api/init.rst:334 ../../c-api/init.rst:1594 ../../c-api/init.rst:1689 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 msgid "sys" msgstr "sys" -#: ../../c-api/init.rst:334 ../../c-api/init.rst:596 ../../c-api/init.rst:622 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:696 msgid "search" msgstr "search(搜尋)" -#: ../../c-api/init.rst:334 ../../c-api/init.rst:596 ../../c-api/init.rst:622 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:696 msgid "path" msgstr "path(路徑)" -#: ../../c-api/init.rst:334 -msgid "PySys_SetArgv (C function)" -msgstr "PySys_SetArgv(C 函式)" - -#: ../../c-api/init.rst:334 -msgid "PySys_SetArgvEx (C function)" -msgstr "PySys_SetArgvEx(C 函式)" - -#: ../../c-api/init.rst:334 ../../c-api/init.rst:1654 ../../c-api/init.rst:1707 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1709 ../../c-api/init.rst:1762 msgid "Py_FinalizeEx (C function)" msgstr "Py_FinalizeEx(C 函式)" -#: ../../c-api/init.rst:437 ../../c-api/init.rst:474 +#: ../../c-api/init.rst:562 msgid "Py_Initialize()" msgstr "Py_Initialize()" -#: ../../c-api/init.rst:437 ../../c-api/init.rst:474 ../../c-api/init.rst:730 +#: ../../c-api/init.rst:562 ../../c-api/init.rst:794 msgid "main()" msgstr "main()" -#: ../../c-api/init.rst:437 -msgid "stdin" -msgstr "stdin" - -#: ../../c-api/init.rst:437 -msgid "stdout" -msgstr "stdout" - -#: ../../c-api/init.rst:437 -msgid "sdterr" -msgstr "sdterr" - -#: ../../c-api/init.rst:474 ../../c-api/init.rst:622 +#: ../../c-api/init.rst:562 msgid "Py_GetPath()" msgstr "Py_GetPath()" -#: ../../c-api/init.rst:577 +#: ../../c-api/init.rst:675 msgid "executable (in module sys)" msgstr "executable(sys 模組中)" -#: ../../c-api/init.rst:596 -msgid "Py_SetPath()" -msgstr "Py_SetPath()" - -#: ../../c-api/init.rst:665 ../../c-api/init.rst:707 ../../c-api/init.rst:721 +#: ../../c-api/init.rst:729 ../../c-api/init.rst:771 ../../c-api/init.rst:785 msgid "version (in module sys)" msgstr "version(sys 模組中)" -#: ../../c-api/init.rst:677 +#: ../../c-api/init.rst:741 msgid "platform (in module sys)" msgstr "platform(sys 模組中)" -#: ../../c-api/init.rst:694 +#: ../../c-api/init.rst:758 msgid "copyright (in module sys)" msgstr "copyright(sys 模組中)" -#: ../../c-api/init.rst:730 +#: ../../c-api/init.rst:794 msgid "Py_FatalError()" msgstr "Py_FatalError()" -#: ../../c-api/init.rst:730 +#: ../../c-api/init.rst:794 msgid "argv (in module sys)" msgstr "argv(sys 模組中)" -#: ../../c-api/init.rst:846 +#: ../../c-api/init.rst:914 msgid "global interpreter lock" msgstr "global interpreter lock(全域直譯器鎖)" -#: ../../c-api/init.rst:846 +#: ../../c-api/init.rst:914 msgid "interpreter lock" msgstr "interpreter lock(直譯器鎖)" -#: ../../c-api/init.rst:846 +#: ../../c-api/init.rst:914 msgid "lock, interpreter" msgstr "lock, interpreter(鎖、直譯器)" -#: ../../c-api/init.rst:859 +#: ../../c-api/init.rst:927 msgid "setswitchinterval (in module sys)" msgstr "setswitchinterval (sys 模組中)" -#: ../../c-api/init.rst:868 +#: ../../c-api/init.rst:936 msgid "PyThreadState (C type)" msgstr "PyThreadState(C 型別)" -#: ../../c-api/init.rst:894 +#: ../../c-api/init.rst:962 msgid "Py_BEGIN_ALLOW_THREADS (C macro)" msgstr "Py_BEGIN_ALLOW_THREADS(C 巨集)" -#: ../../c-api/init.rst:894 +#: ../../c-api/init.rst:962 msgid "Py_END_ALLOW_THREADS (C macro)" msgstr "Py_END_ALLOW_THREADS(C 巨集)" -#: ../../c-api/init.rst:910 +#: ../../c-api/init.rst:978 msgid "PyEval_RestoreThread (C function)" msgstr "PyEval_RestoreThread(C 函式)" -#: ../../c-api/init.rst:910 +#: ../../c-api/init.rst:978 msgid "PyEval_SaveThread (C function)" msgstr "PyEval_SaveThread(C 函式)" -#: ../../c-api/init.rst:1041 +#: ../../c-api/init.rst:1109 msgid "PyEval_AcquireThread()" msgstr "PyEval_AcquireThread()" -#: ../../c-api/init.rst:1041 +#: ../../c-api/init.rst:1109 msgid "PyEval_ReleaseThread()" msgstr "PyEval_ReleaseThread()" -#: ../../c-api/init.rst:1041 +#: ../../c-api/init.rst:1109 msgid "PyEval_SaveThread()" msgstr "PyEval_SaveThread()" -#: ../../c-api/init.rst:1041 +#: ../../c-api/init.rst:1109 msgid "PyEval_RestoreThread()" msgstr "PyEval_RestoreThread()" -#: ../../c-api/init.rst:1063 +#: ../../c-api/init.rst:1131 msgid "_thread" msgstr "_thread" -#: ../../c-api/init.rst:1594 ../../c-api/init.rst:1689 +#: ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 msgid "stdout (in module sys)" msgstr "stdout(sys 模組中)" -#: ../../c-api/init.rst:1594 ../../c-api/init.rst:1689 +#: ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 msgid "stderr (in module sys)" msgstr "stderr(sys 模組中)" -#: ../../c-api/init.rst:1594 ../../c-api/init.rst:1689 +#: ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 msgid "stdin (in module sys)" msgstr "stdin(sys 模組中)" -#: ../../c-api/init.rst:1654 +#: ../../c-api/init.rst:1709 msgid "Py_Initialize (C function)" msgstr "Py_Initialize(C 函式)" -#: ../../c-api/init.rst:1684 +#: ../../c-api/init.rst:1739 msgid "close (in module os)" msgstr "close(os 模組中)" diff --git a/c-api/init_config.po b/c-api/init_config.po index b2ac9bf415..434dd0394e 100644 --- a/c-api/init_config.po +++ b/c-api/init_config.po @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-07 03:11+0800\n" +"POT-Creation-Date: 2025-03-14 00:14+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -149,7 +149,7 @@ msgid "*index* must be greater than or equal to ``0``." msgstr "" #: ../../c-api/init_config.rst:108 ../../c-api/init_config.rst:128 -#: ../../c-api/init_config.rst:235 ../../c-api/init_config.rst:544 +#: ../../c-api/init_config.rst:235 ../../c-api/init_config.rst:554 msgid "Structure fields:" msgstr "" @@ -355,116 +355,135 @@ msgid "" "allocator ` with :ref:`debug hooks `." msgstr "" -#: ../../c-api/init_config.rst:257 +#: ../../c-api/init_config.rst:256 +msgid "" +"``PYMEM_ALLOCATOR_MIMALLOC`` (``6``): use ``mimalloc``, a fast malloc " +"replacement." +msgstr "" + +#: ../../c-api/init_config.rst:258 +msgid "" +"``PYMEM_ALLOCATOR_MIMALLOC_DEBUG`` (``7``): use ``mimalloc``, a fast malloc " +"replacement with :ref:`debug hooks `." +msgstr "" + +#: ../../c-api/init_config.rst:262 msgid "" "``PYMEM_ALLOCATOR_PYMALLOC`` and ``PYMEM_ALLOCATOR_PYMALLOC_DEBUG`` are not " "supported if Python is :option:`configured using --without-pymalloc <--" "without-pymalloc>`." msgstr "" -#: ../../c-api/init_config.rst:261 +#: ../../c-api/init_config.rst:266 +msgid "" +"``PYMEM_ALLOCATOR_MIMALLOC`` and ``PYMEM_ALLOCATOR_MIMALLOC_DEBUG`` are not " +"supported if Python is :option:`configured using --without-mimalloc <--" +"without-mimalloc>` or if the underlying atomic support isn't available." +msgstr "" + +#: ../../c-api/init_config.rst:271 msgid "See :ref:`Memory Management `." msgstr "請見\\ :ref:`記憶體管理 `。" -#: ../../c-api/init_config.rst:263 +#: ../../c-api/init_config.rst:273 msgid "Default: ``PYMEM_ALLOCATOR_NOT_SET``." msgstr "預設:``PYMEM_ALLOCATOR_NOT_SET``。" -#: ../../c-api/init_config.rst:267 +#: ../../c-api/init_config.rst:277 msgid "Set the LC_CTYPE locale to the user preferred locale." msgstr "" -#: ../../c-api/init_config.rst:269 +#: ../../c-api/init_config.rst:279 msgid "" "If equals to ``0``, set :c:member:`~PyPreConfig.coerce_c_locale` and :c:" "member:`~PyPreConfig.coerce_c_locale_warn` members to ``0``." msgstr "" -#: ../../c-api/init_config.rst:272 ../../c-api/init_config.rst:283 +#: ../../c-api/init_config.rst:282 ../../c-api/init_config.rst:293 msgid "See the :term:`locale encoding`." msgstr "請見 :term:`locale encoding`。" -#: ../../c-api/init_config.rst:274 ../../c-api/init_config.rst:329 -#: ../../c-api/init_config.rst:684 +#: ../../c-api/init_config.rst:284 ../../c-api/init_config.rst:339 +#: ../../c-api/init_config.rst:710 msgid "Default: ``1`` in Python config, ``0`` in isolated config." msgstr "" -#: ../../c-api/init_config.rst:278 +#: ../../c-api/init_config.rst:288 msgid "If equals to ``2``, coerce the C locale." msgstr "" -#: ../../c-api/init_config.rst:280 +#: ../../c-api/init_config.rst:290 msgid "" "If equals to ``1``, read the LC_CTYPE locale to decide if it should be " "coerced." msgstr "" -#: ../../c-api/init_config.rst:285 ../../c-api/init_config.rst:291 +#: ../../c-api/init_config.rst:295 ../../c-api/init_config.rst:301 msgid "Default: ``-1`` in Python config, ``0`` in isolated config." msgstr "" -#: ../../c-api/init_config.rst:289 +#: ../../c-api/init_config.rst:299 msgid "If non-zero, emit a warning if the C locale is coerced." msgstr "" -#: ../../c-api/init_config.rst:295 +#: ../../c-api/init_config.rst:305 msgid "" ":ref:`Python Development Mode `: see :c:member:`PyConfig.dev_mode`." msgstr "" -#: ../../c-api/init_config.rst:298 ../../c-api/init_config.rst:693 -#: ../../c-api/init_config.rst:735 ../../c-api/init_config.rst:1188 +#: ../../c-api/init_config.rst:308 ../../c-api/init_config.rst:719 +#: ../../c-api/init_config.rst:765 ../../c-api/init_config.rst:1244 msgid "Default: ``-1`` in Python mode, ``0`` in isolated mode." msgstr "" -#: ../../c-api/init_config.rst:302 +#: ../../c-api/init_config.rst:312 msgid "Isolated mode: see :c:member:`PyConfig.isolated`." msgstr "" -#: ../../c-api/init_config.rst:304 ../../c-api/init_config.rst:880 +#: ../../c-api/init_config.rst:314 ../../c-api/init_config.rst:921 msgid "Default: ``0`` in Python mode, ``1`` in isolated mode." msgstr "" -#: ../../c-api/init_config.rst:308 +#: ../../c-api/init_config.rst:318 msgid "If non-zero:" msgstr "如果不為 0:" -#: ../../c-api/init_config.rst:310 +#: ../../c-api/init_config.rst:320 msgid "Set :c:member:`PyPreConfig.utf8_mode` to ``0``," msgstr "將 :c:member:`PyPreConfig.utf8_mode` 設為 ``0``、" -#: ../../c-api/init_config.rst:311 +#: ../../c-api/init_config.rst:321 msgid "Set :c:member:`PyConfig.filesystem_encoding` to ``\"mbcs\"``," msgstr "將 :c:member:`PyConfig.filesystem_encoding` 設為 ``\"mbcs\"``、" -#: ../../c-api/init_config.rst:312 +#: ../../c-api/init_config.rst:322 msgid "Set :c:member:`PyConfig.filesystem_errors` to ``\"replace\"``." msgstr "將 :c:member:`PyConfig.filesystem_errors` 設為 ``\"replace\"``。" -#: ../../c-api/init_config.rst:314 +#: ../../c-api/init_config.rst:324 msgid "" "Initialized from the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment " "variable value." msgstr "" -#: ../../c-api/init_config.rst:317 ../../c-api/init_config.rst:894 +#: ../../c-api/init_config.rst:327 ../../c-api/init_config.rst:935 msgid "" "Only available on Windows. ``#ifdef MS_WINDOWS`` macro can be used for " "Windows specific code." msgstr "" -#: ../../c-api/init_config.rst:320 ../../c-api/init_config.rst:632 -#: ../../c-api/init_config.rst:639 ../../c-api/init_config.rst:706 -#: ../../c-api/init_config.rst:815 ../../c-api/init_config.rst:829 -#: ../../c-api/init_config.rst:843 ../../c-api/init_config.rst:897 -#: ../../c-api/init_config.rst:911 ../../c-api/init_config.rst:971 -#: ../../c-api/init_config.rst:1023 ../../c-api/init_config.rst:1083 -#: ../../c-api/init_config.rst:1123 ../../c-api/init_config.rst:1152 -#: ../../c-api/init_config.rst:1239 +#: ../../c-api/init_config.rst:330 ../../c-api/init_config.rst:658 +#: ../../c-api/init_config.rst:665 ../../c-api/init_config.rst:732 +#: ../../c-api/init_config.rst:843 ../../c-api/init_config.rst:857 +#: ../../c-api/init_config.rst:871 ../../c-api/init_config.rst:938 +#: ../../c-api/init_config.rst:952 ../../c-api/init_config.rst:1012 +#: ../../c-api/init_config.rst:1064 ../../c-api/init_config.rst:1126 +#: ../../c-api/init_config.rst:1180 ../../c-api/init_config.rst:1209 +#: ../../c-api/init_config.rst:1298 msgid "Default: ``0``." msgstr "預設:``0``。" -#: ../../c-api/init_config.rst:324 +#: ../../c-api/init_config.rst:334 msgid "" "If non-zero, :c:func:`Py_PreInitializeFromArgs` and :c:func:" "`Py_PreInitializeFromBytesArgs` parse their ``argv`` argument the same way " @@ -472,95 +491,95 @@ msgid "" "Arguments `." msgstr "" -#: ../../c-api/init_config.rst:333 +#: ../../c-api/init_config.rst:343 msgid "" "Use :ref:`environment variables `? See :c:member:`PyConfig." "use_environment`." msgstr "" -#: ../../c-api/init_config.rst:336 ../../c-api/init_config.rst:1213 +#: ../../c-api/init_config.rst:346 ../../c-api/init_config.rst:1272 msgid "Default: ``1`` in Python config and ``0`` in isolated config." msgstr "" -#: ../../c-api/init_config.rst:340 +#: ../../c-api/init_config.rst:350 msgid "If non-zero, enable the :ref:`Python UTF-8 Mode `." msgstr "" -#: ../../c-api/init_config.rst:342 +#: ../../c-api/init_config.rst:352 msgid "" "Set to ``0`` or ``1`` by the :option:`-X utf8 <-X>` command line option and " "the :envvar:`PYTHONUTF8` environment variable." msgstr "" -#: ../../c-api/init_config.rst:345 +#: ../../c-api/init_config.rst:355 msgid "Also set to ``1`` if the ``LC_CTYPE`` locale is ``C`` or ``POSIX``." msgstr "" -#: ../../c-api/init_config.rst:347 +#: ../../c-api/init_config.rst:357 msgid "Default: ``-1`` in Python config and ``0`` in isolated config." msgstr "" -#: ../../c-api/init_config.rst:353 +#: ../../c-api/init_config.rst:363 msgid "Preinitialize Python with PyPreConfig" msgstr "" -#: ../../c-api/init_config.rst:355 +#: ../../c-api/init_config.rst:365 msgid "The preinitialization of Python:" msgstr "" -#: ../../c-api/init_config.rst:357 +#: ../../c-api/init_config.rst:367 msgid "Set the Python memory allocators (:c:member:`PyPreConfig.allocator`)" msgstr "" -#: ../../c-api/init_config.rst:358 +#: ../../c-api/init_config.rst:368 msgid "Configure the LC_CTYPE locale (:term:`locale encoding`)" msgstr "" -#: ../../c-api/init_config.rst:359 +#: ../../c-api/init_config.rst:369 msgid "" "Set the :ref:`Python UTF-8 Mode ` (:c:member:`PyPreConfig." "utf8_mode`)" msgstr "" -#: ../../c-api/init_config.rst:362 +#: ../../c-api/init_config.rst:372 msgid "" "The current preconfiguration (``PyPreConfig`` type) is stored in " "``_PyRuntime.preconfig``." msgstr "" -#: ../../c-api/init_config.rst:365 +#: ../../c-api/init_config.rst:375 msgid "Functions to preinitialize Python:" msgstr "" -#: ../../c-api/init_config.rst:369 ../../c-api/init_config.rst:375 -#: ../../c-api/init_config.rst:384 +#: ../../c-api/init_config.rst:379 ../../c-api/init_config.rst:385 +#: ../../c-api/init_config.rst:394 msgid "Preinitialize Python from *preconfig* preconfiguration." msgstr "" -#: ../../c-api/init_config.rst:371 ../../c-api/init_config.rst:380 -#: ../../c-api/init_config.rst:389 +#: ../../c-api/init_config.rst:381 ../../c-api/init_config.rst:390 +#: ../../c-api/init_config.rst:399 msgid "*preconfig* must not be ``NULL``." msgstr "*preconfig* 不可為 ``NULL``。" -#: ../../c-api/init_config.rst:377 +#: ../../c-api/init_config.rst:387 msgid "" "Parse *argv* command line arguments (bytes strings) if :c:member:" "`~PyPreConfig.parse_argv` of *preconfig* is non-zero." msgstr "" -#: ../../c-api/init_config.rst:386 +#: ../../c-api/init_config.rst:396 msgid "" "Parse *argv* command line arguments (wide strings) if :c:member:" "`~PyPreConfig.parse_argv` of *preconfig* is non-zero." msgstr "" -#: ../../c-api/init_config.rst:391 ../../c-api/init_config.rst:1301 +#: ../../c-api/init_config.rst:401 ../../c-api/init_config.rst:1359 msgid "" "The caller is responsible to handle exceptions (error or exit) using :c:func:" "`PyStatus_Exception` and :c:func:`Py_ExitStatusException`." msgstr "" -#: ../../c-api/init_config.rst:394 +#: ../../c-api/init_config.rst:404 msgid "" "For :ref:`Python Configuration ` (:c:func:" "`PyPreConfig_InitPythonConfig`), if Python is initialized with command line " @@ -570,7 +589,7 @@ msgid "" "`Python UTF-8 Mode `." msgstr "" -#: ../../c-api/init_config.rst:401 +#: ../../c-api/init_config.rst:411 msgid "" "``PyMem_SetAllocator()`` can be called after :c:func:`Py_PreInitialize` and " "before :c:func:`Py_InitializeFromConfig` to install a custom memory " @@ -578,7 +597,7 @@ msgid "" "`PyPreConfig.allocator` is set to ``PYMEM_ALLOCATOR_NOT_SET``." msgstr "" -#: ../../c-api/init_config.rst:406 +#: ../../c-api/init_config.rst:416 msgid "" "Python memory allocation functions like :c:func:`PyMem_RawMalloc` must not " "be used before the Python preinitialization, whereas calling directly " @@ -586,13 +605,13 @@ msgid "" "not be called before the Python preinitialization." msgstr "" -#: ../../c-api/init_config.rst:411 +#: ../../c-api/init_config.rst:421 msgid "" "Example using the preinitialization to enable the :ref:`Python UTF-8 Mode " "`::" msgstr "" -#: ../../c-api/init_config.rst:414 +#: ../../c-api/init_config.rst:424 msgid "" "PyStatus status;\n" "PyPreConfig preconfig;\n" @@ -612,84 +631,84 @@ msgid "" "Py_Finalize();" msgstr "" -#: ../../c-api/init_config.rst:433 +#: ../../c-api/init_config.rst:443 msgid "PyConfig" msgstr "PyConfig" -#: ../../c-api/init_config.rst:437 +#: ../../c-api/init_config.rst:447 msgid "Structure containing most parameters to configure Python." msgstr "" -#: ../../c-api/init_config.rst:439 +#: ../../c-api/init_config.rst:449 msgid "" "When done, the :c:func:`PyConfig_Clear` function must be used to release the " "configuration memory." msgstr "" -#: ../../c-api/init_config.rst:444 +#: ../../c-api/init_config.rst:454 msgid "Structure methods:" msgstr "" -#: ../../c-api/init_config.rst:448 +#: ../../c-api/init_config.rst:458 msgid "" "Initialize configuration with the :ref:`Python Configuration `." msgstr "" -#: ../../c-api/init_config.rst:453 +#: ../../c-api/init_config.rst:463 msgid "" "Initialize configuration with the :ref:`Isolated Configuration `." msgstr "" -#: ../../c-api/init_config.rst:458 +#: ../../c-api/init_config.rst:468 msgid "Copy the wide character string *str* into ``*config_str``." msgstr "" -#: ../../c-api/init_config.rst:460 ../../c-api/init_config.rst:467 -#: ../../c-api/init_config.rst:474 ../../c-api/init_config.rst:482 -#: ../../c-api/init_config.rst:488 ../../c-api/init_config.rst:505 +#: ../../c-api/init_config.rst:470 ../../c-api/init_config.rst:477 +#: ../../c-api/init_config.rst:484 ../../c-api/init_config.rst:492 +#: ../../c-api/init_config.rst:498 ../../c-api/init_config.rst:515 msgid ":ref:`Preinitialize Python ` if needed." msgstr "" -#: ../../c-api/init_config.rst:464 +#: ../../c-api/init_config.rst:474 msgid "" "Decode *str* using :c:func:`Py_DecodeLocale` and set the result into " "``*config_str``." msgstr "" -#: ../../c-api/init_config.rst:471 +#: ../../c-api/init_config.rst:481 msgid "" "Set command line arguments (:c:member:`~PyConfig.argv` member of *config*) " "from the *argv* list of wide character strings." msgstr "" -#: ../../c-api/init_config.rst:478 +#: ../../c-api/init_config.rst:488 msgid "" "Set command line arguments (:c:member:`~PyConfig.argv` member of *config*) " "from the *argv* list of bytes strings. Decode bytes using :c:func:" "`Py_DecodeLocale`." msgstr "" -#: ../../c-api/init_config.rst:486 +#: ../../c-api/init_config.rst:496 msgid "Set the list of wide strings *list* to *length* and *items*." msgstr "" -#: ../../c-api/init_config.rst:492 +#: ../../c-api/init_config.rst:502 msgid "Read all Python configuration." msgstr "" -#: ../../c-api/init_config.rst:494 +#: ../../c-api/init_config.rst:504 msgid "Fields which are already initialized are left unchanged." msgstr "" -#: ../../c-api/init_config.rst:496 +#: ../../c-api/init_config.rst:506 msgid "" "Fields for :ref:`path configuration ` are no longer " "calculated or modified when calling this function, as of Python 3.11." msgstr "" -#: ../../c-api/init_config.rst:499 ../../c-api/init_config.rst:1000 +#: ../../c-api/init_config.rst:509 ../../c-api/init_config.rst:1041 msgid "" "The :c:func:`PyConfig_Read` function only parses :c:member:`PyConfig.argv` " "arguments once: :c:member:`PyConfig.parse_argv` is set to ``2`` after " @@ -698,25 +717,25 @@ msgid "" "as Python options." msgstr "" -#: ../../c-api/init_config.rst:507 +#: ../../c-api/init_config.rst:517 msgid "" "The :c:member:`PyConfig.argv` arguments are now only parsed once, :c:member:" "`PyConfig.parse_argv` is set to ``2`` after arguments are parsed, and " "arguments are only parsed if :c:member:`PyConfig.parse_argv` equals ``1``." msgstr "" -#: ../../c-api/init_config.rst:513 +#: ../../c-api/init_config.rst:523 msgid "" ":c:func:`PyConfig_Read` no longer calculates all paths, and so fields listed " "under :ref:`Python Path Configuration ` may no longer be " "updated until :c:func:`Py_InitializeFromConfig` is called." msgstr "" -#: ../../c-api/init_config.rst:521 +#: ../../c-api/init_config.rst:531 msgid "Release configuration memory." msgstr "" -#: ../../c-api/init_config.rst:523 +#: ../../c-api/init_config.rst:533 msgid "" "Most ``PyConfig`` methods :ref:`preinitialize Python ` if needed. " "In that case, the Python preinitialization configuration (:c:type:" @@ -725,23 +744,23 @@ msgid "" "before calling a :c:type:`PyConfig` method:" msgstr "" -#: ../../c-api/init_config.rst:529 +#: ../../c-api/init_config.rst:539 msgid ":c:member:`PyConfig.dev_mode`" msgstr ":c:member:`PyConfig.dev_mode`" -#: ../../c-api/init_config.rst:530 +#: ../../c-api/init_config.rst:540 msgid ":c:member:`PyConfig.isolated`" msgstr ":c:member:`PyConfig.isolated`" -#: ../../c-api/init_config.rst:531 +#: ../../c-api/init_config.rst:541 msgid ":c:member:`PyConfig.parse_argv`" msgstr ":c:member:`PyConfig.parse_argv`" -#: ../../c-api/init_config.rst:532 +#: ../../c-api/init_config.rst:542 msgid ":c:member:`PyConfig.use_environment`" msgstr ":c:member:`PyConfig.use_environment`" -#: ../../c-api/init_config.rst:534 +#: ../../c-api/init_config.rst:544 msgid "" "Moreover, if :c:func:`PyConfig_SetArgv` or :c:func:`PyConfig_SetBytesArgv` " "is used, this method must be called before other methods, since the " @@ -749,412 +768,435 @@ msgid "" "member:`~PyConfig.parse_argv` is non-zero)." msgstr "" -#: ../../c-api/init_config.rst:539 +#: ../../c-api/init_config.rst:549 msgid "" "The caller of these methods is responsible to handle exceptions (error or " "exit) using ``PyStatus_Exception()`` and ``Py_ExitStatusException()``." msgstr "" -#: ../../c-api/init_config.rst:548 -msgid "Command line arguments: :data:`sys.argv`." -msgstr "命令列引數::data:`sys.argv`。" +#: ../../c-api/init_config.rst:562 +msgid "" +"Set :data:`sys.argv` command line arguments based on :c:member:`~PyConfig." +"argv`. These parameters are similar to those passed to the program's :c:" +"func:`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 :c:member:`~PyConfig.argv` can be an empty string." +msgstr "" -#: ../../c-api/init_config.rst:550 +#: ../../c-api/init_config.rst:570 msgid "" "Set :c:member:`~PyConfig.parse_argv` to ``1`` to parse :c:member:`~PyConfig." "argv` the same way the regular Python parses Python command line arguments " "and then to strip Python arguments from :c:member:`~PyConfig.argv`." msgstr "" -#: ../../c-api/init_config.rst:555 +#: ../../c-api/init_config.rst:575 msgid "" "If :c:member:`~PyConfig.argv` is empty, an empty string is added to ensure " "that :data:`sys.argv` always exists and is never empty." msgstr "" -#: ../../c-api/init_config.rst:558 ../../c-api/init_config.rst:585 -#: ../../c-api/init_config.rst:597 ../../c-api/init_config.rst:605 -#: ../../c-api/init_config.rst:713 ../../c-api/init_config.rst:722 -#: ../../c-api/init_config.rst:804 ../../c-api/init_config.rst:941 -#: ../../c-api/init_config.rst:1042 ../../c-api/init_config.rst:1060 -#: ../../c-api/init_config.rst:1074 ../../c-api/init_config.rst:1091 -#: ../../c-api/init_config.rst:1104 ../../c-api/init_config.rst:1112 +#: ../../c-api/init_config.rst:578 ../../c-api/init_config.rst:605 +#: ../../c-api/init_config.rst:619 ../../c-api/init_config.rst:629 +#: ../../c-api/init_config.rst:739 ../../c-api/init_config.rst:750 +#: ../../c-api/init_config.rst:832 ../../c-api/init_config.rst:982 +#: ../../c-api/init_config.rst:1083 ../../c-api/init_config.rst:1102 +#: ../../c-api/init_config.rst:1117 ../../c-api/init_config.rst:1134 +#: ../../c-api/init_config.rst:1147 ../../c-api/init_config.rst:1155 +#: ../../c-api/init_config.rst:1169 msgid "Default: ``NULL``." msgstr "預設值:``NULL``。" -#: ../../c-api/init_config.rst:560 +#: ../../c-api/init_config.rst:580 msgid "See also the :c:member:`~PyConfig.orig_argv` member." -msgstr "" +msgstr "另請參閱 :c:member:`~PyConfig.orig_argv` 成員。" -#: ../../c-api/init_config.rst:564 +#: ../../c-api/init_config.rst:584 msgid "" "If equals to zero, ``Py_RunMain()`` prepends a potentially unsafe path to :" "data:`sys.path` at startup:" msgstr "" -#: ../../c-api/init_config.rst:567 +#: ../../c-api/init_config.rst:587 msgid "" "If :c:member:`argv[0] ` is equal to ``L\"-m\"`` (``python -m " "module``), prepend the current working directory." msgstr "" -#: ../../c-api/init_config.rst:569 +#: ../../c-api/init_config.rst:589 msgid "" "If running a script (``python script.py``), prepend the script's directory. " "If it's a symbolic link, resolve symbolic links." msgstr "" -#: ../../c-api/init_config.rst:571 +#: ../../c-api/init_config.rst:591 msgid "" "Otherwise (``python -c code`` and ``python``), prepend an empty string, " "which means the current working directory." msgstr "" -#: ../../c-api/init_config.rst:574 +#: ../../c-api/init_config.rst:594 msgid "" "Set to ``1`` by the :option:`-P` command line option and the :envvar:" "`PYTHONSAFEPATH` environment variable." msgstr "" -#: ../../c-api/init_config.rst:577 +#: ../../c-api/init_config.rst:597 msgid "Default: ``0`` in Python config, ``1`` in isolated config." msgstr "" -#: ../../c-api/init_config.rst:583 +#: ../../c-api/init_config.rst:603 msgid ":data:`sys.base_exec_prefix`." msgstr ":data:`sys.base_exec_prefix`。" -#: ../../c-api/init_config.rst:587 ../../c-api/init_config.rst:599 -#: ../../c-api/init_config.rst:607 ../../c-api/init_config.rst:715 -#: ../../c-api/init_config.rst:724 ../../c-api/init_config.rst:958 -#: ../../c-api/init_config.rst:1044 +#: ../../c-api/init_config.rst:607 ../../c-api/init_config.rst:621 +#: ../../c-api/init_config.rst:631 ../../c-api/init_config.rst:741 +#: ../../c-api/init_config.rst:752 ../../c-api/init_config.rst:999 +#: ../../c-api/init_config.rst:1085 msgid "Part of the :ref:`Python Path Configuration ` output." msgstr "" -#: ../../c-api/init_config.rst:591 +#: ../../c-api/init_config.rst:609 +msgid "See also :c:member:`PyConfig.exec_prefix`." +msgstr "也請見 :c:member:`PyConfig.exec_prefix`" + +#: ../../c-api/init_config.rst:613 msgid "Python base executable: :data:`sys._base_executable`." msgstr "" -#: ../../c-api/init_config.rst:593 +#: ../../c-api/init_config.rst:615 msgid "Set by the :envvar:`__PYVENV_LAUNCHER__` environment variable." msgstr "" -#: ../../c-api/init_config.rst:595 +#: ../../c-api/init_config.rst:617 msgid "Set from :c:member:`PyConfig.executable` if ``NULL``." msgstr "" -#: ../../c-api/init_config.rst:603 +#: ../../c-api/init_config.rst:623 +msgid "See also :c:member:`PyConfig.executable`." +msgstr "也請見 :c:member:`PyConfig.executable`" + +#: ../../c-api/init_config.rst:627 msgid ":data:`sys.base_prefix`." msgstr ":data:`sys.base_prefix`。" -#: ../../c-api/init_config.rst:611 +#: ../../c-api/init_config.rst:633 +msgid "See also :c:member:`PyConfig.prefix`." +msgstr "也請見 :c:member:`PyConfig.prefix`" + +#: ../../c-api/init_config.rst:637 msgid "" "If equals to ``0`` and :c:member:`~PyConfig.configure_c_stdio` is non-zero, " "disable buffering on the C streams stdout and stderr." msgstr "" -#: ../../c-api/init_config.rst:614 +#: ../../c-api/init_config.rst:640 msgid "" "Set to ``0`` by the :option:`-u` command line option and the :envvar:" "`PYTHONUNBUFFERED` environment variable." msgstr "" -#: ../../c-api/init_config.rst:617 +#: ../../c-api/init_config.rst:643 msgid "stdin is always opened in buffered mode." msgstr "" -#: ../../c-api/init_config.rst:619 ../../c-api/init_config.rst:652 -#: ../../c-api/init_config.rst:1140 ../../c-api/init_config.rst:1271 +#: ../../c-api/init_config.rst:645 ../../c-api/init_config.rst:678 +#: ../../c-api/init_config.rst:1197 ../../c-api/init_config.rst:1330 msgid "Default: ``1``." msgstr "預設值:``1``。" -#: ../../c-api/init_config.rst:623 +#: ../../c-api/init_config.rst:649 msgid "" "If equals to ``1``, issue a warning when comparing :class:`bytes` or :class:" "`bytearray` with :class:`str`, or comparing :class:`bytes` with :class:`int`." msgstr "" -#: ../../c-api/init_config.rst:627 +#: ../../c-api/init_config.rst:653 msgid "" "If equal or greater to ``2``, raise a :exc:`BytesWarning` exception in these " "cases." msgstr "" -#: ../../c-api/init_config.rst:630 +#: ../../c-api/init_config.rst:656 msgid "Incremented by the :option:`-b` command line option." msgstr "" -#: ../../c-api/init_config.rst:636 +#: ../../c-api/init_config.rst:662 msgid "" "If non-zero, emit a :exc:`EncodingWarning` warning when :class:`io." "TextIOWrapper` uses its default encoding. See :ref:`io-encoding-warning` for " "details." msgstr "" -#: ../../c-api/init_config.rst:645 +#: ../../c-api/init_config.rst:671 msgid "" "If equals to ``0``, disables the inclusion of the end line and column " "mappings in code objects. Also disables traceback printing carets to " "specific error locations." msgstr "" -#: ../../c-api/init_config.rst:649 +#: ../../c-api/init_config.rst:675 msgid "" "Set to ``0`` by the :envvar:`PYTHONNODEBUGRANGES` environment variable and " "by the :option:`-X no_debug_ranges <-X>` command line option." msgstr "" -#: ../../c-api/init_config.rst:658 +#: ../../c-api/init_config.rst:684 msgid "" "Control the validation behavior of hash-based ``.pyc`` files: value of the :" "option:`--check-hash-based-pycs` command line option." msgstr "" -#: ../../c-api/init_config.rst:661 +#: ../../c-api/init_config.rst:687 msgid "Valid values:" msgstr "" -#: ../../c-api/init_config.rst:663 +#: ../../c-api/init_config.rst:689 msgid "" "``L\"always\"``: Hash the source file for invalidation regardless of value " "of the 'check_source' flag." msgstr "" -#: ../../c-api/init_config.rst:665 +#: ../../c-api/init_config.rst:691 msgid "``L\"never\"``: Assume that hash-based pycs always are valid." msgstr "" -#: ../../c-api/init_config.rst:666 +#: ../../c-api/init_config.rst:692 msgid "" "``L\"default\"``: The 'check_source' flag in hash-based pycs determines " "invalidation." msgstr "" -#: ../../c-api/init_config.rst:669 +#: ../../c-api/init_config.rst:695 msgid "Default: ``L\"default\"``." msgstr "預設:``L\"default\"``。" -#: ../../c-api/init_config.rst:671 +#: ../../c-api/init_config.rst:697 msgid "See also :pep:`552` \"Deterministic pycs\"." msgstr "" -#: ../../c-api/init_config.rst:675 +#: ../../c-api/init_config.rst:701 msgid "If non-zero, configure C standard streams:" msgstr "" -#: ../../c-api/init_config.rst:677 +#: ../../c-api/init_config.rst:703 msgid "" "On Windows, set the binary mode (``O_BINARY``) on stdin, stdout and stderr." msgstr "" -#: ../../c-api/init_config.rst:679 +#: ../../c-api/init_config.rst:705 msgid "" "If :c:member:`~PyConfig.buffered_stdio` equals zero, disable buffering of " "stdin, stdout and stderr streams." msgstr "" -#: ../../c-api/init_config.rst:681 +#: ../../c-api/init_config.rst:707 msgid "" "If :c:member:`~PyConfig.interactive` is non-zero, enable stream buffering on " "stdin and stdout (only stdout on Windows)." msgstr "" -#: ../../c-api/init_config.rst:688 +#: ../../c-api/init_config.rst:714 msgid "If non-zero, enable the :ref:`Python Development Mode `." msgstr "" -#: ../../c-api/init_config.rst:690 +#: ../../c-api/init_config.rst:716 msgid "" "Set to ``1`` by the :option:`-X dev <-X>` option and the :envvar:" "`PYTHONDEVMODE` environment variable." msgstr "" -#: ../../c-api/init_config.rst:697 +#: ../../c-api/init_config.rst:723 msgid "Dump Python references?" msgstr "" -#: ../../c-api/init_config.rst:699 +#: ../../c-api/init_config.rst:725 msgid "If non-zero, dump all objects which are still alive at exit." msgstr "" -#: ../../c-api/init_config.rst:701 +#: ../../c-api/init_config.rst:727 msgid "Set to ``1`` by the :envvar:`PYTHONDUMPREFS` environment variable." msgstr "" -#: ../../c-api/init_config.rst:703 +#: ../../c-api/init_config.rst:729 msgid "" -"Need a special build of Python with the ``Py_TRACE_REFS`` macro defined: see " -"the :option:`configure --with-trace-refs option <--with-trace-refs>`." +"Needs a special build of Python with the ``Py_TRACE_REFS`` macro defined: " +"see the :option:`configure --with-trace-refs option <--with-trace-refs>`." msgstr "" -#: ../../c-api/init_config.rst:710 +#: ../../c-api/init_config.rst:736 msgid "" "The site-specific directory prefix where the platform-dependent Python files " "are installed: :data:`sys.exec_prefix`." msgstr "" -#: ../../c-api/init_config.rst:719 +#: ../../c-api/init_config.rst:743 +msgid "See also :c:member:`PyConfig.base_exec_prefix`." +msgstr "也請見 :c:member:`PyConfig.base_exec_prefix`" + +#: ../../c-api/init_config.rst:747 msgid "" "The absolute path of the executable binary for the Python interpreter: :data:" "`sys.executable`." msgstr "" -#: ../../c-api/init_config.rst:728 +#: ../../c-api/init_config.rst:754 +msgid "See also :c:member:`PyConfig.base_executable`." +msgstr "也請見 :c:member:`PyConfig.base_executable`" + +#: ../../c-api/init_config.rst:758 msgid "Enable faulthandler?" msgstr "" -#: ../../c-api/init_config.rst:730 +#: ../../c-api/init_config.rst:760 msgid "If non-zero, call :func:`faulthandler.enable` at startup." msgstr "" -#: ../../c-api/init_config.rst:732 +#: ../../c-api/init_config.rst:762 msgid "" "Set to ``1`` by :option:`-X faulthandler <-X>` and the :envvar:" "`PYTHONFAULTHANDLER` environment variable." msgstr "" -#: ../../c-api/init_config.rst:739 +#: ../../c-api/init_config.rst:769 msgid "" ":term:`Filesystem encoding `: :func:" "`sys.getfilesystemencoding`." msgstr "" -#: ../../c-api/init_config.rst:742 +#: ../../c-api/init_config.rst:772 msgid "On macOS, Android and VxWorks: use ``\"utf-8\"`` by default." msgstr "" -#: ../../c-api/init_config.rst:744 +#: ../../c-api/init_config.rst:774 msgid "" "On Windows: use ``\"utf-8\"`` by default, or ``\"mbcs\"`` if :c:member:" "`~PyPreConfig.legacy_windows_fs_encoding` of :c:type:`PyPreConfig` is non-" "zero." msgstr "" -#: ../../c-api/init_config.rst:748 +#: ../../c-api/init_config.rst:778 msgid "Default encoding on other platforms:" msgstr "" -#: ../../c-api/init_config.rst:750 +#: ../../c-api/init_config.rst:780 msgid "``\"utf-8\"`` if :c:member:`PyPreConfig.utf8_mode` is non-zero." msgstr "" -#: ../../c-api/init_config.rst:751 +#: ../../c-api/init_config.rst:781 msgid "" "``\"ascii\"`` if Python detects that ``nl_langinfo(CODESET)`` announces the " "ASCII encoding, whereas the ``mbstowcs()`` function decodes from a different " "encoding (usually Latin1)." msgstr "" -#: ../../c-api/init_config.rst:754 +#: ../../c-api/init_config.rst:784 msgid "``\"utf-8\"`` if ``nl_langinfo(CODESET)`` returns an empty string." msgstr "" -#: ../../c-api/init_config.rst:755 +#: ../../c-api/init_config.rst:785 msgid "" "Otherwise, use the :term:`locale encoding`: ``nl_langinfo(CODESET)`` result." msgstr "" -#: ../../c-api/init_config.rst:758 +#: ../../c-api/init_config.rst:788 msgid "" "At Python startup, the encoding name is normalized to the Python codec name. " "For example, ``\"ANSI_X3.4-1968\"`` is replaced with ``\"ascii\"``." msgstr "" -#: ../../c-api/init_config.rst:761 +#: ../../c-api/init_config.rst:791 msgid "See also the :c:member:`~PyConfig.filesystem_errors` member." -msgstr "" +msgstr "另請參閱 :c:member:`~PyConfig.filesystem_errors` 成員。" -#: ../../c-api/init_config.rst:765 +#: ../../c-api/init_config.rst:795 msgid "" ":term:`Filesystem error handler `: :" "func:`sys.getfilesystemencodeerrors`." msgstr "" -#: ../../c-api/init_config.rst:768 +#: ../../c-api/init_config.rst:798 msgid "" "On Windows: use ``\"surrogatepass\"`` by default, or ``\"replace\"`` if :c:" "member:`~PyPreConfig.legacy_windows_fs_encoding` of :c:type:`PyPreConfig` is " "non-zero." msgstr "" -#: ../../c-api/init_config.rst:772 +#: ../../c-api/init_config.rst:802 msgid "On other platforms: use ``\"surrogateescape\"`` by default." msgstr "" -#: ../../c-api/init_config.rst:774 +#: ../../c-api/init_config.rst:804 msgid "Supported error handlers:" msgstr "" -#: ../../c-api/init_config.rst:776 +#: ../../c-api/init_config.rst:806 msgid "``\"strict\"``" msgstr "``\"strict\"``" -#: ../../c-api/init_config.rst:777 +#: ../../c-api/init_config.rst:807 msgid "``\"surrogateescape\"``" msgstr "``\"surrogateescape\"``" -#: ../../c-api/init_config.rst:778 +#: ../../c-api/init_config.rst:808 msgid "``\"surrogatepass\"`` (only supported with the UTF-8 encoding)" -msgstr "" +msgstr "``\"surrogatepass\"``\\ (僅支援 UTF-8 編碼)" -#: ../../c-api/init_config.rst:780 +#: ../../c-api/init_config.rst:810 msgid "See also the :c:member:`~PyConfig.filesystem_encoding` member." -msgstr "" +msgstr "另請參閱 :c:member:`~PyConfig.filesystem_encoding` 成員。" -#: ../../c-api/init_config.rst:785 +#: ../../c-api/init_config.rst:815 msgid "Randomized hash function seed." msgstr "" -#: ../../c-api/init_config.rst:787 +#: ../../c-api/init_config.rst:817 msgid "" "If :c:member:`~PyConfig.use_hash_seed` is zero, a seed is chosen randomly at " "Python startup, and :c:member:`~PyConfig.hash_seed` is ignored." msgstr "" -#: ../../c-api/init_config.rst:790 +#: ../../c-api/init_config.rst:820 msgid "Set by the :envvar:`PYTHONHASHSEED` environment variable." -msgstr "" +msgstr "由 :envvar:`PYTHONHASHSEED` 環境變數設定。" -#: ../../c-api/init_config.rst:792 +#: ../../c-api/init_config.rst:822 msgid "" "Default *use_hash_seed* value: ``-1`` in Python mode, ``0`` in isolated mode." msgstr "" -#: ../../c-api/init_config.rst:797 -msgid "Python home directory." -msgstr "" - -#: ../../c-api/init_config.rst:799 +#: ../../c-api/init_config.rst:827 msgid "" -"If :c:func:`Py_SetPythonHome` has been called, use its argument if it is not " -"``NULL``." +"Set the default Python \"home\" directory, that is, the location of the " +"standard Python libraries (see :envvar:`PYTHONHOME`)." msgstr "" -#: ../../c-api/init_config.rst:802 +#: ../../c-api/init_config.rst:830 msgid "Set by the :envvar:`PYTHONHOME` environment variable." -msgstr "" +msgstr "由 :envvar:`PYTHONHOME` 環境變數設定。" -#: ../../c-api/init_config.rst:806 ../../c-api/init_config.rst:923 -#: ../../c-api/init_config.rst:943 ../../c-api/init_config.rst:1032 -#: ../../c-api/init_config.rst:1062 +#: ../../c-api/init_config.rst:834 ../../c-api/init_config.rst:964 +#: ../../c-api/init_config.rst:984 ../../c-api/init_config.rst:1073 +#: ../../c-api/init_config.rst:1104 msgid "Part of the :ref:`Python Path Configuration ` input." msgstr "" -#: ../../c-api/init_config.rst:810 +#: ../../c-api/init_config.rst:838 msgid "If non-zero, profile import time." msgstr "" -#: ../../c-api/init_config.rst:812 +#: ../../c-api/init_config.rst:840 msgid "" "Set the ``1`` by the :option:`-X importtime <-X>` option and the :envvar:" "`PYTHONPROFILEIMPORTTIME` environment variable." msgstr "" -#: ../../c-api/init_config.rst:819 +#: ../../c-api/init_config.rst:847 msgid "Enter interactive mode after executing a script or a command." msgstr "" -#: ../../c-api/init_config.rst:821 +#: ../../c-api/init_config.rst:849 msgid "" "If greater than ``0``, enable inspect: when a script is passed as first " "argument or the -c option is used, enter interactive mode after executing " @@ -1162,30 +1204,30 @@ msgid "" "a terminal." msgstr "" -#: ../../c-api/init_config.rst:826 +#: ../../c-api/init_config.rst:854 msgid "" "Incremented by the :option:`-i` command line option. Set to ``1`` if the :" "envvar:`PYTHONINSPECT` environment variable is non-empty." msgstr "" -#: ../../c-api/init_config.rst:833 +#: ../../c-api/init_config.rst:861 msgid "Install Python signal handlers?" msgstr "" -#: ../../c-api/init_config.rst:835 ../../c-api/init_config.rst:1006 -#: ../../c-api/init_config.rst:1030 ../../c-api/init_config.rst:1223 +#: ../../c-api/init_config.rst:863 ../../c-api/init_config.rst:1047 +#: ../../c-api/init_config.rst:1071 ../../c-api/init_config.rst:1282 msgid "Default: ``1`` in Python mode, ``0`` in isolated mode." msgstr "" -#: ../../c-api/init_config.rst:839 +#: ../../c-api/init_config.rst:867 msgid "If greater than ``0``, enable the interactive mode (REPL)." msgstr "" -#: ../../c-api/init_config.rst:841 +#: ../../c-api/init_config.rst:869 msgid "Incremented by the :option:`-i` command line option." msgstr "" -#: ../../c-api/init_config.rst:847 +#: ../../c-api/init_config.rst:875 msgid "" "Configures the :ref:`integer string conversion length limitation " "`. An initial value of ``-1`` means the value will be " @@ -1195,30 +1237,47 @@ msgid "" "str_digits_check_threshold`) are unsupported and will produce an error." msgstr "" -#: ../../c-api/init_config.rst:855 +#: ../../c-api/init_config.rst:883 msgid "" "Configured by the :option:`-X int_max_str_digits <-X>` command line flag or " "the :envvar:`PYTHONINTMAXSTRDIGITS` environment variable." msgstr "" -#: ../../c-api/init_config.rst:858 +#: ../../c-api/init_config.rst:886 msgid "" "Default: ``-1`` in Python mode. 4300 (:data:`sys.int_info." "default_max_str_digits`) in isolated mode." msgstr "" -#: ../../c-api/init_config.rst:865 +#: ../../c-api/init_config.rst:893 +msgid "" +"If the value of :c:member:`~PyConfig.cpu_count` is not ``-1`` then it will " +"override the return values of :func:`os.cpu_count`, :func:`os." +"process_cpu_count`, and :func:`multiprocessing.cpu_count`." +msgstr "" + +#: ../../c-api/init_config.rst:897 +msgid "" +"Configured by the :samp:`-X cpu_count={n|default}` command line flag or the :" +"envvar:`PYTHON_CPU_COUNT` environment variable." +msgstr "" + +#: ../../c-api/init_config.rst:900 ../../c-api/init_config.rst:1259 +msgid "Default: ``-1``." +msgstr "預設值:``1``。" + +#: ../../c-api/init_config.rst:906 msgid "If greater than ``0``, enable isolated mode:" msgstr "" -#: ../../c-api/init_config.rst:867 +#: ../../c-api/init_config.rst:908 msgid "" "Set :c:member:`~PyConfig.safe_path` to ``1``: don't prepend a potentially " "unsafe path to :data:`sys.path` at Python startup, such as the current " "directory, the script's directory or an empty string." msgstr "" -#: ../../c-api/init_config.rst:871 +#: ../../c-api/init_config.rst:912 msgid "" "Set :c:member:`~PyConfig.use_environment` to ``0``: ignore ``PYTHON`` " "environment variables." @@ -1226,77 +1285,77 @@ msgstr "" "將 :c:member:`~PyConfig.use_environment` 設定為 ``0``:忽略 ``PYTHON`` 環境變" "數。" -#: ../../c-api/init_config.rst:873 +#: ../../c-api/init_config.rst:914 msgid "" "Set :c:member:`~PyConfig.user_site_directory` to ``0``: don't add the user " "site directory to :data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:875 +#: ../../c-api/init_config.rst:916 msgid "" "Python REPL doesn't import :mod:`readline` nor enable default readline " "configuration on interactive prompts." msgstr "" -#: ../../c-api/init_config.rst:878 +#: ../../c-api/init_config.rst:919 msgid "Set to ``1`` by the :option:`-I` command line option." msgstr "" -#: ../../c-api/init_config.rst:882 +#: ../../c-api/init_config.rst:923 msgid "" "See also the :ref:`Isolated Configuration ` and :c:" "member:`PyPreConfig.isolated`." msgstr "" -#: ../../c-api/init_config.rst:887 +#: ../../c-api/init_config.rst:928 msgid "" "If non-zero, use :class:`io.FileIO` instead of :class:`!io." "_WindowsConsoleIO` for :data:`sys.stdin`, :data:`sys.stdout` and :data:`sys." "stderr`." msgstr "" -#: ../../c-api/init_config.rst:891 +#: ../../c-api/init_config.rst:932 msgid "" "Set to ``1`` if the :envvar:`PYTHONLEGACYWINDOWSSTDIO` environment variable " "is set to a non-empty string." msgstr "" -#: ../../c-api/init_config.rst:899 +#: ../../c-api/init_config.rst:940 msgid "See also the :pep:`528` (Change Windows console encoding to UTF-8)." msgstr "" -#: ../../c-api/init_config.rst:903 +#: ../../c-api/init_config.rst:944 msgid "" "If non-zero, dump statistics on :ref:`Python pymalloc memory allocator " "` at exit." msgstr "" -#: ../../c-api/init_config.rst:906 +#: ../../c-api/init_config.rst:947 msgid "Set to ``1`` by the :envvar:`PYTHONMALLOCSTATS` environment variable." msgstr "" -#: ../../c-api/init_config.rst:908 +#: ../../c-api/init_config.rst:949 msgid "" "The option is ignored if Python is :option:`configured using the --without-" "pymalloc option <--without-pymalloc>`." msgstr "" -#: ../../c-api/init_config.rst:915 +#: ../../c-api/init_config.rst:956 msgid "Platform library directory name: :data:`sys.platlibdir`." msgstr "" -#: ../../c-api/init_config.rst:917 +#: ../../c-api/init_config.rst:958 msgid "Set by the :envvar:`PYTHONPLATLIBDIR` environment variable." msgstr "" -#: ../../c-api/init_config.rst:919 +#: ../../c-api/init_config.rst:960 msgid "" "Default: value of the ``PLATLIBDIR`` macro which is set by the :option:" "`configure --with-platlibdir option <--with-platlibdir>` (default: " "``\"lib\"``, or ``\"DLLs\"`` on Windows)." msgstr "" -#: ../../c-api/init_config.rst:927 +#: ../../c-api/init_config.rst:968 msgid "" "This macro is now used on Windows to locate the standard library extension " "modules, typically under ``DLLs``. However, for compatibility, note that " @@ -1304,21 +1363,21 @@ msgid "" "and virtual environments." msgstr "" -#: ../../c-api/init_config.rst:936 +#: ../../c-api/init_config.rst:977 msgid "" "Module search paths (:data:`sys.path`) as a string separated by ``DELIM`` (:" "data:`os.pathsep`)." msgstr "" -#: ../../c-api/init_config.rst:939 +#: ../../c-api/init_config.rst:980 msgid "Set by the :envvar:`PYTHONPATH` environment variable." msgstr "" -#: ../../c-api/init_config.rst:948 +#: ../../c-api/init_config.rst:989 msgid "Module search paths: :data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:950 +#: ../../c-api/init_config.rst:991 msgid "" "If :c:member:`~PyConfig.module_search_paths_set` is equal to ``0``, :c:func:" "`Py_InitializeFromConfig` will replace :c:member:`~PyConfig." @@ -1326,41 +1385,41 @@ msgid "" "to ``1``." msgstr "" -#: ../../c-api/init_config.rst:955 +#: ../../c-api/init_config.rst:996 msgid "" "Default: empty list (``module_search_paths``) and ``0`` " "(``module_search_paths_set``)." msgstr "" -#: ../../c-api/init_config.rst:962 +#: ../../c-api/init_config.rst:1003 msgid "Compilation optimization level:" msgstr "" -#: ../../c-api/init_config.rst:964 +#: ../../c-api/init_config.rst:1005 msgid "``0``: Peephole optimizer, set ``__debug__`` to ``True``." msgstr "" -#: ../../c-api/init_config.rst:965 +#: ../../c-api/init_config.rst:1006 msgid "``1``: Level 0, remove assertions, set ``__debug__`` to ``False``." msgstr "" -#: ../../c-api/init_config.rst:966 +#: ../../c-api/init_config.rst:1007 msgid "``2``: Level 1, strip docstrings." msgstr "" -#: ../../c-api/init_config.rst:968 +#: ../../c-api/init_config.rst:1009 msgid "" "Incremented by the :option:`-O` command line option. Set to the :envvar:" "`PYTHONOPTIMIZE` environment variable value." msgstr "" -#: ../../c-api/init_config.rst:975 +#: ../../c-api/init_config.rst:1016 msgid "" "The list of the original command line arguments passed to the Python " "executable: :data:`sys.orig_argv`." msgstr "" -#: ../../c-api/init_config.rst:978 +#: ../../c-api/init_config.rst:1019 msgid "" "If :c:member:`~PyConfig.orig_argv` list is empty and :c:member:`~PyConfig." "argv` is not a list only containing an empty string, :c:func:`PyConfig_Read` " @@ -1369,388 +1428,400 @@ msgid "" "parse_argv` is non-zero)." msgstr "" -#: ../../c-api/init_config.rst:985 +#: ../../c-api/init_config.rst:1026 msgid "" "See also the :c:member:`~PyConfig.argv` member and the :c:func:" "`Py_GetArgcArgv` function." msgstr "" -#: ../../c-api/init_config.rst:988 ../../c-api/init_config.rst:1258 -#: ../../c-api/init_config.rst:1277 +#: ../../c-api/init_config.rst:1029 ../../c-api/init_config.rst:1317 +#: ../../c-api/init_config.rst:1336 msgid "Default: empty list." msgstr "" -#: ../../c-api/init_config.rst:994 +#: ../../c-api/init_config.rst:1035 msgid "Parse command line arguments?" msgstr "" -#: ../../c-api/init_config.rst:996 +#: ../../c-api/init_config.rst:1037 msgid "" "If equals to ``1``, parse :c:member:`~PyConfig.argv` the same way the " "regular Python parses :ref:`command line arguments `, and " "strip Python arguments from :c:member:`~PyConfig.argv`." msgstr "" -#: ../../c-api/init_config.rst:1008 +#: ../../c-api/init_config.rst:1049 msgid "" "The :c:member:`PyConfig.argv` arguments are now only parsed if :c:member:" "`PyConfig.parse_argv` equals to ``1``." msgstr "" -#: ../../c-api/init_config.rst:1014 +#: ../../c-api/init_config.rst:1055 msgid "" "Parser debug mode. If greater than ``0``, turn on parser debugging output " "(for expert only, depending on compilation options)." msgstr "" -#: ../../c-api/init_config.rst:1017 +#: ../../c-api/init_config.rst:1058 msgid "" "Incremented by the :option:`-d` command line option. Set to the :envvar:" "`PYTHONDEBUG` environment variable value." msgstr "" -#: ../../c-api/init_config.rst:1020 +#: ../../c-api/init_config.rst:1061 ../../c-api/init_config.rst:1166 msgid "" -"Need a :ref:`debug build of Python ` (the ``Py_DEBUG`` macro " +"Needs a :ref:`debug build of Python ` (the ``Py_DEBUG`` macro " "must be defined)." msgstr "" -#: ../../c-api/init_config.rst:1027 +#: ../../c-api/init_config.rst:1068 msgid "" "If non-zero, calculation of path configuration is allowed to log warnings " "into ``stderr``. If equals to ``0``, suppress these warnings." msgstr "" -#: ../../c-api/init_config.rst:1034 +#: ../../c-api/init_config.rst:1075 msgid "Now also applies on Windows." msgstr "" -#: ../../c-api/init_config.rst:1039 +#: ../../c-api/init_config.rst:1080 msgid "" "The site-specific directory prefix where the platform independent Python " "files are installed: :data:`sys.prefix`." msgstr "" -#: ../../c-api/init_config.rst:1048 +#: ../../c-api/init_config.rst:1087 +msgid "See also :c:member:`PyConfig.base_prefix`." +msgstr "也請見 :c:member:`PyConfig.base_prefix`" + +#: ../../c-api/init_config.rst:1091 msgid "" "Program name used to initialize :c:member:`~PyConfig.executable` and in " "early error messages during Python initialization." msgstr "" -#: ../../c-api/init_config.rst:1051 -msgid "If :func:`Py_SetProgramName` has been called, use its argument." -msgstr "" - -#: ../../c-api/init_config.rst:1052 +#: ../../c-api/init_config.rst:1094 msgid "On macOS, use :envvar:`PYTHONEXECUTABLE` environment variable if set." msgstr "" -#: ../../c-api/init_config.rst:1053 +#: ../../c-api/init_config.rst:1095 msgid "" "If the ``WITH_NEXT_FRAMEWORK`` macro is defined, use :envvar:" "`__PYVENV_LAUNCHER__` environment variable if set." msgstr "" -#: ../../c-api/init_config.rst:1055 +#: ../../c-api/init_config.rst:1097 msgid "" "Use ``argv[0]`` of :c:member:`~PyConfig.argv` if available and non-empty." msgstr "" -#: ../../c-api/init_config.rst:1057 +#: ../../c-api/init_config.rst:1099 msgid "" "Otherwise, use ``L\"python\"`` on Windows, or ``L\"python3\"`` on other " "platforms." msgstr "" -#: ../../c-api/init_config.rst:1066 +#: ../../c-api/init_config.rst:1108 msgid "" "Directory where cached ``.pyc`` files are written: :data:`sys." "pycache_prefix`." msgstr "" -#: ../../c-api/init_config.rst:1069 +#: ../../c-api/init_config.rst:1111 msgid "" "Set by the :option:`-X pycache_prefix=PATH <-X>` command line option and " -"the :envvar:`PYTHONPYCACHEPREFIX` environment variable." +"the :envvar:`PYTHONPYCACHEPREFIX` environment variable. The command-line " +"option takes precedence." msgstr "" -#: ../../c-api/init_config.rst:1072 +#: ../../c-api/init_config.rst:1115 msgid "If ``NULL``, :data:`sys.pycache_prefix` is set to ``None``." msgstr "" -#: ../../c-api/init_config.rst:1078 +#: ../../c-api/init_config.rst:1121 msgid "" "Quiet mode. If greater than ``0``, don't display the copyright and version " "at Python startup in interactive mode." msgstr "" -#: ../../c-api/init_config.rst:1081 +#: ../../c-api/init_config.rst:1124 msgid "Incremented by the :option:`-q` command line option." msgstr "" -#: ../../c-api/init_config.rst:1087 +#: ../../c-api/init_config.rst:1130 msgid "Value of the :option:`-c` command line option." msgstr "" -#: ../../c-api/init_config.rst:1089 ../../c-api/init_config.rst:1110 +#: ../../c-api/init_config.rst:1132 ../../c-api/init_config.rst:1153 msgid "Used by :c:func:`Py_RunMain`." msgstr "" -#: ../../c-api/init_config.rst:1095 +#: ../../c-api/init_config.rst:1138 msgid "" "Filename passed on the command line: trailing command line argument without :" "option:`-c` or :option:`-m`. It is used by the :c:func:`Py_RunMain` function." msgstr "" -#: ../../c-api/init_config.rst:1099 +#: ../../c-api/init_config.rst:1142 msgid "" "For example, it is set to ``script.py`` by the ``python3 script.py arg`` " "command line." msgstr "" -#: ../../c-api/init_config.rst:1102 +#: ../../c-api/init_config.rst:1145 msgid "See also the :c:member:`PyConfig.skip_source_first_line` option." msgstr "也請見 :c:member:`PyConfig.skip_source_first_line` 選項。" -#: ../../c-api/init_config.rst:1108 +#: ../../c-api/init_config.rst:1151 msgid "Value of the :option:`-m` command line option." msgstr "" -#: ../../c-api/init_config.rst:1116 -msgid "Show total reference count at exit (excluding immortal objects)?" +#: ../../c-api/init_config.rst:1159 +msgid "" +"``package.module`` path to module that should be imported before ``site.py`` " +"is run." +msgstr "" + +#: ../../c-api/init_config.rst:1162 +msgid "" +"Set by the :option:`-X presite=package.module <-X>` command-line option and " +"the :envvar:`PYTHON_PRESITE` environment variable. The command-line option " +"takes precedence." +msgstr "" + +#: ../../c-api/init_config.rst:1173 +msgid "" +"Show total reference count at exit (excluding :term:`immortal` objects)?" msgstr "" -#: ../../c-api/init_config.rst:1118 +#: ../../c-api/init_config.rst:1175 msgid "Set to ``1`` by :option:`-X showrefcount <-X>` command line option." msgstr "" -#: ../../c-api/init_config.rst:1120 +#: ../../c-api/init_config.rst:1177 msgid "" -"Need a :ref:`debug build of Python ` (the ``Py_REF_DEBUG`` " +"Needs a :ref:`debug build of Python ` (the ``Py_REF_DEBUG`` " "macro must be defined)." msgstr "" -#: ../../c-api/init_config.rst:1127 +#: ../../c-api/init_config.rst:1184 msgid "Import the :mod:`site` module at startup?" msgstr "" -#: ../../c-api/init_config.rst:1129 +#: ../../c-api/init_config.rst:1186 msgid "" "If equal to zero, disable the import of the module site and the site-" "dependent manipulations of :data:`sys.path` that it entails." msgstr "" -#: ../../c-api/init_config.rst:1132 +#: ../../c-api/init_config.rst:1189 msgid "" "Also disable these manipulations if the :mod:`site` module is explicitly " "imported later (call :func:`site.main` if you want them to be triggered)." msgstr "" -#: ../../c-api/init_config.rst:1135 +#: ../../c-api/init_config.rst:1192 msgid "Set to ``0`` by the :option:`-S` command line option." msgstr "" -#: ../../c-api/init_config.rst:1137 +#: ../../c-api/init_config.rst:1194 msgid "" ":data:`sys.flags.no_site ` is set to the inverted value of :c:" "member:`~PyConfig.site_import`." msgstr "" -#: ../../c-api/init_config.rst:1144 +#: ../../c-api/init_config.rst:1201 msgid "" "If non-zero, skip the first line of the :c:member:`PyConfig.run_filename` " "source." msgstr "" -#: ../../c-api/init_config.rst:1147 +#: ../../c-api/init_config.rst:1204 msgid "" "It allows the usage of non-Unix forms of ``#!cmd``. This is intended for a " "DOS specific hack only." msgstr "" -#: ../../c-api/init_config.rst:1150 +#: ../../c-api/init_config.rst:1207 msgid "Set to ``1`` by the :option:`-x` command line option." msgstr "" -#: ../../c-api/init_config.rst:1157 +#: ../../c-api/init_config.rst:1214 msgid "" "Encoding and encoding errors of :data:`sys.stdin`, :data:`sys.stdout` and :" "data:`sys.stderr` (but :data:`sys.stderr` always uses " "``\"backslashreplace\"`` error handler)." msgstr "" -#: ../../c-api/init_config.rst:1161 -msgid "" -"If :c:func:`Py_SetStandardStreamEncoding` has been called, use its *error* " -"and *errors* arguments if they are not ``NULL``." -msgstr "" - -#: ../../c-api/init_config.rst:1164 +#: ../../c-api/init_config.rst:1218 msgid "" "Use the :envvar:`PYTHONIOENCODING` environment variable if it is non-empty." msgstr "" -#: ../../c-api/init_config.rst:1167 +#: ../../c-api/init_config.rst:1221 msgid "Default encoding:" msgstr "" -#: ../../c-api/init_config.rst:1169 +#: ../../c-api/init_config.rst:1223 msgid "``\"UTF-8\"`` if :c:member:`PyPreConfig.utf8_mode` is non-zero." msgstr "" -#: ../../c-api/init_config.rst:1170 +#: ../../c-api/init_config.rst:1224 msgid "Otherwise, use the :term:`locale encoding`." msgstr "" -#: ../../c-api/init_config.rst:1172 +#: ../../c-api/init_config.rst:1226 msgid "Default error handler:" msgstr "" -#: ../../c-api/init_config.rst:1174 +#: ../../c-api/init_config.rst:1228 msgid "On Windows: use ``\"surrogateescape\"``." msgstr "" -#: ../../c-api/init_config.rst:1175 +#: ../../c-api/init_config.rst:1229 msgid "" "``\"surrogateescape\"`` if :c:member:`PyPreConfig.utf8_mode` is non-zero, or " "if the LC_CTYPE locale is \"C\" or \"POSIX\"." msgstr "" -#: ../../c-api/init_config.rst:1177 +#: ../../c-api/init_config.rst:1231 msgid "``\"strict\"`` otherwise." msgstr "" -#: ../../c-api/init_config.rst:1181 +#: ../../c-api/init_config.rst:1233 +msgid "See also :c:member:`PyConfig.legacy_windows_stdio`." +msgstr "也請見 :c:member:`PyConfig.legacy_windows_stdio`。" + +#: ../../c-api/init_config.rst:1237 msgid "Enable tracemalloc?" msgstr "" -#: ../../c-api/init_config.rst:1183 +#: ../../c-api/init_config.rst:1239 msgid "If non-zero, call :func:`tracemalloc.start` at startup." msgstr "" -#: ../../c-api/init_config.rst:1185 +#: ../../c-api/init_config.rst:1241 msgid "" "Set by :option:`-X tracemalloc=N <-X>` command line option and by the :" "envvar:`PYTHONTRACEMALLOC` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1192 +#: ../../c-api/init_config.rst:1248 msgid "Enable compatibility mode with the perf profiler?" msgstr "" -#: ../../c-api/init_config.rst:1194 +#: ../../c-api/init_config.rst:1250 msgid "" "If non-zero, initialize the perf trampoline. See :ref:`perf_profiling` for " "more information." msgstr "" -#: ../../c-api/init_config.rst:1197 +#: ../../c-api/init_config.rst:1253 msgid "" -"Set by :option:`-X perf <-X>` command line option and by the :envvar:" -"`PYTHONPERFSUPPORT` environment variable." +"Set by :option:`-X perf <-X>` command-line option and by the :envvar:" +"`PYTHON_PERF_JIT_SUPPORT` environment variable for perf support with stack " +"pointers and :option:`-X perf_jit <-X>` command-line option and by the :" +"envvar:`PYTHON_PERF_JIT_SUPPORT` environment variable for perf support with " +"DWARF JIT information." msgstr "" -#: ../../c-api/init_config.rst:1200 -msgid "Default: ``-1``." -msgstr "預設值:``1``。" - -#: ../../c-api/init_config.rst:1206 +#: ../../c-api/init_config.rst:1265 msgid "Use :ref:`environment variables `?" msgstr "" -#: ../../c-api/init_config.rst:1208 +#: ../../c-api/init_config.rst:1267 msgid "" "If equals to zero, ignore the :ref:`environment variables `." msgstr "" -#: ../../c-api/init_config.rst:1211 +#: ../../c-api/init_config.rst:1270 msgid "Set to ``0`` by the :option:`-E` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1217 +#: ../../c-api/init_config.rst:1276 msgid "If non-zero, add the user site directory to :data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:1219 +#: ../../c-api/init_config.rst:1278 msgid "Set to ``0`` by the :option:`-s` and :option:`-I` command line options." msgstr "" -#: ../../c-api/init_config.rst:1221 +#: ../../c-api/init_config.rst:1280 msgid "Set to ``0`` by the :envvar:`PYTHONNOUSERSITE` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1227 +#: ../../c-api/init_config.rst:1286 msgid "" "Verbose mode. If greater than ``0``, print a message each time a module is " "imported, showing the place (filename or built-in module) from which it is " "loaded." msgstr "" -#: ../../c-api/init_config.rst:1231 +#: ../../c-api/init_config.rst:1290 msgid "" "If greater than or equal to ``2``, print a message for each file that is " "checked for when searching for a module. Also provides information on module " "cleanup at exit." msgstr "" -#: ../../c-api/init_config.rst:1235 +#: ../../c-api/init_config.rst:1294 msgid "Incremented by the :option:`-v` command line option." msgstr "" -#: ../../c-api/init_config.rst:1237 +#: ../../c-api/init_config.rst:1296 msgid "Set by the :envvar:`PYTHONVERBOSE` environment variable value." msgstr "" -#: ../../c-api/init_config.rst:1243 +#: ../../c-api/init_config.rst:1302 msgid "" "Options of the :mod:`warnings` module to build warnings filters, lowest to " "highest priority: :data:`sys.warnoptions`." msgstr "" -#: ../../c-api/init_config.rst:1246 +#: ../../c-api/init_config.rst:1305 msgid "" "The :mod:`warnings` module adds :data:`sys.warnoptions` in the reverse " "order: the last :c:member:`PyConfig.warnoptions` item becomes the first item " "of :data:`warnings.filters` which is checked first (highest priority)." msgstr "" -#: ../../c-api/init_config.rst:1251 +#: ../../c-api/init_config.rst:1310 msgid "" "The :option:`-W` command line options adds its value to :c:member:`~PyConfig." "warnoptions`, it can be used multiple times." msgstr "" -#: ../../c-api/init_config.rst:1254 +#: ../../c-api/init_config.rst:1313 msgid "" "The :envvar:`PYTHONWARNINGS` environment variable can also be used to add " "warning options. Multiple options can be specified, separated by commas (``," "``)." msgstr "" -#: ../../c-api/init_config.rst:1262 +#: ../../c-api/init_config.rst:1321 msgid "" "If equal to ``0``, Python won't try to write ``.pyc`` files on the import of " "source modules." msgstr "" -#: ../../c-api/init_config.rst:1265 +#: ../../c-api/init_config.rst:1324 msgid "" "Set to ``0`` by the :option:`-B` command line option and the :envvar:" "`PYTHONDONTWRITEBYTECODE` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1268 +#: ../../c-api/init_config.rst:1327 msgid "" ":data:`sys.dont_write_bytecode` is initialized to the inverted value of :c:" "member:`~PyConfig.write_bytecode`." msgstr "" -#: ../../c-api/init_config.rst:1275 +#: ../../c-api/init_config.rst:1334 msgid "Values of the :option:`-X` command line options: :data:`sys._xoptions`." msgstr "" -#: ../../c-api/init_config.rst:1279 +#: ../../c-api/init_config.rst:1338 msgid "" "If :c:member:`~PyConfig.parse_argv` is non-zero, :c:member:`~PyConfig.argv` " "arguments are parsed the same way the regular Python parses :ref:`command " @@ -1758,29 +1829,27 @@ msgid "" "c:member:`~PyConfig.argv`." msgstr "" -#: ../../c-api/init_config.rst:1284 +#: ../../c-api/init_config.rst:1343 msgid "" "The :c:member:`~PyConfig.xoptions` options are parsed to set other options: " "see the :option:`-X` command line option." msgstr "" -#: ../../c-api/init_config.rst:1289 +#: ../../c-api/init_config.rst:1348 msgid "The ``show_alloc_count`` field has been removed." msgstr "" -#: ../../c-api/init_config.rst:1293 +#: ../../c-api/init_config.rst:1354 msgid "Initialization with PyConfig" msgstr "" -#: ../../c-api/init_config.rst:1295 -msgid "Function to initialize Python:" -msgstr "" - -#: ../../c-api/init_config.rst:1299 -msgid "Initialize Python from *config* configuration." +#: ../../c-api/init_config.rst:1356 +msgid "" +"Initializing the interpreter from a populated configuration struct is " +"handled by calling :c:func:`Py_InitializeFromConfig`." msgstr "" -#: ../../c-api/init_config.rst:1304 +#: ../../c-api/init_config.rst:1362 msgid "" "If :c:func:`PyImport_FrozenModules`, :c:func:`PyImport_AppendInittab` or :c:" "func:`PyImport_ExtendInittab` are used, they must be set or called after " @@ -1789,17 +1858,17 @@ msgid "" "`PyImport_ExtendInittab` must be called before each Python initialization." msgstr "" -#: ../../c-api/init_config.rst:1311 +#: ../../c-api/init_config.rst:1369 msgid "" "The current configuration (``PyConfig`` type) is stored in " "``PyInterpreterState.config``." msgstr "" -#: ../../c-api/init_config.rst:1314 +#: ../../c-api/init_config.rst:1372 msgid "Example setting the program name::" msgstr "" -#: ../../c-api/init_config.rst:1316 +#: ../../c-api/init_config.rst:1374 msgid "" "void init_python(void)\n" "{\n" @@ -1853,7 +1922,7 @@ msgstr "" " Py_ExitStatusException(status);\n" "}" -#: ../../c-api/init_config.rst:1342 +#: ../../c-api/init_config.rst:1400 msgid "" "More complete example modifying the default configuration, read the " "configuration, and then override some parameters. Note that since 3.11, many " @@ -1862,7 +1931,7 @@ msgid "" "called will be left unchanged by initialization::" msgstr "" -#: ../../c-api/init_config.rst:1349 +#: ../../c-api/init_config.rst:1407 msgid "" "PyStatus init_python(const char *program_name)\n" "{\n" @@ -1917,18 +1986,18 @@ msgid "" "}" msgstr "" -#: ../../c-api/init_config.rst:1405 +#: ../../c-api/init_config.rst:1463 msgid "Isolated Configuration" msgstr "" -#: ../../c-api/init_config.rst:1407 +#: ../../c-api/init_config.rst:1465 msgid "" ":c:func:`PyPreConfig_InitIsolatedConfig` and :c:func:" "`PyConfig_InitIsolatedConfig` functions create a configuration to isolate " "Python from the system. For example, to embed Python into an application." msgstr "" -#: ../../c-api/init_config.rst:1412 +#: ../../c-api/init_config.rst:1470 msgid "" "This configuration ignores global configuration variables, environment " "variables, command line arguments (:c:member:`PyConfig.argv` is not parsed) " @@ -1936,115 +2005,115 @@ msgid "" "LC_CTYPE locale are left unchanged. Signal handlers are not installed." msgstr "" -#: ../../c-api/init_config.rst:1417 +#: ../../c-api/init_config.rst:1475 msgid "" "Configuration files are still used with this configuration to determine " "paths that are unspecified. Ensure :c:member:`PyConfig.home` is specified to " "avoid computing the default path configuration." msgstr "" -#: ../../c-api/init_config.rst:1425 +#: ../../c-api/init_config.rst:1483 msgid "Python Configuration" msgstr "" -#: ../../c-api/init_config.rst:1427 +#: ../../c-api/init_config.rst:1485 msgid "" ":c:func:`PyPreConfig_InitPythonConfig` and :c:func:" "`PyConfig_InitPythonConfig` functions create a configuration to build a " "customized Python which behaves as the regular Python." msgstr "" -#: ../../c-api/init_config.rst:1431 +#: ../../c-api/init_config.rst:1489 msgid "" "Environments variables and command line arguments are used to configure " "Python, whereas global configuration variables are ignored." msgstr "" -#: ../../c-api/init_config.rst:1434 +#: ../../c-api/init_config.rst:1492 msgid "" "This function enables C locale coercion (:pep:`538`) and :ref:`Python UTF-8 " "Mode ` (:pep:`540`) depending on the LC_CTYPE locale, :envvar:" "`PYTHONUTF8` and :envvar:`PYTHONCOERCECLOCALE` environment variables." msgstr "" -#: ../../c-api/init_config.rst:1443 +#: ../../c-api/init_config.rst:1501 msgid "Python Path Configuration" msgstr "" -#: ../../c-api/init_config.rst:1445 +#: ../../c-api/init_config.rst:1503 msgid ":c:type:`PyConfig` contains multiple fields for the path configuration:" msgstr "" -#: ../../c-api/init_config.rst:1447 +#: ../../c-api/init_config.rst:1505 msgid "Path configuration inputs:" msgstr "" -#: ../../c-api/init_config.rst:1449 +#: ../../c-api/init_config.rst:1507 msgid ":c:member:`PyConfig.home`" msgstr ":c:member:`PyConfig.home`" -#: ../../c-api/init_config.rst:1450 +#: ../../c-api/init_config.rst:1508 msgid ":c:member:`PyConfig.platlibdir`" msgstr ":c:member:`PyConfig.platlibdir`" -#: ../../c-api/init_config.rst:1451 +#: ../../c-api/init_config.rst:1509 msgid ":c:member:`PyConfig.pathconfig_warnings`" msgstr ":c:member:`PyConfig.pathconfig_warnings`" -#: ../../c-api/init_config.rst:1452 +#: ../../c-api/init_config.rst:1510 msgid ":c:member:`PyConfig.program_name`" msgstr ":c:member:`PyConfig.program_name`" -#: ../../c-api/init_config.rst:1453 +#: ../../c-api/init_config.rst:1511 msgid ":c:member:`PyConfig.pythonpath_env`" msgstr ":c:member:`PyConfig.pythonpath_env`" -#: ../../c-api/init_config.rst:1454 +#: ../../c-api/init_config.rst:1512 msgid "current working directory: to get absolute paths" msgstr "" -#: ../../c-api/init_config.rst:1455 +#: ../../c-api/init_config.rst:1513 msgid "" "``PATH`` environment variable to get the program full path (from :c:member:" "`PyConfig.program_name`)" msgstr "" -#: ../../c-api/init_config.rst:1457 +#: ../../c-api/init_config.rst:1515 msgid "``__PYVENV_LAUNCHER__`` environment variable" msgstr "``__PYVENV_LAUNCHER__`` 環境變數" -#: ../../c-api/init_config.rst:1458 +#: ../../c-api/init_config.rst:1516 msgid "" "(Windows only) Application paths in the registry under " "\"Software\\Python\\PythonCore\\X.Y\\PythonPath\" of HKEY_CURRENT_USER and " "HKEY_LOCAL_MACHINE (where X.Y is the Python version)." msgstr "" -#: ../../c-api/init_config.rst:1462 +#: ../../c-api/init_config.rst:1520 msgid "Path configuration output fields:" msgstr "" -#: ../../c-api/init_config.rst:1464 +#: ../../c-api/init_config.rst:1522 msgid ":c:member:`PyConfig.base_exec_prefix`" msgstr ":c:member:`PyConfig.base_exec_prefix`" -#: ../../c-api/init_config.rst:1465 +#: ../../c-api/init_config.rst:1523 msgid ":c:member:`PyConfig.base_executable`" msgstr ":c:member:`PyConfig.base_executable`" -#: ../../c-api/init_config.rst:1466 +#: ../../c-api/init_config.rst:1524 msgid ":c:member:`PyConfig.base_prefix`" msgstr ":c:member:`PyConfig.base_prefix`" -#: ../../c-api/init_config.rst:1467 +#: ../../c-api/init_config.rst:1525 msgid ":c:member:`PyConfig.exec_prefix`" msgstr ":c:member:`PyConfig.exec_prefix`" -#: ../../c-api/init_config.rst:1468 +#: ../../c-api/init_config.rst:1526 msgid ":c:member:`PyConfig.executable`" msgstr ":c:member:`PyConfig.executable`" -#: ../../c-api/init_config.rst:1469 +#: ../../c-api/init_config.rst:1527 msgid "" ":c:member:`PyConfig.module_search_paths_set`, :c:member:`PyConfig." "module_search_paths`" @@ -2052,11 +2121,11 @@ msgstr "" ":c:member:`PyConfig.module_search_paths_set`, :c:member:`PyConfig." "module_search_paths`" -#: ../../c-api/init_config.rst:1471 +#: ../../c-api/init_config.rst:1529 msgid ":c:member:`PyConfig.prefix`" msgstr ":c:member:`PyConfig.prefix`" -#: ../../c-api/init_config.rst:1473 +#: ../../c-api/init_config.rst:1531 msgid "" "If at least one \"output field\" is not set, Python calculates the path " "configuration to fill unset fields. If :c:member:`~PyConfig." @@ -2065,7 +2134,7 @@ msgid "" "module_search_paths_set` is set to ``1``." msgstr "" -#: ../../c-api/init_config.rst:1479 +#: ../../c-api/init_config.rst:1537 msgid "" "It is possible to completely ignore the function calculating the default " "path configuration by setting explicitly all path configuration output " @@ -2075,52 +2144,52 @@ msgid "" "modification." msgstr "" -#: ../../c-api/init_config.rst:1486 +#: ../../c-api/init_config.rst:1544 msgid "" "Set :c:member:`~PyConfig.pathconfig_warnings` to ``0`` to suppress warnings " "when calculating the path configuration (Unix only, Windows does not log any " "warning)." msgstr "" -#: ../../c-api/init_config.rst:1489 +#: ../../c-api/init_config.rst:1547 msgid "" "If :c:member:`~PyConfig.base_prefix` or :c:member:`~PyConfig." "base_exec_prefix` fields are not set, they inherit their value from :c:" "member:`~PyConfig.prefix` and :c:member:`~PyConfig.exec_prefix` respectively." msgstr "" -#: ../../c-api/init_config.rst:1493 +#: ../../c-api/init_config.rst:1551 msgid ":c:func:`Py_RunMain` and :c:func:`Py_Main` modify :data:`sys.path`:" msgstr "" -#: ../../c-api/init_config.rst:1495 +#: ../../c-api/init_config.rst:1553 msgid "" "If :c:member:`~PyConfig.run_filename` is set and is a directory which " "contains a ``__main__.py`` script, prepend :c:member:`~PyConfig." "run_filename` to :data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:1498 +#: ../../c-api/init_config.rst:1556 msgid "If :c:member:`~PyConfig.isolated` is zero:" -msgstr "" +msgstr "如果 :c:member:`~PyConfig.isolated` 為零:" -#: ../../c-api/init_config.rst:1500 +#: ../../c-api/init_config.rst:1558 msgid "" "If :c:member:`~PyConfig.run_module` is set, prepend the current directory " "to :data:`sys.path`. Do nothing if the current directory cannot be read." msgstr "" -#: ../../c-api/init_config.rst:1502 +#: ../../c-api/init_config.rst:1560 msgid "" "If :c:member:`~PyConfig.run_filename` is set, prepend the directory of the " "filename to :data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:1504 +#: ../../c-api/init_config.rst:1562 msgid "Otherwise, prepend an empty string to :data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:1506 +#: ../../c-api/init_config.rst:1564 msgid "" "If :c:member:`~PyConfig.site_import` is non-zero, :data:`sys.path` can be " "modified by the :mod:`site` module. If :c:member:`~PyConfig." @@ -2129,170 +2198,143 @@ msgid "" "data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:1512 +#: ../../c-api/init_config.rst:1570 msgid "The following configuration files are used by the path configuration:" msgstr "" -#: ../../c-api/init_config.rst:1514 +#: ../../c-api/init_config.rst:1572 msgid "``pyvenv.cfg``" msgstr "``pyvenv.cfg``" -#: ../../c-api/init_config.rst:1515 +#: ../../c-api/init_config.rst:1573 msgid "``._pth`` file (ex: ``python._pth``)" msgstr "" -#: ../../c-api/init_config.rst:1516 +#: ../../c-api/init_config.rst:1574 msgid "``pybuilddir.txt`` (Unix only)" -msgstr "" +msgstr "``pybuilddir.txt``\\ (僅限 Unix)" -#: ../../c-api/init_config.rst:1518 +#: ../../c-api/init_config.rst:1576 msgid "If a ``._pth`` file is present:" msgstr "" -#: ../../c-api/init_config.rst:1520 +#: ../../c-api/init_config.rst:1578 msgid "Set :c:member:`~PyConfig.isolated` to ``1``." msgstr "將 :c:member:`~PyConfig.isolated` 設定為 ``1``。" -#: ../../c-api/init_config.rst:1521 +#: ../../c-api/init_config.rst:1579 msgid "Set :c:member:`~PyConfig.use_environment` to ``0``." msgstr "將 :c:member:`~PyConfig.use_environment` 設定為 ``0``。" -#: ../../c-api/init_config.rst:1522 +#: ../../c-api/init_config.rst:1580 msgid "Set :c:member:`~PyConfig.site_import` to ``0``." msgstr "將 :c:member:`~PyConfig.site_import` 設定為 ``0``。" -#: ../../c-api/init_config.rst:1523 +#: ../../c-api/init_config.rst:1581 msgid "Set :c:member:`~PyConfig.safe_path` to ``1``." msgstr "將 :c:member:`~PyConfig.safe_path` 設定為 ``1``。" -#: ../../c-api/init_config.rst:1525 +#: ../../c-api/init_config.rst:1583 msgid "" "The ``__PYVENV_LAUNCHER__`` environment variable is used to set :c:member:" -"`PyConfig.base_executable`" -msgstr "" - -#: ../../c-api/init_config.rst:1530 -msgid "Py_RunMain()" -msgstr "Py_RunMain()" - -#: ../../c-api/init_config.rst:1534 -msgid "" -"Execute the command (:c:member:`PyConfig.run_command`), the script (:c:" -"member:`PyConfig.run_filename`) or the module (:c:member:`PyConfig." -"run_module`) specified on the command line or in the configuration." +"`PyConfig.base_executable`." msgstr "" -#: ../../c-api/init_config.rst:1539 -msgid "By default and when if :option:`-i` option is used, run the REPL." -msgstr "" - -#: ../../c-api/init_config.rst:1541 -msgid "" -"Finally, finalizes Python and returns an exit status that can be passed to " -"the ``exit()`` function." -msgstr "" - -#: ../../c-api/init_config.rst:1544 -msgid "" -"See :ref:`Python Configuration ` for an example of " -"customized Python always running in isolated mode using :c:func:`Py_RunMain`." -msgstr "" - -#: ../../c-api/init_config.rst:1550 +#: ../../c-api/init_config.rst:1588 msgid "Py_GetArgcArgv()" msgstr "Py_GetArgcArgv()" -#: ../../c-api/init_config.rst:1554 +#: ../../c-api/init_config.rst:1592 msgid "Get the original command line arguments, before Python modified them." msgstr "" -#: ../../c-api/init_config.rst:1556 +#: ../../c-api/init_config.rst:1594 msgid "See also :c:member:`PyConfig.orig_argv` member." -msgstr "" +msgstr "也請參與 :c:member:`PyConfig.orig_argv` 成員。" -#: ../../c-api/init_config.rst:1560 +#: ../../c-api/init_config.rst:1598 msgid "Multi-Phase Initialization Private Provisional API" msgstr "" -#: ../../c-api/init_config.rst:1562 +#: ../../c-api/init_config.rst:1600 msgid "" "This section is a private provisional API introducing multi-phase " "initialization, the core feature of :pep:`432`:" msgstr "" -#: ../../c-api/init_config.rst:1565 +#: ../../c-api/init_config.rst:1603 msgid "\"Core\" initialization phase, \"bare minimum Python\":" msgstr "" -#: ../../c-api/init_config.rst:1567 +#: ../../c-api/init_config.rst:1605 msgid "Builtin types;" msgstr "內建型別;" -#: ../../c-api/init_config.rst:1568 +#: ../../c-api/init_config.rst:1606 msgid "Builtin exceptions;" msgstr "內建例外;" -#: ../../c-api/init_config.rst:1569 +#: ../../c-api/init_config.rst:1607 msgid "Builtin and frozen modules;" msgstr "" -#: ../../c-api/init_config.rst:1570 +#: ../../c-api/init_config.rst:1608 msgid "" "The :mod:`sys` module is only partially initialized (ex: :data:`sys.path` " "doesn't exist yet)." msgstr "" -#: ../../c-api/init_config.rst:1573 +#: ../../c-api/init_config.rst:1611 msgid "\"Main\" initialization phase, Python is fully initialized:" msgstr "" -#: ../../c-api/init_config.rst:1575 +#: ../../c-api/init_config.rst:1613 msgid "Install and configure :mod:`importlib`;" msgstr "" -#: ../../c-api/init_config.rst:1576 +#: ../../c-api/init_config.rst:1614 msgid "Apply the :ref:`Path Configuration `;" msgstr "" -#: ../../c-api/init_config.rst:1577 +#: ../../c-api/init_config.rst:1615 msgid "Install signal handlers;" msgstr "" -#: ../../c-api/init_config.rst:1578 +#: ../../c-api/init_config.rst:1616 msgid "" "Finish :mod:`sys` module initialization (ex: create :data:`sys.stdout` and :" "data:`sys.path`);" msgstr "" -#: ../../c-api/init_config.rst:1580 +#: ../../c-api/init_config.rst:1618 msgid "" "Enable optional features like :mod:`faulthandler` and :mod:`tracemalloc`;" msgstr "" -#: ../../c-api/init_config.rst:1581 +#: ../../c-api/init_config.rst:1619 msgid "Import the :mod:`site` module;" msgstr "引入 :mod:`site` 模組;" -#: ../../c-api/init_config.rst:1582 +#: ../../c-api/init_config.rst:1620 msgid "etc." msgstr "" -#: ../../c-api/init_config.rst:1584 +#: ../../c-api/init_config.rst:1622 msgid "Private provisional API:" msgstr "" -#: ../../c-api/init_config.rst:1586 +#: ../../c-api/init_config.rst:1624 msgid "" ":c:member:`PyConfig._init_main`: if set to ``0``, :c:func:" "`Py_InitializeFromConfig` stops at the \"Core\" initialization phase." msgstr "" -#: ../../c-api/init_config.rst:1591 +#: ../../c-api/init_config.rst:1629 msgid "" "Move to the \"Main\" initialization phase, finish the Python initialization." msgstr "" -#: ../../c-api/init_config.rst:1593 +#: ../../c-api/init_config.rst:1631 msgid "" "No module is imported during the \"Core\" phase and the ``importlib`` module " "is not configured: the :ref:`Path Configuration ` is only " @@ -2301,14 +2343,14 @@ msgid "" "maybe install a custom :data:`sys.meta_path` importer or an import hook, etc." msgstr "" -#: ../../c-api/init_config.rst:1599 +#: ../../c-api/init_config.rst:1637 msgid "" "It may become possible to calculate the :ref:`Path Configuration ` in Python, after the Core phase and before the Main phase, which is " "one of the :pep:`432` motivation." msgstr "" -#: ../../c-api/init_config.rst:1603 +#: ../../c-api/init_config.rst:1641 msgid "" "The \"Core\" phase is not properly defined: what should be and what should " "not be available at this phase is not specified yet. The API is marked as " @@ -2316,13 +2358,13 @@ msgid "" "until a proper public API is designed." msgstr "" -#: ../../c-api/init_config.rst:1608 +#: ../../c-api/init_config.rst:1646 msgid "" "Example running Python code between \"Core\" and \"Main\" initialization " "phases::" msgstr "" -#: ../../c-api/init_config.rst:1611 +#: ../../c-api/init_config.rst:1649 msgid "" "void init_python(void)\n" "{\n" @@ -2358,3 +2400,11 @@ msgid "" " }\n" "}" msgstr "" + +#: ../../c-api/init_config.rst:558 +msgid "main()" +msgstr "main()" + +#: ../../c-api/init_config.rst:558 +msgid "argv (in module sys)" +msgstr "" diff --git a/c-api/intro.po b/c-api/intro.po index 5432552e14..4c39517d62 100644 --- a/c-api/intro.po +++ b/c-api/intro.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2023-04-25 18:01+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -179,8 +178,8 @@ msgid "" "option:`prefix <--prefix>` include the platform specific headers from :" "option:`exec_prefix <--exec-prefix>`." msgstr "" -"要引入標頭,請將兩個(如果不同)目錄放在編譯器的引入搜索路徑 (search path) " -"中。*不要*\\ 將父目錄放在搜索路徑上,然後使用 ``#include ``;這會在多平台建置上壞掉,因為 :option:`prefix <--prefix>` 下獨立於平台的" "標頭包括來自 :option:`exec_prefix <--exec-prefix>` 的平台特定標頭。" @@ -225,7 +224,7 @@ msgstr "" #: ../../c-api/intro.rst:119 msgid "" "static struct PyModuleDef spam_module = {\n" -" PyModuleDef_HEAD_INIT,\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" " .m_name = \"spam\",\n" " ...\n" "};\n" @@ -233,11 +232,11 @@ msgid "" "PyMODINIT_FUNC\n" "PyInit_spam(void)\n" "{\n" -" return PyModule_Create(&spam_module);\n" +" return PyModuleDef_Init(&spam_module);\n" "}" msgstr "" "static struct PyModuleDef spam_module = {\n" -" PyModuleDef_HEAD_INIT,\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" " .m_name = \"spam\",\n" " ...\n" "};\n" @@ -245,7 +244,7 @@ msgstr "" "PyMODINIT_FUNC\n" "PyInit_spam(void)\n" "{\n" -" return PyModule_Create(&spam_module);\n" +" return PyModuleDef_Init(&spam_module);\n" "}" #: ../../c-api/intro.rst:134 @@ -255,7 +254,7 @@ msgstr "回傳 ``x`` 的絕對值。" #: ../../c-api/intro.rst:140 msgid "" "Ask the compiler to always inline a static inline function. The compiler can " -"ignore it and decides to not inline the function." +"ignore it and decide to not inline the function." msgstr "" "要求編譯器總是嵌入靜態行內函式 (static inline function),編譯器可以忽略它並決" "定不嵌入該函式。" @@ -600,7 +599,7 @@ msgid "" msgstr "" "然而,一個常見的陷阱是從一個 list 中提取一個物件並保留它一段時間而不取得其參" "照。某些其他操作可能會從列表中刪除該物件,減少其參照計數並可能取消分配它。真" -"正的危險是看似無害的操作可能會呼叫可以執行此操作的任意 Python 程式碼;有一個" +"正的危險是看似無害的操作可能會叫用可以執行此操作的任意 Python 程式碼;有一個" "程式碼路徑允許控制權從 :c:func:`Py_DECREF` 回歸使用者,因此幾乎任何操作都有潛" "在危險。" @@ -702,7 +701,7 @@ msgid "" msgstr "" "這裡 :c:func:`PyLong_FromLong` 會回傳一個新的參照,它立即被 :c:func:" "`PyTuple_SetItem` 竊取。如果你想繼續使用一個物件,儘管對它的參照將被竊取,請" -"在呼叫參照竊取函式之前使用 :c:func:`Py_INCREF` 來獲取另一個參照。" +"在呼叫參照竊取函式之前使用 :c:func:`Py_INCREF` 來取得另一個參照。" #: ../../c-api/intro.rst:427 msgid "" @@ -839,7 +838,7 @@ msgstr "" "重要的是要意識到你是否擁有一個函式回傳的參照只取決於你呼叫哪個函式 --- *羽毛 " "(plumage)*(作為引數傳遞給函式的物件之型別)\\ *不會進入它!*\\ 因此,如果你" "使用 :c:func:`PyList_GetItem` 從 list 中提取一個項目,你不會擁有其參照 --- 但" -"如果你使用 :c:func:`PySequence_GetItem` 從同一 list 中獲取相同的項目(且恰好" +"如果你使用 :c:func:`PySequence_GetItem` 從同一 list 中取得相同的項目(且恰好" "使用完全相同的引數),你確實會擁有對回傳物件的參照。" #: ../../c-api/intro.rst:497 @@ -987,8 +986,8 @@ msgid "" "general) function to set the exception state, and :c:func:`PyErr_Clear` " "clears the exception state." msgstr "" -"例外的狀態會在個別執行緒的存儲空間 (per-thread storage) 中維護(這相當於在非" -"執行緒應用程式中使用全域存儲空間)。執行緒可以處於兩種狀態之一:發生例外或未" +"例外的狀態會在個別執行緒的儲存空間 (per-thread storage) 中維護(這相當於在非" +"執行緒應用程式中使用全域儲存空間)。執行緒可以處於兩種狀態之一:發生例外或未" "發生例外。函式 :c:func:`PyErr_Occurred` 可用於檢查這一點:當例外發生時,它回" "傳對例外型別物件的借用參照,否則回傳 ``NULL``。設定例外狀態的函式有很多::c:" "func:`PyErr_SetString` 是最常見的(儘管不是最通用的)設定例外狀態的函式,而 :" @@ -1189,8 +1188,8 @@ msgid "" msgstr "" "在大多數系統上(特別是在 Unix 和 Windows 上,儘管細節略有不同),:c:func:" "`Py_Initialize` 會假設Python 函式庫相對於 Python 直譯器可執行檔案的位置固定," -"並根據其對標準 Python 直譯器可執行檔案位置的最佳猜測來計算模組搜索路徑。或者" -"更詳細地說,它會在 shell 命令搜索路徑(環境變數 :envvar:`PATH`)中找到名為 :" +"並根據其對標準 Python 直譯器可執行檔案位置的最佳猜測來計算模組搜尋路徑。或者" +"更詳細地說,它會在 shell 命令搜尋路徑(環境變數 :envvar:`PATH`)中找到名為 :" "file:`python` 的可執行檔案,並在其父目錄中查找一個名為 :file:`lib/python{X.Y}" "` 的目錄的相對位置。" @@ -1211,18 +1210,18 @@ msgstr "" "`PYTHONHOME`,或者透過設定 :envvar:`PYTHONPATH` 在標準路徑前面插入額外的目" "錄。" -#: ../../c-api/intro.rst:779 +#: ../../c-api/intro.rst:778 msgid "" -"The embedding application can steer the search by calling " -"``Py_SetProgramName(file)`` *before* calling :c:func:`Py_Initialize`. Note " -"that :envvar:`PYTHONHOME` still overrides this and :envvar:`PYTHONPATH` is " -"still inserted in front of the standard path. An application that requires " -"total control has to provide its own implementation of :c:func:" +"The embedding application can steer the search by setting :c:member:" +"`PyConfig.program_name` *before* calling :c:func:`Py_InitializeFromConfig`. " +"Note that :envvar:`PYTHONHOME` still overrides this and :envvar:`PYTHONPATH` " +"is still inserted in front of the standard path. An application that " +"requires total control has to provide its own implementation of :c:func:" "`Py_GetPath`, :c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, and :c:" "func:`Py_GetProgramFullPath` (all defined in :file:`Modules/getpath.c`)." msgstr "" -"嵌入的應用程式可以透過在呼叫 :c:func:`Py_Initialize` *之前*\\ 呼叫 " -"``Py_SetProgramName(file)`` 來引導搜索。請注意 :envvar:`PYTHONHOME` 仍然覆蓋" +"嵌入的應用程式可以透過在呼叫 :c:func:`Py_InitializeFromConfig` *之前*\\ 設定 " +":c:member:`PyConfig.program_name` 來引導搜尋。請注意 :envvar:`PYTHONHOME` 仍然覆蓋" "它並且 :envvar:`PYTHONPATH` 仍然插入在標準路徑的前面。需要完全控制權的應用程" "式必須實作自己的 :c:func:`Py_GetPath`、:c:func:`Py_GetPrefix`、:c:func:" "`Py_GetExecPrefix` 和 :c:func:`Py_GetProgramFullPath`\\(全部定義在 :file:" @@ -1244,7 +1243,7 @@ msgstr "" "有時會希望能夠「取消初始化 (uninitialize)」Python。例如,應用程式可能想要重新" "開始(再次呼叫 :c:func:`Py_Initialize`)或者應用程式簡單地完成了對 Python 的" "使用並想要釋放 Python 分配的記憶體。這可以透過呼叫 :c:func:`Py_FinalizeEx` 來" -"完成。如果 Python 當前處於初始化狀態,函式 :c:func:`Py_IsInitialized` 會回傳 " +"完成。如果 Python 目前處於初始化狀態,函式 :c:func:`Py_IsInitialized` 會回傳 " "true。有關這些功能的更多資訊將在後面的章節中給出。請注意 :c:func:" "`Py_FinalizeEx` *不會*\\ 釋放由 Python 直譯器分配的所有記憶體,例如目前無法釋" "放被擴充模組所分配的記憶體。" @@ -1308,7 +1307,7 @@ msgid "" "well. Upon exit, all existing references are printed. (In interactive mode " "this happens after every statement run by the interpreter.)" msgstr "" -"定義 :c:macro:`Py_TRACE_REFS` 來啟用參照追蹤(參見\\ :option:`調用 --with-" +"定義 :c:macro:`Py_TRACE_REFS` 來啟用參照追蹤(參見\\ :option:`設定 --with-" "trace-refs 選項 <--with-trace-refs>`)。當有定義時,透過向每個 :c:type:" "`PyObject` 新增兩個額外欄位來維護有效物件的循環雙向鍊表 (circular doubly " "linked list)。全體分配也有被追蹤。退出時將印出所有現行參照。(在交互模式下," @@ -1322,6 +1321,80 @@ msgstr "" "有關更多詳細資訊,請參閱 Python 原始碼發布版中的 :file:`Misc/SpecialBuilds." "txt`。" +#: ../../c-api/intro.rst:842 +msgid "Recommended third party tools" +msgstr "" + +#: ../../c-api/intro.rst:844 +msgid "" +"The following third party tools offer both simpler and more sophisticated " +"approaches to creating C, C++ and Rust extensions for Python:" +msgstr "" + +#: ../../c-api/intro.rst:847 +msgid "`Cython `_" +msgstr "" + +#: ../../c-api/intro.rst:848 +msgid "`cffi `_" +msgstr "" + +#: ../../c-api/intro.rst:849 +msgid "`HPy `_" +msgstr "" + +#: ../../c-api/intro.rst:850 +msgid "`nanobind `_ (C++)" +msgstr "" + +#: ../../c-api/intro.rst:851 +msgid "`Numba `_" +msgstr "" + +#: ../../c-api/intro.rst:852 +msgid "`pybind11 `_ (C++)" +msgstr "" + +#: ../../c-api/intro.rst:853 +msgid "`PyO3 `_ (Rust)" +msgstr "" + +#: ../../c-api/intro.rst:854 +msgid "`SWIG `_" +msgstr "" + +#: ../../c-api/intro.rst:856 +msgid "" +"Using tools such as these can help avoid writing code that is tightly bound " +"to a particular version of CPython, avoid reference counting errors, and " +"focus more on your own code than on using the CPython API. In general, new " +"versions of Python can be supported by updating the tool, and your code will " +"often use newer and more efficient APIs automatically. Some tools also " +"support compiling for other implementations of Python from a single set of " +"sources." +msgstr "" + +#: ../../c-api/intro.rst:863 +msgid "" +"These projects are not supported by the same people who maintain Python, and " +"issues need to be raised with the projects directly. Remember to check that " +"the project is still maintained and supported, as the list above may become " +"outdated." +msgstr "" + +#: ../../c-api/intro.rst:870 +msgid "" +"`Python Packaging User Guide: Binary Extensions `_" +msgstr "" + +#: ../../c-api/intro.rst:871 +msgid "" +"The Python Packaging User Guide not only covers several available tools that " +"simplify the creation of binary extensions, but also discusses the various " +"reasons why creating an extension module may be desirable in the first place." +msgstr "" + #: ../../c-api/intro.rst:288 msgid "object" msgstr "object(物件)" @@ -1426,10 +1499,6 @@ msgstr "path(路徑)" msgid "path (in module sys)" msgstr "path(sys 模組中)" -#: ../../c-api/intro.rst:772 -msgid "Py_SetProgramName (C function)" -msgstr "Py_SetProgramName(C 函式)" - #: ../../c-api/intro.rst:772 msgid "Py_GetPath (C function)" msgstr "Py_GetPath(C 函式)" @@ -1449,3 +1518,6 @@ msgstr "Py_GetProgramFullPath(C 函式)" #: ../../c-api/intro.rst:787 msgid "Py_IsInitialized (C function)" msgstr "Py_IsInitialized(C 函式)" + +#~ msgid "Py_SetProgramName (C function)" +#~ msgstr "Py_SetProgramName(C 函式)" diff --git a/c-api/iter.po b/c-api/iter.po index 8b674435cc..71d9e97f69 100644 --- a/c-api/iter.po +++ b/c-api/iter.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,7 +6,7 @@ # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-01 22:24+0800\n" "PO-Revision-Date: 2023-07-01 03:44+0800\n" @@ -22,7 +22,7 @@ msgstr "" #: ../../c-api/iter.rst:6 msgid "Iterator Protocol" -msgstr "疊代器協議" +msgstr "疊代器協定" #: ../../c-api/iter.rst:8 msgid "There are two functions specifically for working with iterators." @@ -41,7 +41,7 @@ msgid "" "Return non-zero if the object *o* provides the :class:`AsyncIterator` " "protocol, and ``0`` otherwise. This function always succeeds." msgstr "" -"如果物件 *o* 有提供 :class:`AsyncIterator` 協議,則回傳非零,否則回傳 0。這個" +"如果物件 *o* 有提供 :class:`AsyncIterator` 協定,則回傳非零,否則回傳 0。這個" "函式一定會執行成功。" #: ../../c-api/iter.rst:24 @@ -87,6 +87,28 @@ msgid "" " /* continue doing useful work */\n" "}" msgstr "" +"PyObject *iterator = PyObject_GetIter(obj);\n" +"PyObject *item;\n" +"\n" +"if (iterator == NULL) {\n" +" /* 傳播錯誤 */\n" +"}\n" +"\n" +"while ((item = PyIter_Next(iterator))) {\n" +" /* 對 item 做些事情 */\n" +" ...\n" +" /* 完成後釋放參照 */\n" +" Py_DECREF(item);\n" +"}\n" +"\n" +"Py_DECREF(iterator);\n" +"\n" +"if (PyErr_Occurred()) {\n" +" /* 傳播錯誤 */\n" +"}\n" +"else {\n" +" /* 繼續做一些有用的任務 */\n" +"}" #: ../../c-api/iter.rst:59 msgid "" diff --git a/c-api/iterator.po b/c-api/iterator.po index fe68f1fa77..3675b02e9a 100644 --- a/c-api/iterator.po +++ b/c-api/iterator.po @@ -6,7 +6,7 @@ # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-07-24 00:03+0000\n" "PO-Revision-Date: 2017-09-22 18:26+0000\n" diff --git a/c-api/list.po b/c-api/list.po index ed430f77a6..5b7fb4a6e1 100644 --- a/c-api/list.po +++ b/c-api/list.po @@ -6,9 +6,9 @@ # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-05-09 00:15+0000\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2023-08-24 00:55+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -33,8 +33,8 @@ msgid "" "This instance of :c:type:`PyTypeObject` represents the Python list type. " "This is the same object as :class:`list` in the Python layer." msgstr "" -"此 :c:type:`PyTypeObject` 實例表示 Python 的 list 型別。這與 Python 層中的 :" -"class:`list` 是同一個物件。" +"此 :c:type:`PyTypeObject` 實例表示 Python 的 list 型別。這與 Python 層中" +"的 :class:`list` 是同一個物件。" #: ../../c-api/list.rst:24 msgid "" @@ -59,41 +59,51 @@ msgstr "成功時回傳長度為 *len* 的新串列,失敗時回傳 ``NULL`` #: ../../c-api/list.rst:40 msgid "" "If *len* is greater than zero, the returned list object's items are set to " -"``NULL``. Thus you cannot use abstract API functions such as :c:func:" -"`PySequence_SetItem` or expose the object to Python code before setting all " -"items to a real object with :c:func:`PyList_SetItem`." +"``NULL``. Thus you cannot use abstract API functions such " +"as :c:func:`PySequence_SetItem` or expose the object to Python code before " +"setting all items to a real object with :c:func:`PyList_SetItem` " +"or :c:func:`PyList_SET_ITEM()`. The following APIs are safe APIs before the " +"list is fully initialized: :c:func:`PyList_SetItem()` " +"and :c:func:`PyList_SET_ITEM()`." msgstr "" -"如果 *len* 大於零,則回傳的串列物件之項目將被設定為 ``NULL``。因此,在使用 :" -"c:func:`PyList_SetItem` 來將所有項目設定為一個真實物件前,你無法使用像是 :c:" -"func:`PySequence_SetItem` 的使用抽象 API 函式,也不能將物件暴露 (expose) 給 " -"Python 程式碼。" +"如果 *len* 大於零,則回傳的串列物件之項目將被設定為 ``NULL``。因此,在使" +"用 :c:func:`PyList_SetItem` 或 :c:func:`PyList_SET_ITEM()` 來將所有項目設定為" +"一個真實物件前,你無法使用像是 :c:func:`PySequence_SetItem` 的抽象 API 函式," +"也不能將物件暴露 (expose) 給 Python 程式碼。以下 API 在串列完全初始化之前是安" +"全的::c:func:`PyList_SetItem()` 和 :c:func:`PyList_SET_ITEM()`。" -#: ../../c-api/list.rst:50 +#: ../../c-api/list.rst:53 msgid "" "Return the length of the list object in *list*; this is equivalent to " "``len(list)`` on a list object." msgstr "回傳 *list* 串列物件的長度;這相當於串列物件的 ``len(list)``。" -#: ../../c-api/list.rst:56 +#: ../../c-api/list.rst:59 msgid "Similar to :c:func:`PyList_Size`, but without error checking." msgstr "與 :c:func:`PyList_Size` 類似,但沒有錯誤檢查。" -#: ../../c-api/list.rst:61 +#: ../../c-api/list.rst:64 msgid "" "Return the object at position *index* in the list pointed to by *list*. The " "position must be non-negative; indexing from the end of the list is not " -"supported. If *index* is out of bounds (<0 or >=len(list)), return ``NULL`` " -"and set an :exc:`IndexError` exception." +"supported. If *index* is out of bounds (:code:`<0 or >=len(list)`), return " +"``NULL`` and set an :exc:`IndexError` exception." msgstr "" "回傳 *list* 指向的串列中位於 *index* 位置的物件。該位置不可為負數;並不支援從" -"串列尾末開始索引。如果 *index* 超出邊界範圍(<0 或 >=len(list))則回傳 " -"``NULL`` 並設定 :exc:`IndexError` 例外。" +"串列尾末開始索引。如果 *index* 超出邊界範圍 (:code:`<0 or >=len(list)`) 則回" +"傳 ``NULL`` 並設定 :exc:`IndexError` 例外。" -#: ../../c-api/list.rst:69 +#: ../../c-api/list.rst:74 +msgid "" +"Like :c:func:`PyList_GetItemRef`, but returns a :term:`borrowed reference` " +"instead of a :term:`strong reference`." +msgstr "" + +#: ../../c-api/list.rst:80 msgid "Similar to :c:func:`PyList_GetItem`, but without error checking." msgstr "與 :c:func:`PyList_GetItem` 類似,但沒有錯誤檢查。" -#: ../../c-api/list.rst:74 +#: ../../c-api/list.rst:85 msgid "" "Set the item at index *index* in list to *item*. Return ``0`` on success. " "If *index* is out of bounds, return ``-1`` and set an :exc:`IndexError` " @@ -102,14 +112,14 @@ msgstr "" "將串列中索引 *index* 處的項目設定為 *item*。成功時回傳 ``0``。如果 *index* 超" "出邊界範圍則回傳 ``-1`` 並設定一個 :exc:`IndexError` 例外。" -#: ../../c-api/list.rst:80 +#: ../../c-api/list.rst:91 msgid "" "This function \"steals\" a reference to *item* and discards a reference to " "an item already in the list at the affected position." msgstr "" "此函式「竊取」對 *item* 的參照,並丟棄對串列中受影響位置上已存在項目的參照。" -#: ../../c-api/list.rst:86 +#: ../../c-api/list.rst:97 msgid "" "Macro form of :c:func:`PyList_SetItem` without error checking. This is " "normally only used to fill in new lists where there is no previous content." @@ -117,17 +127,25 @@ msgstr "" ":c:func:`PyList_SetItem` 的巨集形式,沒有錯誤檢查。這通常僅用於填充沒有已存在" "內容的新串列。" -#: ../../c-api/list.rst:91 +#: ../../c-api/list.rst:100 msgid "" -"This macro \"steals\" a reference to *item*, and, unlike :c:func:" -"`PyList_SetItem`, does *not* discard a reference to any item that is being " -"replaced; any reference in *list* at position *i* will be leaked." +"Bounds checking is performed as an assertion if Python is built " +"in :ref:`debug mode ` or :option:`with assertions <--with-" +"assertions>`." +msgstr "" + +#: ../../c-api/list.rst:106 +msgid "" +"This macro \"steals\" a reference to *item*, and, " +"unlike :c:func:`PyList_SetItem`, does *not* discard a reference to any item " +"that is being replaced; any reference in *list* at position *i* will be " +"leaked." msgstr "" "該巨集「竊取」對 *item* 的參照,並且與 :c:func:`PyList_SetItem` 不同的是,它" "\\ *不會*\\ 丟棄對任意被替換項目的參照;*list* 中位置 *i* 的任何參照都將被洩" "漏 (leak)。" -#: ../../c-api/list.rst:99 +#: ../../c-api/list.rst:114 msgid "" "Insert the item *item* into list *list* in front of index *index*. Return " "``0`` if successful; return ``-1`` and set an exception if unsuccessful. " @@ -137,7 +155,7 @@ msgstr "" "``0``;如果失敗則回傳 ``-1`` 並設定例外。類似於 ``list.insert(index, " "item)``。" -#: ../../c-api/list.rst:106 +#: ../../c-api/list.rst:121 msgid "" "Append the object *item* at the end of list *list*. Return ``0`` if " "successful; return ``-1`` and set an exception if unsuccessful. Analogous " @@ -146,7 +164,7 @@ msgstr "" "將物件 *item* 附加到串列 *list* 的最後面。如果成功則回傳 ``0``;如果不成功," "則回傳 ``-1`` 並設定例外。類似於 ``list.append(item)``。" -#: ../../c-api/list.rst:113 +#: ../../c-api/list.rst:128 msgid "" "Return a list of the objects in *list* containing the objects *between* " "*low* and *high*. Return ``NULL`` and set an exception if unsuccessful. " @@ -157,7 +175,7 @@ msgstr "" "成功則回傳 ``NULL`` 並設定例外。類似於 ``list[low:high]``。不支援從串列尾末開" "始索引。" -#: ../../c-api/list.rst:120 +#: ../../c-api/list.rst:135 msgid "" "Set the slice of *list* between *low* and *high* to the contents of " "*itemlist*. Analogous to ``list[low:high] = itemlist``. The *itemlist* may " @@ -170,7 +188,33 @@ msgstr "" "(切片刪除)。成功時回傳 ``0``,失敗時則回傳 ``-1``。不支援從串列尾末開始索" "引。" -#: ../../c-api/list.rst:129 +#: ../../c-api/list.rst:144 +msgid "" +"Extend *list* with the contents of *iterable*. This is the same as " +"``PyList_SetSlice(list, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, iterable)`` and " +"analogous to ``list.extend(iterable)`` or ``list += iterable``." +msgstr "" + +#: ../../c-api/list.rst:148 +msgid "" +"Raise an exception and return ``-1`` if *list* is not a :class:`list` " +"object. Return 0 on success." +msgstr "" + +#: ../../c-api/list.rst:156 +msgid "" +"Remove all items from *list*. This is the same as ``PyList_SetSlice(list, " +"0, PY_SSIZE_T_MAX, NULL)`` and analogous to ``list.clear()`` or ``del " +"list[:]``." +msgstr "" + +#: ../../c-api/list.rst:160 +msgid "" +"Raise an exception and return ``-1`` if *list* is not a :class:`list` " +"object. Return 0 on success." +msgstr "" + +#: ../../c-api/list.rst:168 msgid "" "Sort the items of *list* in place. Return ``0`` on success, ``-1`` on " "failure. This is equivalent to ``list.sort()``." @@ -178,15 +222,15 @@ msgstr "" "對 *list* 的項目進行原地 (in place) 排序。成功時回傳 ``0``,失敗時回傳 " "``-1``。這相當於 ``list.sort()``。" -#: ../../c-api/list.rst:135 +#: ../../c-api/list.rst:174 msgid "" "Reverse the items of *list* in place. Return ``0`` on success, ``-1`` on " "failure. This is the equivalent of ``list.reverse()``." msgstr "" -"原地反轉 *list* 的項目。成功時回傳 ``0``,失敗時回傳 ``-1``。這相當於 ``list." -"reverse()``。" +"原地反轉 *list* 的項目。成功時回傳 ``0``,失敗時回傳 ``-1``。這相當於 " +"``list.reverse()``。" -#: ../../c-api/list.rst:143 +#: ../../c-api/list.rst:182 msgid "" "Return a new tuple object containing the contents of *list*; equivalent to " "``tuple(list)``." @@ -202,14 +246,14 @@ msgstr "object(物件)" msgid "list" msgstr "list(串列)" -#: ../../c-api/list.rst:48 ../../c-api/list.rst:141 +#: ../../c-api/list.rst:51 ../../c-api/list.rst:180 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../c-api/list.rst:48 +#: ../../c-api/list.rst:51 msgid "len" msgstr "len" -#: ../../c-api/list.rst:141 +#: ../../c-api/list.rst:180 msgid "tuple" msgstr "tuple(元組)" diff --git a/c-api/long.po b/c-api/long.po index dc269967a2..a32b953e3e 100644 --- a/c-api/long.po +++ b/c-api/long.po @@ -5,9 +5,9 @@ # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-06 00:03+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 14:06+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -138,35 +138,80 @@ msgid "" "retrieved from the resulting value using :c:func:`PyLong_AsVoidPtr`." msgstr "" -#: ../../c-api/long.rst:123 ../../c-api/long.rst:141 +#: ../../c-api/long.rst:118 +msgid "" +"Create a Python integer from the value contained in the first *n_bytes* of " +"*buffer*, interpreted as a two's-complement signed number." +msgstr "" + +#: ../../c-api/long.rst:121 +msgid "" +"*flags* are as for :c:func:`PyLong_AsNativeBytes`. Passing ``-1`` will " +"select the native endian that CPython was compiled with and assume that the " +"most-significant bit is a sign bit. Passing " +"``Py_ASNATIVEBYTES_UNSIGNED_BUFFER`` will produce the same result as " +"calling :c:func:`PyLong_FromUnsignedNativeBytes`. Other flags are ignored." +msgstr "" + +#: ../../c-api/long.rst:132 +msgid "" +"Create a Python integer from the value contained in the first *n_bytes* of " +"*buffer*, interpreted as an unsigned number." +msgstr "" + +#: ../../c-api/long.rst:135 +msgid "" +"*flags* are as for :c:func:`PyLong_AsNativeBytes`. Passing ``-1`` will " +"select the native endian that CPython was compiled with and assume that the " +"most-significant bit is not a sign bit. Flags other than endian are ignored." +msgstr "" + +#: ../../c-api/long.rst:148 ../../c-api/long.rst:184 msgid "" "Return a C :c:expr:`long` representation of *obj*. If *obj* is not an " "instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` " "method (if present) to convert it to a :c:type:`PyLongObject`." msgstr "" -#: ../../c-api/long.rst:127 +#: ../../c-api/long.rst:152 msgid "" "Raise :exc:`OverflowError` if the value of *obj* is out of range for a :c:" "expr:`long`." msgstr "" -#: ../../c-api/long.rst:130 ../../c-api/long.rst:150 ../../c-api/long.rst:171 -#: ../../c-api/long.rst:191 ../../c-api/long.rst:214 +#: ../../c-api/long.rst:155 ../../c-api/long.rst:193 ../../c-api/long.rst:214 +#: ../../c-api/long.rst:234 ../../c-api/long.rst:257 msgid "Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate." msgstr "" -#: ../../c-api/long.rst:132 ../../c-api/long.rst:152 ../../c-api/long.rst:173 -#: ../../c-api/long.rst:195 ../../c-api/long.rst:279 ../../c-api/long.rst:299 +#: ../../c-api/long.rst:157 ../../c-api/long.rst:195 ../../c-api/long.rst:216 +#: ../../c-api/long.rst:238 ../../c-api/long.rst:322 ../../c-api/long.rst:342 msgid "Use :meth:`~object.__index__` if available." msgstr "" -#: ../../c-api/long.rst:135 ../../c-api/long.rst:155 ../../c-api/long.rst:176 -#: ../../c-api/long.rst:198 ../../c-api/long.rst:282 ../../c-api/long.rst:302 +#: ../../c-api/long.rst:160 ../../c-api/long.rst:198 ../../c-api/long.rst:219 +#: ../../c-api/long.rst:241 ../../c-api/long.rst:325 ../../c-api/long.rst:345 msgid "This function will no longer use :meth:`~object.__int__`." msgstr "" -#: ../../c-api/long.rst:145 +#: ../../c-api/long.rst:167 +msgid "" +"A :term:`soft deprecated` alias. Exactly equivalent to the preferred " +"``PyLong_AsLong``. In particular, it can fail with :exc:`OverflowError` or " +"another exception." +msgstr "" + +#: ../../c-api/long.rst:171 +msgid "The function is soft deprecated." +msgstr "" + +#: ../../c-api/long.rst:176 +msgid "" +"Similar to :c:func:`PyLong_AsLong`, but store the result in a C :c:expr:" +"`int` instead of a C :c:expr:`long`." +msgstr "" + +#: ../../c-api/long.rst:188 msgid "" "If the value of *obj* is greater than :c:macro:`LONG_MAX` or less than :c:" "macro:`LONG_MIN`, set *\\*overflow* to ``1`` or ``-1``, respectively, and " @@ -174,20 +219,20 @@ msgid "" "exception occurs set *\\*overflow* to ``0`` and return ``-1`` as usual." msgstr "" -#: ../../c-api/long.rst:164 ../../c-api/long.rst:182 +#: ../../c-api/long.rst:207 ../../c-api/long.rst:225 msgid "" "Return a C :c:expr:`long long` representation of *obj*. If *obj* is not an " "instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` " "method (if present) to convert it to a :c:type:`PyLongObject`." msgstr "" -#: ../../c-api/long.rst:168 +#: ../../c-api/long.rst:211 msgid "" "Raise :exc:`OverflowError` if the value of *obj* is out of range for a :c:" "expr:`long long`." msgstr "" -#: ../../c-api/long.rst:186 +#: ../../c-api/long.rst:229 msgid "" "If the value of *obj* is greater than :c:macro:`LLONG_MAX` or less than :c:" "macro:`LLONG_MIN`, set *\\*overflow* to ``1`` or ``-1``, respectively, and " @@ -195,133 +240,133 @@ msgid "" "exception occurs set *\\*overflow* to ``0`` and return ``-1`` as usual." msgstr "" -#: ../../c-api/long.rst:208 +#: ../../c-api/long.rst:251 msgid "" "Return a C :c:type:`Py_ssize_t` representation of *pylong*. *pylong* must " "be an instance of :c:type:`PyLongObject`." msgstr "" -#: ../../c-api/long.rst:211 +#: ../../c-api/long.rst:254 msgid "" "Raise :exc:`OverflowError` if the value of *pylong* is out of range for a :c:" "type:`Py_ssize_t`." msgstr "" -#: ../../c-api/long.rst:223 +#: ../../c-api/long.rst:266 msgid "" "Return a C :c:expr:`unsigned long` representation of *pylong*. *pylong* " "must be an instance of :c:type:`PyLongObject`." msgstr "" -#: ../../c-api/long.rst:226 +#: ../../c-api/long.rst:269 msgid "" "Raise :exc:`OverflowError` if the value of *pylong* is out of range for a :c:" "expr:`unsigned long`." msgstr "" -#: ../../c-api/long.rst:229 +#: ../../c-api/long.rst:272 msgid "" "Returns ``(unsigned long)-1`` on error. Use :c:func:`PyErr_Occurred` to " "disambiguate." msgstr "" -#: ../../c-api/long.rst:239 +#: ../../c-api/long.rst:282 msgid "" "Return a C :c:type:`size_t` representation of *pylong*. *pylong* must be an " "instance of :c:type:`PyLongObject`." msgstr "" -#: ../../c-api/long.rst:242 +#: ../../c-api/long.rst:285 msgid "" "Raise :exc:`OverflowError` if the value of *pylong* is out of range for a :c:" "type:`size_t`." msgstr "" -#: ../../c-api/long.rst:245 +#: ../../c-api/long.rst:288 msgid "" "Returns ``(size_t)-1`` on error. Use :c:func:`PyErr_Occurred` to " "disambiguate." msgstr "" -#: ../../c-api/long.rst:254 +#: ../../c-api/long.rst:297 msgid "" "Return a C :c:expr:`unsigned long long` representation of *pylong*. " "*pylong* must be an instance of :c:type:`PyLongObject`." msgstr "" -#: ../../c-api/long.rst:257 +#: ../../c-api/long.rst:300 msgid "" "Raise :exc:`OverflowError` if the value of *pylong* is out of range for an :" "c:expr:`unsigned long long`." msgstr "" -#: ../../c-api/long.rst:260 +#: ../../c-api/long.rst:303 msgid "" "Returns ``(unsigned long long)-1`` on error. Use :c:func:`PyErr_Occurred` to " "disambiguate." msgstr "" -#: ../../c-api/long.rst:263 +#: ../../c-api/long.rst:306 msgid "" "A negative *pylong* now raises :exc:`OverflowError`, not :exc:`TypeError`." msgstr "" -#: ../../c-api/long.rst:269 +#: ../../c-api/long.rst:312 msgid "" "Return a C :c:expr:`unsigned long` representation of *obj*. If *obj* is not " "an instance of :c:type:`PyLongObject`, first call its :meth:`~object." "__index__` method (if present) to convert it to a :c:type:`PyLongObject`." msgstr "" -#: ../../c-api/long.rst:273 +#: ../../c-api/long.rst:316 msgid "" "If the value of *obj* is out of range for an :c:expr:`unsigned long`, return " "the reduction of that value modulo ``ULONG_MAX + 1``." msgstr "" -#: ../../c-api/long.rst:276 +#: ../../c-api/long.rst:319 msgid "" "Returns ``(unsigned long)-1`` on error. Use :c:func:`PyErr_Occurred` to " "disambiguate." msgstr "" -#: ../../c-api/long.rst:288 +#: ../../c-api/long.rst:331 msgid "" "Return a C :c:expr:`unsigned long long` representation of *obj*. If *obj* " "is not an instance of :c:type:`PyLongObject`, first call its :meth:`~object." "__index__` method (if present) to convert it to a :c:type:`PyLongObject`." msgstr "" -#: ../../c-api/long.rst:293 +#: ../../c-api/long.rst:336 msgid "" "If the value of *obj* is out of range for an :c:expr:`unsigned long long`, " "return the reduction of that value modulo ``ULLONG_MAX + 1``." msgstr "" -#: ../../c-api/long.rst:296 +#: ../../c-api/long.rst:339 msgid "" "Returns ``(unsigned long long)-1`` on error. Use :c:func:`PyErr_Occurred` " "to disambiguate." msgstr "" -#: ../../c-api/long.rst:308 +#: ../../c-api/long.rst:351 msgid "" "Return a C :c:expr:`double` representation of *pylong*. *pylong* must be an " "instance of :c:type:`PyLongObject`." msgstr "" -#: ../../c-api/long.rst:311 +#: ../../c-api/long.rst:354 msgid "" "Raise :exc:`OverflowError` if the value of *pylong* is out of range for a :c:" "expr:`double`." msgstr "" -#: ../../c-api/long.rst:314 +#: ../../c-api/long.rst:357 msgid "" "Returns ``-1.0`` on error. Use :c:func:`PyErr_Occurred` to disambiguate." msgstr "" -#: ../../c-api/long.rst:319 +#: ../../c-api/long.rst:362 msgid "" "Convert a Python integer *pylong* to a C :c:expr:`void` pointer. If *pylong* " "cannot be converted, an :exc:`OverflowError` will be raised. This is only " @@ -329,52 +374,263 @@ msgid "" "c:func:`PyLong_FromVoidPtr`." msgstr "" -#: ../../c-api/long.rst:324 +#: ../../c-api/long.rst:367 msgid "" "Returns ``NULL`` on error. Use :c:func:`PyErr_Occurred` to disambiguate." msgstr "" -#: ../../c-api/long.rst:329 +#: ../../c-api/long.rst:372 +msgid "" +"Copy the Python integer value *pylong* to a native *buffer* of size " +"*n_bytes*. The *flags* can be set to ``-1`` to behave similarly to a C cast, " +"or to values documented below to control the behavior." +msgstr "" + +#: ../../c-api/long.rst:376 +msgid "" +"Returns ``-1`` with an exception raised on error. This may happen if " +"*pylong* cannot be interpreted as an integer, or if *pylong* was negative " +"and the ``Py_ASNATIVEBYTES_REJECT_NEGATIVE`` flag was set." +msgstr "" + +#: ../../c-api/long.rst:380 +msgid "" +"Otherwise, returns the number of bytes required to store the value. If this " +"is equal to or less than *n_bytes*, the entire value was copied. All " +"*n_bytes* of the buffer are written: large buffers are padded with zeroes." +msgstr "" + +#: ../../c-api/long.rst:385 +msgid "" +"If the returned value is greater than *n_bytes*, the value was truncated: as " +"many of the lowest bits of the value as could fit are written, and the " +"higher bits are ignored. This matches the typical behavior of a C-style " +"downcast." +msgstr "" + +#: ../../c-api/long.rst:392 +msgid "" +"Overflow is not considered an error. If the returned value is larger than " +"*n_bytes*, most significant bits were discarded." +msgstr "" + +#: ../../c-api/long.rst:395 +msgid "``0`` will never be returned." +msgstr "``0`` 將永不被回傳。" + +#: ../../c-api/long.rst:397 +msgid "Values are always copied as two's-complement." +msgstr "" + +#: ../../c-api/long.rst:399 +msgid "Usage example::" +msgstr "使用範例: ::" + +#: ../../c-api/long.rst:401 +msgid "" +"int32_t value;\n" +"Py_ssize_t bytes = PyLong_AsNativeBytes(pylong, &value, sizeof(value), -1);\n" +"if (bytes < 0) {\n" +" // Failed. A Python exception was set with the reason.\n" +" return NULL;\n" +"}\n" +"else if (bytes <= (Py_ssize_t)sizeof(value)) {\n" +" // Success!\n" +"}\n" +"else {\n" +" // Overflow occurred, but 'value' contains the truncated\n" +" // lowest bits of pylong.\n" +"}" +msgstr "" + +#: ../../c-api/long.rst:415 +msgid "" +"Passing zero to *n_bytes* will return the size of a buffer that would be " +"large enough to hold the value. This may be larger than technically " +"necessary, but not unreasonably so. If *n_bytes=0*, *buffer* may be ``NULL``." +msgstr "" + +#: ../../c-api/long.rst:422 +msgid "" +"Passing *n_bytes=0* to this function is not an accurate way to determine the " +"bit length of the value." +msgstr "" + +#: ../../c-api/long.rst:425 +msgid "" +"To get at the entire Python value of an unknown size, the function can be " +"called twice: first to determine the buffer size, then to fill it::" +msgstr "" + +#: ../../c-api/long.rst:428 +msgid "" +"// Ask how much space we need.\n" +"Py_ssize_t expected = PyLong_AsNativeBytes(pylong, NULL, 0, -1);\n" +"if (expected < 0) {\n" +" // Failed. A Python exception was set with the reason.\n" +" return NULL;\n" +"}\n" +"assert(expected != 0); // Impossible per the API definition.\n" +"uint8_t *bignum = malloc(expected);\n" +"if (!bignum) {\n" +" PyErr_SetString(PyExc_MemoryError, \"bignum malloc failed.\");\n" +" return NULL;\n" +"}\n" +"// Safely get the entire value.\n" +"Py_ssize_t bytes = PyLong_AsNativeBytes(pylong, bignum, expected, -1);\n" +"if (bytes < 0) { // Exception has been set.\n" +" free(bignum);\n" +" return NULL;\n" +"}\n" +"else if (bytes > expected) { // This should not be possible.\n" +" PyErr_SetString(PyExc_RuntimeError,\n" +" \"Unexpected bignum truncation after a size check.\");\n" +" free(bignum);\n" +" return NULL;\n" +"}\n" +"// The expected success given the above pre-check.\n" +"// ... use bignum ...\n" +"free(bignum);" +msgstr "" + +#: ../../c-api/long.rst:456 +msgid "" +"*flags* is either ``-1`` (``Py_ASNATIVEBYTES_DEFAULTS``) to select defaults " +"that behave most like a C cast, or a combination of the other flags in the " +"table below. Note that ``-1`` cannot be combined with other flags." +msgstr "" + +#: ../../c-api/long.rst:461 +msgid "" +"Currently, ``-1`` corresponds to ``Py_ASNATIVEBYTES_NATIVE_ENDIAN | " +"Py_ASNATIVEBYTES_UNSIGNED_BUFFER``." +msgstr "" + +#: ../../c-api/long.rst:467 +msgid "Flag" +msgstr "旗標" + +#: ../../c-api/long.rst:467 +msgid "Value" +msgstr "數值" + +#: ../../c-api/long.rst:469 +msgid "``-1``" +msgstr "``-1``" + +#: ../../c-api/long.rst:470 +msgid "``0``" +msgstr "``0``" + +#: ../../c-api/long.rst:471 +msgid "``1``" +msgstr "``1``" + +#: ../../c-api/long.rst:472 +msgid "``3``" +msgstr "``3``" + +#: ../../c-api/long.rst:473 +msgid "``4``" +msgstr "``4``" + +#: ../../c-api/long.rst:474 +msgid "``8``" +msgstr "``8``" + +#: ../../c-api/long.rst:475 +msgid "``16``" +msgstr "``16``" + +#: ../../c-api/long.rst:478 +msgid "" +"Specifying ``Py_ASNATIVEBYTES_NATIVE_ENDIAN`` will override any other endian " +"flags. Passing ``2`` is reserved." +msgstr "" + +#: ../../c-api/long.rst:481 +msgid "" +"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." +msgstr "" + +#: ../../c-api/long.rst:485 +msgid "" +"If ``Py_ASNATIVEBYTES_UNSIGNED_BUFFER`` is specified, a zero sign bit will " +"be omitted from size calculations. This allows, for example, 128 to fit in a " +"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." +msgstr "" + +#: ../../c-api/long.rst:492 +msgid "" +"Specifying ``Py_ASNATIVEBYTES_REJECT_NEGATIVE`` causes an exception to be " +"set if *pylong* is negative. Without this flag, negative values will be " +"copied provided there is enough space for at least one sign bit, regardless " +"of whether ``Py_ASNATIVEBYTES_UNSIGNED_BUFFER`` was specified." +msgstr "" + +#: ../../c-api/long.rst:497 +msgid "" +"If ``Py_ASNATIVEBYTES_ALLOW_INDEX`` is specified and a non-integer value is " +"passed, its :meth:`~object.__index__` method will be called first. This may " +"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 :exc:" +"`TypeError`." +msgstr "" + +#: ../../c-api/long.rst:506 +msgid "" +"With the default *flags* (``-1``, or *UNSIGNED_BUFFER* without " +"*REJECT_NEGATIVE*), multiple Python integers can map to a single value " +"without overflow. For example, both ``255`` and ``-1`` fit a single-byte " +"buffer and set all its bits. This matches typical C cast behavior." +msgstr "" + +#: ../../c-api/long.rst:517 msgid "" "On success, return a read only :term:`named tuple`, that holds information " "about Python's internal representation of integers. See :data:`sys.int_info` " "for description of individual fields." msgstr "" -#: ../../c-api/long.rst:333 +#: ../../c-api/long.rst:521 msgid "On failure, return ``NULL`` with an exception set." msgstr "在失敗時,會回傳 ``NULL`` 並設定例外。" -#: ../../c-api/long.rst:340 +#: ../../c-api/long.rst:528 msgid "Return 1 if *op* is compact, 0 otherwise." msgstr "" -#: ../../c-api/long.rst:342 +#: ../../c-api/long.rst:530 msgid "" "This function makes it possible for performance-critical code to implement a " "“fast path” for small integers. For compact values use :c:func:" "`PyUnstable_Long_CompactValue`; for others fall back to a :c:func:" -"`PyLong_As* ` function or :c:func:`calling " -"` :meth:`int.to_bytes`." +"`PyLong_As* ` function or :c:func:`PyLong_AsNativeBytes`." msgstr "" -#: ../../c-api/long.rst:348 +#: ../../c-api/long.rst:536 msgid "The speedup is expected to be negligible for most users." msgstr "" -#: ../../c-api/long.rst:350 +#: ../../c-api/long.rst:538 msgid "" "Exactly what values are considered compact is an implementation detail and " "is subject to change." msgstr "" -#: ../../c-api/long.rst:355 +#: ../../c-api/long.rst:546 msgid "" "If *op* is compact, as determined by :c:func:`PyUnstable_Long_IsCompact`, " "return its value." msgstr "" -#: ../../c-api/long.rst:358 +#: ../../c-api/long.rst:549 msgid "Otherwise, the return value is undefined." msgstr "" @@ -384,29 +640,29 @@ msgstr "object(物件)" #: ../../c-api/long.rst:8 msgid "long integer" -msgstr "long integer(長整数)" +msgstr "long integer(長整數)" #: ../../c-api/long.rst:8 msgid "integer" -msgstr "integer(整数)" +msgstr "integer(整數)" -#: ../../c-api/long.rst:119 +#: ../../c-api/long.rst:144 msgid "LONG_MAX (C macro)" msgstr "LONG_MAX(C 巨集)" -#: ../../c-api/long.rst:119 ../../c-api/long.rst:161 ../../c-api/long.rst:204 -#: ../../c-api/long.rst:219 ../../c-api/long.rst:235 ../../c-api/long.rst:251 +#: ../../c-api/long.rst:144 ../../c-api/long.rst:204 ../../c-api/long.rst:247 +#: ../../c-api/long.rst:262 ../../c-api/long.rst:278 ../../c-api/long.rst:294 msgid "OverflowError (built-in exception)" -msgstr "OverflowError(内建例外)" +msgstr "OverflowError(內建例外)" -#: ../../c-api/long.rst:204 +#: ../../c-api/long.rst:247 msgid "PY_SSIZE_T_MAX (C macro)" msgstr "PY_SSIZE_T_MAX(C 巨集)" -#: ../../c-api/long.rst:219 +#: ../../c-api/long.rst:262 msgid "ULONG_MAX (C macro)" msgstr "ULONG_MAX(C 巨集)" -#: ../../c-api/long.rst:235 +#: ../../c-api/long.rst:278 msgid "SIZE_MAX (C macro)" msgstr "SIZE_MAX(C 巨集)" diff --git a/c-api/mapping.po b/c-api/mapping.po index aa99402ad8..49e8987a80 100644 --- a/c-api/mapping.po +++ b/c-api/mapping.po @@ -5,9 +5,9 @@ # Matt Wang , 2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-09-03 00:03+0000\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2024-05-11 14:32+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -61,6 +61,31 @@ msgstr "" #: ../../c-api/mapping.rst:38 msgid "" +"Variant of :c:func:`PyObject_GetItem` which doesn't raise :exc:`KeyError` if " +"the key is not found." +msgstr "" + +#: ../../c-api/mapping.rst:41 +msgid "" +"If the key is found, return ``1`` and set *\\*result* to a new :term:`strong " +"reference` to the corresponding value. If the key is not found, return ``0`` " +"and set *\\*result* to ``NULL``; the :exc:`KeyError` is silenced. If an " +"error other than :exc:`KeyError` is raised, return ``-1`` and set " +"*\\*result* to ``NULL``." +msgstr "" + +#: ../../c-api/mapping.rst:53 +#, fuzzy +msgid "" +"This is the same as :c:func:`PyMapping_GetOptionalItem`, but *key* is " +"specified as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." +msgstr "" +"這與 :c:func:`PyMapping_HasKey` 相同,但 *key* 被指定為 :c:expr:`const " +"char*` UTF-8 編碼位元組字串,而不是 :c:expr:`PyObject*`。" + +#: ../../c-api/mapping.rst:62 +msgid "" "This is the same as :c:func:`PyObject_SetItem`, but *key* is specified as a :" "c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." @@ -68,11 +93,11 @@ msgstr "" "這與 :c:func:`PyObject_SetItem` 相同,但 *key* 被指定為 :c:expr:`const " "char*` UTF-8 編碼位元組字串,而不是 :c:expr:`PyObject*`。" -#: ../../c-api/mapping.rst:45 +#: ../../c-api/mapping.rst:69 msgid "This is an alias of :c:func:`PyObject_DelItem`." msgstr "這是 :c:func:`PyObject_DelItem` 的別名。" -#: ../../c-api/mapping.rst:50 +#: ../../c-api/mapping.rst:74 msgid "" "This is the same as :c:func:`PyObject_DelItem`, but *key* is specified as a :" "c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" @@ -81,7 +106,27 @@ msgstr "" "這與 :c:func:`PyObject_DelItem` 相同,但 *key* 被指定為 :c:expr:`const " "char*` UTF-8 編碼位元組字串,而不是 :c:expr:`PyObject*`。" -#: ../../c-api/mapping.rst:57 +#: ../../c-api/mapping.rst:81 +#, fuzzy +msgid "" +"Return ``1`` if the mapping object has the key *key* and ``0`` otherwise. " +"This is equivalent to the Python expression ``key in o``. On failure, return " +"``-1``." +msgstr "" +"如果對映物件具有鍵 *key* 則回傳 ``1``,否則回傳 ``0``。這相當於 Python 運算" +"式 ``key in o``。這個函式總會是成功的。" + +#: ../../c-api/mapping.rst:90 +#, fuzzy +msgid "" +"This is the same as :c:func:`PyMapping_HasKeyWithError`, but *key* is " +"specified as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." +msgstr "" +"這與 :c:func:`PyMapping_HasKey` 相同,但 *key* 被指定為 :c:expr:`const " +"char*` UTF-8 編碼位元組字串,而不是 :c:expr:`PyObject*`。" + +#: ../../c-api/mapping.rst:99 msgid "" "Return ``1`` if the mapping object has the key *key* and ``0`` otherwise. " "This is equivalent to the Python expression ``key in o``. This function " @@ -90,16 +135,18 @@ msgstr "" "如果對映物件具有鍵 *key* 則回傳 ``1``,否則回傳 ``0``。這相當於 Python 運算" "式 ``key in o``。這個函式總會是成功的。" -#: ../../c-api/mapping.rst:63 +#: ../../c-api/mapping.rst:105 +#, fuzzy msgid "" "Exceptions which occur when this calls :meth:`~object.__getitem__` method " "are silently ignored. For proper error handling, use :c:func:" +"`PyMapping_HasKeyWithError`, :c:func:`PyMapping_GetOptionalItem` or :c:func:" "`PyObject_GetItem()` instead." msgstr "" "當它呼叫 :meth:`~object.__getitem__` 方法時發生的例外將被默默忽略。為了適當地" "處理錯誤,請改用 :c:func:`PyObject_GetItem()`。" -#: ../../c-api/mapping.rst:70 +#: ../../c-api/mapping.rst:113 msgid "" "This is the same as :c:func:`PyMapping_HasKey`, but *key* is specified as a :" "c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" @@ -108,34 +155,37 @@ msgstr "" "這與 :c:func:`PyMapping_HasKey` 相同,但 *key* 被指定為 :c:expr:`const " "char*` UTF-8 編碼位元組字串,而不是 :c:expr:`PyObject*`。" -#: ../../c-api/mapping.rst:76 +#: ../../c-api/mapping.rst:119 +#, fuzzy msgid "" "Exceptions that occur when this calls :meth:`~object.__getitem__` method or " "while creating the temporary :class:`str` object are silently ignored. For " -"proper error handling, use :c:func:`PyMapping_GetItemString` instead." +"proper error handling, use :c:func:`PyMapping_HasKeyStringWithError`, :c:" +"func:`PyMapping_GetOptionalItemString` or :c:func:`PyMapping_GetItemString` " +"instead." msgstr "" "當它呼叫 :meth:`~object.__getitem__` 方法或建立臨時 :class:`str` 物件時發生的" "例外將被默默忽略。為了適當地處理錯誤,請改用 :c:func:" "`PyMapping_GetItemString`。" -#: ../../c-api/mapping.rst:84 +#: ../../c-api/mapping.rst:129 msgid "" "On success, return a list of the keys in object *o*. On failure, return " "``NULL``." msgstr "成功時回傳一個物件 *o* 內之鍵的串列,失敗時回傳 ``NULL``。" -#: ../../c-api/mapping.rst:87 ../../c-api/mapping.rst:96 -#: ../../c-api/mapping.rst:105 +#: ../../c-api/mapping.rst:132 ../../c-api/mapping.rst:141 +#: ../../c-api/mapping.rst:150 msgid "Previously, the function returned a list or a tuple." msgstr "在以前,該函式會回傳串列或元組。" -#: ../../c-api/mapping.rst:93 +#: ../../c-api/mapping.rst:138 msgid "" "On success, return a list of the values in object *o*. On failure, return " "``NULL``." msgstr "成功時回傳物件 *o* 中值的串列。失敗時回傳 ``NULL``。" -#: ../../c-api/mapping.rst:102 +#: ../../c-api/mapping.rst:147 msgid "" "On success, return a list of the items in object *o*, where each item is a " "tuple containing a key-value pair. On failure, return ``NULL``." diff --git a/c-api/marshal.po b/c-api/marshal.po index 536fc0744c..88d77fe2c1 100644 --- a/c-api/marshal.po +++ b/c-api/marshal.po @@ -1,15 +1,16 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: +# Adrian Liaw , 2018 +# Matt Wang , 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-07-20 00:03+0000\n" -"PO-Revision-Date: 2018-05-23 14:06+0000\n" -"Last-Translator: Adrian Liaw \n" +"PO-Revision-Date: 2025-06-28 02:44+0800\n" +"Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -17,10 +18,11 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Poedit 3.6\n" #: ../../c-api/marshal.rst:6 msgid "Data marshalling support" -msgstr "資料 marshal 的支援" +msgstr "資料 marshal 操作的支援" #: ../../c-api/marshal.rst:8 msgid "" @@ -30,10 +32,13 @@ msgid "" "read the data back. Files used to store marshalled data must be opened in " "binary mode." msgstr "" +"這些例程允許 C 程式碼使用與 :mod:`marshal` 模組相同的資料格式來處理序列化物" +"件。有函式可以將資料寫入序列化格式,還有其他函式可以用來讀取回資料。用來儲存 " +"marshal 過的資料的檔案必須以二進位模式開啟。" #: ../../c-api/marshal.rst:14 msgid "Numeric values are stored with the least significant byte first." -msgstr "" +msgstr "數值會以最低有效位元組 (the least significant byte) 優先的方式儲存。" #: ../../c-api/marshal.rst:16 msgid "" @@ -42,6 +47,9 @@ msgid "" "unmarshalling. Version 2 uses a binary format for floating-point numbers. " "``Py_MARSHAL_VERSION`` indicates the current file format (currently 2)." msgstr "" +"這個模組支援兩個版本的資料格式:版本 0 是歷史版本,版本 1 在檔案中共享駐留字" +"串 (interned strings),並在 unmarshal 時使用。版本 2 使用二進位格式來儲存浮點" +"數。``Py_MARSHAL_VERSION`` 表示目前的檔案格式(目前為 2)。" #: ../../c-api/marshal.rst:24 msgid "" @@ -49,28 +57,35 @@ msgid "" "the least-significant 32 bits of *value*; regardless of the size of the " "native :c:expr:`long` type. *version* indicates the file format." msgstr "" +"將一個 :c:expr:`long` 整數 *value* marshal 為 *file*。這只會寫入 *value* 的最" +"低有效 32 位元;無論原生 :c:expr:`long` 型別的大小如何。*version* 表示檔案的格" +"式。" #: ../../c-api/marshal.rst:28 ../../c-api/marshal.rst:36 msgid "" -"This function can fail, in which case it sets the error indicator. Use :c:" -"func:`PyErr_Occurred` to check for that." +"This function can fail, in which case it sets the error indicator. " +"Use :c:func:`PyErr_Occurred` to check for that." msgstr "" +"這個函式可能會失敗,這時會設定錯誤指示器。使用 :c:func:`PyErr_Occurred` 來檢" +"查是否發生錯誤。" #: ../../c-api/marshal.rst:33 msgid "" "Marshal a Python object, *value*, to *file*. *version* indicates the file " "format." msgstr "" +"將一個 Python 物件 *value* marshal 為 *file*。*version* 表示檔案的格式。" #: ../../c-api/marshal.rst:41 msgid "" "Return a bytes object containing the marshalled representation of *value*. " "*version* indicates the file format." msgstr "" +"回傳一個位元組物件,包含 *value* 的 marshal 表示。*version* 為檔案的格式。" #: ../../c-api/marshal.rst:45 msgid "The following functions allow marshalled values to be read back in." -msgstr "" +msgstr "以下函式允許將 marshal 過後的值讀取回來。" #: ../../c-api/marshal.rst:50 msgid "" @@ -78,12 +93,14 @@ msgid "" "for reading. Only a 32-bit value can be read in using this function, " "regardless of the native size of :c:expr:`long`." msgstr "" +"從一個為讀取而開啟的 :c:expr:`FILE*` 中的資料串流回傳一個 C :c:expr:`long`。" +"無論 :c:expr:`long` 的原生大小如何,這個函式只能讀取 32 位元的值。" #: ../../c-api/marshal.rst:54 ../../c-api/marshal.rst:64 msgid "" "On error, sets the appropriate exception (:exc:`EOFError`) and returns " "``-1``." -msgstr "" +msgstr "在錯誤發生時,會設定合適的例外(:exc:`EOFError`)並回傳 ``-1``。" #: ../../c-api/marshal.rst:60 msgid "" @@ -91,12 +108,15 @@ msgid "" "for reading. Only a 16-bit value can be read in using this function, " "regardless of the native size of :c:expr:`short`." msgstr "" +"從一個為讀取而開啟的 :c:expr:`FILE*` 中的資料串流回傳一個 C :c:expr:`short`。" +"無論 :c:expr:`short` 的原生大小如何,這個函式只能讀取 16 位元的值。" #: ../../c-api/marshal.rst:70 msgid "" "Return a Python object from the data stream in a :c:expr:`FILE*` opened for " "reading." msgstr "" +"從一個為讀取而開啟的 :c:expr:`FILE*` 中的資料串流回傳一個 Python 物件。" #: ../../c-api/marshal.rst:73 ../../c-api/marshal.rst:87 #: ../../c-api/marshal.rst:96 @@ -104,6 +124,8 @@ msgid "" "On error, sets the appropriate exception (:exc:`EOFError`, :exc:`ValueError` " "or :exc:`TypeError`) and returns ``NULL``." msgstr "" +"在錯誤發生時,會設定合適的例外(:exc:`EOFError`、:exc:`ValueError` " +"或 :exc:`TypeError`)並回傳 ``NULL``。" #: ../../c-api/marshal.rst:79 msgid "" @@ -115,9 +137,16 @@ msgid "" "file. Only use these variant if you are certain that you won't be reading " "anything else from the file." msgstr "" +"從一個為讀取而開啟的 :c:expr:`FILE*` 中的資料串流回傳一個 Python 物件。" +"與 :c:func:`PyMarshal_ReadObjectFromFile` 不同,這個函式假設不會從檔案中讀取" +"其他物件,允許它積極地將檔案資料載入記憶體,以便反序列化可以從記憶體中的資料" +"操作,而不是從檔案中逐位元組讀取。只有在確定不會從檔案中讀取其他內容時,才使" +"用這個變體。" #: ../../c-api/marshal.rst:93 msgid "" "Return a Python object from the data stream in a byte buffer containing " "*len* bytes pointed to by *data*." msgstr "" +"從一個包含 *len* 位元組、被 *data* 指向的位元組緩衝區中的資料串流回傳一個 " +"Python 物件。" diff --git a/c-api/memory.po b/c-api/memory.po index 27c22cf58f..0b7ee268d0 100644 --- a/c-api/memory.po +++ b/c-api/memory.po @@ -6,9 +6,9 @@ # Ching-Lung Chuang, 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2025-07-21 00:18+0000\n" "PO-Revision-Date: 2018-05-23 14:06+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -135,59 +135,70 @@ msgid "" "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 :ref:`here `. There is no hard requirement to use the memory returned by the " -"allocation functions belonging to a given domain for only the purposes " -"hinted by that domain (although this is the recommended practice). For " -"example, one could use the memory returned by :c:func:`PyMem_RawMalloc` for " -"allocating Python objects or the memory returned by :c:func:" -"`PyObject_Malloc` for allocating memory for buffers." +"allocators>`. The APIs used to allocate and free a block of memory must be " +"from the same domain. For example, :c:func:`PyMem_Free` must be used to free " +"memory allocated using :c:func:`PyMem_Malloc`." msgstr "" -#: ../../c-api/memory.rst:112 +#: ../../c-api/memory.rst:109 msgid "The three allocation domains are:" msgstr "" -#: ../../c-api/memory.rst:114 +#: ../../c-api/memory.rst:111 msgid "" "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 :term:`GIL`. The memory is requested " -"directly to the system." +"directly from the system. See :ref:`Raw Memory Interface `." msgstr "" -#: ../../c-api/memory.rst:119 +#: ../../c-api/memory.rst:116 msgid "" "\"Mem\" domain: intended for allocating memory for Python buffers and " "general-purpose memory buffers where the allocation must be performed with " -"the :term:`GIL` held. The memory is taken from the Python private heap." +"the :term:`GIL` held. The memory is taken from the Python private heap. See :" +"ref:`Memory Interface `." msgstr "" -#: ../../c-api/memory.rst:123 +#: ../../c-api/memory.rst:121 msgid "" -"Object domain: intended for allocating memory belonging to Python objects. " -"The memory is taken from the Python private heap." +"Object domain: intended for allocating memory for Python objects. The memory " +"is taken from the Python private heap. See :ref:`Object allocators " +"`." msgstr "" #: ../../c-api/memory.rst:126 msgid "" -"When freeing memory previously allocated by the allocating functions " -"belonging to a given domain,the matching specific deallocating functions " -"must be used. For example, :c:func:`PyMem_Free` must be used to free memory " -"allocated using :c:func:`PyMem_Malloc`." +"The :term:`free-threaded ` build requires that only Python " +"objects are allocated using the \"object\" domain and that all Python " +"objects are allocated using that domain. This differs from the prior Python " +"versions, where this was only a best practice and not a hard requirement." msgstr "" -#: ../../c-api/memory.rst:131 -msgid "Raw Memory Interface" +#: ../../c-api/memory.rst:130 +msgid "" +"For example, buffers (non-Python objects) should be allocated using :c:func:" +"`PyMem_Malloc`, :c:func:`PyMem_RawMalloc`, or :c:func:`malloc`, but not :c:" +"func:`PyObject_Malloc`." msgstr "" #: ../../c-api/memory.rst:133 +msgid "See :ref:`Memory Allocation APIs `." +msgstr "" + +#: ../../c-api/memory.rst:139 +msgid "Raw Memory Interface" +msgstr "" + +#: ../../c-api/memory.rst:141 msgid "" "The following function sets are wrappers to the system allocator. These " "functions are thread-safe, the :term:`GIL ` does " "not need to be held." msgstr "" -#: ../../c-api/memory.rst:137 +#: ../../c-api/memory.rst:145 msgid "" "The :ref:`default raw memory allocator ` uses the " "following functions: :c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` " @@ -195,63 +206,63 @@ msgid "" "requesting zero bytes." msgstr "" -#: ../../c-api/memory.rst:146 ../../c-api/memory.rst:217 -#: ../../c-api/memory.rst:325 +#: ../../c-api/memory.rst:154 ../../c-api/memory.rst:225 +#: ../../c-api/memory.rst:335 msgid "" "Allocates *n* bytes and returns a pointer of type :c:expr:`void*` to the " "allocated memory, or ``NULL`` if the request fails." msgstr "" -#: ../../c-api/memory.rst:149 +#: ../../c-api/memory.rst:157 msgid "" "Requesting zero bytes returns a distinct non-``NULL`` pointer if possible, " "as if ``PyMem_RawMalloc(1)`` had been called instead. The memory will not " "have been initialized in any way." msgstr "" -#: ../../c-api/memory.rst:156 ../../c-api/memory.rst:227 -#: ../../c-api/memory.rst:335 +#: ../../c-api/memory.rst:164 ../../c-api/memory.rst:235 +#: ../../c-api/memory.rst:345 msgid "" "Allocates *nelem* elements each whose size in bytes is *elsize* and returns " "a pointer of type :c:expr:`void*` to the allocated memory, or ``NULL`` if " "the request fails. The memory is initialized to zeros." msgstr "" -#: ../../c-api/memory.rst:160 +#: ../../c-api/memory.rst:168 msgid "" "Requesting zero elements or elements of size zero bytes returns a distinct " "non-``NULL`` pointer if possible, as if ``PyMem_RawCalloc(1, 1)`` had been " "called instead." msgstr "" -#: ../../c-api/memory.rst:169 ../../c-api/memory.rst:240 -#: ../../c-api/memory.rst:348 +#: ../../c-api/memory.rst:177 ../../c-api/memory.rst:248 +#: ../../c-api/memory.rst:358 msgid "" "Resizes the memory block pointed to by *p* to *n* bytes. The contents will " "be unchanged to the minimum of the old and the new sizes." msgstr "" -#: ../../c-api/memory.rst:172 +#: ../../c-api/memory.rst:180 msgid "" "If *p* is ``NULL``, the call is equivalent to ``PyMem_RawMalloc(n)``; else " "if *n* is equal to zero, the memory block is resized but is not freed, and " "the returned pointer is non-``NULL``." msgstr "" -#: ../../c-api/memory.rst:176 +#: ../../c-api/memory.rst:184 msgid "" "Unless *p* is ``NULL``, it must have been returned by a previous call to :c:" "func:`PyMem_RawMalloc`, :c:func:`PyMem_RawRealloc` or :c:func:" "`PyMem_RawCalloc`." msgstr "" -#: ../../c-api/memory.rst:180 +#: ../../c-api/memory.rst:188 msgid "" "If the request fails, :c:func:`PyMem_RawRealloc` returns ``NULL`` and *p* " "remains a valid pointer to the previous memory area." msgstr "" -#: ../../c-api/memory.rst:186 +#: ../../c-api/memory.rst:194 msgid "" "Frees the memory block pointed to by *p*, which must have been returned by a " "previous call to :c:func:`PyMem_RawMalloc`, :c:func:`PyMem_RawRealloc` or :c:" @@ -259,73 +270,73 @@ msgid "" "called before, undefined behavior occurs." msgstr "" -#: ../../c-api/memory.rst:191 ../../c-api/memory.rst:261 -#: ../../c-api/memory.rst:369 +#: ../../c-api/memory.rst:199 ../../c-api/memory.rst:269 +#: ../../c-api/memory.rst:379 msgid "If *p* is ``NULL``, no operation is performed." msgstr "" -#: ../../c-api/memory.rst:197 +#: ../../c-api/memory.rst:205 msgid "Memory Interface" msgstr "記憶體介面" -#: ../../c-api/memory.rst:199 ../../c-api/memory.rst:305 +#: ../../c-api/memory.rst:207 ../../c-api/memory.rst:315 msgid "" "The following function sets, modeled after the ANSI C standard, but " "specifying behavior when requesting zero bytes, are available for allocating " "and releasing memory from the Python heap." msgstr "" -#: ../../c-api/memory.rst:203 +#: ../../c-api/memory.rst:211 msgid "" "The :ref:`default memory allocator ` uses the :" "ref:`pymalloc memory allocator `." msgstr "" -#: ../../c-api/memory.rst:208 ../../c-api/memory.rst:320 +#: ../../c-api/memory.rst:216 ../../c-api/memory.rst:330 msgid "" "The :term:`GIL ` must be held when using these " "functions." msgstr "" -#: ../../c-api/memory.rst:213 +#: ../../c-api/memory.rst:221 msgid "" "The default allocator is now pymalloc instead of system :c:func:`malloc`." msgstr "" -#: ../../c-api/memory.rst:220 +#: ../../c-api/memory.rst:228 msgid "" "Requesting zero bytes returns a distinct non-``NULL`` pointer if possible, " "as if ``PyMem_Malloc(1)`` had been called instead. The memory will not have " "been initialized in any way." msgstr "" -#: ../../c-api/memory.rst:231 +#: ../../c-api/memory.rst:239 msgid "" "Requesting zero elements or elements of size zero bytes returns a distinct " "non-``NULL`` pointer if possible, as if ``PyMem_Calloc(1, 1)`` had been " "called instead." msgstr "" -#: ../../c-api/memory.rst:243 +#: ../../c-api/memory.rst:251 msgid "" "If *p* is ``NULL``, the call is equivalent to ``PyMem_Malloc(n)``; else if " "*n* is equal to zero, the memory block is resized but is not freed, and the " "returned pointer is non-``NULL``." msgstr "" -#: ../../c-api/memory.rst:247 +#: ../../c-api/memory.rst:255 msgid "" "Unless *p* is ``NULL``, it must have been returned by a previous call to :c:" "func:`PyMem_Malloc`, :c:func:`PyMem_Realloc` or :c:func:`PyMem_Calloc`." msgstr "" -#: ../../c-api/memory.rst:250 +#: ../../c-api/memory.rst:258 msgid "" "If the request fails, :c:func:`PyMem_Realloc` returns ``NULL`` and *p* " "remains a valid pointer to the previous memory area." msgstr "" -#: ../../c-api/memory.rst:256 +#: ../../c-api/memory.rst:264 msgid "" "Frees the memory block pointed to by *p*, which must have been returned by a " "previous call to :c:func:`PyMem_Malloc`, :c:func:`PyMem_Realloc` or :c:func:" @@ -333,20 +344,20 @@ msgid "" "undefined behavior occurs." msgstr "" -#: ../../c-api/memory.rst:263 +#: ../../c-api/memory.rst:271 msgid "" "The following type-oriented macros are provided for convenience. Note that " "*TYPE* refers to any C type." msgstr "" -#: ../../c-api/memory.rst:269 +#: ../../c-api/memory.rst:277 msgid "" "Same as :c:func:`PyMem_Malloc`, but allocates ``(n * sizeof(TYPE))`` bytes " "of memory. Returns a pointer cast to ``TYPE*``. The memory will not have " "been initialized in any way." msgstr "" -#: ../../c-api/memory.rst:276 +#: ../../c-api/memory.rst:284 msgid "" "Same as :c:func:`PyMem_Realloc`, but the memory block is resized to ``(n * " "sizeof(TYPE))`` bytes. Returns a pointer cast to ``TYPE*``. On return, *p* " @@ -354,17 +365,17 @@ msgid "" "failure." msgstr "" -#: ../../c-api/memory.rst:281 +#: ../../c-api/memory.rst:289 msgid "" "This is a C preprocessor macro; *p* is always reassigned. Save the original " "value of *p* to avoid losing memory when handling errors." msgstr "" -#: ../../c-api/memory.rst:287 +#: ../../c-api/memory.rst:295 msgid "Same as :c:func:`PyMem_Free`." msgstr "和 :c:func:`PyMem_Free` 相同。" -#: ../../c-api/memory.rst:289 +#: ../../c-api/memory.rst:297 msgid "" "In addition, the following macro sets are provided for calling the Python " "memory allocator directly, without involving the C API functions listed " @@ -372,35 +383,35 @@ msgid "" "across Python versions and is therefore deprecated in extension modules." msgstr "" -#: ../../c-api/memory.rst:294 +#: ../../c-api/memory.rst:302 msgid "``PyMem_MALLOC(size)``" msgstr "``PyMem_MALLOC(size)``" -#: ../../c-api/memory.rst:295 +#: ../../c-api/memory.rst:303 msgid "``PyMem_NEW(type, size)``" msgstr "``PyMem_NEW(type, size)``" -#: ../../c-api/memory.rst:296 +#: ../../c-api/memory.rst:304 msgid "``PyMem_REALLOC(ptr, size)``" msgstr "``PyMem_REALLOC(ptr, size)``" -#: ../../c-api/memory.rst:297 +#: ../../c-api/memory.rst:305 msgid "``PyMem_RESIZE(ptr, type, size)``" msgstr "``PyMem_RESIZE(ptr, type, size)``" -#: ../../c-api/memory.rst:298 +#: ../../c-api/memory.rst:306 msgid "``PyMem_FREE(ptr)``" msgstr "``PyMem_FREE(ptr)``" -#: ../../c-api/memory.rst:299 +#: ../../c-api/memory.rst:307 msgid "``PyMem_DEL(ptr)``" msgstr "``PyMem_DEL(ptr)``" -#: ../../c-api/memory.rst:303 +#: ../../c-api/memory.rst:313 msgid "Object allocators" msgstr "" -#: ../../c-api/memory.rst:310 +#: ../../c-api/memory.rst:320 msgid "" "There is no guarantee that the memory returned by these allocators can be " "successfully cast to a Python object when intercepting the allocating " @@ -408,47 +419,47 @@ msgid "" "Memory Allocators ` section." msgstr "" -#: ../../c-api/memory.rst:315 +#: ../../c-api/memory.rst:325 msgid "" "The :ref:`default object allocator ` uses the :" "ref:`pymalloc memory allocator `." msgstr "" -#: ../../c-api/memory.rst:328 +#: ../../c-api/memory.rst:338 msgid "" "Requesting zero bytes returns a distinct non-``NULL`` pointer if possible, " "as if ``PyObject_Malloc(1)`` had been called instead. The memory will not " "have been initialized in any way." msgstr "" -#: ../../c-api/memory.rst:339 +#: ../../c-api/memory.rst:349 msgid "" "Requesting zero elements or elements of size zero bytes returns a distinct " "non-``NULL`` pointer if possible, as if ``PyObject_Calloc(1, 1)`` had been " "called instead." msgstr "" -#: ../../c-api/memory.rst:351 +#: ../../c-api/memory.rst:361 msgid "" "If *p* is ``NULL``, the call is equivalent to ``PyObject_Malloc(n)``; else " "if *n* is equal to zero, the memory block is resized but is not freed, and " "the returned pointer is non-``NULL``." msgstr "" -#: ../../c-api/memory.rst:355 +#: ../../c-api/memory.rst:365 msgid "" "Unless *p* is ``NULL``, it must have been returned by a previous call to :c:" "func:`PyObject_Malloc`, :c:func:`PyObject_Realloc` or :c:func:" "`PyObject_Calloc`." msgstr "" -#: ../../c-api/memory.rst:358 +#: ../../c-api/memory.rst:368 msgid "" "If the request fails, :c:func:`PyObject_Realloc` returns ``NULL`` and *p* " "remains a valid pointer to the previous memory area." msgstr "" -#: ../../c-api/memory.rst:364 +#: ../../c-api/memory.rst:374 msgid "" "Frees the memory block pointed to by *p*, which must have been returned by a " "previous call to :c:func:`PyObject_Malloc`, :c:func:`PyObject_Realloc` or :c:" @@ -456,277 +467,283 @@ msgid "" "called before, undefined behavior occurs." msgstr "" -#: ../../c-api/memory.rst:375 +#: ../../c-api/memory.rst:385 msgid "Default Memory Allocators" msgstr "" -#: ../../c-api/memory.rst:377 +#: ../../c-api/memory.rst:387 msgid "Default memory allocators:" msgstr "" -#: ../../c-api/memory.rst:380 +#: ../../c-api/memory.rst:390 msgid "Configuration" msgstr "配置" -#: ../../c-api/memory.rst:380 +#: ../../c-api/memory.rst:390 msgid "Name" msgstr "名稱" -#: ../../c-api/memory.rst:380 +#: ../../c-api/memory.rst:390 msgid "PyMem_RawMalloc" msgstr "PyMem_RawMalloc" -#: ../../c-api/memory.rst:380 +#: ../../c-api/memory.rst:390 msgid "PyMem_Malloc" msgstr "PyMem_Malloc" -#: ../../c-api/memory.rst:380 +#: ../../c-api/memory.rst:390 msgid "PyObject_Malloc" msgstr "PyObject_Malloc" -#: ../../c-api/memory.rst:382 +#: ../../c-api/memory.rst:392 msgid "Release build" msgstr "" -#: ../../c-api/memory.rst:382 +#: ../../c-api/memory.rst:392 msgid "``\"pymalloc\"``" msgstr "``\"pymalloc\"``" -#: ../../c-api/memory.rst:382 ../../c-api/memory.rst:384 +#: ../../c-api/memory.rst:392 ../../c-api/memory.rst:394 msgid "``malloc``" msgstr "``malloc``" -#: ../../c-api/memory.rst:382 +#: ../../c-api/memory.rst:392 msgid "``pymalloc``" msgstr "``pymalloc``" -#: ../../c-api/memory.rst:383 +#: ../../c-api/memory.rst:393 msgid "Debug build" msgstr "" -#: ../../c-api/memory.rst:383 +#: ../../c-api/memory.rst:393 msgid "``\"pymalloc_debug\"``" msgstr "``\"pymalloc_debug\"``" -#: ../../c-api/memory.rst:383 ../../c-api/memory.rst:385 +#: ../../c-api/memory.rst:393 ../../c-api/memory.rst:395 msgid "``malloc`` + debug" msgstr "" -#: ../../c-api/memory.rst:383 +#: ../../c-api/memory.rst:393 msgid "``pymalloc`` + debug" msgstr "" -#: ../../c-api/memory.rst:384 +#: ../../c-api/memory.rst:394 msgid "Release build, without pymalloc" msgstr "" -#: ../../c-api/memory.rst:384 +#: ../../c-api/memory.rst:394 msgid "``\"malloc\"``" msgstr "``\"malloc\"``" -#: ../../c-api/memory.rst:385 +#: ../../c-api/memory.rst:395 msgid "Debug build, without pymalloc" msgstr "" -#: ../../c-api/memory.rst:385 +#: ../../c-api/memory.rst:395 msgid "``\"malloc_debug\"``" msgstr "``\"malloc_debug\"``" -#: ../../c-api/memory.rst:388 +#: ../../c-api/memory.rst:398 msgid "Legend:" msgstr "" -#: ../../c-api/memory.rst:390 +#: ../../c-api/memory.rst:400 msgid "Name: value for :envvar:`PYTHONMALLOC` environment variable." msgstr "" -#: ../../c-api/memory.rst:391 +#: ../../c-api/memory.rst:401 msgid "" "``malloc``: system allocators from the standard C library, C functions: :c:" "func:`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`." msgstr "" -#: ../../c-api/memory.rst:393 +#: ../../c-api/memory.rst:403 msgid "``pymalloc``: :ref:`pymalloc memory allocator `." msgstr "" -#: ../../c-api/memory.rst:394 +#: ../../c-api/memory.rst:404 +msgid "" +"``mimalloc``: :ref:`mimalloc memory allocator `. The pymalloc " +"allocator will be used if mimalloc support isn't available." +msgstr "" + +#: ../../c-api/memory.rst:406 msgid "" "\"+ debug\": with :ref:`debug hooks on the Python memory allocators `." msgstr "" -#: ../../c-api/memory.rst:396 +#: ../../c-api/memory.rst:408 msgid "\"Debug build\": :ref:`Python build in debug mode `." msgstr "" -#: ../../c-api/memory.rst:401 +#: ../../c-api/memory.rst:413 msgid "Customize Memory Allocators" msgstr "" -#: ../../c-api/memory.rst:407 +#: ../../c-api/memory.rst:419 msgid "" "Structure used to describe a memory block allocator. The structure has the " "following fields:" msgstr "" -#: ../../c-api/memory.rst:411 ../../c-api/memory.rst:658 +#: ../../c-api/memory.rst:423 ../../c-api/memory.rst:674 msgid "Field" msgstr "欄位" -#: ../../c-api/memory.rst:411 ../../c-api/memory.rst:658 +#: ../../c-api/memory.rst:423 ../../c-api/memory.rst:674 msgid "Meaning" msgstr "意義" -#: ../../c-api/memory.rst:413 ../../c-api/memory.rst:660 +#: ../../c-api/memory.rst:425 ../../c-api/memory.rst:676 msgid "``void *ctx``" msgstr "``void *ctx``" -#: ../../c-api/memory.rst:413 ../../c-api/memory.rst:660 +#: ../../c-api/memory.rst:425 ../../c-api/memory.rst:676 msgid "user context passed as first argument" msgstr "" -#: ../../c-api/memory.rst:415 +#: ../../c-api/memory.rst:427 msgid "``void* malloc(void *ctx, size_t size)``" msgstr "``void* malloc(void *ctx, size_t size)``" -#: ../../c-api/memory.rst:415 +#: ../../c-api/memory.rst:427 msgid "allocate a memory block" msgstr "" -#: ../../c-api/memory.rst:417 +#: ../../c-api/memory.rst:429 msgid "``void* calloc(void *ctx, size_t nelem, size_t elsize)``" msgstr "``void* calloc(void *ctx, size_t nelem, size_t elsize)``" -#: ../../c-api/memory.rst:417 +#: ../../c-api/memory.rst:429 msgid "allocate a memory block initialized with zeros" msgstr "" -#: ../../c-api/memory.rst:420 +#: ../../c-api/memory.rst:432 msgid "``void* realloc(void *ctx, void *ptr, size_t new_size)``" msgstr "``void* realloc(void *ctx, void *ptr, size_t new_size)``" -#: ../../c-api/memory.rst:420 +#: ../../c-api/memory.rst:432 msgid "allocate or resize a memory block" msgstr "" -#: ../../c-api/memory.rst:422 +#: ../../c-api/memory.rst:434 msgid "``void free(void *ctx, void *ptr)``" msgstr "``void free(void *ctx, void *ptr)``" -#: ../../c-api/memory.rst:422 +#: ../../c-api/memory.rst:434 msgid "free a memory block" msgstr "" -#: ../../c-api/memory.rst:425 +#: ../../c-api/memory.rst:437 msgid "" "The :c:type:`!PyMemAllocator` structure was renamed to :c:type:" "`PyMemAllocatorEx` and a new ``calloc`` field was added." msgstr "" -#: ../../c-api/memory.rst:432 +#: ../../c-api/memory.rst:444 msgid "Enum used to identify an allocator domain. Domains:" msgstr "" -#: ../../c-api/memory.rst:438 ../../c-api/memory.rst:447 -#: ../../c-api/memory.rst:456 +#: ../../c-api/memory.rst:450 ../../c-api/memory.rst:459 +#: ../../c-api/memory.rst:468 msgid "Functions:" msgstr "函式:" -#: ../../c-api/memory.rst:440 +#: ../../c-api/memory.rst:452 msgid ":c:func:`PyMem_RawMalloc`" msgstr ":c:func:`PyMem_RawMalloc`" -#: ../../c-api/memory.rst:441 +#: ../../c-api/memory.rst:453 msgid ":c:func:`PyMem_RawRealloc`" msgstr ":c:func:`PyMem_RawRealloc`" -#: ../../c-api/memory.rst:442 +#: ../../c-api/memory.rst:454 msgid ":c:func:`PyMem_RawCalloc`" msgstr ":c:func:`PyMem_RawCalloc`" -#: ../../c-api/memory.rst:443 +#: ../../c-api/memory.rst:455 msgid ":c:func:`PyMem_RawFree`" msgstr ":c:func:`PyMem_RawFree`" -#: ../../c-api/memory.rst:449 +#: ../../c-api/memory.rst:461 msgid ":c:func:`PyMem_Malloc`," msgstr ":c:func:`PyMem_Malloc`," -#: ../../c-api/memory.rst:450 +#: ../../c-api/memory.rst:462 msgid ":c:func:`PyMem_Realloc`" msgstr ":c:func:`PyMem_Realloc`" -#: ../../c-api/memory.rst:451 +#: ../../c-api/memory.rst:463 msgid ":c:func:`PyMem_Calloc`" msgstr ":c:func:`PyMem_Calloc`" -#: ../../c-api/memory.rst:452 +#: ../../c-api/memory.rst:464 msgid ":c:func:`PyMem_Free`" msgstr ":c:func:`PyMem_Free`" -#: ../../c-api/memory.rst:458 +#: ../../c-api/memory.rst:470 msgid ":c:func:`PyObject_Malloc`" msgstr ":c:func:`PyObject_Malloc`" -#: ../../c-api/memory.rst:459 +#: ../../c-api/memory.rst:471 msgid ":c:func:`PyObject_Realloc`" msgstr ":c:func:`PyObject_Realloc`" -#: ../../c-api/memory.rst:460 +#: ../../c-api/memory.rst:472 msgid ":c:func:`PyObject_Calloc`" msgstr ":c:func:`PyObject_Calloc`" -#: ../../c-api/memory.rst:461 +#: ../../c-api/memory.rst:473 msgid ":c:func:`PyObject_Free`" msgstr ":c:func:`PyObject_Free`" -#: ../../c-api/memory.rst:465 +#: ../../c-api/memory.rst:477 msgid "Get the memory block allocator of the specified domain." msgstr "" -#: ../../c-api/memory.rst:470 +#: ../../c-api/memory.rst:482 msgid "Set the memory block allocator of the specified domain." msgstr "" -#: ../../c-api/memory.rst:472 +#: ../../c-api/memory.rst:484 msgid "" "The new allocator must return a distinct non-``NULL`` pointer when " "requesting zero bytes." msgstr "" -#: ../../c-api/memory.rst:475 +#: ../../c-api/memory.rst:487 msgid "" "For the :c:macro:`PYMEM_DOMAIN_RAW` domain, the allocator must be thread-" "safe: the :term:`GIL ` is not held when the " "allocator is called." msgstr "" -#: ../../c-api/memory.rst:479 +#: ../../c-api/memory.rst:491 msgid "" "For the remaining domains, the allocator must also be thread-safe: the " "allocator may be called in different interpreters that do not share a " "``GIL``." msgstr "" -#: ../../c-api/memory.rst:483 +#: ../../c-api/memory.rst:495 msgid "" "If the new allocator is not a hook (does not call the previous allocator), " "the :c:func:`PyMem_SetupDebugHooks` function must be called to reinstall the " "debug hooks on top on the new allocator." msgstr "" -#: ../../c-api/memory.rst:487 +#: ../../c-api/memory.rst:499 msgid "" "See also :c:member:`PyPreConfig.allocator` and :ref:`Preinitialize Python " "with PyPreConfig `." msgstr "" -#: ../../c-api/memory.rst:492 +#: ../../c-api/memory.rst:504 msgid ":c:func:`PyMem_SetAllocator` does have the following contract:" msgstr "" -#: ../../c-api/memory.rst:494 +#: ../../c-api/memory.rst:506 msgid "" "It can be called after :c:func:`Py_PreInitialize` and before :c:func:" "`Py_InitializeFromConfig` to install a custom memory allocator. There are no " @@ -736,7 +753,7 @@ msgid "" "domains>` for more information." msgstr "" -#: ../../c-api/memory.rst:502 +#: ../../c-api/memory.rst:514 msgid "" "If called after Python has finish initializing (after :c:func:" "`Py_InitializeFromConfig` has been called) the allocator **must** wrap the " @@ -744,21 +761,21 @@ msgid "" "arbitrary one is **not supported**." msgstr "" -#: ../../c-api/memory.rst:507 +#: ../../c-api/memory.rst:519 msgid "All allocators must be thread-safe." msgstr "" -#: ../../c-api/memory.rst:513 +#: ../../c-api/memory.rst:525 msgid "" "Setup :ref:`debug hooks in the Python memory allocators ` " "to detect memory errors." msgstr "" -#: ../../c-api/memory.rst:520 +#: ../../c-api/memory.rst:532 msgid "Debug hooks on the Python memory allocators" msgstr "" -#: ../../c-api/memory.rst:522 +#: ../../c-api/memory.rst:534 msgid "" "When :ref:`Python is built in debug mode `, the :c:func:" "`PyMem_SetupDebugHooks` function is called at the :ref:`Python " @@ -766,19 +783,19 @@ msgid "" "allocators to detect memory errors." msgstr "" -#: ../../c-api/memory.rst:527 +#: ../../c-api/memory.rst:539 msgid "" "The :envvar:`PYTHONMALLOC` environment variable can be used to install debug " "hooks on a Python compiled in release mode (ex: ``PYTHONMALLOC=debug``)." msgstr "" -#: ../../c-api/memory.rst:530 +#: ../../c-api/memory.rst:542 msgid "" "The :c:func:`PyMem_SetupDebugHooks` function can be used to set debug hooks " "after calling :c:func:`PyMem_SetAllocator`." msgstr "" -#: ../../c-api/memory.rst:533 +#: ../../c-api/memory.rst:545 msgid "" "These debug hooks fill dynamically allocated memory blocks with special, " "recognizable bit patterns. Newly allocated memory is filled with the byte " @@ -788,25 +805,25 @@ msgid "" "these bytes are unlikely to be valid addresses, floats, or ASCII strings." msgstr "" -#: ../../c-api/memory.rst:540 +#: ../../c-api/memory.rst:552 msgid "Runtime checks:" msgstr "Runtime 檢查:" -#: ../../c-api/memory.rst:542 +#: ../../c-api/memory.rst:554 msgid "" "Detect API violations. For example, detect if :c:func:`PyObject_Free` is " "called on a memory block allocated by :c:func:`PyMem_Malloc`." msgstr "" -#: ../../c-api/memory.rst:544 +#: ../../c-api/memory.rst:556 msgid "Detect write before the start of the buffer (buffer underflow)." msgstr "" -#: ../../c-api/memory.rst:545 +#: ../../c-api/memory.rst:557 msgid "Detect write after the end of the buffer (buffer overflow)." msgstr "" -#: ../../c-api/memory.rst:546 +#: ../../c-api/memory.rst:558 msgid "" "Check that the :term:`GIL ` is held when allocator " "functions of :c:macro:`PYMEM_DOMAIN_OBJ` (ex: :c:func:`PyObject_Malloc`) " @@ -814,7 +831,7 @@ msgid "" "called." msgstr "" -#: ../../c-api/memory.rst:551 +#: ../../c-api/memory.rst:563 msgid "" "On error, the debug hooks use the :mod:`tracemalloc` module to get the " "traceback where a memory block was allocated. The traceback is only " @@ -822,7 +839,7 @@ msgid "" "memory block was traced." msgstr "" -#: ../../c-api/memory.rst:556 +#: ../../c-api/memory.rst:568 msgid "" "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 " @@ -832,49 +849,49 @@ msgid "" "from a Python slice):" msgstr "" -#: ../../c-api/memory.rst:562 +#: ../../c-api/memory.rst:574 msgid "``p[-2*S:-S]``" msgstr "``p[-2*S:-S]``" -#: ../../c-api/memory.rst:563 +#: ../../c-api/memory.rst:575 msgid "" "Number of bytes originally asked for. This is a size_t, big-endian (easier " "to read in a memory dump)." msgstr "" -#: ../../c-api/memory.rst:565 +#: ../../c-api/memory.rst:577 msgid "``p[-S]``" msgstr "``p[-S]``" -#: ../../c-api/memory.rst:566 +#: ../../c-api/memory.rst:578 msgid "API identifier (ASCII character):" msgstr "" -#: ../../c-api/memory.rst:568 +#: ../../c-api/memory.rst:580 msgid "``'r'`` for :c:macro:`PYMEM_DOMAIN_RAW`." msgstr "" -#: ../../c-api/memory.rst:569 +#: ../../c-api/memory.rst:581 msgid "``'m'`` for :c:macro:`PYMEM_DOMAIN_MEM`." msgstr "" -#: ../../c-api/memory.rst:570 +#: ../../c-api/memory.rst:582 msgid "``'o'`` for :c:macro:`PYMEM_DOMAIN_OBJ`." msgstr "" -#: ../../c-api/memory.rst:572 +#: ../../c-api/memory.rst:584 msgid "``p[-S+1:0]``" msgstr "``p[-S+1:0]``" -#: ../../c-api/memory.rst:573 +#: ../../c-api/memory.rst:585 msgid "Copies of PYMEM_FORBIDDENBYTE. Used to catch under- writes and reads." msgstr "" -#: ../../c-api/memory.rst:575 +#: ../../c-api/memory.rst:587 msgid "``p[0:N]``" msgstr "``p[0:N]``" -#: ../../c-api/memory.rst:576 +#: ../../c-api/memory.rst:588 msgid "" "The requested memory, filled with copies of PYMEM_CLEANBYTE, used to catch " "reference to uninitialized memory. When a realloc-like function is called " @@ -885,25 +902,25 @@ msgid "" "bytes are also filled with PYMEM_DEADBYTE." msgstr "" -#: ../../c-api/memory.rst:584 +#: ../../c-api/memory.rst:596 msgid "``p[N:N+S]``" msgstr "``p[N:N+S]``" -#: ../../c-api/memory.rst:585 +#: ../../c-api/memory.rst:597 msgid "Copies of PYMEM_FORBIDDENBYTE. Used to catch over- writes and reads." msgstr "" -#: ../../c-api/memory.rst:587 +#: ../../c-api/memory.rst:599 msgid "``p[N+S:N+2*S]``" msgstr "``p[N+S:N+2*S]``" -#: ../../c-api/memory.rst:588 +#: ../../c-api/memory.rst:600 msgid "" "Only used if the ``PYMEM_DEBUG_SERIALNO`` macro is defined (not defined by " "default)." msgstr "" -#: ../../c-api/memory.rst:591 +#: ../../c-api/memory.rst:603 msgid "" "A serial number, incremented by 1 on each call to a malloc-like or realloc-" "like function. Big-endian :c:type:`size_t`. If \"bad memory\" is detected " @@ -913,7 +930,7 @@ msgid "" "number is incremented, and exists so you can set such a breakpoint easily." msgstr "" -#: ../../c-api/memory.rst:598 +#: ../../c-api/memory.rst:610 msgid "" "A realloc-like or free-like function first checks that the " "PYMEM_FORBIDDENBYTE bytes at each end are intact. If they've been altered, " @@ -926,7 +943,7 @@ msgid "" "getting used)." msgstr "" -#: ../../c-api/memory.rst:607 +#: ../../c-api/memory.rst:619 msgid "" "The :c:func:`PyMem_SetupDebugHooks` function now also works on Python " "compiled in release mode. On error, the debug hooks now use :mod:" @@ -935,7 +952,7 @@ msgid "" "`PYMEM_DOMAIN_OBJ` and :c:macro:`PYMEM_DOMAIN_MEM` domains are called." msgstr "" -#: ../../c-api/memory.rst:615 +#: ../../c-api/memory.rst:627 msgid "" "Byte patterns ``0xCB`` (``PYMEM_CLEANBYTE``), ``0xDB`` (``PYMEM_DEADBYTE``) " "and ``0xFB`` (``PYMEM_FORBIDDENBYTE``) have been replaced with ``0xCD``, " @@ -943,11 +960,11 @@ msgid "" "``malloc()`` and ``free()``." msgstr "" -#: ../../c-api/memory.rst:625 +#: ../../c-api/memory.rst:637 msgid "The pymalloc allocator" msgstr "" -#: ../../c-api/memory.rst:627 +#: ../../c-api/memory.rst:639 msgid "" "Python has a *pymalloc* allocator optimized for small objects (smaller or " "equal to 512 bytes) with a short lifetime. It uses memory mappings called " @@ -956,110 +973,129 @@ msgid "" "`PyMem_RawRealloc` for allocations larger than 512 bytes." msgstr "" -#: ../../c-api/memory.rst:633 +#: ../../c-api/memory.rst:645 msgid "" "*pymalloc* is the :ref:`default allocator ` of " "the :c:macro:`PYMEM_DOMAIN_MEM` (ex: :c:func:`PyMem_Malloc`) and :c:macro:" "`PYMEM_DOMAIN_OBJ` (ex: :c:func:`PyObject_Malloc`) domains." msgstr "" -#: ../../c-api/memory.rst:637 +#: ../../c-api/memory.rst:649 msgid "The arena allocator uses the following functions:" msgstr "" -#: ../../c-api/memory.rst:639 +#: ../../c-api/memory.rst:651 msgid ":c:func:`!VirtualAlloc` and :c:func:`!VirtualFree` on Windows," msgstr "" -#: ../../c-api/memory.rst:640 +#: ../../c-api/memory.rst:652 msgid ":c:func:`!mmap` and :c:func:`!munmap` if available," msgstr "" -#: ../../c-api/memory.rst:641 +#: ../../c-api/memory.rst:653 msgid ":c:func:`malloc` and :c:func:`free` otherwise." msgstr "" -#: ../../c-api/memory.rst:643 +#: ../../c-api/memory.rst:655 msgid "" "This allocator is disabled if Python is configured with the :option:`--" "without-pymalloc` option. It can also be disabled at runtime using the :" "envvar:`PYTHONMALLOC` environment variable (ex: ``PYTHONMALLOC=malloc``)." msgstr "" -#: ../../c-api/memory.rst:648 +#: ../../c-api/memory.rst:659 +msgid "" +"Typically, it makes sense to disable the pymalloc allocator when building " +"Python with AddressSanitizer (:option:`--with-address-sanitizer`) which " +"helps uncover low level bugs within the C code." +msgstr "" + +#: ../../c-api/memory.rst:664 msgid "Customize pymalloc Arena Allocator" msgstr "" -#: ../../c-api/memory.rst:654 +#: ../../c-api/memory.rst:670 msgid "" "Structure used to describe an arena allocator. The structure has three " "fields:" msgstr "" -#: ../../c-api/memory.rst:662 +#: ../../c-api/memory.rst:678 msgid "``void* alloc(void *ctx, size_t size)``" msgstr "``void* alloc(void *ctx, size_t size)``" -#: ../../c-api/memory.rst:662 +#: ../../c-api/memory.rst:678 msgid "allocate an arena of size bytes" msgstr "" -#: ../../c-api/memory.rst:664 +#: ../../c-api/memory.rst:680 msgid "``void free(void *ctx, void *ptr, size_t size)``" msgstr "``void free(void *ctx, void *ptr, size_t size)``" -#: ../../c-api/memory.rst:664 +#: ../../c-api/memory.rst:680 msgid "free an arena" msgstr "" -#: ../../c-api/memory.rst:669 +#: ../../c-api/memory.rst:685 msgid "Get the arena allocator." msgstr "" -#: ../../c-api/memory.rst:673 +#: ../../c-api/memory.rst:689 msgid "Set the arena allocator." msgstr "" -#: ../../c-api/memory.rst:677 +#: ../../c-api/memory.rst:694 +msgid "The mimalloc allocator" +msgstr "" + +#: ../../c-api/memory.rst:698 +msgid "" +"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.\"" +msgstr "" + +#: ../../c-api/memory.rst:703 msgid "tracemalloc C API" msgstr "" -#: ../../c-api/memory.rst:683 +#: ../../c-api/memory.rst:709 msgid "Track an allocated memory block in the :mod:`tracemalloc` module." msgstr "" -#: ../../c-api/memory.rst:685 +#: ../../c-api/memory.rst:711 msgid "" "Return ``0`` on success, return ``-1`` on error (failed to allocate memory " "to store the trace). Return ``-2`` if tracemalloc is disabled." msgstr "" -#: ../../c-api/memory.rst:688 +#: ../../c-api/memory.rst:714 msgid "If memory block is already tracked, update the existing trace." msgstr "" -#: ../../c-api/memory.rst:692 +#: ../../c-api/memory.rst:718 msgid "" "Untrack an allocated memory block in the :mod:`tracemalloc` module. Do " "nothing if the block was not tracked." msgstr "" -#: ../../c-api/memory.rst:695 +#: ../../c-api/memory.rst:721 msgid "Return ``-2`` if tracemalloc is disabled, otherwise return ``0``." msgstr "" -#: ../../c-api/memory.rst:701 +#: ../../c-api/memory.rst:727 msgid "Examples" msgstr "範例" -#: ../../c-api/memory.rst:703 +#: ../../c-api/memory.rst:729 msgid "" "Here is the example from section :ref:`memoryoverview`, rewritten so that " "the I/O buffer is allocated from the Python heap by using the first function " "set::" msgstr "" -#: ../../c-api/memory.rst:706 +#: ../../c-api/memory.rst:732 msgid "" "PyObject *res;\n" "char *buf = (char *) PyMem_Malloc(BUFSIZ); /* for I/O */\n" @@ -1072,11 +1108,11 @@ msgid "" "return res;" msgstr "" -#: ../../c-api/memory.rst:716 +#: ../../c-api/memory.rst:742 msgid "The same code using the type-oriented function set::" msgstr "" -#: ../../c-api/memory.rst:718 +#: ../../c-api/memory.rst:744 msgid "" "PyObject *res;\n" "char *buf = PyMem_New(char, BUFSIZ); /* for I/O */\n" @@ -1089,7 +1125,7 @@ msgid "" "return res;" msgstr "" -#: ../../c-api/memory.rst:728 +#: ../../c-api/memory.rst:754 msgid "" "Note that in the two examples above, the buffer is always manipulated via " "functions belonging to the same set. Indeed, it is required to use the same " @@ -1099,7 +1135,7 @@ msgid "" "different allocators operating on different heaps. ::" msgstr "" -#: ../../c-api/memory.rst:735 +#: ../../c-api/memory.rst:761 msgid "" "char *buf1 = PyMem_New(char, BUFSIZ);\n" "char *buf2 = (char *) malloc(BUFSIZ);\n" @@ -1110,14 +1146,14 @@ msgid "" "free(buf1); /* Fatal -- should be PyMem_Del() */" msgstr "" -#: ../../c-api/memory.rst:743 +#: ../../c-api/memory.rst:769 msgid "" "In addition to the functions aimed at handling raw memory blocks from the " "Python heap, objects in Python are allocated and released with :c:macro:" "`PyObject_New`, :c:macro:`PyObject_NewVar` and :c:func:`PyObject_Del`." msgstr "" -#: ../../c-api/memory.rst:747 +#: ../../c-api/memory.rst:773 msgid "" "These will be explained in the next chapter on defining and implementing new " "object types in C." diff --git a/c-api/memoryview.po b/c-api/memoryview.po index 25b6abf571..0221f2b2b8 100644 --- a/c-api/memoryview.po +++ b/c-api/memoryview.po @@ -5,7 +5,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-01-30 00:03+0000\n" "PO-Revision-Date: 2015-12-09 17:51+0000\n" diff --git a/c-api/method.po b/c-api/method.po index 749218e03a..1583723816 100644 --- a/c-api/method.po +++ b/c-api/method.po @@ -6,7 +6,7 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-07-24 00:03+0000\n" "PO-Revision-Date: 2022-01-24 22:22+0800\n" diff --git a/c-api/module.po b/c-api/module.po index a5f3d840f4..16304cac16 100644 --- a/c-api/module.po +++ b/c-api/module.po @@ -5,9 +5,9 @@ # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 14:32+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -42,29 +42,33 @@ msgstr "" #: ../../c-api/module.rst:40 msgid "" -"Return a new module object with the :attr:`__name__` attribute set to " -"*name*. The module's :attr:`__name__`, :attr:`__doc__`, :attr:`__package__`, " -"and :attr:`__loader__` attributes are filled in (all but :attr:`__name__` " -"are set to ``None``); the caller is responsible for providing a :attr:" -"`__file__` attribute." +"Return a new module object with :attr:`module.__name__` set to *name*. The " +"module's :attr:`!__name__`, :attr:`~module.__doc__`, :attr:`~module." +"__package__` and :attr:`~module.__loader__` attributes are filled in (all " +"but :attr:`!__name__` are set to ``None``). The caller is responsible for " +"setting a :attr:`~module.__file__` attribute." msgstr "" -#: ../../c-api/module.rst:46 ../../c-api/module.rst:270 -#: ../../c-api/module.rst:445 +#: ../../c-api/module.rst:46 ../../c-api/module.rst:272 +#: ../../c-api/module.rst:492 msgid "Return ``NULL`` with an exception set on error." msgstr "在失敗時回傳 ``NULL`` 並設定例外。" #: ../../c-api/module.rst:50 -msgid ":attr:`__package__` and :attr:`__loader__` are set to ``None``." -msgstr ":attr:`__package__` 和 :attr:`__loader__` 被設為 ``None``。" +msgid "" +":attr:`~module.__package__` and :attr:`~module.__loader__` are now set to " +"``None``." +msgstr "" +":attr:`~module.__package__` 和 :attr:`~module.__loader__` 現在被設為 " +"``None``。" -#: ../../c-api/module.rst:56 +#: ../../c-api/module.rst:57 msgid "" "Similar to :c:func:`PyModule_NewObject`, but the name is a UTF-8 encoded " "string instead of a Unicode object." msgstr "" -#: ../../c-api/module.rst:64 +#: ../../c-api/module.rst:65 msgid "" "Return the dictionary object that implements *module*'s namespace; this " "object is the same as the :attr:`~object.__dict__` attribute of the module " @@ -72,64 +76,64 @@ msgid "" "object), :exc:`SystemError` is raised and ``NULL`` is returned." msgstr "" -#: ../../c-api/module.rst:69 +#: ../../c-api/module.rst:70 msgid "" "It is recommended extensions use other ``PyModule_*`` and ``PyObject_*`` " "functions rather than directly manipulate a module's :attr:`~object." "__dict__`." msgstr "" -#: ../../c-api/module.rst:80 +#: ../../c-api/module.rst:81 msgid "" -"Return *module*'s :attr:`__name__` value. If the module does not provide " -"one, or if it is not a string, :exc:`SystemError` is raised and ``NULL`` is " -"returned." +"Return *module*'s :attr:`~module.__name__` value. If the module does not " +"provide one, or if it is not a string, :exc:`SystemError` is raised and " +"``NULL`` is returned." msgstr "" -#: ../../c-api/module.rst:88 +#: ../../c-api/module.rst:90 msgid "" "Similar to :c:func:`PyModule_GetNameObject` but return the name encoded to " "``'utf-8'``." msgstr "" -#: ../../c-api/module.rst:93 +#: ../../c-api/module.rst:95 msgid "" "Return the \"state\" of the module, that is, a pointer to the block of " "memory allocated at module creation time, or ``NULL``. See :c:member:" "`PyModuleDef.m_size`." msgstr "" -#: ../../c-api/module.rst:100 +#: ../../c-api/module.rst:102 msgid "" "Return a pointer to the :c:type:`PyModuleDef` struct from which the module " "was created, or ``NULL`` if the module wasn't created from a definition." msgstr "" -#: ../../c-api/module.rst:110 +#: ../../c-api/module.rst:112 msgid "" "Return the name of the file from which *module* was loaded using *module*'s :" -"attr:`__file__` attribute. If this is not defined, or if it is not a " -"unicode string, raise :exc:`SystemError` and return ``NULL``; otherwise " -"return a reference to a Unicode object." +"attr:`~module.__file__` attribute. If this is not defined, or if it is not " +"a string, raise :exc:`SystemError` and return ``NULL``; otherwise return a " +"reference to a Unicode object." msgstr "" -#: ../../c-api/module.rst:120 +#: ../../c-api/module.rst:122 msgid "" "Similar to :c:func:`PyModule_GetFilenameObject` but return the filename " "encoded to 'utf-8'." msgstr "" -#: ../../c-api/module.rst:123 +#: ../../c-api/module.rst:125 msgid "" ":c:func:`PyModule_GetFilename` raises :exc:`UnicodeEncodeError` on " "unencodable filenames, use :c:func:`PyModule_GetFilenameObject` instead." msgstr "" -#: ../../c-api/module.rst:131 +#: ../../c-api/module.rst:133 msgid "Initializing C modules" msgstr "初始化 C 模組" -#: ../../c-api/module.rst:133 +#: ../../c-api/module.rst:135 msgid "" "Modules objects are usually created from extension modules (shared libraries " "which export an initialization function), or compiled-in modules (where the " @@ -137,55 +141,55 @@ msgid "" "See :ref:`building` or :ref:`extending-with-embedding` for details." msgstr "" -#: ../../c-api/module.rst:138 +#: ../../c-api/module.rst:140 msgid "" "The initialization function can either pass a module definition instance to :" "c:func:`PyModule_Create`, and return the resulting module object, or request " "\"multi-phase initialization\" by returning the definition struct itself." msgstr "" -#: ../../c-api/module.rst:144 +#: ../../c-api/module.rst:146 msgid "" "The module definition struct, which holds all information needed to create a " "module object. There is usually only one statically initialized variable of " "this type for each module." msgstr "" -#: ../../c-api/module.rst:150 +#: ../../c-api/module.rst:152 msgid "Always initialize this member to :c:macro:`PyModuleDef_HEAD_INIT`." msgstr "" -#: ../../c-api/module.rst:154 +#: ../../c-api/module.rst:156 msgid "Name for the new module." msgstr "" -#: ../../c-api/module.rst:158 +#: ../../c-api/module.rst:160 msgid "" "Docstring for the module; usually a docstring variable created with :c:macro:" "`PyDoc_STRVAR` is used." msgstr "" -#: ../../c-api/module.rst:163 +#: ../../c-api/module.rst:165 msgid "" "Module state may be kept in a per-module memory area that can be retrieved " "with :c:func:`PyModule_GetState`, rather than in static globals. This makes " "modules safe for use in multiple sub-interpreters." msgstr "" -#: ../../c-api/module.rst:167 +#: ../../c-api/module.rst:169 msgid "" "This memory area is allocated based on *m_size* on module creation, and " "freed when the module object is deallocated, after the :c:member:" "`~PyModuleDef.m_free` function has been called, if present." msgstr "" -#: ../../c-api/module.rst:171 +#: ../../c-api/module.rst:173 msgid "" "Setting ``m_size`` to ``-1`` means that the module does not support sub-" "interpreters, because it has global state." msgstr "" -#: ../../c-api/module.rst:174 +#: ../../c-api/module.rst:176 msgid "" "Setting it to a non-negative value means that the module can be re-" "initialized and specifies the additional amount of memory it requires for " @@ -193,37 +197,37 @@ msgid "" "initialization." msgstr "" -#: ../../c-api/module.rst:179 +#: ../../c-api/module.rst:181 msgid "See :PEP:`3121` for more details." msgstr "更多詳情請見 :pep:`3121`。" -#: ../../c-api/module.rst:183 +#: ../../c-api/module.rst:185 msgid "" "A pointer to a table of module-level functions, described by :c:type:" "`PyMethodDef` values. Can be ``NULL`` if no functions are present." msgstr "" -#: ../../c-api/module.rst:188 +#: ../../c-api/module.rst:190 msgid "" "An array of slot definitions for multi-phase initialization, terminated by a " "``{0, NULL}`` entry. When using single-phase initialization, *m_slots* must " "be ``NULL``." msgstr "" -#: ../../c-api/module.rst:194 +#: ../../c-api/module.rst:196 msgid "" "Prior to version 3.5, this member was always set to ``NULL``, and was " "defined as:" msgstr "" -#: ../../c-api/module.rst:201 +#: ../../c-api/module.rst:203 msgid "" "A traversal function to call during GC traversal of the module object, or " "``NULL`` if not needed." msgstr "" -#: ../../c-api/module.rst:204 ../../c-api/module.rst:219 -#: ../../c-api/module.rst:240 +#: ../../c-api/module.rst:206 ../../c-api/module.rst:221 +#: ../../c-api/module.rst:242 msgid "" "This function is not called if the module state was requested but is not " "allocated yet. This is the case immediately after the module is created and " @@ -233,18 +237,18 @@ msgid "" "`PyModule_GetState`) is ``NULL``." msgstr "" -#: ../../c-api/module.rst:211 ../../c-api/module.rst:232 -#: ../../c-api/module.rst:247 +#: ../../c-api/module.rst:213 ../../c-api/module.rst:234 +#: ../../c-api/module.rst:249 msgid "No longer called before the module state is allocated." msgstr "" -#: ../../c-api/module.rst:216 +#: ../../c-api/module.rst:218 msgid "" "A clear function to call during GC clearing of the module object, or " "``NULL`` if not needed." msgstr "" -#: ../../c-api/module.rst:226 +#: ../../c-api/module.rst:228 msgid "" "Like :c:member:`PyTypeObject.tp_clear`, this function is not *always* called " "before a module is deallocated. For example, when reference counting is " @@ -253,85 +257,108 @@ msgid "" "directly." msgstr "" -#: ../../c-api/module.rst:237 +#: ../../c-api/module.rst:239 msgid "" "A function to call during deallocation of the module object, or ``NULL`` if " "not needed." msgstr "" -#: ../../c-api/module.rst:251 +#: ../../c-api/module.rst:253 msgid "Single-phase initialization" msgstr "" -#: ../../c-api/module.rst:253 +#: ../../c-api/module.rst:255 msgid "" "The module initialization function may create and return the module object " "directly. This is referred to as \"single-phase initialization\", and uses " "one of the following two module creation functions:" msgstr "" -#: ../../c-api/module.rst:259 +#: ../../c-api/module.rst:261 msgid "" "Create a new module object, given the definition in *def*. This behaves " "like :c:func:`PyModule_Create2` with *module_api_version* set to :c:macro:" "`PYTHON_API_VERSION`." msgstr "" -#: ../../c-api/module.rst:266 +#: ../../c-api/module.rst:268 msgid "" "Create a new module object, given the definition in *def*, assuming the API " "version *module_api_version*. If that version does not match the version of " "the running interpreter, a :exc:`RuntimeWarning` is emitted." msgstr "" -#: ../../c-api/module.rst:274 +#: ../../c-api/module.rst:276 msgid "" "Most uses of this function should be using :c:func:`PyModule_Create` " "instead; only use this if you are sure you need it." msgstr "" -#: ../../c-api/module.rst:277 +#: ../../c-api/module.rst:279 msgid "" "Before it is returned from in the initialization function, the resulting " "module object is typically populated using functions like :c:func:" "`PyModule_AddObjectRef`." msgstr "" -#: ../../c-api/module.rst:283 +#: ../../c-api/module.rst:285 msgid "Multi-phase initialization" msgstr "" -#: ../../c-api/module.rst:285 +#: ../../c-api/module.rst:287 msgid "" "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 :py:meth:`!__new__` and :py:meth:`!" -"__init__` methods of classes." +"The distinction is similar to the :py:meth:`~object.__new__` and :py:meth:" +"`~object.__init__` methods of classes." msgstr "" -#: ../../c-api/module.rst:292 +#: ../../c-api/module.rst:294 msgid "" "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 :c:func:" -"`PyModule_GetState`), or its contents (such as the module's :attr:`~object." -"__dict__` or individual classes created with :c:func:`PyType_FromSpec`)." +"not singletons. For example, if the :py:attr:`sys.modules` entry is removed " +"and the module is re-imported, a new module object is created, and typically " +"populated with fresh method and type objects. The old module is subject to " +"normal garbage collection. This mirrors the behavior of pure-Python modules." msgstr "" #: ../../c-api/module.rst:302 msgid "" +"Additional module instances may be created in :ref:`sub-interpreters ` or after after Python runtime reinitialization (:c:" +"func:`Py_Finalize` and :c:func:`Py_Initialize`). In these cases, sharing " +"Python objects between module instances would likely cause crashes or " +"undefined behavior." +msgstr "" + +#: ../../c-api/module.rst:309 +msgid "" +"To avoid such issues, each instance of an extension module should be " +"*isolated*: changes to one instance should not implicitly affect the others, " +"and all state, including references to Python objects, should be specific to " +"a particular module instance. See :ref:`isolating-extensions-howto` for more " +"details and a practical guide." +msgstr "" + +#: ../../c-api/module.rst:315 +msgid "" +"A simpler way to avoid these issues is :ref:`raising an error on repeated " +"initialization `." +msgstr "" + +#: ../../c-api/module.rst:318 +msgid "" "All modules created using multi-phase initialization are expected to " -"support :ref:`sub-interpreters `. Making sure " -"multiple modules are independent is typically enough to achieve this." +"support :ref:`sub-interpreters `, or otherwise " +"explicitly signal a lack of support. This is usually achieved by isolation " +"or blocking repeated initialization, as above. A module may also be limited " +"to the main interpreter using the :c:data:`Py_mod_multiple_interpreters` " +"slot." msgstr "" -#: ../../c-api/module.rst:306 +#: ../../c-api/module.rst:326 msgid "" "To request multi-phase initialization, the initialization function " "(PyInit_modulename) returns a :c:type:`PyModuleDef` instance with non-empty :" @@ -339,65 +366,65 @@ msgid "" "instance must be initialized with the following function:" msgstr "" -#: ../../c-api/module.rst:313 +#: ../../c-api/module.rst:333 msgid "" "Ensures a module definition is a properly initialized Python object that " "correctly reports its type and reference count." msgstr "" -#: ../../c-api/module.rst:316 +#: ../../c-api/module.rst:336 msgid "Returns *def* cast to ``PyObject*``, or ``NULL`` if an error occurred." msgstr "" -#: ../../c-api/module.rst:320 +#: ../../c-api/module.rst:340 msgid "" "The *m_slots* member of the module definition must point to an array of " "``PyModuleDef_Slot`` structures:" msgstr "" -#: ../../c-api/module.rst:327 +#: ../../c-api/module.rst:347 msgid "A slot ID, chosen from the available values explained below." msgstr "" -#: ../../c-api/module.rst:331 +#: ../../c-api/module.rst:351 msgid "Value of the slot, whose meaning depends on the slot ID." msgstr "" -#: ../../c-api/module.rst:335 +#: ../../c-api/module.rst:355 msgid "The *m_slots* array must be terminated by a slot with id 0." msgstr "" -#: ../../c-api/module.rst:337 +#: ../../c-api/module.rst:357 msgid "The available slot types are:" msgstr "" -#: ../../c-api/module.rst:341 +#: ../../c-api/module.rst:361 msgid "" "Specifies a function that is called to create the module object itself. The " "*value* pointer of this slot must point to a function of the signature:" msgstr "" -#: ../../c-api/module.rst:348 +#: ../../c-api/module.rst:368 msgid "" "The function receives a :py:class:`~importlib.machinery.ModuleSpec` " "instance, as defined in :PEP:`451`, and the module definition. It should " "return a new module object, or set an error and return ``NULL``." msgstr "" -#: ../../c-api/module.rst:353 +#: ../../c-api/module.rst:373 msgid "" "This function should be kept minimal. In particular, it should not call " "arbitrary Python code, as trying to import the same module again may result " "in an infinite loop." msgstr "" -#: ../../c-api/module.rst:357 +#: ../../c-api/module.rst:377 msgid "" "Multiple ``Py_mod_create`` slots may not be specified in one module " "definition." msgstr "" -#: ../../c-api/module.rst:360 +#: ../../c-api/module.rst:380 msgid "" "If ``Py_mod_create`` is not specified, the import machinery will create a " "normal module object using :c:func:`PyModule_New`. The name is taken from " @@ -406,7 +433,7 @@ msgid "" "through symlinks, all while sharing a single module definition." msgstr "" -#: ../../c-api/module.rst:366 +#: ../../c-api/module.rst:386 msgid "" "There is no requirement for the returned object to be an instance of :c:type:" "`PyModule_Type`. Any type can be used, as long as it supports setting and " @@ -416,7 +443,7 @@ msgid "" "``Py_mod_create``." msgstr "" -#: ../../c-api/module.rst:375 +#: ../../c-api/module.rst:395 msgid "" "Specifies a function that is called to *execute* the module. This is " "equivalent to executing the code of a Python module: typically, this " @@ -424,59 +451,88 @@ msgid "" "function is:" msgstr "" -#: ../../c-api/module.rst:384 +#: ../../c-api/module.rst:404 msgid "" "If multiple ``Py_mod_exec`` slots are specified, they are processed in the " "order they appear in the *m_slots* array." msgstr "" -#: ../../c-api/module.rst:389 +#: ../../c-api/module.rst:409 ../../c-api/module.rst:442 msgid "Specifies one of the following values:" msgstr "" -#: ../../c-api/module.rst:395 +#: ../../c-api/module.rst:415 msgid "The module does not support being imported in subinterpreters." msgstr "" -#: ../../c-api/module.rst:399 +#: ../../c-api/module.rst:419 msgid "" "The module supports being imported in subinterpreters, but only when they " "share the main interpreter's GIL. (See :ref:`isolating-extensions-howto`.)" msgstr "" -#: ../../c-api/module.rst:405 +#: ../../c-api/module.rst:425 msgid "" "The module supports being imported in subinterpreters, even when they have " "their own GIL. (See :ref:`isolating-extensions-howto`.)" msgstr "" -#: ../../c-api/module.rst:409 +#: ../../c-api/module.rst:429 msgid "" "This slot determines whether or not importing this module in a " "subinterpreter will fail." msgstr "" -#: ../../c-api/module.rst:412 +#: ../../c-api/module.rst:432 msgid "" "Multiple ``Py_mod_multiple_interpreters`` slots may not be specified in one " "module definition." msgstr "" -#: ../../c-api/module.rst:415 +#: ../../c-api/module.rst:435 msgid "" "If ``Py_mod_multiple_interpreters`` is not specified, the import machinery " -"defaults to ``Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED``." +"defaults to ``Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED``." msgstr "" -#: ../../c-api/module.rst:420 -msgid "See :PEP:`489` for more details on multi-phase initialization." +#: ../../c-api/module.rst:448 +msgid "" +"The module depends on the presence of the global interpreter lock (GIL), and " +"may access global state without synchronization." +msgstr "" + +#: ../../c-api/module.rst:453 +msgid "The module is safe to run without an active GIL." +msgstr "" + +#: ../../c-api/module.rst:455 +msgid "" +"This slot is ignored by Python builds not configured with :option:`--disable-" +"gil`. Otherwise, it determines whether or not importing this module will " +"cause the GIL to be automatically enabled. See :ref:`whatsnew313-free-" +"threaded-cpython` for more detail." +msgstr "" + +#: ../../c-api/module.rst:460 +msgid "" +"Multiple ``Py_mod_gil`` slots may not be specified in one module definition." +msgstr "" + +#: ../../c-api/module.rst:462 +msgid "" +"If ``Py_mod_gil`` is not specified, the import machinery defaults to " +"``Py_MOD_GIL_USED``." msgstr "" -#: ../../c-api/module.rst:423 +#: ../../c-api/module.rst:467 +msgid "See :PEP:`489` for more details on multi-phase initialization." +msgstr "更多關於多階段初始化的詳細資訊,請參閱 :pep:`489`。" + +#: ../../c-api/module.rst:470 msgid "Low-level module creation functions" msgstr "" -#: ../../c-api/module.rst:425 +#: ../../c-api/module.rst:472 msgid "" "The following functions are called under the hood when using multi-phase " "initialization. They can be used directly, for example when creating module " @@ -484,14 +540,14 @@ msgid "" "``PyModule_ExecDef`` must be called to fully initialize a module." msgstr "" -#: ../../c-api/module.rst:432 +#: ../../c-api/module.rst:479 msgid "" "Create a new module object, given the definition in *def* and the ModuleSpec " "*spec*. This behaves like :c:func:`PyModule_FromDefAndSpec2` with " "*module_api_version* set to :c:macro:`PYTHON_API_VERSION`." msgstr "" -#: ../../c-api/module.rst:440 +#: ../../c-api/module.rst:487 msgid "" "Create a new module object, given the definition in *def* and the ModuleSpec " "*spec*, assuming the API version *module_api_version*. If that version does " @@ -499,24 +555,24 @@ msgid "" "emitted." msgstr "" -#: ../../c-api/module.rst:449 +#: ../../c-api/module.rst:496 msgid "" "Most uses of this function should be using :c:func:`PyModule_FromDefAndSpec` " "instead; only use this if you are sure you need it." msgstr "" -#: ../../c-api/module.rst:456 +#: ../../c-api/module.rst:503 msgid "Process any execution slots (:c:data:`Py_mod_exec`) given in *def*." msgstr "" -#: ../../c-api/module.rst:462 +#: ../../c-api/module.rst:509 msgid "" "Set the docstring for *module* to *docstring*. This function is called " "automatically when creating a module from ``PyModuleDef``, using either " "``PyModule_Create`` or ``PyModule_FromDefAndSpec``." msgstr "" -#: ../../c-api/module.rst:471 +#: ../../c-api/module.rst:518 msgid "" "Add the functions from the ``NULL`` terminated *functions* array to " "*module*. Refer to the :c:type:`PyMethodDef` documentation for details on " @@ -528,11 +584,11 @@ msgid "" "``PyModule_FromDefAndSpec``." msgstr "" -#: ../../c-api/module.rst:483 +#: ../../c-api/module.rst:530 msgid "Support functions" msgstr "支援的函式" -#: ../../c-api/module.rst:485 +#: ../../c-api/module.rst:532 msgid "" "The module initialization function (if using single phase initialization) or " "a function called from a module execution slot (if using multi-phase " @@ -540,28 +596,23 @@ msgid "" "module state:" msgstr "" -#: ../../c-api/module.rst:492 +#: ../../c-api/module.rst:539 msgid "" "Add an object to *module* as *name*. This is a convenience function which " "can be used from the module's initialization function." msgstr "" -#: ../../c-api/module.rst:495 +#: ../../c-api/module.rst:542 msgid "" "On success, return ``0``. On error, raise an exception and return ``-1``." msgstr "" -#: ../../c-api/module.rst:497 -msgid "" -"Return ``-1`` if *value* is ``NULL``. It must be called with an exception " -"raised in this case." -msgstr "" - -#: ../../c-api/module.rst:500 ../../c-api/module.rst:549 +#: ../../c-api/module.rst:544 ../../c-api/module.rst:595 +#: ../../c-api/module.rst:622 msgid "Example usage::" msgstr "用法範例: ::" -#: ../../c-api/module.rst:502 +#: ../../c-api/module.rst:546 msgid "" "static int\n" "add_spam(PyObject *module, int value)\n" @@ -587,13 +638,20 @@ msgstr "" " return res;\n" " }" -#: ../../c-api/module.rst:514 ../../c-api/module.rst:567 +#: ../../c-api/module.rst:558 +msgid "" +"To be convenient, the function accepts ``NULL`` *value* with an exception " +"set. In this case, return ``-1`` and just leave the raised exception " +"unchanged." +msgstr "" + +#: ../../c-api/module.rst:562 msgid "" "The example can also be written without checking explicitly if *obj* is " "``NULL``::" msgstr "" -#: ../../c-api/module.rst:517 +#: ../../c-api/module.rst:565 msgid "" "static int\n" "add_spam(PyObject *module, int value)\n" @@ -613,80 +671,94 @@ msgstr "" " return res;\n" " }" -#: ../../c-api/module.rst:526 ../../c-api/module.rst:583 +#: ../../c-api/module.rst:574 msgid "" "Note that ``Py_XDECREF()`` should be used instead of ``Py_DECREF()`` in this " "case, since *obj* can be ``NULL``." msgstr "" -#: ../../c-api/module.rst:534 +#: ../../c-api/module.rst:577 +msgid "" +"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 :c:func:" +"`PyUnicode_FromString` and :c:func:`PyObject_SetAttr` directly. For more " +"details, see :c:func:`PyUnicode_InternFromString`, which may be used " +"internally to create a key object." +msgstr "" + +#: ../../c-api/module.rst:590 +msgid "" +"Similar to :c:func:`PyModule_AddObjectRef`, 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." +msgstr "" + +#: ../../c-api/module.rst:597 +msgid "" +"if (PyModule_Add(module, \"spam\", PyBytes_FromString(value)) < 0) {\n" +" goto error;\n" +"}" +msgstr "" + +#: ../../c-api/module.rst:606 msgid "" "Similar to :c:func:`PyModule_AddObjectRef`, but steals a reference to " "*value* on success (if it returns ``0``)." msgstr "" -#: ../../c-api/module.rst:537 +#: ../../c-api/module.rst:609 msgid "" -"The new :c:func:`PyModule_AddObjectRef` function is recommended, since it is " -"easy to introduce reference leaks by misusing the :c:func:" -"`PyModule_AddObject` function." +"The new :c:func:`PyModule_Add` or :c:func:`PyModule_AddObjectRef` functions " +"are recommended, since it is easy to introduce reference leaks by misusing " +"the :c:func:`PyModule_AddObject` function." msgstr "" -#: ../../c-api/module.rst:543 +#: ../../c-api/module.rst:616 msgid "" "Unlike other functions that steal references, ``PyModule_AddObject()`` only " "releases the reference to *value* **on success**." msgstr "" -#: ../../c-api/module.rst:546 +#: ../../c-api/module.rst:619 msgid "" "This means that its return value must be checked, and calling code must :c:" -"func:`Py_DECREF` *value* manually on error." +"func:`Py_XDECREF` *value* manually on error." msgstr "" -#: ../../c-api/module.rst:551 +#: ../../c-api/module.rst:624 msgid "" -"static int\n" -"add_spam(PyObject *module, int value)\n" -"{\n" -" PyObject *obj = PyLong_FromLong(value);\n" -" if (obj == NULL) {\n" -" return -1;\n" -" }\n" -" if (PyModule_AddObject(module, \"spam\", obj) < 0) {\n" -" Py_DECREF(obj);\n" -" return -1;\n" -" }\n" -" // PyModule_AddObject() stole a reference to obj:\n" -" // Py_DECREF(obj) is not needed here\n" -" return 0;\n" -"}" +"PyObject *obj = PyBytes_FromString(value);\n" +"if (PyModule_AddObject(module, \"spam\", obj) < 0) {\n" +" // If 'obj' is not NULL and PyModule_AddObject() failed,\n" +" // 'obj' strong reference must be deleted with Py_XDECREF().\n" +" // If 'obj' is NULL, Py_XDECREF() does nothing.\n" +" Py_XDECREF(obj);\n" +" goto error;\n" +"}\n" +"// PyModule_AddObject() stole a reference to obj:\n" +"// Py_XDECREF(obj) is not needed here." msgstr "" -#: ../../c-api/module.rst:570 -msgid "" -"static int\n" -"add_spam(PyObject *module, int value)\n" -"{\n" -" PyObject *obj = PyLong_FromLong(value);\n" -" if (PyModule_AddObject(module, \"spam\", obj) < 0) {\n" -" Py_XDECREF(obj);\n" -" return -1;\n" -" }\n" -" // PyModule_AddObject() stole a reference to obj:\n" -" // Py_DECREF(obj) is not needed here\n" -" return 0;\n" -"}" +#: ../../c-api/module.rst:637 +msgid ":c:func:`PyModule_AddObject` is :term:`soft deprecated`." msgstr "" -#: ../../c-api/module.rst:589 +#: ../../c-api/module.rst:642 msgid "" "Add an integer constant to *module* as *name*. This convenience function " "can be used from the module's initialization function. Return ``-1`` with an " "exception set on error, ``0`` on success." msgstr "" -#: ../../c-api/module.rst:596 +#: ../../c-api/module.rst:646 +msgid "" +"This is a convenience function that calls :c:func:`PyLong_FromLong` and :c:" +"func:`PyModule_AddObjectRef`; see their documentation for details." +msgstr "" + +#: ../../c-api/module.rst:652 msgid "" "Add a string constant to *module* as *name*. This convenience function can " "be used from the module's initialization function. The string *value* must " @@ -694,7 +766,14 @@ msgid "" "on success." msgstr "" -#: ../../c-api/module.rst:604 +#: ../../c-api/module.rst:657 +msgid "" +"This is a convenience function that calls :c:func:" +"`PyUnicode_InternFromString` and :c:func:`PyModule_AddObjectRef`; see their " +"documentation for details." +msgstr "" + +#: ../../c-api/module.rst:664 msgid "" "Add an int constant to *module*. The name and the value are taken from " "*macro*. For example ``PyModule_AddIntMacro(module, AF_INET)`` adds the int " @@ -702,11 +781,11 @@ msgid "" "with an exception set on error, ``0`` on success." msgstr "" -#: ../../c-api/module.rst:612 +#: ../../c-api/module.rst:672 msgid "Add a string constant to *module*." -msgstr "" +msgstr "將字串常數加入到 *module* 中。" -#: ../../c-api/module.rst:616 +#: ../../c-api/module.rst:676 msgid "" "Add a type object to *module*. The type object is finalized by calling " "internally :c:func:`PyType_Ready`. The name of the type object is taken from " @@ -714,25 +793,36 @@ msgid "" "``-1`` with an exception set on error, ``0`` on success." msgstr "" -#: ../../c-api/module.rst:626 +#: ../../c-api/module.rst:686 +msgid "" +"Indicate that *module* does or does not support running without the global " +"interpreter lock (GIL), using one of the values from :c:macro:`Py_mod_gil`. " +"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 :option:`--disable-gil`. " +"Return ``-1`` with an exception set on error, ``0`` on success." +msgstr "" + +#: ../../c-api/module.rst:699 msgid "Module lookup" msgstr "模組查找" -#: ../../c-api/module.rst:628 +#: ../../c-api/module.rst:701 msgid "" "Single-phase initialization creates singleton modules that can be looked up " "in the context of the current interpreter. This allows the module object to " "be retrieved later with only a reference to the module definition." msgstr "" -#: ../../c-api/module.rst:632 +#: ../../c-api/module.rst:705 msgid "" "These functions will not work on modules created using multi-phase " "initialization, since multiple such modules can be created from a single " "definition." msgstr "" -#: ../../c-api/module.rst:637 +#: ../../c-api/module.rst:710 msgid "" "Returns the module object that was created from *def* for the current " "interpreter. This method requires that the module object has been attached " @@ -741,18 +831,18 @@ msgid "" "to the interpreter state yet, it returns ``NULL``." msgstr "" -#: ../../c-api/module.rst:644 +#: ../../c-api/module.rst:717 msgid "" "Attaches the module object passed to the function to the interpreter state. " "This allows the module object to be accessible via :c:func:" "`PyState_FindModule`." msgstr "" -#: ../../c-api/module.rst:647 +#: ../../c-api/module.rst:720 msgid "Only effective on modules created using single-phase initialization." msgstr "" -#: ../../c-api/module.rst:649 +#: ../../c-api/module.rst:722 msgid "" "Python calls ``PyState_AddModule`` automatically after importing a module, " "so it is unnecessary (but harmless) to call it from module initialization " @@ -763,15 +853,15 @@ msgid "" "state updates)." msgstr "" -#: ../../c-api/module.rst:657 ../../c-api/module.rst:668 +#: ../../c-api/module.rst:730 ../../c-api/module.rst:741 msgid "The caller must hold the GIL." msgstr "" -#: ../../c-api/module.rst:659 +#: ../../c-api/module.rst:732 msgid "Return ``-1`` with an exception set on error, ``0`` on success." msgstr "成功時回傳 ``0``,在失敗時回傳 ``-1`` 並設定例外。" -#: ../../c-api/module.rst:665 +#: ../../c-api/module.rst:738 msgid "" "Removes the module object created from *def* from the interpreter state. " "Return ``-1`` with an exception set on error, ``0`` on success." @@ -789,7 +879,7 @@ msgstr "module(模組)" msgid "ModuleType (in module types)" msgstr "MethodType(types 模組中)" -#: ../../c-api/module.rst:33 ../../c-api/module.rst:76 +#: ../../c-api/module.rst:33 ../../c-api/module.rst:77 msgid "__name__ (module attribute)" msgstr "__name__(模組屬性)" @@ -797,7 +887,7 @@ msgstr "__name__(模組屬性)" msgid "__doc__ (module attribute)" msgstr "__doc__(模組屬性)" -#: ../../c-api/module.rst:33 ../../c-api/module.rst:106 +#: ../../c-api/module.rst:33 ../../c-api/module.rst:108 msgid "__file__ (module attribute)" msgstr "__file__(模組屬性)" @@ -809,10 +899,10 @@ msgstr "__package__(模組屬性)" msgid "__loader__ (module attribute)" msgstr "__loader__(模組屬性)" -#: ../../c-api/module.rst:62 +#: ../../c-api/module.rst:63 msgid "__dict__ (module attribute)" msgstr "__dict__(模組屬性)" -#: ../../c-api/module.rst:76 ../../c-api/module.rst:106 +#: ../../c-api/module.rst:77 ../../c-api/module.rst:108 msgid "SystemError (built-in exception)" msgstr "SystemError(內建例外)" diff --git a/c-api/monitoring.po b/c-api/monitoring.po new file mode 100644 index 0000000000..ac7e58b853 --- /dev/null +++ b/c-api/monitoring.po @@ -0,0 +1,294 @@ +# Copyright (C) 2001-2024, Python Software Foundation +# This file is distributed under the same license as the Python package. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.13\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-03-20 00:14+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" +"Language: zh_TW\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../../c-api/monitoring.rst:6 +msgid "Monitoring C API" +msgstr "監控 C API" + +#: ../../c-api/monitoring.rst:8 +msgid "Added in version 3.13." +msgstr "於 3.13 版本中新增。" + +#: ../../c-api/monitoring.rst:10 +msgid "" +"An extension may need to interact with the event monitoring system. " +"Subscribing to events and registering callbacks can be done via the Python " +"API exposed in :mod:`sys.monitoring`." +msgstr "" + +#: ../../c-api/monitoring.rst:15 +msgid "Generating Execution Events" +msgstr "" + +#: ../../c-api/monitoring.rst:17 +msgid "" +"The functions below make it possible for an extension to fire monitoring " +"events as it emulates the execution of Python code. Each of these functions " +"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 :mod:`sys." +"monitoring` for details about the signatures of the different event " +"callbacks). The ``codelike`` argument should be an instance of :class:`types." +"CodeType` or of a type that emulates it." +msgstr "" + +#: ../../c-api/monitoring.rst:27 +msgid "" +"The VM disables tracing when firing an event, so there is no need for user " +"code to do that." +msgstr "" + +#: ../../c-api/monitoring.rst:30 +msgid "" +"Monitoring functions should not be called with an exception set, except " +"those listed below as working with the current exception." +msgstr "" + +#: ../../c-api/monitoring.rst:35 +msgid "" +"Representation of the state of an event type. It is allocated by the user " +"while its contents are maintained by the monitoring API functions described " +"below." +msgstr "" + +#: ../../c-api/monitoring.rst:39 +msgid "" +"All of the functions below return 0 on success and -1 (with an exception " +"set) on error." +msgstr "" + +#: ../../c-api/monitoring.rst:41 +msgid "See :mod:`sys.monitoring` for descriptions of the events." +msgstr "關於事件的敘述請見 :mod:`sys.monitoring`。" + +#: ../../c-api/monitoring.rst:45 +msgid "Fire a ``PY_START`` event." +msgstr "發出一個 ``PY_START`` 事件。" + +#: ../../c-api/monitoring.rst:50 +msgid "Fire a ``PY_RESUME`` event." +msgstr "發出一個 ``PY_RESUME`` 事件。" + +#: ../../c-api/monitoring.rst:55 +msgid "Fire a ``PY_RETURN`` event." +msgstr "發出一個 ``PY_RETURN`` 事件。" + +#: ../../c-api/monitoring.rst:60 +msgid "Fire a ``PY_YIELD`` event." +msgstr "發出一個 ``PY_YIELD`` 事件。" + +#: ../../c-api/monitoring.rst:65 +msgid "Fire a ``CALL`` event." +msgstr "發出一個 ``CALL`` 事件。" + +#: ../../c-api/monitoring.rst:70 +msgid "Fire a ``LINE`` event." +msgstr "發出一個 ``LINE`` 事件。" + +#: ../../c-api/monitoring.rst:75 +msgid "Fire a ``JUMP`` event." +msgstr "發出一個 ``JUMP`` 事件。" + +#: ../../c-api/monitoring.rst:80 +msgid "Fire a ``BRANCH`` event." +msgstr "發出一個 ``BRANCH`` 事件。" + +#: ../../c-api/monitoring.rst:85 +msgid "Fire a ``C_RETURN`` event." +msgstr "發出一個 ``C_RETURN`` 事件。" + +#: ../../c-api/monitoring.rst:90 +msgid "" +"Fire a ``PY_THROW`` event with the current exception (as returned by :c:func:" +"`PyErr_GetRaisedException`)." +msgstr "" + +#: ../../c-api/monitoring.rst:96 +msgid "" +"Fire a ``RAISE`` event with the current exception (as returned by :c:func:" +"`PyErr_GetRaisedException`)." +msgstr "" + +#: ../../c-api/monitoring.rst:102 +msgid "" +"Fire a ``C_RAISE`` event with the current exception (as returned by :c:func:" +"`PyErr_GetRaisedException`)." +msgstr "" + +#: ../../c-api/monitoring.rst:108 +msgid "" +"Fire a ``RERAISE`` event with the current exception (as returned by :c:func:" +"`PyErr_GetRaisedException`)." +msgstr "" + +#: ../../c-api/monitoring.rst:114 +msgid "" +"Fire an ``EXCEPTION_HANDLED`` event with the current exception (as returned " +"by :c:func:`PyErr_GetRaisedException`)." +msgstr "" + +#: ../../c-api/monitoring.rst:120 +msgid "" +"Fire a ``PY_UNWIND`` event with the current exception (as returned by :c:" +"func:`PyErr_GetRaisedException`)." +msgstr "" + +#: ../../c-api/monitoring.rst:126 +msgid "" +"Fire a ``STOP_ITERATION`` event. If ``value`` is an instance of :exc:" +"`StopIteration`, it is used. Otherwise, a new :exc:`StopIteration` instance " +"is created with ``value`` as its argument." +msgstr "" + +#: ../../c-api/monitoring.rst:131 +msgid "Managing the Monitoring State" +msgstr "" + +#: ../../c-api/monitoring.rst:133 +msgid "" +"Monitoring states can be managed with the help of monitoring scopes. A scope " +"would typically correspond to a python function." +msgstr "" + +#: ../../c-api/monitoring.rst:138 +msgid "" +"Enter a monitored scope. ``event_types`` is an array of the event IDs for " +"events that may be fired from the scope. For example, the ID of a " +"``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 :" +"c:func:`!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``." +msgstr "" + +#: ../../c-api/monitoring.rst:148 +msgid "" +"The ``version`` argument is a pointer to a value which should be allocated " +"by the user together with ``state_array`` and initialized to 0, and then set " +"only by :c:func:`!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." +msgstr "" + +#: ../../c-api/monitoring.rst:154 +msgid "" +"The scopes referred to here are lexical scopes: a function, class or " +"method. :c:func:`!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." +msgstr "" + +#: ../../c-api/monitoring.rst:161 +msgid "The macros for *event_types* are:" +msgstr "*event_types* 的巨集有:" + +#: ../../c-api/monitoring.rst:169 +msgid "Macro" +msgstr "巨集" + +#: ../../c-api/monitoring.rst:169 +msgid "Event" +msgstr "事件" + +#: ../../c-api/monitoring.rst:171 +msgid ":monitoring-event:`BRANCH`" +msgstr ":monitoring-event:`BRANCH`" + +#: ../../c-api/monitoring.rst:172 +msgid ":monitoring-event:`CALL`" +msgstr ":monitoring-event:`CALL`" + +#: ../../c-api/monitoring.rst:173 +msgid ":monitoring-event:`C_RAISE`" +msgstr ":monitoring-event:`C_RAISE`" + +#: ../../c-api/monitoring.rst:174 +msgid ":monitoring-event:`C_RETURN`" +msgstr ":monitoring-event:`C_RETURN`" + +#: ../../c-api/monitoring.rst:175 +msgid ":monitoring-event:`EXCEPTION_HANDLED`" +msgstr ":monitoring-event:`EXCEPTION_HANDLED`" + +#: ../../c-api/monitoring.rst:176 +msgid ":monitoring-event:`INSTRUCTION`" +msgstr ":monitoring-event:`INSTRUCTION`" + +#: ../../c-api/monitoring.rst:177 +msgid ":monitoring-event:`JUMP`" +msgstr ":monitoring-event:`JUMP`" + +#: ../../c-api/monitoring.rst:178 +msgid ":monitoring-event:`LINE`" +msgstr ":monitoring-event:`LINE`" + +#: ../../c-api/monitoring.rst:179 +msgid ":monitoring-event:`PY_RESUME`" +msgstr ":monitoring-event:`PY_RESUME`" + +#: ../../c-api/monitoring.rst:180 +msgid ":monitoring-event:`PY_RETURN`" +msgstr ":monitoring-event:`PY_RETURN`" + +#: ../../c-api/monitoring.rst:181 +msgid ":monitoring-event:`PY_START`" +msgstr ":monitoring-event:`PY_START`" + +#: ../../c-api/monitoring.rst:182 +msgid ":monitoring-event:`PY_THROW`" +msgstr ":monitoring-event:`PY_THROW`" + +#: ../../c-api/monitoring.rst:183 +msgid ":monitoring-event:`PY_UNWIND`" +msgstr ":monitoring-event:`PY_UNWIND`" + +#: ../../c-api/monitoring.rst:184 +msgid ":monitoring-event:`PY_YIELD`" +msgstr ":monitoring-event:`PY_YIELD`" + +#: ../../c-api/monitoring.rst:185 +msgid ":monitoring-event:`RAISE`" +msgstr ":monitoring-event:`RAISE`" + +#: ../../c-api/monitoring.rst:186 +msgid ":monitoring-event:`RERAISE`" +msgstr ":monitoring-event:`RERAISE`" + +#: ../../c-api/monitoring.rst:187 +msgid ":monitoring-event:`STOP_ITERATION`" +msgstr ":monitoring-event:`STOP_ITERATION`" + +#: ../../c-api/monitoring.rst:192 +msgid "" +"Exit the last scope that was entered with :c:func:`!PyMonitoring_EnterScope`." +msgstr "" + +#: ../../c-api/monitoring.rst:197 +msgid "" +"Return true if the event corresponding to the event ID *ev* is a :ref:`local " +"event `." +msgstr "" + +#: ../../c-api/monitoring.rst:204 +msgid "This function is :term:`soft deprecated`." +msgstr "" diff --git a/c-api/none.po b/c-api/none.po index a4dc2654ef..2a360b0167 100644 --- a/c-api/none.po +++ b/c-api/none.po @@ -6,9 +6,9 @@ # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-07-29 00:03+0000\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2018-05-23 14:07+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -34,12 +34,12 @@ msgstr "" #: ../../c-api/none.rst:18 msgid "" "The Python ``None`` object, denoting lack of value. This object has no " -"methods and is `immortal `_." +"methods and is :term:`immortal`." msgstr "" #: ../../c-api/none.rst:21 -msgid ":c:data:`Py_None` is immortal." -msgstr ":c:data:`Py_None` 為不滅的 (immortal)。" +msgid ":c:data:`Py_None` is :term:`immortal`." +msgstr ":c:data:`Py_None` 為\\ :term:`不滅的 (immortal) `。" #: ../../c-api/none.rst:26 msgid "Return :c:data:`Py_None` from a function." diff --git a/c-api/number.po b/c-api/number.po index d058488140..83e14a4b31 100644 --- a/c-api/number.po +++ b/c-api/number.po @@ -5,7 +5,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-07-20 00:03+0000\n" "PO-Revision-Date: 2018-05-23 14:07+0000\n" diff --git a/c-api/objbuffer.po b/c-api/objbuffer.po deleted file mode 100644 index 8b850ef948..0000000000 --- a/c-api/objbuffer.po +++ /dev/null @@ -1,105 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation -# This file is distributed under the same license as the Python package. -# -# Translators: -# Liang-Bo Wang , 2015 -# Matt Wang , 2023 -msgid "" -msgstr "" -"Project-Id-Version: Python 3.12\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-20 18:08+0800\n" -"PO-Revision-Date: 2023-07-01 04:33+0800\n" -"Last-Translator: Matt Wang \n" -"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" -"tw)\n" -"Language: zh_TW\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Poedit 3.3.2\n" - -#: ../../c-api/objbuffer.rst:4 -msgid "Old Buffer Protocol" -msgstr "舊式緩衝協定 (Buffer Protocol)" - -#: ../../c-api/objbuffer.rst:8 -msgid "" -"These functions were part of the \"old buffer protocol\" API in Python 2. In " -"Python 3, this protocol doesn't exist anymore but the functions are still " -"exposed to ease porting 2.x code. They act as a compatibility wrapper " -"around the :ref:`new buffer protocol `, but they don't give " -"you control over the lifetime of the resources acquired when a buffer is " -"exported." -msgstr "" -"這些函式是 Python 2 中「舊式緩衝區協定」API 的一部分。在 Python 3 中,該協議" -"已經不存在,但這些函式仍有公開以供移植 2.x 程式碼。它們充當\\ :ref:`新式緩衝" -"區協定 `\\ 的相容性包裝器,但它們無法讓你控制匯出 (export) 緩" -"衝區時所獲取資源的生命週期。" - -#: ../../c-api/objbuffer.rst:15 -msgid "" -"Therefore, it is recommended that you call :c:func:`PyObject_GetBuffer` (or " -"the ``y*`` or ``w*`` :ref:`format codes ` with the :c:func:" -"`PyArg_ParseTuple` family of functions) to get a buffer view over an object, " -"and :c:func:`PyBuffer_Release` when the buffer view can be released." -msgstr "" -"因此,建議你呼叫 :c:func:`PyObject_GetBuffer` (或是以 ``y*`` 或 ``w*`` :ref:" -"`格式碼 (format code) ` 呼叫 :c:func:`PyArg_ParseTuple` 系列函" -"式)獲取物件的緩衝區視圖 (buffer view),以及緩衝區視圖可被釋放時呼叫 :c:func:" -"`PyBuffer_Release` 。" - -#: ../../c-api/objbuffer.rst:23 -msgid "" -"Returns a pointer to a read-only memory location usable as character-based " -"input. The *obj* argument must support the single-segment character buffer " -"interface. On success, returns ``0``, sets *buffer* to the memory location " -"and *buffer_len* to the buffer length. Returns ``-1`` and sets a :exc:" -"`TypeError` on error." -msgstr "" -"回傳一個指向可用作基於字元輸入之唯讀記憶體位置的指標。 *obj* 引數必須支援單一" -"片段 (single-segment) 字元緩衝區介面。成功時回傳 ``0``,並將 *buffer* 設定為" -"記憶體位置、將 *buffer_len* 設定為緩衝區長度。回傳 ``-1`` 並在錯誤時設定 :" -"exc:`TypeError`。" - -#: ../../c-api/objbuffer.rst:32 -msgid "" -"Returns a pointer to a read-only memory location containing arbitrary data. " -"The *obj* argument must support the single-segment readable buffer " -"interface. On success, returns ``0``, sets *buffer* to the memory location " -"and *buffer_len* to the buffer length. Returns ``-1`` and sets a :exc:" -"`TypeError` on error." -msgstr "" -"回傳一個指向包含任意資料之唯讀記憶體位置的指標。*obj* 引數必須支援單一片段可" -"讀緩衝區介面。成功時回傳 ``0``,並將 *buffer* 設定為記憶體位置、將 " -"*buffer_len* 設定為緩衝區長度。回傳 ``-1`` 並在錯誤時設定 :exc:`TypeError`。" - -#: ../../c-api/objbuffer.rst:41 -msgid "" -"Returns ``1`` if *o* supports the single-segment readable buffer interface. " -"Otherwise returns ``0``. This function always succeeds." -msgstr "" -"如果 *o* 支援單一片段可讀緩衝區介面,則回傳 ``1``,否則回傳 ``0``。這個函式一" -"定會執行成功的。" - -#: ../../c-api/objbuffer.rst:44 -msgid "" -"Note that this function tries to get and release a buffer, and exceptions " -"which occur while calling corresponding functions will get suppressed. To " -"get error reporting use :c:func:`PyObject_GetBuffer()` instead." -msgstr "" -"請注意,該函式嘗試獲取和釋放緩衝區,並且呼叫相應函式時發生的例外將被抑制。要" -"獲取錯誤報告,請改用 :c:func:`PyObject_GetBuffer()`。" - -#: ../../c-api/objbuffer.rst:51 -msgid "" -"Returns a pointer to a writable memory location. The *obj* argument must " -"support the single-segment, character buffer interface. On success, returns " -"``0``, sets *buffer* to the memory location and *buffer_len* to the buffer " -"length. Returns ``-1`` and sets a :exc:`TypeError` on error." -msgstr "" -"回傳指向可寫記憶體位置的指標。 *obj* 引數必須支援單一片段字元緩衝區介面。成功" -"時回傳 ``0``,並將 *buffer* 設定為記憶體位置,且將 *buffer_len* 設定為緩衝區" -"長度。回傳 ``-1`` 並在錯誤時設定 :exc:`TypeError`。" diff --git a/c-api/object.po b/c-api/object.po index eb0e3cc2c1..85e8adfd09 100644 --- a/c-api/object.po +++ b/c-api/object.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-09 00:03+0000\n" +"POT-Creation-Date: 2025-01-05 00:15+0000\n" "PO-Revision-Date: 2018-05-23 14:32+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,26 +23,150 @@ msgid "Object Protocol" msgstr "物件協定" #: ../../c-api/object.rst:11 +msgid "Get a :term:`strong reference` to a constant." +msgstr "" + +#: ../../c-api/object.rst:13 +msgid "Set an exception and return ``NULL`` if *constant_id* is invalid." +msgstr "如果 *constant_id* 無效,則設定一個例外並回傳 ``NULL``。" + +#: ../../c-api/object.rst:15 +msgid "*constant_id* must be one of these constant identifiers:" +msgstr "*constant_id* 必須是這些常數識別字之一:" + +#: ../../c-api/object.rst:20 +msgid "Constant Identifier" +msgstr "常數識別字" + +#: ../../c-api/object.rst:20 +msgid "Value" +msgstr "數值" + +#: ../../c-api/object.rst:20 +msgid "Returned object" +msgstr "回傳物件" + +#: ../../c-api/object.rst:22 ../../c-api/object.rst:27 +msgid "``0``" +msgstr "``0``" + +#: ../../c-api/object.rst:22 +msgid ":py:data:`None`" +msgstr ":py:data:`None`" + +#: ../../c-api/object.rst:23 ../../c-api/object.rst:28 +msgid "``1``" +msgstr "``1``" + +#: ../../c-api/object.rst:23 +msgid ":py:data:`False`" +msgstr ":py:data:`False`" + +#: ../../c-api/object.rst:24 +msgid "``2``" +msgstr "``2``" + +#: ../../c-api/object.rst:24 +msgid ":py:data:`True`" +msgstr ":py:data:`True`" + +#: ../../c-api/object.rst:25 +msgid "``3``" +msgstr "``3``" + +#: ../../c-api/object.rst:25 +msgid ":py:data:`Ellipsis`" +msgstr ":py:data:`Ellipsis`" + +#: ../../c-api/object.rst:26 +msgid "``4``" +msgstr "``4``" + +#: ../../c-api/object.rst:26 +msgid ":py:data:`NotImplemented`" +msgstr ":py:data:`NotImplemented`" + +#: ../../c-api/object.rst:27 +msgid "``5``" +msgstr "``5``" + +#: ../../c-api/object.rst:28 +msgid "``6``" +msgstr "``6``" + +#: ../../c-api/object.rst:29 +msgid "``7``" +msgstr "``7``" + +#: ../../c-api/object.rst:29 +msgid "``''``" +msgstr "``''``" + +#: ../../c-api/object.rst:30 +msgid "``8``" +msgstr "``8``" + +#: ../../c-api/object.rst:30 +msgid "``b''``" +msgstr "``b''``" + +#: ../../c-api/object.rst:31 +msgid "``9``" +msgstr "``9``" + +#: ../../c-api/object.rst:31 +msgid "``()``" +msgstr "``()``" + +#: ../../c-api/object.rst:34 +msgid "" +"Numeric values are only given for projects which cannot use the constant " +"identifiers." +msgstr "" + +#: ../../c-api/object.rst:42 +msgid "In CPython, all of these constants are :term:`immortal`." +msgstr "在 CPython 中,所有這些常數都是\\ :term:`不滅 `\\ 的。" + +#: ../../c-api/object.rst:47 +msgid "" +"Similar to :c:func:`Py_GetConstant`, but return a :term:`borrowed reference`." +msgstr "" + +#: ../../c-api/object.rst:50 +msgid "" +"This function is primarily intended for backwards compatibility: " +"using :c:func:`Py_GetConstant` is recommended for new code." +msgstr "" + +#: ../../c-api/object.rst:53 +msgid "" +"The reference is borrowed from the interpreter, and is valid until the " +"interpreter finalization." +msgstr "" + +#: ../../c-api/object.rst:61 msgid "" "The ``NotImplemented`` singleton, used to signal that an operation is not " "implemented for the given type combination." msgstr "" -#: ../../c-api/object.rst:17 +#: ../../c-api/object.rst:67 msgid "" "Properly handle returning :c:data:`Py_NotImplemented` from within a C " -"function (that is, create a new :term:`strong reference` to :const:" -"`NotImplemented` and return it)." +"function (that is, create a new :term:`strong reference` " +"to :const:`NotImplemented` and return it)." msgstr "" -#: ../../c-api/object.rst:24 +#: ../../c-api/object.rst:74 msgid "" -"Flag to be used with multiple functions that print the object (like :c:func:" -"`PyObject_Print` and :c:func:`PyFile_WriteObject`). If passed, these " -"function would use the :func:`str` of the object instead of the :func:`repr`." +"Flag to be used with multiple functions that print the object " +"(like :c:func:`PyObject_Print` and :c:func:`PyFile_WriteObject`). If passed, " +"these function would use the :func:`str` of the object instead of " +"the :func:`repr`." msgstr "" -#: ../../c-api/object.rst:32 +#: ../../c-api/object.rst:82 msgid "" "Print an object *o*, on file *fp*. Returns ``-1`` on error. The flags " "argument is used to enable certain printing options. The only option " @@ -50,87 +174,150 @@ msgid "" "the object is written instead of the :func:`repr`." msgstr "" -#: ../../c-api/object.rst:40 +#: ../../c-api/object.rst:90 msgid "" -"Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise. " -"This is equivalent to the Python expression ``hasattr(o, attr_name)``. This " -"function always succeeds." +"Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise. " +"This is equivalent to the Python expression ``hasattr(o, attr_name)``. On " +"failure, return ``-1``." msgstr "" -#: ../../c-api/object.rst:46 +#: ../../c-api/object.rst:99 msgid "" -"Exceptions that occur when this calls :meth:`~object.__getattr__` and :meth:" -"`~object.__getattribute__` methods are silently ignored. For proper error " -"handling, use :c:func:`PyObject_GetAttr` instead." +"This is the same as :c:func:`PyObject_HasAttrWithError`, but *attr_name* is " +"specified as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." msgstr "" -#: ../../c-api/object.rst:53 +#: ../../c-api/object.rst:108 +msgid "" +"Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise. " +"This function always succeeds." +msgstr "" + +#: ../../c-api/object.rst:113 +msgid "" +"Exceptions that occur when this calls :meth:`~object.__getattr__` " +"and :meth:`~object.__getattribute__` methods aren't propagated, but instead " +"given to :func:`sys.unraisablehook`. For proper error handling, " +"use :c:func:`PyObject_HasAttrWithError`, :c:func:`PyObject_GetOptionalAttr` " +"or :c:func:`PyObject_GetAttr` instead." +msgstr "" + +#: ../../c-api/object.rst:122 msgid "" "This is the same as :c:func:`PyObject_HasAttr`, but *attr_name* is specified " -"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" -"`PyObject*`." +"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." msgstr "" -#: ../../c-api/object.rst:59 +#: ../../c-api/object.rst:128 msgid "" -"Exceptions that occur when this calls :meth:`~object.__getattr__` and :meth:" -"`~object.__getattribute__` methods or while creating the temporary :class:" -"`str` object are silently ignored. For proper error handling, use :c:func:" -"`PyObject_GetAttrString` instead." +"Exceptions that occur when this calls :meth:`~object.__getattr__` " +"and :meth:`~object.__getattribute__` methods or while creating the " +"temporary :class:`str` object are silently ignored. For proper error " +"handling, " +"use :c:func:`PyObject_HasAttrStringWithError`, :c:func:`PyObject_GetOptionalAttrString` " +"or :c:func:`PyObject_GetAttrString` instead." msgstr "" -#: ../../c-api/object.rst:67 +#: ../../c-api/object.rst:138 msgid "" "Retrieve an attribute named *attr_name* from object *o*. Returns the " "attribute value on success, or ``NULL`` on failure. This is the equivalent " "of the Python expression ``o.attr_name``." msgstr "" -#: ../../c-api/object.rst:74 +#: ../../c-api/object.rst:142 +msgid "" +"If the missing attribute should not be treated as a failure, you can " +"use :c:func:`PyObject_GetOptionalAttr` instead." +msgstr "" + +#: ../../c-api/object.rst:148 msgid "" "This is the same as :c:func:`PyObject_GetAttr`, but *attr_name* is specified " -"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" -"`PyObject*`." +"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." +msgstr "" + +#: ../../c-api/object.rst:152 +msgid "" +"If the missing attribute should not be treated as a failure, you can " +"use :c:func:`PyObject_GetOptionalAttrString` instead." +msgstr "" + +#: ../../c-api/object.rst:158 +msgid "" +"Variant of :c:func:`PyObject_GetAttr` which doesn't " +"raise :exc:`AttributeError` if the attribute is not found." +msgstr "" + +#: ../../c-api/object.rst:161 +msgid "" +"If the attribute is found, return ``1`` and set *\\*result* to a " +"new :term:`strong reference` to the attribute. If the attribute is not " +"found, return ``0`` and set *\\*result* to ``NULL``; " +"the :exc:`AttributeError` is silenced. If an error other " +"than :exc:`AttributeError` is raised, return ``-1`` and set *\\*result* to " +"``NULL``." +msgstr "" + +#: ../../c-api/object.rst:173 +msgid "" +"This is the same as :c:func:`PyObject_GetOptionalAttr`, but *attr_name* is " +"specified as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." msgstr "" -#: ../../c-api/object.rst:81 +#: ../../c-api/object.rst:181 msgid "" "Generic attribute getter function that is meant to be put into a type " "object's ``tp_getattro`` slot. It looks for a descriptor in the dictionary " -"of classes in the object's MRO as well as an attribute in the object's :attr:" -"`~object.__dict__` (if present). As outlined in :ref:`descriptors`, data " -"descriptors take preference over instance attributes, while non-data " -"descriptors don't. Otherwise, an :exc:`AttributeError` is raised." +"of classes in the object's MRO as well as an attribute in the " +"object's :attr:`~object.__dict__` (if present). As outlined " +"in :ref:`descriptors`, data descriptors take preference over instance " +"attributes, while non-data descriptors don't. Otherwise, " +"an :exc:`AttributeError` is raised." msgstr "" -#: ../../c-api/object.rst:91 +#: ../../c-api/object.rst:191 msgid "" "Set the value of the attribute named *attr_name*, for object *o*, to the " "value *v*. Raise an exception and return ``-1`` on failure; return ``0`` on " "success. This is the equivalent of the Python statement ``o.attr_name = v``." msgstr "" -#: ../../c-api/object.rst:96 +#: ../../c-api/object.rst:196 msgid "" "If *v* is ``NULL``, the attribute is deleted. This behaviour is deprecated " "in favour of using :c:func:`PyObject_DelAttr`, but there are currently no " "plans to remove it." msgstr "" -#: ../../c-api/object.rst:103 +#: ../../c-api/object.rst:203 msgid "" "This is the same as :c:func:`PyObject_SetAttr`, but *attr_name* is specified " -"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" -"`PyObject*`." +"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." msgstr "" -#: ../../c-api/object.rst:107 +#: ../../c-api/object.rst:207 msgid "" "If *v* is ``NULL``, the attribute is deleted, but this feature is deprecated " "in favour of using :c:func:`PyObject_DelAttrString`." msgstr "" -#: ../../c-api/object.rst:113 +#: ../../c-api/object.rst:210 +msgid "" +"The number of different attribute names passed to this function should be " +"kept small, usually by using a statically allocated string as *attr_name*. " +"For attribute names that aren't known at compile time, prefer " +"calling :c:func:`PyUnicode_FromString` and :c:func:`PyObject_SetAttr` " +"directly. For more details, see :c:func:`PyUnicode_InternFromString`, which " +"may be used internally to create a key object." +msgstr "" + +#: ../../c-api/object.rst:220 msgid "" "Generic attribute setter and deleter function that is meant to be put into a " "type object's :c:member:`~PyTypeObject.tp_setattro` slot. It looks for a " @@ -142,26 +329,36 @@ msgid "" "returned." msgstr "" -#: ../../c-api/object.rst:125 +#: ../../c-api/object.rst:232 msgid "" "Delete attribute named *attr_name*, for object *o*. Returns ``-1`` on " "failure. This is the equivalent of the Python statement ``del o.attr_name``." msgstr "" -#: ../../c-api/object.rst:131 +#: ../../c-api/object.rst:238 msgid "" "This is the same as :c:func:`PyObject_DelAttr`, but *attr_name* is specified " -"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" -"`PyObject*`." +"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." msgstr "" -#: ../../c-api/object.rst:138 +#: ../../c-api/object.rst:242 +msgid "" +"The number of different attribute names passed to this function should be " +"kept small, usually by using a statically allocated string as *attr_name*. " +"For attribute names that aren't known at compile time, prefer " +"calling :c:func:`PyUnicode_FromString` and :c:func:`PyObject_DelAttr` " +"directly. For more details, see :c:func:`PyUnicode_InternFromString`, which " +"may be used internally to create a key object for lookup." +msgstr "" + +#: ../../c-api/object.rst:253 msgid "" "A generic implementation for the getter of a ``__dict__`` descriptor. It " "creates the dictionary if necessary." msgstr "" -#: ../../c-api/object.rst:141 +#: ../../c-api/object.rst:256 msgid "" "This function may also be called to get the :py:attr:`~object.__dict__` of " "the object *o*. Pass ``NULL`` for *context* when calling it. Since this " @@ -170,67 +367,67 @@ msgid "" "the object." msgstr "" -#: ../../c-api/object.rst:147 +#: ../../c-api/object.rst:262 msgid "On failure, returns ``NULL`` with an exception set." msgstr "在失敗時,會回傳 ``NULL`` 並設定例外。" -#: ../../c-api/object.rst:154 +#: ../../c-api/object.rst:269 msgid "" "A generic implementation for the setter of a ``__dict__`` descriptor. This " "implementation does not allow the dictionary to be deleted." msgstr "" -#: ../../c-api/object.rst:162 +#: ../../c-api/object.rst:277 msgid "" "Return a pointer to :py:attr:`~object.__dict__` of the object *obj*. If " "there is no ``__dict__``, return ``NULL`` without setting an exception." msgstr "" -#: ../../c-api/object.rst:165 +#: ../../c-api/object.rst:280 msgid "" "This function may need to allocate memory for the dictionary, so it may be " "more efficient to call :c:func:`PyObject_GetAttr` when accessing an " "attribute on the object." msgstr "" -#: ../../c-api/object.rst:172 +#: ../../c-api/object.rst:287 msgid "" "Compare the values of *o1* and *o2* using the operation specified by *opid*, " -"which must be one of :c:macro:`Py_LT`, :c:macro:`Py_LE`, :c:macro:`Py_EQ`, :" -"c:macro:`Py_NE`, :c:macro:`Py_GT`, or :c:macro:`Py_GE`, 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." +"which must be one " +"of :c:macro:`Py_LT`, :c:macro:`Py_LE`, :c:macro:`Py_EQ`, :c:macro:`Py_NE`, :c:macro:`Py_GT`, " +"or :c:macro:`Py_GE`, 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." msgstr "" -#: ../../c-api/object.rst:182 +#: ../../c-api/object.rst:297 msgid "" "Compare the values of *o1* and *o2* using the operation specified by *opid*, " "like :c:func:`PyObject_RichCompare`, but returns ``-1`` on error, ``0`` if " "the result is false, ``1`` otherwise." msgstr "" -#: ../../c-api/object.rst:187 +#: ../../c-api/object.rst:302 msgid "" "If *o1* and *o2* are the same object, :c:func:`PyObject_RichCompareBool` " "will always return ``1`` for :c:macro:`Py_EQ` and ``0`` for :c:macro:`Py_NE`." msgstr "" -#: ../../c-api/object.rst:192 +#: ../../c-api/object.rst:307 msgid "" "Format *obj* using *format_spec*. This is equivalent to the Python " "expression ``format(obj, format_spec)``." msgstr "" -#: ../../c-api/object.rst:195 +#: ../../c-api/object.rst:310 msgid "" "*format_spec* may be ``NULL``. In this case the call is equivalent to " "``format(obj)``. Returns the formatted string on success, ``NULL`` on " "failure." msgstr "" -#: ../../c-api/object.rst:203 +#: ../../c-api/object.rst:318 msgid "" "Compute a string representation of object *o*. Returns the string " "representation on success, ``NULL`` on failure. This is the equivalent of " @@ -238,22 +435,22 @@ msgid "" "function." msgstr "" -#: ../../c-api/object.rst:207 ../../c-api/object.rst:231 +#: ../../c-api/object.rst:322 ../../c-api/object.rst:346 msgid "" "This function now includes a debug assertion to help ensure that it does not " "silently discard an active exception." msgstr "" -#: ../../c-api/object.rst:215 +#: ../../c-api/object.rst:330 msgid "" "As :c:func:`PyObject_Repr`, compute a string representation of object *o*, " -"but escape the non-ASCII characters in the string returned by :c:func:" -"`PyObject_Repr` with ``\\x``, ``\\u`` or ``\\U`` escapes. This generates a " -"string similar to that returned by :c:func:`PyObject_Repr` in Python 2. " -"Called by the :func:`ascii` built-in function." +"but escape the non-ASCII characters in the string returned " +"by :c:func:`PyObject_Repr` with ``\\x``, ``\\u`` or ``\\U`` escapes. This " +"generates a string similar to that returned by :c:func:`PyObject_Repr` in " +"Python 2. Called by the :func:`ascii` built-in function." msgstr "" -#: ../../c-api/object.rst:226 +#: ../../c-api/object.rst:341 msgid "" "Compute a string representation of object *o*. Returns the string " "representation on success, ``NULL`` on failure. This is the equivalent of " @@ -261,7 +458,7 @@ msgid "" "function and, therefore, by the :func:`print` function." msgstr "" -#: ../../c-api/object.rst:240 +#: ../../c-api/object.rst:355 msgid "" "Compute a bytes representation of object *o*. ``NULL`` is returned on " "failure and a bytes object on success. This is equivalent to the Python " @@ -270,73 +467,73 @@ msgid "" "bytes object." msgstr "" -#: ../../c-api/object.rst:249 +#: ../../c-api/object.rst:364 msgid "" "Return ``1`` if the class *derived* is identical to or derived from the " "class *cls*, otherwise return ``0``. In case of an error, return ``-1``." msgstr "" -#: ../../c-api/object.rst:252 ../../c-api/object.rst:271 +#: ../../c-api/object.rst:367 ../../c-api/object.rst:386 msgid "" "If *cls* is a tuple, the check will be done against every entry in *cls*. " "The result will be ``1`` when at least one of the checks returns ``1``, " "otherwise it will be ``0``." msgstr "" -#: ../../c-api/object.rst:256 +#: ../../c-api/object.rst:371 msgid "" -"If *cls* has a :meth:`~class.__subclasscheck__` method, it will be called to " +"If *cls* has a :meth:`~type.__subclasscheck__` method, it will be called to " "determine the subclass status as described in :pep:`3119`. Otherwise, " -"*derived* is a subclass of *cls* if it is a direct or indirect subclass, i." -"e. contained in ``cls.__mro__``." +"*derived* is a subclass of *cls* if it is a direct or indirect subclass, " +"i.e. contained in :attr:`cls.__mro__ `." msgstr "" -#: ../../c-api/object.rst:261 +#: ../../c-api/object.rst:376 msgid "" "Normally only class objects, i.e. instances of :class:`type` or a derived " "class, are considered classes. However, objects can override this by having " -"a :attr:`~class.__bases__` attribute (which must be a tuple of base classes)." +"a :attr:`~type.__bases__` attribute (which must be a tuple of base classes)." msgstr "" -#: ../../c-api/object.rst:268 +#: ../../c-api/object.rst:383 msgid "" "Return ``1`` if *inst* is an instance of the class *cls* or a subclass of " "*cls*, or ``0`` if not. On error, returns ``-1`` and sets an exception." msgstr "" -#: ../../c-api/object.rst:275 +#: ../../c-api/object.rst:390 msgid "" -"If *cls* has a :meth:`~class.__instancecheck__` method, it will be called to " +"If *cls* has a :meth:`~type.__instancecheck__` method, it will be called to " "determine the subclass status as described in :pep:`3119`. Otherwise, " "*inst* is an instance of *cls* if its class is a subclass of *cls*." msgstr "" -#: ../../c-api/object.rst:279 +#: ../../c-api/object.rst:394 msgid "" -"An instance *inst* can override what is considered its class by having a :" -"attr:`~instance.__class__` attribute." +"An instance *inst* can override what is considered its class by having " +"a :attr:`~object.__class__` attribute." msgstr "" -#: ../../c-api/object.rst:282 +#: ../../c-api/object.rst:397 msgid "" "An object *cls* can override if it is considered a class, and what its base " -"classes are, by having a :attr:`~class.__bases__` attribute (which must be a " +"classes are, by having a :attr:`~type.__bases__` attribute (which must be a " "tuple of base classes)." msgstr "" -#: ../../c-api/object.rst:291 +#: ../../c-api/object.rst:406 msgid "" "Compute and return the hash value of an object *o*. On failure, return " "``-1``. This is the equivalent of the Python expression ``hash(o)``." msgstr "" -#: ../../c-api/object.rst:294 +#: ../../c-api/object.rst:409 msgid "" "The return type is now Py_hash_t. This is a signed integer the same size " "as :c:type:`Py_ssize_t`." msgstr "" -#: ../../c-api/object.rst:301 +#: ../../c-api/object.rst:416 msgid "" "Set a :exc:`TypeError` indicating that ``type(o)`` is not :term:`hashable` " "and return ``-1``. This function receives special treatment when stored in a " @@ -344,21 +541,21 @@ msgid "" "that it is not hashable." msgstr "" -#: ../../c-api/object.rst:309 +#: ../../c-api/object.rst:424 msgid "" "Returns ``1`` if the object *o* is considered to be true, and ``0`` " "otherwise. This is equivalent to the Python expression ``not not o``. On " "failure, return ``-1``." msgstr "" -#: ../../c-api/object.rst:316 +#: ../../c-api/object.rst:431 msgid "" "Returns ``0`` if the object *o* is considered to be true, and ``1`` " "otherwise. This is equivalent to the Python expression ``not o``. On " "failure, return ``-1``." msgstr "" -#: ../../c-api/object.rst:325 +#: ../../c-api/object.rst:440 msgid "" "When *o* is non-``NULL``, returns a type object corresponding to the object " "type of object *o*. On failure, raises :exc:`SystemError` and returns " @@ -369,13 +566,13 @@ msgid "" "when a new :term:`strong reference` is needed." msgstr "" -#: ../../c-api/object.rst:337 +#: ../../c-api/object.rst:452 msgid "" "Return non-zero if the object *o* is of type *type* or a subtype of *type*, " "and ``0`` otherwise. Both parameters must be non-``NULL``." msgstr "" -#: ../../c-api/object.rst:346 +#: ../../c-api/object.rst:461 msgid "" "Return the length of object *o*. If the object *o* provides either the " "sequence and mapping protocols, the sequence length is returned. On error, " @@ -383,7 +580,7 @@ msgid "" "``len(o)``." msgstr "" -#: ../../c-api/object.rst:353 +#: ../../c-api/object.rst:468 msgid "" "Return an estimated length for the object *o*. First try to return its " "actual length, then an estimate using :meth:`~object.__length_hint__`, and " @@ -392,36 +589,43 @@ msgid "" "defaultvalue)``." msgstr "" -#: ../../c-api/object.rst:363 +#: ../../c-api/object.rst:478 msgid "" "Return element of *o* corresponding to the object *key* or ``NULL`` on " "failure. This is the equivalent of the Python expression ``o[key]``." msgstr "" -#: ../../c-api/object.rst:369 +#: ../../c-api/object.rst:484 msgid "" "Map the object *key* to the value *v*. Raise an exception and return ``-1`` " "on failure; return ``0`` on success. This is the equivalent of the Python " "statement ``o[key] = v``. This function *does not* steal a reference to *v*." msgstr "" -#: ../../c-api/object.rst:377 +#: ../../c-api/object.rst:492 msgid "" "Remove the mapping for the object *key* from the object *o*. Return ``-1`` " "on failure. This is equivalent to the Python statement ``del o[key]``." msgstr "" -#: ../../c-api/object.rst:383 +#: ../../c-api/object.rst:498 +msgid "" +"This is the same as :c:func:`PyObject_DelItem`, but *key* is specified as " +"a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." +msgstr "" + +#: ../../c-api/object.rst:505 msgid "" "This is equivalent to the Python expression ``dir(o)``, returning a " "(possibly empty) list of strings appropriate for the object argument, or " "``NULL`` if there was an error. If the argument is ``NULL``, this is like " "the Python ``dir()``, returning the names of the current locals; in this " -"case, if no execution frame is active then ``NULL`` is returned but :c:func:" -"`PyErr_Occurred` will return false." +"case, if no execution frame is active then ``NULL`` is returned " +"but :c:func:`PyErr_Occurred` will return false." msgstr "" -#: ../../c-api/object.rst:392 +#: ../../c-api/object.rst:514 msgid "" "This is equivalent to the Python expression ``iter(o)``. It returns a new " "iterator for the object argument, or the object itself if the object is " @@ -429,99 +633,122 @@ msgid "" "object cannot be iterated." msgstr "" -#: ../../c-api/object.rst:400 +#: ../../c-api/object.rst:522 msgid "" -"This is the equivalent to the Python expression ``aiter(o)``. Takes an :" -"class:`AsyncIterable` object and returns an :class:`AsyncIterator` for it. " -"This is typically a new iterator but if the argument is an :class:" -"`AsyncIterator`, this returns itself. Raises :exc:`TypeError` and returns " -"``NULL`` if the object cannot be iterated." +"This is equivalent to the Python ``__iter__(self): return self`` method. It " +"is intended for :term:`iterator` types, to be used in " +"the :c:member:`PyTypeObject.tp_iter` slot." msgstr "" -#: ../../c-api/object.rst:410 +#: ../../c-api/object.rst:528 +msgid "" +"This is the equivalent to the Python expression ``aiter(o)``. Takes " +"an :class:`AsyncIterable` object and returns an :class:`AsyncIterator` for " +"it. This is typically a new iterator but if the argument is " +"an :class:`AsyncIterator`, this returns itself. Raises :exc:`TypeError` and " +"returns ``NULL`` if the object cannot be iterated." +msgstr "" + +#: ../../c-api/object.rst:538 msgid "Get a pointer to subclass-specific data reserved for *cls*." msgstr "" -#: ../../c-api/object.rst:412 +#: ../../c-api/object.rst:540 msgid "" "The object *o* must be an instance of *cls*, and *cls* must have been " "created using negative :c:member:`PyType_Spec.basicsize`. Python does not " "check this." msgstr "" -#: ../../c-api/object.rst:416 +#: ../../c-api/object.rst:544 msgid "On error, set an exception and return ``NULL``." -msgstr "" +msgstr "錯誤時設定一個例外並回傳 ``NULL``。" -#: ../../c-api/object.rst:422 +#: ../../c-api/object.rst:550 msgid "" "Return the size of the instance memory space reserved for *cls*, i.e. the " "size of the memory :c:func:`PyObject_GetTypeData` returns." msgstr "" -#: ../../c-api/object.rst:425 +#: ../../c-api/object.rst:553 msgid "" "This may be larger than requested using :c:member:`-PyType_Spec.basicsize " -"`; it is safe to use this larger size (e.g. with :c:" -"func:`!memset`)." +"`; it is safe to use this larger size (e.g. " +"with :c:func:`!memset`)." msgstr "" -#: ../../c-api/object.rst:428 +#: ../../c-api/object.rst:556 msgid "" -"The type *cls* **must** have been created using negative :c:member:" -"`PyType_Spec.basicsize`. Python does not check this." +"The type *cls* **must** have been created using " +"negative :c:member:`PyType_Spec.basicsize`. Python does not check this." msgstr "" -#: ../../c-api/object.rst:432 +#: ../../c-api/object.rst:560 msgid "On error, set an exception and return a negative value." -msgstr "" +msgstr "錯誤時設定一個例外並回傳一個負值。" -#: ../../c-api/object.rst:438 +#: ../../c-api/object.rst:566 msgid "" -"Get a pointer to per-item data for a class with :c:macro:" -"`Py_TPFLAGS_ITEMS_AT_END`." +"Get a pointer to per-item data for a class " +"with :c:macro:`Py_TPFLAGS_ITEMS_AT_END`." msgstr "" -#: ../../c-api/object.rst:441 +#: ../../c-api/object.rst:569 msgid "" "On error, set an exception and return ``NULL``. :py:exc:`TypeError` is " "raised if *o* does not have :c:macro:`Py_TPFLAGS_ITEMS_AT_END` set." msgstr "" +"錯誤時設定一個例外並回傳 ``NULL``。如果 *o* 沒有設" +"定 :c:macro:`Py_TPFLAGS_ITEMS_AT_END`,則會引發 :py:exc:`TypeError`。" + +#: ../../c-api/object.rst:577 +msgid "Visit the managed dictionary of *obj*." +msgstr "" + +#: ../../c-api/object.rst:579 ../../c-api/object.rst:588 +msgid "" +"This function must only be called in a traverse function of the type which " +"has the :c:macro:`Py_TPFLAGS_MANAGED_DICT` flag set." +msgstr "" -#: ../../c-api/object.rst:201 ../../c-api/object.rst:213 -#: ../../c-api/object.rst:238 ../../c-api/object.rst:289 -#: ../../c-api/object.rst:323 ../../c-api/object.rst:344 +#: ../../c-api/object.rst:586 +msgid "Clear the managed dictionary of *obj*." +msgstr "" + +#: ../../c-api/object.rst:316 ../../c-api/object.rst:328 +#: ../../c-api/object.rst:353 ../../c-api/object.rst:404 +#: ../../c-api/object.rst:438 ../../c-api/object.rst:459 msgid "built-in function" msgstr "bulit-in function(內建函式)" -#: ../../c-api/object.rst:201 +#: ../../c-api/object.rst:316 msgid "repr" msgstr "repr" -#: ../../c-api/object.rst:213 +#: ../../c-api/object.rst:328 msgid "ascii" msgstr "ascii" -#: ../../c-api/object.rst:221 +#: ../../c-api/object.rst:336 msgid "string" msgstr "string(字串)" -#: ../../c-api/object.rst:221 +#: ../../c-api/object.rst:336 msgid "PyObject_Str (C function)" msgstr "PyObject_Str(C 函式)" -#: ../../c-api/object.rst:238 +#: ../../c-api/object.rst:353 msgid "bytes" msgstr "bytes(位元組)" -#: ../../c-api/object.rst:289 +#: ../../c-api/object.rst:404 msgid "hash" msgstr "hash(雜湊)" -#: ../../c-api/object.rst:323 +#: ../../c-api/object.rst:438 msgid "type" msgstr "type(型別)" -#: ../../c-api/object.rst:344 +#: ../../c-api/object.rst:459 msgid "len" msgstr "len" diff --git a/c-api/objimpl.po b/c-api/objimpl.po index 7ae527d6fb..b468c22948 100644 --- a/c-api/objimpl.po +++ b/c-api/objimpl.po @@ -5,11 +5,11 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" -"PO-Revision-Date: 2015-12-09 17:51+0000\n" -"Last-Translator: Liang-Bo Wang \n" +"PO-Revision-Date: 2025-07-14 02:51+0000\n" +"Last-Translator: AI Assistant\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -20,10 +20,10 @@ msgstr "" #: ../../c-api/objimpl.rst:7 msgid "Object Implementation Support" -msgstr "" +msgstr "物件實作支援" #: ../../c-api/objimpl.rst:9 msgid "" "This chapter describes the functions, types, and macros used when defining " "new object types." -msgstr "" +msgstr "本章節說明在定義新的物件型別時所使用的函式、型別和巨集。" diff --git a/c-api/perfmaps.po b/c-api/perfmaps.po index f46aea6a4b..ee98fd31d1 100644 --- a/c-api/perfmaps.po +++ b/c-api/perfmaps.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-07-17 17:39+0800\n" "PO-Revision-Date: 2024-05-11 14:42+0800\n" @@ -45,8 +45,8 @@ msgid "" "In Python, these helper APIs can be used by libraries and features that rely " "on generating machine code on the fly." msgstr "" -"在 Python 中,這些輔助 API 可以被依賴於運行期間 (on the fly) 產生機器碼的函式庫和" -"功能所使用。" +"在 Python 中,這些輔助 API 可以被依賴於運行期間 (on the fly) 產生機器碼的函式" +"庫和功能所使用。" #: ../../c-api/perfmaps.rst:19 msgid "" @@ -75,7 +75,7 @@ msgid "" "information about the cause of a failure." msgstr "" "建立/打開 perf map 檔案成功時回傳 ``0``,失敗時回傳 ``-1``,建立鎖時失敗則回" -"傳 ``-2``。檢查 ``errno`` 以獲取更多造成失敗的資訊。" +"傳 ``-2``。檢查 ``errno`` 以取得更多造成失敗的資訊。" #: ../../c-api/perfmaps.rst:35 msgid "" @@ -90,6 +90,8 @@ msgid "" "# address size name\n" "7f3529fcf759 b py::bar:/run/t.py" msgstr "" +"# 位址 大小 名稱\n" +"7f3529fcf759 b py::bar:/run/t.py" #: ../../c-api/perfmaps.rst:41 msgid "" diff --git a/c-api/refcounting.po b/c-api/refcounting.po index 301f66bcb9..ddee8b5b89 100644 --- a/c-api/refcounting.po +++ b/c-api/refcounting.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,9 +6,9 @@ # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-18 00:04+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2023-08-06 14:19+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -37,14 +37,14 @@ msgstr "取得物件 *o* 的參照計數。" #: ../../c-api/refcounting.rst:18 msgid "" "Note that the returned value may not actually reflect how many references to " -"the object are actually held. For example, some objects are \"immortal\" " -"and have a very high refcount that does not reflect the actual number of " -"references. Consequently, do not rely on the returned value to be accurate, " -"other than a value of 0 or 1." +"the object are actually held. For example, some objects are :term:" +"`immortal` and have a very high refcount that does not reflect the actual " +"number of references. Consequently, do not rely on the returned value to be " +"accurate, other than a value of 0 or 1." msgstr "" "請注意,回傳的值可能實際上並不反映實際保存了多少對該物件的參照。例如,某些物" -"件是「不滅的 (immortal)」,並且具有非常高的參照計數,不能反映實際的參照數量。" -"因此,除了 0 或 1 以外,不要依賴回傳值的準確性。" +"件是「:term:`不滅的 (immortal) `」,並且具有非常高的參照計" +"數,不能反映實際的參照數量。因此,除了 0 或 1 以外,不要依賴回傳值的準確性。" #: ../../c-api/refcounting.rst:24 msgid "" @@ -65,18 +65,23 @@ msgstr "設定物件 *o* 的參照計數。" #: ../../c-api/refcounting.rst:37 msgid "" -"Note that this function has no effect on `immortal `_ objects." +"On :ref:`Python build with Free Threading `, if " +"*refcnt* is larger than ``UINT32_MAX``, the object is made :term:`immortal`." msgstr "" -"請注意,此函式對\\ `不滅的 `_\\ 物件沒有影" -"響。" +"在\\ :ref:`啟用自由執行緒的 Python 建置 `\\ 中,如果 " +"*refcnt* 大於 ``UINT32_MAX``,則該物件會被設為\\ :term:`不滅的 (immortal) `。" -#: ../../c-api/refcounting.rst:43 ../../c-api/refcounting.rst:65 -#: ../../c-api/refcounting.rst:142 +#: ../../c-api/refcounting.rst:40 ../../c-api/refcounting.rst:53 +#: ../../c-api/refcounting.rst:119 +msgid "This function has no effect on :term:`immortal` objects." +msgstr "請注意,此函式對\\ :term:`不滅的 `\\ 物件沒有影響。" + +#: ../../c-api/refcounting.rst:44 ../../c-api/refcounting.rst:68 +#: ../../c-api/refcounting.rst:147 msgid "Immortal objects are not modified." msgstr "不滅的物件不會被修改。" -#: ../../c-api/refcounting.rst:49 +#: ../../c-api/refcounting.rst:50 msgid "" "Indicate taking a new :term:`strong reference` to object *o*, indicating it " "is in use and should not be destroyed." @@ -84,7 +89,7 @@ msgstr "" "代表取得對於物件 *o* 的新\\ :term:`強參照 `,即它正在使用且" "不應被銷毀。" -#: ../../c-api/refcounting.rst:52 +#: ../../c-api/refcounting.rst:55 msgid "" "This function is usually used to convert a :term:`borrowed reference` to a :" "term:`strong reference` in-place. The :c:func:`Py_NewRef` function can be " @@ -94,11 +99,11 @@ msgstr "" "換為\\ :term:`強參照 `。:c:func:`Py_NewRef` 函式可用於建立" "新的\\ :term:`強參照 `。" -#: ../../c-api/refcounting.rst:56 -msgid "When done using the object, release it by calling :c:func:`Py_DECREF`." +#: ../../c-api/refcounting.rst:59 +msgid "When done using the object, release is by calling :c:func:`Py_DECREF`." msgstr "使用完該物件後,透過呼叫 :c:func:`Py_DECREF` 來釋放它。" -#: ../../c-api/refcounting.rst:58 +#: ../../c-api/refcounting.rst:61 msgid "" "The object must not be ``NULL``; if you aren't sure that it isn't ``NULL``, " "use :c:func:`Py_XINCREF`." @@ -106,7 +111,7 @@ msgstr "" "該物件不能為 ``NULL``;如果你不確定它不是 ``NULL``,請使用 :c:func:" "`Py_XINCREF`。" -#: ../../c-api/refcounting.rst:61 +#: ../../c-api/refcounting.rst:64 msgid "" "Do not expect this function to actually modify *o* in any way. For at least :" "pep:`some objects <0683>`, this function has no effect." @@ -114,7 +119,7 @@ msgstr "" "不要期望此函式會以任何方式實際修改 *o*,至少對於\\ :pep:`某些物件 <0683>`\\ " "來說,此函式沒有任何效果。" -#: ../../c-api/refcounting.rst:71 +#: ../../c-api/refcounting.rst:74 msgid "" "Similar to :c:func:`Py_INCREF`, but the object *o* can be ``NULL``, in which " "case this has no effect." @@ -122,11 +127,11 @@ msgstr "" "與 :c:func:`Py_INCREF` 類似,但物件 *o* 可以為 ``NULL``,在這種情況下這就不會" "有任何效果。" -#: ../../c-api/refcounting.rst:74 +#: ../../c-api/refcounting.rst:77 msgid "See also :c:func:`Py_XNewRef`." msgstr "另請見 :c:func:`Py_XNewRef`。" -#: ../../c-api/refcounting.rst:79 +#: ../../c-api/refcounting.rst:82 msgid "" "Create a new :term:`strong reference` to an object: call :c:func:`Py_INCREF` " "on *o* and return the object *o*." @@ -134,7 +139,7 @@ msgstr "" "建立對物件的新\\ :term:`強參照 `:於 *o* 呼叫 :c:func:" "`Py_INCREF` 並回傳物件 *o*。" -#: ../../c-api/refcounting.rst:82 +#: ../../c-api/refcounting.rst:85 msgid "" "When the :term:`strong reference` is no longer needed, :c:func:`Py_DECREF` " "should be called on it to release the reference." @@ -142,7 +147,7 @@ msgstr "" "當不再需要\\ :term:`強參照 `\\ 時,應對其呼叫 :c:func:" "`Py_DECREF` 以釋放該參照。" -#: ../../c-api/refcounting.rst:85 +#: ../../c-api/refcounting.rst:88 msgid "" "The object *o* must not be ``NULL``; use :c:func:`Py_XNewRef` if *o* can be " "``NULL``." @@ -150,11 +155,11 @@ msgstr "" "物件 *o* 不能為 ``NULL``;如果 *o* 可以為 ``NULL``,則使用 :c:func:" "`Py_XNewRef`。" -#: ../../c-api/refcounting.rst:88 +#: ../../c-api/refcounting.rst:91 msgid "For example::" msgstr "舉例來說: ::" -#: ../../c-api/refcounting.rst:90 +#: ../../c-api/refcounting.rst:93 msgid "" "Py_INCREF(obj);\n" "self->attr = obj;" @@ -162,27 +167,27 @@ msgstr "" "Py_INCREF(obj);\n" "self->attr = obj;" -#: ../../c-api/refcounting.rst:93 +#: ../../c-api/refcounting.rst:96 msgid "can be written as::" msgstr "可以寫成: ::" -#: ../../c-api/refcounting.rst:95 +#: ../../c-api/refcounting.rst:98 msgid "self->attr = Py_NewRef(obj);" msgstr "self->attr = Py_NewRef(obj);" -#: ../../c-api/refcounting.rst:97 +#: ../../c-api/refcounting.rst:100 msgid "See also :c:func:`Py_INCREF`." msgstr "另請參閱 :c:func:`Py_INCREF`。" -#: ../../c-api/refcounting.rst:104 +#: ../../c-api/refcounting.rst:107 msgid "Similar to :c:func:`Py_NewRef`, but the object *o* can be NULL." msgstr "與 :c:func:`Py_NewRef` 類似,但物件 *o* 可以為 NULL。" -#: ../../c-api/refcounting.rst:106 +#: ../../c-api/refcounting.rst:109 msgid "If the object *o* is ``NULL``, the function just returns ``NULL``." msgstr "如果物件 *o* 為 ``NULL``,則該函式僅回傳 ``NULL``。" -#: ../../c-api/refcounting.rst:113 +#: ../../c-api/refcounting.rst:116 msgid "" "Release a :term:`strong reference` to object *o*, indicating the reference " "is no longer used." @@ -190,7 +195,7 @@ msgstr "" "釋放一個對物件 *o* 的\\ :term:`強參照 `,代表該參照不會再被" "使用。" -#: ../../c-api/refcounting.rst:116 +#: ../../c-api/refcounting.rst:121 msgid "" "Once the last :term:`strong reference` is released (i.e. the object's " "reference count reaches 0), the object's type's deallocation function (which " @@ -200,14 +205,14 @@ msgstr "" "到零),則觸發物件之型別的釋放函式 (deallocation function)(不得為 " "``NULL``\\ )。" -#: ../../c-api/refcounting.rst:121 +#: ../../c-api/refcounting.rst:126 msgid "" "This function is usually used to delete a :term:`strong reference` before " "exiting its scope." msgstr "" "此函式通常用於在退出作用域之前刪除\\ :term:`強參照 `。" -#: ../../c-api/refcounting.rst:124 +#: ../../c-api/refcounting.rst:129 msgid "" "The object must not be ``NULL``; if you aren't sure that it isn't ``NULL``, " "use :c:func:`Py_XDECREF`." @@ -215,7 +220,7 @@ msgstr "" "該物件不能為 ``NULL``;如果你不確定它不是 ``NULL``,請改用 :c:func:" "`Py_XDECREF`。" -#: ../../c-api/refcounting.rst:127 +#: ../../c-api/refcounting.rst:132 msgid "" "Do not expect this function to actually modify *o* in any way. For at least :" "pep:`some objects <683>`, this function has no effect." @@ -223,7 +228,7 @@ msgstr "" "不要期望此函式會以任何方式實際修改 *o*,至少對於\\ :pep:`某些物件 <683>`\\ 來" "說,此函式沒有任何效果。" -#: ../../c-api/refcounting.rst:133 +#: ../../c-api/refcounting.rst:138 msgid "" "The deallocation function can cause arbitrary Python code to be invoked (e." "g. when a class instance with a :meth:`~object.__del__` method is " @@ -235,14 +240,14 @@ msgid "" "object in a temporary variable, update the list data structure, and then " "call :c:func:`Py_DECREF` for the temporary variable." msgstr "" -"釋放函式可以導致任意 Python 程式碼被調用(例如,當釋放具有 :meth:`~object." +"釋放函式可以導致任意 Python 程式碼被叫用(例如,當釋放具有 :meth:`~object." "__del__` 方法的類別實例時)。雖然此類程式碼中的例外不會被傳遞出來,但​​執行的程" -"式碼可以自由存取所有 Python 全域變數。這意味著在調用 :c:func:`Py_DECREF` 之" +"式碼可以自由存取所有 Python 全域變數。這意味著在叫用 :c:func:`Py_DECREF` 之" "前,可從全域變數存取的任何物件都應處於一致狀態。例如,從 list 中刪除物件的程" "式碼應將已刪除物件的參照複製到臨時變數中,更新 list 資料結構,然後為臨時變數" "呼叫 :c:func:`Py_DECREF`。" -#: ../../c-api/refcounting.rst:148 +#: ../../c-api/refcounting.rst:153 msgid "" "Similar to :c:func:`Py_DECREF`, but the object *o* can be ``NULL``, in which " "case this has no effect. The same warning from :c:func:`Py_DECREF` applies " @@ -251,7 +256,7 @@ msgstr "" "和 :c:func:`Py_DECREF` 類似,但該物件可以是 ``NULL``,在這種情況下巨集不起作" "用。在這裡也會出現與 :c:func:`Py_DECREF` 相同的警告。" -#: ../../c-api/refcounting.rst:155 +#: ../../c-api/refcounting.rst:160 msgid "" "Release a :term:`strong reference` for object *o*. The object may be " "``NULL``, in which case the macro has no effect; otherwise the effect is the " @@ -265,7 +270,7 @@ msgstr "" "非引數也設定為 ``NULL``。:c:func:`Py_DECREF` 的警告不適用於傳遞的物件,因為巨" "集在釋放其參照之前小心地使用臨時變數並將引數設定為 ``NULL``。" -#: ../../c-api/refcounting.rst:163 +#: ../../c-api/refcounting.rst:168 msgid "" "It is a good idea to use this macro whenever releasing a reference to an " "object that might be traversed during garbage collection." @@ -273,7 +278,7 @@ msgstr "" "每當要釋放垃圾回收 (garbage collection) 期間可能被遍歷到之對於物件的參照時," "使用此巨集是個好主意。" -#: ../../c-api/refcounting.rst:166 +#: ../../c-api/refcounting.rst:171 msgid "" "The macro argument is now only evaluated once. If the argument has side " "effects, these are no longer duplicated." @@ -281,7 +286,7 @@ msgstr "" "巨集引數現在僅會被求值 (evaluate) 一次。如果引數有其他副作用,則不再重複作" "用。" -#: ../../c-api/refcounting.rst:173 +#: ../../c-api/refcounting.rst:178 msgid "" "Indicate taking a new :term:`strong reference` to object *o*. A function " "version of :c:func:`Py_XINCREF`. It can be used for runtime dynamic " @@ -290,7 +295,7 @@ msgstr "" "代表取得對於物件 *o* 的\\ :term:`強參照 `。:c:func:" "`Py_XINCREF` 的函式版本。它可用於 Python 的 runtime 動態嵌入。" -#: ../../c-api/refcounting.rst:180 +#: ../../c-api/refcounting.rst:185 msgid "" "Release a :term:`strong reference` to object *o*. A function version of :c:" "func:`Py_XDECREF`. It can be used for runtime dynamic embedding of Python." @@ -298,7 +303,7 @@ msgstr "" "釋放對物件 *o* 的\\ :term:`強參照 `。:c:func:`Py_XDECREF` " "的函式版本。它可用於 Python 的 runtime 動態嵌入。" -#: ../../c-api/refcounting.rst:187 +#: ../../c-api/refcounting.rst:192 msgid "" "Macro safely releasing a :term:`strong reference` to object *dst* and " "setting *dst* to *src*." @@ -306,11 +311,11 @@ msgstr "" "巨集安全地釋放對於物件 *dst* 的\\ :term:`強參照 `\\ 並將 " "*dst* 設定為 *src*。" -#: ../../c-api/refcounting.rst:190 +#: ../../c-api/refcounting.rst:195 msgid "As in case of :c:func:`Py_CLEAR`, \"the obvious\" code can be deadly::" msgstr "與 :c:func:`Py_CLEAR` 的情況一樣,「明顯的」程式碼可能是致命的: ::" -#: ../../c-api/refcounting.rst:192 +#: ../../c-api/refcounting.rst:197 msgid "" "Py_DECREF(dst);\n" "dst = src;" @@ -318,31 +323,31 @@ msgstr "" "Py_DECREF(dst);\n" "dst = src;" -#: ../../c-api/refcounting.rst:195 +#: ../../c-api/refcounting.rst:200 msgid "The safe way is::" msgstr "安全的方法是: ::" -#: ../../c-api/refcounting.rst:197 +#: ../../c-api/refcounting.rst:202 msgid "Py_SETREF(dst, src);" msgstr "Py_SETREF(dst, src);" -#: ../../c-api/refcounting.rst:199 +#: ../../c-api/refcounting.rst:204 msgid "" -"That arranges to set *dst* to *src* _before_ releasing the reference to the " +"That arranges to set *dst* to *src* *before* releasing the reference to the " "old value of *dst*, so that any code triggered as a side-effect of *dst* " "getting torn down no longer believes *dst* points to a valid object." msgstr "" -"這會在釋放對 *dst* 舊值的參照\\ _之前_\\ 將 *dst* 設定為 *src*,使得因 *dst* " +"這會在釋放對 *dst* 舊值的參照\\ *之前*\\ 將 *dst* 設定為 *src*,使得因 *dst* " "被拆除而觸發的任何副作用 (side-effect) 之程式碼不會相信 *dst* 是指向一個有效" "物件。" -#: ../../c-api/refcounting.rst:206 ../../c-api/refcounting.rst:218 +#: ../../c-api/refcounting.rst:211 ../../c-api/refcounting.rst:223 msgid "" "The macro arguments are now only evaluated once. If an argument has side " "effects, these are no longer duplicated." msgstr "巨集引數現在僅會被求值一次。如果引數有其他副作用,則不再重複作用。" -#: ../../c-api/refcounting.rst:213 +#: ../../c-api/refcounting.rst:218 msgid "" "Variant of :c:macro:`Py_SETREF` macro that uses :c:func:`Py_XDECREF` instead " "of :c:func:`Py_DECREF`." diff --git a/c-api/reflection.po b/c-api/reflection.po index 38e3cc09e9..6854e16e93 100644 --- a/c-api/reflection.po +++ b/c-api/reflection.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-10-15 20:43+0000\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2015-12-09 17:51+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,41 +22,103 @@ msgstr "" msgid "Reflection" msgstr "" -#: ../../c-api/reflection.rst:10 +#: ../../c-api/reflection.rst:12 +msgid "Use :c:func:`PyEval_GetFrameBuiltins` instead." +msgstr "" + +#: ../../c-api/reflection.rst:14 ../../c-api/reflection.rst:66 msgid "" "Return a dictionary of the builtins in the current execution frame, or the " "interpreter of the thread state if no frame is currently executing." msgstr "" -#: ../../c-api/reflection.rst:16 +#: ../../c-api/reflection.rst:22 msgid "" -"Return a dictionary of the local variables in the current execution frame, " -"or ``NULL`` if no frame is currently executing." +"Use either :c:func:`PyEval_GetFrameLocals` to obtain the same behaviour as " +"calling :func:`locals` in Python code, or else call :c:func:" +"`PyFrame_GetLocals` on the result of :c:func:`PyEval_GetFrame` to access " +"the :attr:`~frame.f_locals` attribute of the currently executing frame." msgstr "" -#: ../../c-api/reflection.rst:22 +#: ../../c-api/reflection.rst:27 +msgid "" +"Return a mapping providing access to the local variables in the current " +"execution frame, or ``NULL`` if no frame is currently executing." +msgstr "" + +#: ../../c-api/reflection.rst:30 +msgid "" +"Refer to :func:`locals` for details of the mapping returned at different " +"scopes." +msgstr "" + +#: ../../c-api/reflection.rst:32 +msgid "" +"As this function returns a :term:`borrowed reference`, the dictionary " +"returned for :term:`optimized scopes ` is cached on the " +"frame object and will remain alive as long as the frame object does. Unlike :" +"c:func:`PyEval_GetFrameLocals` and :func:`locals`, 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." +msgstr "" + +#: ../../c-api/reflection.rst:39 +msgid "" +"As part of :pep:`667`, :c:func:`PyFrame_GetLocals`, :func:`locals`, and :" +"attr:`FrameType.f_locals ` no longer make use of the shared " +"cache dictionary. Refer to the :ref:`What's New entry ` for additional details." +msgstr "" + +#: ../../c-api/reflection.rst:50 +msgid "Use :c:func:`PyEval_GetFrameGlobals` instead." +msgstr "" + +#: ../../c-api/reflection.rst:52 msgid "" "Return a dictionary of the global variables in the current execution frame, " "or ``NULL`` if no frame is currently executing." msgstr "" -#: ../../c-api/reflection.rst:28 +#: ../../c-api/reflection.rst:58 msgid "" "Return the current thread state's frame, which is ``NULL`` if no frame is " "currently executing." msgstr "" -#: ../../c-api/reflection.rst:31 +#: ../../c-api/reflection.rst:61 msgid "See also :c:func:`PyThreadState_GetFrame`." msgstr "另請見 :c:func:`PyThreadState_GetFrame`。" -#: ../../c-api/reflection.rst:36 +#: ../../c-api/reflection.rst:74 +msgid "" +"Return a dictionary of the local variables in the current execution frame, " +"or ``NULL`` if no frame is currently executing. Equivalent to calling :func:" +"`locals` in Python code." +msgstr "" + +#: ../../c-api/reflection.rst:78 +msgid "" +"To access :attr:`~frame.f_locals` on the current frame without making an " +"independent snapshot in :term:`optimized scopes `, call :c:" +"func:`PyFrame_GetLocals` on the result of :c:func:`PyEval_GetFrame`." +msgstr "" + +#: ../../c-api/reflection.rst:87 +msgid "" +"Return a dictionary of the global variables in the current execution frame, " +"or ``NULL`` if no frame is currently executing. Equivalent to calling :func:" +"`globals` in Python code." +msgstr "" + +#: ../../c-api/reflection.rst:96 msgid "" "Return the name of *func* if it is a function, class or instance object, " "else the name of *func*\\s type." msgstr "" -#: ../../c-api/reflection.rst:42 +#: ../../c-api/reflection.rst:102 msgid "" "Return a description string, depending on the type of *func*. Return values " "include \"()\" for functions and methods, \" constructor\", \" instance\", " diff --git a/c-api/sequence.po b/c-api/sequence.po index c321e9b980..88d5a0d4fa 100644 --- a/c-api/sequence.po +++ b/c-api/sequence.po @@ -5,7 +5,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-07-24 00:03+0000\n" "PO-Revision-Date: 2018-05-23 14:32+0000\n" @@ -202,7 +202,7 @@ msgstr "" #: ../../c-api/sequence.rst:21 ../../c-api/sequence.rst:123 msgid "built-in function" -msgstr "built-in function(内建函式)" +msgstr "built-in function(內建函式)" #: ../../c-api/sequence.rst:21 msgid "len" @@ -210,4 +210,4 @@ msgstr "len" #: ../../c-api/sequence.rst:123 msgid "tuple" -msgstr "tuple(元组)" +msgstr "tuple(元組)" diff --git a/c-api/set.po b/c-api/set.po index 0a6f16c6ba..e094b1ee32 100644 --- a/c-api/set.po +++ b/c-api/set.po @@ -5,7 +5,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-11-27 00:03+0000\n" "PO-Revision-Date: 2018-05-23 14:07+0000\n" diff --git a/c-api/slice.po b/c-api/slice.po index 4c70f299c0..fbac58a43a 100644 --- a/c-api/slice.po +++ b/c-api/slice.po @@ -6,9 +6,9 @@ # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2025-02-18 00:13+0000\n" "PO-Revision-Date: 2018-05-23 14:07+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -88,8 +88,8 @@ msgstr "成功時回傳 ``0`` ,在失敗時回傳 ``-1`` 並設定例外。" #: ../../c-api/slice.rst:60 msgid "" "This function is considered not safe for resizable sequences. Its invocation " -"should be replaced by a combination of :c:func:`PySlice_Unpack` and :c:func:" -"`PySlice_AdjustIndices` where ::" +"should be replaced by a combination of :c:func:`PySlice_Unpack` " +"and :c:func:`PySlice_AdjustIndices` where ::" msgstr "" #: ../../c-api/slice.rst:64 @@ -156,15 +156,20 @@ msgstr "" #: ../../c-api/slice.rst:118 msgid "Ellipsis Object" -msgstr "" +msgstr "Ellipsis 物件" #: ../../c-api/slice.rst:123 msgid "" -"The Python ``Ellipsis`` object. This object has no methods. Like :c:data:" -"`Py_None`, it is an `immortal `_. " -"singleton object." +"The type of Python :const:`Ellipsis` object. Same " +"as :class:`types.EllipsisType` in the Python layer." +msgstr "" + +#: ../../c-api/slice.rst:129 +msgid "" +"The Python ``Ellipsis`` object. This object has no methods. " +"Like :c:data:`Py_None`, it is an :term:`immortal` singleton object." msgstr "" -#: ../../c-api/slice.rst:127 +#: ../../c-api/slice.rst:132 msgid ":c:data:`Py_Ellipsis` is immortal." msgstr ":c:data:`Py_Ellipsis` 為不滅的 (immortal)。" diff --git a/c-api/stable.po b/c-api/stable.po index 3bd34e00be..54ff032f04 100644 --- a/c-api/stable.po +++ b/c-api/stable.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-01-19 00:03+0000\n" +"POT-Creation-Date: 2024-12-04 00:14+0000\n" "PO-Revision-Date: 2023-01-24 21:07+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -37,10 +37,10 @@ msgstr "" #: ../../c-api/stable.rst:15 msgid "" "CPython's Application Binary Interface (ABI) is forward- and backwards-" -"compatible across a minor release (if these are compiled the same way; see :" -"ref:`stable-abi-platform` 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." +"compatible across a minor release (if these are compiled the same way; " +"see :ref:`stable-abi-platform` 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." msgstr "" "CPython 的應用程式二進位介面 (Application Binary Interface, ABI) 在次要版本中" "是向前和向後相容的(如果它們以相同的方式編譯;請參閱下面的\\ :ref:`stable-" @@ -65,8 +65,8 @@ msgid "" "releases. When :c:macro:`Py_LIMITED_API` is defined, only this subset is " "exposed from ``Python.h``." msgstr "" -":ref:`受限 API `,在多個次要版本之間相容。當有定義 :c:macro:" -"`Py_LIMITED_API` 時,只有這個子集會從 ``Python.h`` 公開。" +":ref:`受限 API `,在多個次要版本之間相容。當有定" +"義 :c:macro:`Py_LIMITED_API` 時,只有這個子集會從 ``Python.h`` 公開。" #: ../../c-api/stable.rst:29 msgid "These are discussed in more detail below." @@ -76,14 +76,14 @@ msgstr "下面將更詳細地討論這些內容。" msgid "" "Names prefixed by an underscore, such as ``_Py_InternalState``, are private " "API that can change without notice even in patch releases. If you need to " -"use this API, consider reaching out to `CPython developers `_ to discuss adding public API for your use " -"case." +"use this API, consider reaching out to `CPython developers `_ to discuss adding public API for " +"your use case." msgstr "" "帶有底線前綴的名稱是私有 API (private API),像是 ``_Py_InternalState``,即使" "在補丁版本 (patch release) 中也可能被更改,不會另行通知。如果你需要使用這個 " -"API,可以聯繫 `CPython 開發者 `_ 並針對你的使用方法來討論是否新增公開的 API。" +"API,可以聯繫 `CPython 開發者 `_ 並針對你的使用方法來討論是否新增公開的 API。" #: ../../c-api/stable.rst:40 msgid "Unstable C API" @@ -134,13 +134,13 @@ msgstr "受限 C API" #: ../../c-api/stable.rst:67 msgid "" "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 :ref:`listed " +"Extensions that only use the Limited API can be compiled once and be loaded " +"on multiple versions of Python. Contents of the Limited API are :ref:`listed " "below `." msgstr "" "Python 3.2 引入了\\ *受限 API (Limited API)*,它是 Python C API 的一個子集。" -"僅使用受限 API 的擴充可以只編譯一次就使用於多個版本的 Python。受限 API 的內容" -"\\ :ref:`列在下方 `。" +"僅使用受限 API 的擴充可以只編譯一次就被載入於多個版本的 Python。受限 API 的內" +"容\\ :ref:`列在下方 `。" #: ../../c-api/stable.rst:74 msgid "" @@ -153,13 +153,12 @@ msgstr "" msgid "" "Define ``Py_LIMITED_API`` to the value of :c:macro:`PY_VERSION_HEX` " "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." +"extension will be ABI-compatible with all Python 3 releases from the " +"specified one onward, and can use Limited API introduced up to that version." msgstr "" -"將 ``Py_LIMITED_API`` 定義為對應於你的擴充有支援的最低 Python 版本的 :c:" -"macro:`PY_VERSION_HEX` 值。該擴充無需重新編譯即可與從指定版本開始的所有 " -"Python 3 版本一起使用,並且可以使用過去版本有引入的受限 API。" +"將 ``Py_LIMITED_API`` 定義為對應於你的擴充有支援的最低 Python 版本" +"的 :c:macro:`PY_VERSION_HEX` 值。該擴充與從指定版本開始的所有 Python 3 版本" +"之 ABI 相容,並且可以使用過去版本有引入的受限 API。" #: ../../c-api/stable.rst:83 msgid "" @@ -186,12 +185,23 @@ msgstr "穩定 ABI" #: ../../c-api/stable.rst:96 msgid "" "To enable this, Python provides a *Stable ABI*: a set of symbols that will " -"remain compatible across Python 3.x versions." +"remain ABI-compatible across Python 3.x versions." msgstr "" "為了實現它,Python 提供了一個\\ *穩定 ABI (Stable ABI)*:一組將在各個 Python " -"3.x 版本之間保持相容的符號。" +"3.x 版本之間保持 ABI 相容的符號。" -#: ../../c-api/stable.rst:99 +#: ../../c-api/stable.rst:101 +msgid "" +"The Stable ABI prevents ABI issues, like linker errors due to missing " +"symbols or data corruption due to changes in structure layouts or function " +"signatures. However, other changes in Python can change the *behavior* of " +"extensions. See Python's Backwards Compatibility Policy (:pep:`387`) for " +"details." +msgstr "" +"穩定 ABI 可以防止 ABI 問題,例如由於結構布局或函式簽名變化導致缺少符號或數據損壞的鏈接器 (linker) 錯誤。" +"然而,Python 的其他變化可能會改變 *行為* 的擴充。有關詳細信息,請參閱 Python 的向後相容性政策 (:pep:`387`)。" + +#: ../../c-api/stable.rst:107 msgid "" "The Stable ABI contains symbols exposed in the :ref:`Limited API `, but also other ones – for example, functions necessary to support " @@ -200,16 +210,16 @@ msgstr "" "穩定 ABI 被包含在\\ :ref:`受限 API ` 中開放的符號,但也包含其" "他符號 - 例如,支援舊版受限 API 所必需的函式。" -#: ../../c-api/stable.rst:103 +#: ../../c-api/stable.rst:111 msgid "" "On Windows, extensions that use the Stable ABI should be linked against " -"``python3.dll`` rather than a version-specific library such as ``python39." -"dll``." +"``python3.dll`` rather than a version-specific library such as " +"``python39.dll``." msgstr "" "在 Windows 上,使用穩定 ABI 的擴充應該連接到 ``python3.dll`` 而不是特定版本的" "函式庫,例如 ``python39.dll``。" -#: ../../c-api/stable.rst:107 +#: ../../c-api/stable.rst:115 msgid "" "On some platforms, Python will look for and load shared library files named " "with the ``abi3`` tag (e.g. ``mymodule.abi3.so``). It does not check if such " @@ -222,7 +232,7 @@ msgstr "" "用者(或者打包工具)身上,例如使用 3.10+ 受限 API 建置的擴充不會為較低版本的 " "Python 所安裝。" -#: ../../c-api/stable.rst:114 +#: ../../c-api/stable.rst:122 msgid "" "All functions in the Stable ABI are present as functions in Python's shared " "library, not solely as macros. This makes them usable from languages that " @@ -231,28 +241,28 @@ msgstr "" "穩定 ABI 中的所有函式都作為函式存在於 Python 的共享函式庫中,而不僅是作為巨" "集。這使得它們可被用於不使用 C 預處理器 (preprocessor) 的語言。" -#: ../../c-api/stable.rst:120 +#: ../../c-api/stable.rst:128 msgid "Limited API Scope and Performance" msgstr "受限 API 範圍和性能" -#: ../../c-api/stable.rst:122 +#: ../../c-api/stable.rst:130 msgid "" "The goal for the Limited API is to allow everything that is possible with " "the full C API, but possibly with a performance penalty." msgstr "" "受限 API 的目標是允許使用完整的 C API 進行所有可能的操作,但可能會降低性能。" -#: ../../c-api/stable.rst:125 +#: ../../c-api/stable.rst:133 msgid "" "For example, while :c:func:`PyList_GetItem` is available, its “unsafe” macro " "variant :c:func:`PyList_GET_ITEM` is not. The macro can be faster because it " "can rely on version-specific implementation details of the list object." msgstr "" -"例如,雖然 :c:func:`PyList_GetItem` 可用,但它的「不安全」巨集變體 :c:func:" -"`PyList_GET_ITEM` 為不可用。巨集運行可以更快,因為它可以依賴 list 物件的特定" -"版本實作細節。" +"例如,雖然 :c:func:`PyList_GetItem` 可用,但它的「不安全」巨集變" +"體 :c:func:`PyList_GET_ITEM` 為不可用。巨集運行可以更快,因為它可以依賴 list " +"物件的特定版本實作細節。" -#: ../../c-api/stable.rst:130 +#: ../../c-api/stable.rst:138 msgid "" "Without ``Py_LIMITED_API`` defined, some C API functions are inlined or " "replaced by macros. Defining ``Py_LIMITED_API`` disables this inlining, " @@ -263,7 +273,7 @@ msgstr "" "``Py_LIMITED_API`` 會禁用嵌入,從而隨著 Python 資料結構的改進而提高穩定性,但" "可能會降低性能。" -#: ../../c-api/stable.rst:135 +#: ../../c-api/stable.rst:143 msgid "" "By leaving out the ``Py_LIMITED_API`` definition, it is possible to compile " "a Limited API extension with a version-specific ABI. This can improve " @@ -272,28 +282,29 @@ msgid "" "where a version-specific one is not available – for example, for prereleases " "of an upcoming Python version." msgstr "" -"通過省略 ``Py_LIMITED_API`` 定義,可以使用特定版本的 ABI 編譯受限 API 擴充。" +"透過省略 ``Py_LIMITED_API`` 定義,可以使用特定版本的 ABI 編譯受限 API 擴充。" "這可以提高該 Python 版本的性能,但會限制相容性。使用 ``Py_LIMITED_API`` 編譯" "將產生一個擴充,可以在特定版本的擴充不可用的地方發布 — 例如,用於即將發布的 " "Python 版本的預發布版本 (prerelease)。" -#: ../../c-api/stable.rst:144 +#: ../../c-api/stable.rst:152 msgid "Limited API Caveats" msgstr "受限 API 注意事項" -#: ../../c-api/stable.rst:146 +#: ../../c-api/stable.rst:154 msgid "" "Note that compiling with ``Py_LIMITED_API`` is *not* a complete guarantee " -"that code conforms to the :ref:`Limited API ` or the :ref:" -"`Stable ABI `. ``Py_LIMITED_API`` only covers definitions, but " -"an API also includes other issues, such as expected semantics." +"that code conforms to the :ref:`Limited API ` or " +"the :ref:`Stable ABI `. ``Py_LIMITED_API`` only covers " +"definitions, but an API also includes other issues, such as expected " +"semantics." msgstr "" "請注意,使用 ``Py_LIMITED_API`` 進行編譯\\ *不*\\ 完全保證程式碼符合\\ :ref:`" "受限 API ` 或\\ :ref:`穩定 ABI `。" "``Py_LIMITED_API`` 僅涵蓋定義,但 API 還包括其他議題,例如預期的語義 " "(semantic)。" -#: ../../c-api/stable.rst:151 +#: ../../c-api/stable.rst:159 msgid "" "One issue that ``Py_LIMITED_API`` does not guard against is calling a " "function with arguments that are invalid in a lower Python version. For " @@ -307,7 +318,7 @@ msgstr "" "現在代表選擇預設行為,但在 Python 3.8 中,引數將被直接使用,導致 ``NULL`` 取" "消參照 (dereference) 且崩潰 (crash)。類似的引數適用於結構 (struct) 的欄位。" -#: ../../c-api/stable.rst:158 +#: ../../c-api/stable.rst:166 msgid "" "Another issue is that some struct fields are currently not hidden when " "``Py_LIMITED_API`` is defined, even though they're part of the Limited API." @@ -315,7 +326,7 @@ msgstr "" "另一個問題是,當有定義 ``Py_LIMITED_API`` 時,一些結構欄位目前不會被隱藏,即" "使它們是受限 API 的一部分。" -#: ../../c-api/stable.rst:161 +#: ../../c-api/stable.rst:169 msgid "" "For these reasons, we recommend testing an extension with *all* minor Python " "versions it supports, and preferably to build with the *lowest* such version." @@ -323,7 +334,7 @@ msgstr "" "出於這些原因,我們建議要以它支援的\\ *所有*\\ 次要 Python 版本來測試擴充,並" "且最好使用\\ *最低*\\ 版本進行建置。" -#: ../../c-api/stable.rst:164 +#: ../../c-api/stable.rst:172 msgid "" "We also recommend reviewing documentation of all used API to check if it is " "explicitly part of the Limited API. Even with ``Py_LIMITED_API`` defined, a " @@ -334,7 +345,7 @@ msgstr "" "義 ``Py_LIMITED_API``,一些私有聲明也會因為技術原因(或者甚至是無意地,例如臭" "蟲)而被公開出來。" -#: ../../c-api/stable.rst:169 +#: ../../c-api/stable.rst:177 msgid "" "Also note that the Limited API is not necessarily stable: compiling with " "``Py_LIMITED_API`` with Python 3.8 means that the extension will run with " @@ -346,22 +357,22 @@ msgstr "" "行編譯意味著擴充將能以 Python 3.12 運行,但不一定能以 Python 3.12 *編譯*。特" "別是如果穩定 ABI 保持穩定,部分受限 API 可能會被棄用和刪除。" -#: ../../c-api/stable.rst:179 +#: ../../c-api/stable.rst:187 msgid "Platform Considerations" msgstr "平台注意事項" -#: ../../c-api/stable.rst:181 +#: ../../c-api/stable.rst:189 msgid "" "ABI stability depends not only on Python, but also on the compiler used, " -"lower-level libraries and compiler options. For the purposes of the :ref:" -"`Stable ABI `, these details define a “platform”. They usually " -"depend on the OS type and processor architecture" +"lower-level libraries and compiler options. For the purposes of " +"the :ref:`Stable ABI `, these details define a “platform”. They " +"usually depend on the OS type and processor architecture" msgstr "" "ABI 穩定性不僅取決於 Python,還取決於使用的編譯器、低階函式庫和編譯器選項。出" "於\\ :ref:`穩定 ABI ` 的目的,這些細節定義了一個「平台」。它們通" "常取決於作業系統種類和處理器架構" -#: ../../c-api/stable.rst:186 +#: ../../c-api/stable.rst:194 msgid "" "It is the responsibility of each particular distributor of Python to ensure " "that all Python versions on a particular platform are built in a way that " @@ -372,11 +383,11 @@ msgstr "" "定 ABI 的方式建置。``python.org`` 和許多第三方發布者發布的 Windows 和 macOS " "版本就是這種情況。" -#: ../../c-api/stable.rst:196 +#: ../../c-api/stable.rst:204 msgid "Contents of Limited API" msgstr "受限 API 的內容" -#: ../../c-api/stable.rst:199 +#: ../../c-api/stable.rst:207 msgid "" "Currently, the :ref:`Limited API ` includes the following " "items:" diff --git a/c-api/structures.po b/c-api/structures.po index e46450f6bc..eacbf76707 100644 --- a/c-api/structures.po +++ b/c-api/structures.po @@ -5,9 +5,9 @@ # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2025-03-11 00:14+0000\n" "PO-Revision-Date: 2018-05-23 14:07+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -57,11 +57,11 @@ msgstr "" #: ../../c-api/structures.rst:38 msgid "" -"This is an extension of :c:type:`PyObject` that adds the :c:member:" -"`~PyVarObject.ob_size` 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 :c:macro:" -"`Py_REFCNT`, :c:macro:`Py_TYPE`, and :c:macro:`Py_SIZE`." +"This is an extension of :c:type:`PyObject` that adds " +"the :c:member:`~PyVarObject.ob_size` 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 :c:macro:`Py_REFCNT`, :c:macro:`Py_TYPE`, and :c:macro:`Py_SIZE`." msgstr "" #: ../../c-api/structures.rst:47 @@ -95,80 +95,85 @@ msgstr "請見上面 :c:type:`PyVarObject` 的文件。" #: ../../c-api/structures.rst:68 msgid "" +"The base class of all other objects, the same as :class:`object` in Python." +msgstr "" + +#: ../../c-api/structures.rst:73 +msgid "" "Test if the *x* object is the *y* object, the same as ``x is y`` in Python." msgstr "" -#: ../../c-api/structures.rst:75 +#: ../../c-api/structures.rst:80 msgid "" "Test if an object is the ``None`` singleton, the same as ``x is None`` in " "Python." msgstr "" -#: ../../c-api/structures.rst:83 +#: ../../c-api/structures.rst:88 msgid "" "Test if an object is the ``True`` singleton, the same as ``x is True`` in " "Python." msgstr "" -#: ../../c-api/structures.rst:91 +#: ../../c-api/structures.rst:96 msgid "" "Test if an object is the ``False`` singleton, the same as ``x is False`` in " "Python." msgstr "" -#: ../../c-api/structures.rst:99 +#: ../../c-api/structures.rst:104 msgid "Get the type of the Python object *o*." msgstr "" -#: ../../c-api/structures.rst:101 +#: ../../c-api/structures.rst:106 msgid "Return a :term:`borrowed reference`." msgstr "" -#: ../../c-api/structures.rst:103 +#: ../../c-api/structures.rst:108 msgid "Use the :c:func:`Py_SET_TYPE` function to set an object type." msgstr "" -#: ../../c-api/structures.rst:105 +#: ../../c-api/structures.rst:110 msgid "" ":c:func:`Py_TYPE()` is changed to an inline static function. The parameter " "type is no longer :c:expr:`const PyObject*`." msgstr "" -#: ../../c-api/structures.rst:112 +#: ../../c-api/structures.rst:117 msgid "" "Return non-zero if the object *o* type is *type*. Return zero otherwise. " "Equivalent to: ``Py_TYPE(o) == type``." msgstr "" -#: ../../c-api/structures.rst:120 +#: ../../c-api/structures.rst:125 msgid "Set the object *o* type to *type*." msgstr "將物件 *o* 的型別設為 *type*。" -#: ../../c-api/structures.rst:127 +#: ../../c-api/structures.rst:132 msgid "Get the size of the Python object *o*." msgstr "取得 Python 物件 *o* 的大小。" -#: ../../c-api/structures.rst:129 +#: ../../c-api/structures.rst:134 msgid "Use the :c:func:`Py_SET_SIZE` function to set an object size." msgstr "" -#: ../../c-api/structures.rst:131 +#: ../../c-api/structures.rst:136 msgid "" ":c:func:`Py_SIZE()` is changed to an inline static function. The parameter " "type is no longer :c:expr:`const PyVarObject*`." msgstr "" -#: ../../c-api/structures.rst:138 +#: ../../c-api/structures.rst:143 msgid "Set the object *o* size to *size*." msgstr "將物件 *o* 的大小設為 *size*。" -#: ../../c-api/structures.rst:145 +#: ../../c-api/structures.rst:150 msgid "" -"This is a macro which expands to initialization values for a new :c:type:" -"`PyObject` type. This macro expands to::" +"This is a macro which expands to initialization values for a " +"new :c:type:`PyObject` type. This macro expands to::" msgstr "" -#: ../../c-api/structures.rst:148 +#: ../../c-api/structures.rst:153 msgid "" "_PyObject_EXTRA_INIT\n" "1, type," @@ -176,14 +181,14 @@ msgstr "" "_PyObject_EXTRA_INIT\n" "1, type," -#: ../../c-api/structures.rst:154 +#: ../../c-api/structures.rst:159 msgid "" -"This is a macro which expands to initialization values for a new :c:type:" -"`PyVarObject` type, including the :c:member:`~PyVarObject.ob_size` field. " -"This macro expands to::" +"This is a macro which expands to initialization values for a " +"new :c:type:`PyVarObject` type, including " +"the :c:member:`~PyVarObject.ob_size` field. This macro expands to::" msgstr "" -#: ../../c-api/structures.rst:158 +#: ../../c-api/structures.rst:163 msgid "" "_PyObject_EXTRA_INIT\n" "1, type, size," @@ -191,11 +196,11 @@ msgstr "" "_PyObject_EXTRA_INIT\n" "1, type, size," -#: ../../c-api/structures.rst:163 +#: ../../c-api/structures.rst:168 msgid "Implementing functions and methods" msgstr "實作函式與方法" -#: ../../c-api/structures.rst:167 +#: ../../c-api/structures.rst:172 msgid "" "Type of the functions used to implement most Python callables in C. " "Functions of this type take two :c:expr:`PyObject*` parameters and return " @@ -205,11 +210,11 @@ msgid "" "reference." msgstr "" -#: ../../c-api/structures.rst:174 +#: ../../c-api/structures.rst:179 msgid "The function signature is::" msgstr "" -#: ../../c-api/structures.rst:176 +#: ../../c-api/structures.rst:181 msgid "" "PyObject *PyCFunction(PyObject *self,\n" " PyObject *args);" @@ -217,14 +222,14 @@ msgstr "" "PyObject *PyCFunction(PyObject *self,\n" " PyObject *args);" -#: ../../c-api/structures.rst:181 +#: ../../c-api/structures.rst:186 msgid "" "Type of the functions used to implement Python callables in C with " "signature :ref:`METH_VARARGS | METH_KEYWORDS `. " "The function signature is::" msgstr "" -#: ../../c-api/structures.rst:185 +#: ../../c-api/structures.rst:190 msgid "" "PyObject *PyCFunctionWithKeywords(PyObject *self,\n" " PyObject *args,\n" @@ -234,49 +239,49 @@ msgstr "" " PyObject *args,\n" " PyObject *kwargs);" -#: ../../c-api/structures.rst:192 +#: ../../c-api/structures.rst:197 msgid "" "Type of the functions used to implement Python callables in C with " "signature :c:macro:`METH_FASTCALL`. The function signature is::" msgstr "" -#: ../../c-api/structures.rst:196 +#: ../../c-api/structures.rst:201 msgid "" -"PyObject *_PyCFunctionFast(PyObject *self,\n" -" PyObject *const *args,\n" -" Py_ssize_t nargs);" +"PyObject *PyCFunctionFast(PyObject *self,\n" +" PyObject *const *args,\n" +" Py_ssize_t nargs);" msgstr "" -"PyObject *_PyCFunctionFast(PyObject *self,\n" -" PyObject *const *args,\n" -" Py_ssize_t nargs);" +"PyObject *PyCFunctionFast(PyObject *self,\n" +" PyObject *const *args,\n" +" Py_ssize_t nargs);" -#: ../../c-api/structures.rst:202 +#: ../../c-api/structures.rst:207 msgid "" "Type of the functions used to implement Python callables in C with " "signature :ref:`METH_FASTCALL | METH_KEYWORDS `. The function signature is::" msgstr "" -#: ../../c-api/structures.rst:206 +#: ../../c-api/structures.rst:211 msgid "" -"PyObject *_PyCFunctionFastWithKeywords(PyObject *self,\n" -" PyObject *const *args,\n" -" Py_ssize_t nargs,\n" -" PyObject *kwnames);" +"PyObject *PyCFunctionFastWithKeywords(PyObject *self,\n" +" PyObject *const *args,\n" +" Py_ssize_t nargs,\n" +" PyObject *kwnames);" msgstr "" -"PyObject *_PyCFunctionFastWithKeywords(PyObject *self,\n" -" PyObject *const *args,\n" -" Py_ssize_t nargs,\n" -" PyObject *kwnames);" +"PyObject *PyCFunctionFastWithKeywords(PyObject *self,\n" +" PyObject *const *args,\n" +" Py_ssize_t nargs,\n" +" PyObject *kwnames);" -#: ../../c-api/structures.rst:213 +#: ../../c-api/structures.rst:218 msgid "" "Type of the functions used to implement Python callables in C with " "signature :ref:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS `. The function signature is::" msgstr "" -#: ../../c-api/structures.rst:217 +#: ../../c-api/structures.rst:222 msgid "" "PyObject *PyCMethod(PyObject *self,\n" " PyTypeObject *defining_class,\n" @@ -290,29 +295,29 @@ msgstr "" " Py_ssize_t nargs,\n" " PyObject *kwnames)" -#: ../../c-api/structures.rst:228 +#: ../../c-api/structures.rst:233 msgid "" "Structure used to describe a method of an extension type. This structure " "has four fields:" msgstr "" -#: ../../c-api/structures.rst:233 +#: ../../c-api/structures.rst:238 msgid "Name of the method." msgstr "" -#: ../../c-api/structures.rst:237 +#: ../../c-api/structures.rst:242 msgid "Pointer to the C implementation." msgstr "" -#: ../../c-api/structures.rst:241 +#: ../../c-api/structures.rst:246 msgid "Flags bits indicating how the call should be constructed." msgstr "" -#: ../../c-api/structures.rst:245 +#: ../../c-api/structures.rst:250 msgid "Points to the contents of the docstring." msgstr "" -#: ../../c-api/structures.rst:247 +#: ../../c-api/structures.rst:252 msgid "" "The :c:member:`~PyMethodDef.ml_meth` is a C function pointer. The functions " "may be of different types, but they always return :c:expr:`PyObject*`. If " @@ -322,41 +327,42 @@ msgid "" "implementation uses the specific C type of the *self* object." msgstr "" -#: ../../c-api/structures.rst:255 +#: ../../c-api/structures.rst:260 msgid "" "The :c:member:`~PyMethodDef.ml_flags` field is a bitfield which can include " "the following flags. The individual flags indicate either a calling " "convention or a binding convention." msgstr "" -#: ../../c-api/structures.rst:260 +#: ../../c-api/structures.rst:265 msgid "There are these calling conventions:" msgstr "" -#: ../../c-api/structures.rst:264 +#: ../../c-api/structures.rst:269 msgid "" -"This is the typical calling convention, where the methods have the type :c:" -"type:`PyCFunction`. The function expects two :c:expr:`PyObject*` values. The " -"first one is the *self* object for methods; for module functions, it is the " -"module object. The second parameter (often called *args*) is a tuple object " -"representing all arguments. This parameter is typically processed using :c:" -"func:`PyArg_ParseTuple` or :c:func:`PyArg_UnpackTuple`." +"This is the typical calling convention, where the methods have the " +"type :c:type:`PyCFunction`. The function expects two :c:expr:`PyObject*` " +"values. The first one is the *self* object for methods; for module " +"functions, it is the module object. The second parameter (often called " +"*args*) is a tuple object representing all arguments. This parameter is " +"typically processed using :c:func:`PyArg_ParseTuple` " +"or :c:func:`PyArg_UnpackTuple`." msgstr "" -#: ../../c-api/structures.rst:274 +#: ../../c-api/structures.rst:279 msgid "" -"Can only be used in certain combinations with other flags: :ref:" -"`METH_VARARGS | METH_KEYWORDS `, :ref:" -"`METH_FASTCALL | METH_KEYWORDS ` and :ref:" -"`METH_METHOD | METH_FASTCALL | METH_KEYWORDS `." +"Can only be used in certain combinations with other " +"flags: :ref:`METH_VARARGS | METH_KEYWORDS `, :ref:`METH_FASTCALL | METH_KEYWORDS ` and :ref:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS " +"`." msgstr "" -#: ../../c-api/structures.rst:282 +#: ../../c-api/structures.rst:287 msgid ":c:expr:`METH_VARARGS | METH_KEYWORDS`" msgstr ":c:expr:`METH_VARARGS | METH_KEYWORDS`" -#: ../../c-api/structures.rst:283 +#: ../../c-api/structures.rst:288 msgid "" "Methods with these flags must be of type :c:type:`PyCFunctionWithKeywords`. " "The function expects three parameters: *self*, *args*, *kwargs* where " @@ -365,27 +371,27 @@ msgid "" "using :c:func:`PyArg_ParseTupleAndKeywords`." msgstr "" -#: ../../c-api/structures.rst:292 +#: ../../c-api/structures.rst:297 msgid "" "Fast calling convention supporting only positional arguments. The methods " -"have the type :c:type:`_PyCFunctionFast`. The first parameter is *self*, the " +"have the type :c:type:`PyCFunctionFast`. The first parameter is *self*, the " "second parameter is a C array of :c:expr:`PyObject*` values indicating the " "arguments and the third parameter is the number of arguments (the length of " "the array)." msgstr "" -#: ../../c-api/structures.rst:302 +#: ../../c-api/structures.rst:307 msgid "``METH_FASTCALL`` is now part of the :ref:`stable ABI `." msgstr "" -#: ../../c-api/structures.rst:307 +#: ../../c-api/structures.rst:312 msgid ":c:expr:`METH_FASTCALL | METH_KEYWORDS`" msgstr ":c:expr:`METH_FASTCALL | METH_KEYWORDS`" -#: ../../c-api/structures.rst:308 +#: ../../c-api/structures.rst:313 msgid "" "Extension of :c:macro:`METH_FASTCALL` supporting also keyword arguments, " -"with methods of type :c:type:`_PyCFunctionFastWithKeywords`. Keyword " +"with methods of type :c:type:`PyCFunctionFastWithKeywords`. Keyword " "arguments are passed the same way as in the :ref:`vectorcall protocol " "`: there is an additional fourth :c:expr:`PyObject*` parameter " "which is a tuple representing the names of the keyword arguments (which are " @@ -394,17 +400,17 @@ msgid "" "the positional arguments." msgstr "" -#: ../../c-api/structures.rst:323 +#: ../../c-api/structures.rst:328 msgid "" "Can only be used in the combination with other flags: :ref:`METH_METHOD | " "METH_FASTCALL | METH_KEYWORDS `." msgstr "" -#: ../../c-api/structures.rst:329 +#: ../../c-api/structures.rst:334 msgid ":c:expr:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS`" msgstr ":c:expr:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS`" -#: ../../c-api/structures.rst:330 +#: ../../c-api/structures.rst:335 msgid "" "Extension of :ref:`METH_FASTCALL | METH_KEYWORDS ` supporting the *defining class*, that is, the class that " @@ -412,14 +418,14 @@ msgid "" "``Py_TYPE(self)``." msgstr "" -#: ../../c-api/structures.rst:335 +#: ../../c-api/structures.rst:340 msgid "" "The method needs to be of type :c:type:`PyCMethod`, the same as for " "``METH_FASTCALL | METH_KEYWORDS`` with ``defining_class`` argument added " "after ``self``." msgstr "" -#: ../../c-api/structures.rst:344 +#: ../../c-api/structures.rst:349 msgid "" "Methods without parameters don't need to check whether arguments are given " "if they are listed with the :c:macro:`METH_NOARGS` flag. They need to be of " @@ -428,22 +434,22 @@ msgid "" "the second parameter will be ``NULL``." msgstr "" -#: ../../c-api/structures.rst:350 +#: ../../c-api/structures.rst:355 msgid "" -"The function must have 2 parameters. Since the second parameter is unused, :" -"c:macro:`Py_UNUSED` can be used to prevent a compiler warning." +"The function must have 2 parameters. Since the second parameter is " +"unused, :c:macro:`Py_UNUSED` can be used to prevent a compiler warning." msgstr "" -#: ../../c-api/structures.rst:356 +#: ../../c-api/structures.rst:361 msgid "" -"Methods with a single object argument can be listed with the :c:macro:" -"`METH_O` flag, instead of invoking :c:func:`PyArg_ParseTuple` with a " -"``\"O\"`` argument. They have the type :c:type:`PyCFunction`, with the " -"*self* parameter, and a :c:expr:`PyObject*` parameter representing the " +"Methods with a single object argument can be listed with " +"the :c:macro:`METH_O` flag, instead of invoking :c:func:`PyArg_ParseTuple` " +"with a ``\"O\"`` argument. They have the type :c:type:`PyCFunction`, with " +"the *self* parameter, and a :c:expr:`PyObject*` parameter representing the " "single argument." msgstr "" -#: ../../c-api/structures.rst:362 +#: ../../c-api/structures.rst:367 msgid "" "These two constants are not used to indicate the calling convention but the " "binding when use with methods of classes. These may not be used for " @@ -451,53 +457,53 @@ msgid "" "any given method." msgstr "" -#: ../../c-api/structures.rst:372 +#: ../../c-api/structures.rst:377 msgid "" "The method will be passed the type object as the first parameter rather than " "an instance of the type. This is used to create *class methods*, similar to " "what is created when using the :func:`classmethod` built-in function." msgstr "" -#: ../../c-api/structures.rst:382 +#: ../../c-api/structures.rst:387 msgid "" "The method will be passed ``NULL`` as the first parameter rather than an " "instance of the type. This is used to create *static methods*, similar to " "what is created when using the :func:`staticmethod` built-in function." msgstr "" -#: ../../c-api/structures.rst:386 +#: ../../c-api/structures.rst:391 msgid "" "One other constant controls whether a method is loaded in place of another " "definition with the same method name." msgstr "" -#: ../../c-api/structures.rst:392 +#: ../../c-api/structures.rst:397 msgid "" "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 :meth:" -"`~object.__contains__` 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." +"*sq_contains* slot, for example, would generate a wrapped method " +"named :meth:`~object.__contains__` 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." msgstr "" -#: ../../c-api/structures.rst:404 +#: ../../c-api/structures.rst:409 msgid "" "Turn *ml* into a Python :term:`callable` object. The caller must ensure that " "*ml* outlives the :term:`callable`. Typically, *ml* is defined as a static " "variable." msgstr "" -#: ../../c-api/structures.rst:408 +#: ../../c-api/structures.rst:413 msgid "" "The *self* parameter will be passed as the *self* argument to the C function " "in ``ml->ml_meth`` when invoked. *self* can be ``NULL``." msgstr "" -#: ../../c-api/structures.rst:412 +#: ../../c-api/structures.rst:417 msgid "" "The :term:`callable` object's ``__module__`` attribute can be set from the " "given *module* argument. *module* should be a Python string, which will be " @@ -505,89 +511,89 @@ msgid "" "can be set to :const:`None` or ``NULL``." msgstr "" -#: ../../c-api/structures.rst:418 +#: ../../c-api/structures.rst:423 msgid ":attr:`function.__module__`" msgstr ":attr:`function.__module__`" -#: ../../c-api/structures.rst:420 +#: ../../c-api/structures.rst:425 msgid "" "The *cls* parameter will be passed as the *defining_class* argument to the C " "function. Must be set if :c:macro:`METH_METHOD` is set on ``ml->ml_flags``." msgstr "" -#: ../../c-api/structures.rst:429 +#: ../../c-api/structures.rst:434 msgid "Equivalent to ``PyCMethod_New(ml, self, module, NULL)``." msgstr "等價於 ``PyCMethod_New(ml, self, module, NULL)``。" -#: ../../c-api/structures.rst:434 +#: ../../c-api/structures.rst:439 msgid "Equivalent to ``PyCMethod_New(ml, self, NULL, NULL)``." msgstr "等價於 ``PyCMethod_New(ml, self, NULL, NULL)``。" -#: ../../c-api/structures.rst:438 +#: ../../c-api/structures.rst:443 msgid "Accessing attributes of extension types" msgstr "" -#: ../../c-api/structures.rst:442 +#: ../../c-api/structures.rst:447 msgid "" "Structure which describes an attribute of a type which corresponds to a C " "struct member. When defining a class, put a NULL-terminated array of these " "structures in the :c:member:`~PyTypeObject.tp_members` slot." msgstr "" -#: ../../c-api/structures.rst:447 +#: ../../c-api/structures.rst:452 msgid "Its fields are, in order:" msgstr "" -#: ../../c-api/structures.rst:451 +#: ../../c-api/structures.rst:456 msgid "" "Name of the member. A NULL value marks the end of a ``PyMemberDef[]`` array." msgstr "" -#: ../../c-api/structures.rst:454 +#: ../../c-api/structures.rst:459 msgid "The string should be static, no copy is made of it." msgstr "" -#: ../../c-api/structures.rst:458 +#: ../../c-api/structures.rst:463 msgid "" "The type of the member in the C struct. See :ref:`PyMemberDef-types` for the " "possible values." msgstr "" -#: ../../c-api/structures.rst:463 +#: ../../c-api/structures.rst:468 msgid "" "The offset in bytes that the member is located on the type’s object struct." msgstr "" -#: ../../c-api/structures.rst:467 +#: ../../c-api/structures.rst:472 msgid "" "Zero or more of the :ref:`PyMemberDef-flags`, combined using bitwise OR." msgstr "" -#: ../../c-api/structures.rst:471 +#: ../../c-api/structures.rst:476 msgid "" "The docstring, or NULL. The string should be static, no copy is made of it. " "Typically, it is defined using :c:macro:`PyDoc_STR`." msgstr "" -#: ../../c-api/structures.rst:475 +#: ../../c-api/structures.rst:480 msgid "" "By default (when :c:member:`~PyMemberDef.flags` is ``0``), members allow " "both read and write access. Use the :c:macro:`Py_READONLY` flag for read-" -"only access. Certain types, like :c:macro:`Py_T_STRING`, imply :c:macro:" -"`Py_READONLY`. Only :c:macro:`Py_T_OBJECT_EX` (and legacy :c:macro:" -"`T_OBJECT`) members can be deleted." +"only access. Certain types, like :c:macro:`Py_T_STRING`, " +"imply :c:macro:`Py_READONLY`. Only :c:macro:`Py_T_OBJECT_EX` (and " +"legacy :c:macro:`T_OBJECT`) members can be deleted." msgstr "" -#: ../../c-api/structures.rst:484 +#: ../../c-api/structures.rst:489 msgid "" "For heap-allocated types (created using :c:func:`PyType_FromSpec` or " "similar), ``PyMemberDef`` may contain a definition for the special member " -"``\"__vectorcalloffset__\"``, corresponding to :c:member:`~PyTypeObject." -"tp_vectorcall_offset` in type objects. These must be defined with " -"``Py_T_PYSSIZET`` and ``Py_READONLY``, for example::" +"``\"__vectorcalloffset__\"``, corresponding " +"to :c:member:`~PyTypeObject.tp_vectorcall_offset` in type objects. These " +"must be defined with ``Py_T_PYSSIZET`` and ``Py_READONLY``, for example::" msgstr "" -#: ../../c-api/structures.rst:490 +#: ../../c-api/structures.rst:495 msgid "" "static PyMemberDef spam_type_members[] = {\n" " {\"__vectorcalloffset__\", Py_T_PYSSIZET,\n" @@ -601,90 +607,92 @@ msgstr "" " {NULL} /* Sentinel */\n" "};" -#: ../../c-api/structures.rst:496 +#: ../../c-api/structures.rst:501 msgid "(You may need to ``#include `` for :c:func:`!offsetof`.)" msgstr "" -#: ../../c-api/structures.rst:498 +#: ../../c-api/structures.rst:503 msgid "" -"The legacy offsets :c:member:`~PyTypeObject.tp_dictoffset` and :c:member:" -"`~PyTypeObject.tp_weaklistoffset` can be defined similarly using " -"``\"__dictoffset__\"`` and ``\"__weaklistoffset__\"`` members, but " +"The legacy offsets :c:member:`~PyTypeObject.tp_dictoffset` " +"and :c:member:`~PyTypeObject.tp_weaklistoffset` can be defined similarly " +"using ``\"__dictoffset__\"`` and ``\"__weaklistoffset__\"`` members, but " "extensions are strongly encouraged to use :c:macro:`Py_TPFLAGS_MANAGED_DICT` " "and :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` instead." msgstr "" -#: ../../c-api/structures.rst:506 +#: ../../c-api/structures.rst:511 msgid "" "``PyMemberDef`` is always available. Previously, it required including " "``\"structmember.h\"``." msgstr "" -#: ../../c-api/structures.rst:511 +#: ../../c-api/structures.rst:516 msgid "" "Get an attribute belonging to the object at address *obj_addr*. The " "attribute is described by ``PyMemberDef`` *m*. Returns ``NULL`` on error." msgstr "" -#: ../../c-api/structures.rst:517 +#: ../../c-api/structures.rst:522 msgid "" "``PyMember_GetOne`` is always available. Previously, it required including " "``\"structmember.h\"``." msgstr "" -#: ../../c-api/structures.rst:522 +#: ../../c-api/structures.rst:527 msgid "" "Set an attribute belonging to the object at address *obj_addr* to object " "*o*. The attribute to set is described by ``PyMemberDef`` *m*. Returns " "``0`` if successful and a negative value on failure." msgstr "" -#: ../../c-api/structures.rst:528 +#: ../../c-api/structures.rst:533 msgid "" "``PyMember_SetOne`` is always available. Previously, it required including " "``\"structmember.h\"``." msgstr "" -#: ../../c-api/structures.rst:534 +#: ../../c-api/structures.rst:539 msgid "Member flags" msgstr "" -#: ../../c-api/structures.rst:536 +#: ../../c-api/structures.rst:541 msgid "The following flags can be used with :c:member:`PyMemberDef.flags`:" msgstr "" -#: ../../c-api/structures.rst:540 +#: ../../c-api/structures.rst:545 msgid "Not writable." msgstr "不可寫入。" -#: ../../c-api/structures.rst:544 +#: ../../c-api/structures.rst:549 msgid "" "Emit an ``object.__getattr__`` :ref:`audit event ` before " "reading." msgstr "" -#: ../../c-api/structures.rst:549 +#: ../../c-api/structures.rst:554 msgid "" "Indicates that the :c:member:`~PyMemberDef.offset` of this ``PyMemberDef`` " "entry indicates an offset from the subclass-specific data, rather than from " "``PyObject``." msgstr "" -#: ../../c-api/structures.rst:553 +#: ../../c-api/structures.rst:558 msgid "" -"Can only be used as part of :c:member:`Py_tp_members ` :c:type:`slot ` when creating a class using " -"negative :c:member:`~PyType_Spec.basicsize`. It is mandatory in that case." +"Can only be used as part of :c:member:`Py_tp_members " +"` :c:type:`slot ` when creating a " +"class using negative :c:member:`~PyType_Spec.basicsize`. It is mandatory in " +"that case." msgstr "" -#: ../../c-api/structures.rst:558 +#: ../../c-api/structures.rst:563 msgid "" -"This flag is only used in :c:type:`PyType_Slot`. When setting :c:member:" -"`~PyTypeObject.tp_members` during class creation, Python clears it and sets :" -"c:member:`PyMemberDef.offset` to the offset from the ``PyObject`` struct." +"This flag is only used in :c:type:`PyType_Slot`. When " +"setting :c:member:`~PyTypeObject.tp_members` during class creation, Python " +"clears it and sets :c:member:`PyMemberDef.offset` to the offset from the " +"``PyObject`` struct." msgstr "" -#: ../../c-api/structures.rst:570 +#: ../../c-api/structures.rst:575 msgid "" "The :c:macro:`!RESTRICTED`, :c:macro:`!READ_RESTRICTED` and :c:macro:`!" "WRITE_RESTRICTED` macros available with ``#include \"structmember.h\"`` are " @@ -693,20 +701,20 @@ msgid "" "nothing." msgstr "" -#: ../../c-api/structures.rst:581 +#: ../../c-api/structures.rst:586 msgid "" -"The :c:macro:`!READONLY` macro was renamed to :c:macro:`Py_READONLY`. The :c:" -"macro:`!PY_AUDIT_READ` macro was renamed with the ``Py_`` prefix. The new " -"names are now always available. Previously, these required ``#include " +"The :c:macro:`!READONLY` macro was renamed to :c:macro:`Py_READONLY`. " +"The :c:macro:`!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." msgstr "" -#: ../../c-api/structures.rst:590 +#: ../../c-api/structures.rst:595 msgid "Member types" msgstr "" -#: ../../c-api/structures.rst:592 +#: ../../c-api/structures.rst:597 msgid "" ":c:member:`PyMemberDef.type` can be one of the following macros " "corresponding to various C types. When the member is accessed in Python, it " @@ -715,147 +723,147 @@ msgid "" "exception such as :exc:`TypeError` or :exc:`ValueError` is raised." msgstr "" -#: ../../c-api/structures.rst:600 +#: ../../c-api/structures.rst:605 msgid "" -"Unless marked (D), attributes defined this way cannot be deleted using e.g. :" -"keyword:`del` or :py:func:`delattr`." +"Unless marked (D), attributes defined this way cannot be deleted using " +"e.g. :keyword:`del` or :py:func:`delattr`." msgstr "" -#: ../../c-api/structures.rst:604 +#: ../../c-api/structures.rst:609 msgid "Macro name" msgstr "巨集名稱" -#: ../../c-api/structures.rst:604 +#: ../../c-api/structures.rst:609 msgid "C type" msgstr "" -#: ../../c-api/structures.rst:604 +#: ../../c-api/structures.rst:609 msgid "Python type" msgstr "" -#: ../../c-api/structures.rst:606 +#: ../../c-api/structures.rst:611 msgid ":c:expr:`char`" msgstr ":c:expr:`char`" -#: ../../c-api/structures.rst:606 ../../c-api/structures.rst:607 -#: ../../c-api/structures.rst:608 ../../c-api/structures.rst:609 -#: ../../c-api/structures.rst:610 ../../c-api/structures.rst:611 -#: ../../c-api/structures.rst:612 ../../c-api/structures.rst:613 -#: ../../c-api/structures.rst:614 ../../c-api/structures.rst:615 -#: ../../c-api/structures.rst:616 +#: ../../c-api/structures.rst:611 ../../c-api/structures.rst:612 +#: ../../c-api/structures.rst:613 ../../c-api/structures.rst:614 +#: ../../c-api/structures.rst:615 ../../c-api/structures.rst:616 +#: ../../c-api/structures.rst:617 ../../c-api/structures.rst:618 +#: ../../c-api/structures.rst:619 ../../c-api/structures.rst:620 +#: ../../c-api/structures.rst:621 msgid ":py:class:`int`" msgstr ":py:class:`int`" -#: ../../c-api/structures.rst:607 +#: ../../c-api/structures.rst:612 msgid ":c:expr:`short`" msgstr ":c:expr:`short`" -#: ../../c-api/structures.rst:608 +#: ../../c-api/structures.rst:613 msgid ":c:expr:`int`" msgstr ":c:expr:`int`" -#: ../../c-api/structures.rst:609 +#: ../../c-api/structures.rst:614 msgid ":c:expr:`long`" msgstr ":c:expr:`long`" -#: ../../c-api/structures.rst:610 +#: ../../c-api/structures.rst:615 msgid ":c:expr:`long long`" msgstr ":c:expr:`long long`" -#: ../../c-api/structures.rst:611 +#: ../../c-api/structures.rst:616 msgid ":c:expr:`unsigned char`" msgstr ":c:expr:`unsigned char`" -#: ../../c-api/structures.rst:612 +#: ../../c-api/structures.rst:617 msgid ":c:expr:`unsigned int`" msgstr ":c:expr:`unsigned int`" -#: ../../c-api/structures.rst:613 +#: ../../c-api/structures.rst:618 msgid ":c:expr:`unsigned short`" msgstr ":c:expr:`unsigned short`" -#: ../../c-api/structures.rst:614 +#: ../../c-api/structures.rst:619 msgid ":c:expr:`unsigned long`" msgstr ":c:expr:`unsigned long`" -#: ../../c-api/structures.rst:615 +#: ../../c-api/structures.rst:620 msgid ":c:expr:`unsigned long long`" msgstr ":c:expr:`unsigned long long`" -#: ../../c-api/structures.rst:616 +#: ../../c-api/structures.rst:621 msgid ":c:expr:`Py_ssize_t`" msgstr ":c:expr:`Py_ssize_t`" -#: ../../c-api/structures.rst:617 +#: ../../c-api/structures.rst:622 msgid ":c:expr:`float`" msgstr ":c:expr:`float`" -#: ../../c-api/structures.rst:617 ../../c-api/structures.rst:618 +#: ../../c-api/structures.rst:622 ../../c-api/structures.rst:623 msgid ":py:class:`float`" msgstr ":py:class:`float`" -#: ../../c-api/structures.rst:618 +#: ../../c-api/structures.rst:623 msgid ":c:expr:`double`" msgstr ":c:expr:`double`" -#: ../../c-api/structures.rst:619 +#: ../../c-api/structures.rst:624 msgid ":c:expr:`char` (written as 0 or 1)" msgstr ":c:expr:`char` (寫成 0 或 1)" -#: ../../c-api/structures.rst:619 +#: ../../c-api/structures.rst:624 msgid ":py:class:`bool`" msgstr ":py:class:`bool`" -#: ../../c-api/structures.rst:621 +#: ../../c-api/structures.rst:626 msgid ":c:expr:`const char *` (*)" msgstr ":c:expr:`const char *` (*)" -#: ../../c-api/structures.rst:621 ../../c-api/structures.rst:622 +#: ../../c-api/structures.rst:626 ../../c-api/structures.rst:627 msgid ":py:class:`str` (RO)" msgstr ":py:class:`str` (RO)" -#: ../../c-api/structures.rst:622 +#: ../../c-api/structures.rst:627 msgid ":c:expr:`const char[]` (*)" msgstr ":c:expr:`const char[]` (*)" -#: ../../c-api/structures.rst:623 +#: ../../c-api/structures.rst:628 msgid ":c:expr:`char` (0-127)" msgstr ":c:expr:`char` (0-127)" -#: ../../c-api/structures.rst:623 +#: ../../c-api/structures.rst:628 msgid ":py:class:`str` (**)" msgstr ":py:class:`str` (**)" -#: ../../c-api/structures.rst:624 +#: ../../c-api/structures.rst:629 msgid ":c:expr:`PyObject *`" msgstr ":c:expr:`PyObject *`" -#: ../../c-api/structures.rst:624 +#: ../../c-api/structures.rst:629 msgid ":py:class:`object` (D)" msgstr ":py:class:`object` (D)" -#: ../../c-api/structures.rst:627 +#: ../../c-api/structures.rst:632 msgid "" "(*): Zero-terminated, UTF8-encoded C string. With :c:macro:`!Py_T_STRING` " "the C representation is a pointer; with :c:macro:`!Py_T_STRING_INPLACE` the " "string is stored directly in the structure." msgstr "" -#: ../../c-api/structures.rst:632 +#: ../../c-api/structures.rst:637 msgid "(**): String of length 1. Only ASCII is accepted." msgstr "" -#: ../../c-api/structures.rst:634 +#: ../../c-api/structures.rst:639 msgid "(RO): Implies :c:macro:`Py_READONLY`." msgstr "" -#: ../../c-api/structures.rst:636 +#: ../../c-api/structures.rst:641 msgid "" "(D): Can be deleted, in which case the pointer is set to ``NULL``. Reading a " "``NULL`` pointer raises :py:exc:`AttributeError`." msgstr "" -#: ../../c-api/structures.rst:662 +#: ../../c-api/structures.rst:667 msgid "" "In previous versions, the macros were only available with ``#include " "\"structmember.h\"`` and were named without the ``Py_`` prefix (e.g. as " @@ -863,174 +871,174 @@ msgid "" "with the following deprecated types:" msgstr "" -#: ../../c-api/structures.rst:670 +#: ../../c-api/structures.rst:675 msgid "" "Like ``Py_T_OBJECT_EX``, but ``NULL`` is converted to ``None``. This results " "in surprising behavior in Python: deleting the attribute effectively sets it " "to ``None``." msgstr "" -#: ../../c-api/structures.rst:676 +#: ../../c-api/structures.rst:681 msgid "Always ``None``. Must be used with :c:macro:`Py_READONLY`." msgstr "" -#: ../../c-api/structures.rst:679 +#: ../../c-api/structures.rst:684 msgid "Defining Getters and Setters" msgstr "" -#: ../../c-api/structures.rst:683 +#: ../../c-api/structures.rst:688 msgid "" "Structure to define property-like access for a type. See also description of " "the :c:member:`PyTypeObject.tp_getset` slot." msgstr "" -#: ../../c-api/structures.rst:688 +#: ../../c-api/structures.rst:693 msgid "attribute name" msgstr "屬性名稱" -#: ../../c-api/structures.rst:692 +#: ../../c-api/structures.rst:697 msgid "C function to get the attribute." msgstr "" -#: ../../c-api/structures.rst:696 +#: ../../c-api/structures.rst:701 msgid "" "Optional C function to set or delete the attribute. If ``NULL``, the " "attribute is read-only." msgstr "" -#: ../../c-api/structures.rst:701 +#: ../../c-api/structures.rst:706 msgid "optional docstring" msgstr "可選的文件字串" -#: ../../c-api/structures.rst:705 +#: ../../c-api/structures.rst:710 msgid "" "Optional user data pointer, providing additional data for getter and setter." msgstr "" -#: ../../c-api/structures.rst:709 +#: ../../c-api/structures.rst:714 msgid "" "The ``get`` function takes one :c:expr:`PyObject*` parameter (the instance) " "and a user data pointer (the associated ``closure``):" msgstr "" -#: ../../c-api/structures.rst:712 +#: ../../c-api/structures.rst:717 msgid "" "It should return a new reference on success or ``NULL`` with a set exception " "on failure." msgstr "" -#: ../../c-api/structures.rst:717 +#: ../../c-api/structures.rst:722 msgid "" "``set`` functions take two :c:expr:`PyObject*` parameters (the instance and " "the value to be set) and a user data pointer (the associated ``closure``):" msgstr "" -#: ../../c-api/structures.rst:720 +#: ../../c-api/structures.rst:725 msgid "" "In case the attribute should be deleted the second parameter is ``NULL``. " "Should return ``0`` on success or ``-1`` with a set exception on failure." msgstr "" -#: ../../c-api/structures.rst:370 ../../c-api/structures.rst:380 +#: ../../c-api/structures.rst:375 ../../c-api/structures.rst:385 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../c-api/structures.rst:370 +#: ../../c-api/structures.rst:375 msgid "classmethod" msgstr "classmethod" -#: ../../c-api/structures.rst:380 +#: ../../c-api/structures.rst:385 msgid "staticmethod" msgstr "staticmethod" -#: ../../c-api/structures.rst:563 +#: ../../c-api/structures.rst:568 msgid "READ_RESTRICTED (C macro)" msgstr "READ_RESTRICTED(C 巨集)" -#: ../../c-api/structures.rst:563 +#: ../../c-api/structures.rst:568 msgid "WRITE_RESTRICTED (C macro)" msgstr "WRITE_RESTRICTED(C 巨集)" -#: ../../c-api/structures.rst:563 +#: ../../c-api/structures.rst:568 msgid "RESTRICTED (C macro)" msgstr "RESTRICTED(C 巨集)" -#: ../../c-api/structures.rst:576 +#: ../../c-api/structures.rst:581 msgid "READONLY (C macro)" msgstr "READONLY(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_BYTE (C macro)" msgstr "T_BYTE(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_SHORT (C macro)" msgstr "T_SHORT(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_INT (C macro)" msgstr "T_INT(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_LONG (C macro)" msgstr "T_LONG(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_LONGLONG (C macro)" msgstr "T_LONGLONG(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_UBYTE (C macro)" msgstr "T_UBYTE(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_USHORT (C macro)" msgstr "T_USHORT(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_UINT (C macro)" msgstr "T_UINT(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_ULONG (C macro)" msgstr "T_ULONG(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_ULONGULONG (C macro)" msgstr "T_ULONGULONG(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_PYSSIZET (C macro)" msgstr "T_PYSSIZET(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_FLOAT (C macro)" msgstr "T_FLOAT(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_DOUBLE (C macro)" msgstr "T_DOUBLE(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_BOOL (C macro)" msgstr "T_BOOL(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_CHAR (C macro)" msgstr "T_CHAR(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_STRING (C macro)" msgstr "T_STRING(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_STRING_INPLACE (C macro)" msgstr "T_STRING_INPLACE(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_OBJECT_EX (C macro)" msgstr "T_OBJECT_EX(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "structmember.h" msgstr "structmember.h" diff --git a/c-api/sys.po b/c-api/sys.po index 8508ebc7fe..79a6fb3f3f 100644 --- a/c-api/sys.po +++ b/c-api/sys.po @@ -8,9 +8,9 @@ # Liang-Bo Wang , 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-04 00:03+0000\n" +"POT-Creation-Date: 2024-12-12 00:15+0000\n" "PO-Revision-Date: 2018-05-23 14:07+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -282,54 +282,17 @@ msgid "" "prior to :c:func:`Py_Initialize`." msgstr "" -#: ../../c-api/sys.rst:247 ../../c-api/sys.rst:258 -msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"warnoptions` should be used instead, see :ref:`Python Initialization " -"Configuration `." -msgstr "" - -#: ../../c-api/sys.rst:251 -msgid "" -"Append *s* to :data:`sys.warnoptions`. This function must be called prior " -"to :c:func:`Py_Initialize` in order to affect the warnings filter list." -msgstr "" - -#: ../../c-api/sys.rst:262 -msgid "Append *unicode* to :data:`sys.warnoptions`." +#: ../../c-api/sys.rst:245 +msgid "Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead." msgstr "" -#: ../../c-api/sys.rst:264 -msgid "" -"Note: this function is not currently usable from outside the CPython " -"implementation, as it must be called prior to the implicit import of :mod:" -"`warnings` in :c:func:`Py_Initialize` to be effective, but can't be called " -"until enough of the runtime has been initialized to permit the creation of " -"Unicode objects." -msgstr "" - -#: ../../c-api/sys.rst:274 -msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"module_search_paths` and :c:member:`PyConfig.module_search_paths_set` should " -"be used instead, see :ref:`Python Initialization Configuration `." -msgstr "" - -#: ../../c-api/sys.rst:279 -msgid "" -"Set :data:`sys.path` to a list object of paths found in *path* which should " -"be a list of paths separated with the platform's search path delimiter (``:" -"`` on Unix, ``;`` on Windows)." -msgstr "" - -#: ../../c-api/sys.rst:287 +#: ../../c-api/sys.rst:250 msgid "" "Write the output string described by *format* to :data:`sys.stdout`. No " "exceptions are raised, even if truncation occurs (see below)." msgstr "" -#: ../../c-api/sys.rst:290 +#: ../../c-api/sys.rst:253 msgid "" "*format* should limit the total size of the formatted output string to 1000 " "bytes or less -- after 1000 bytes, the output string is truncated. In " @@ -340,85 +303,89 @@ msgid "" "of digits for very large numbers." msgstr "" -#: ../../c-api/sys.rst:298 +#: ../../c-api/sys.rst:261 msgid "" "If a problem occurs, or :data:`sys.stdout` is unset, the formatted message " "is written to the real (C level) *stdout*." msgstr "" -#: ../../c-api/sys.rst:303 +#: ../../c-api/sys.rst:266 msgid "" "As :c:func:`PySys_WriteStdout`, but write to :data:`sys.stderr` or *stderr* " "instead." msgstr "" -#: ../../c-api/sys.rst:308 +#: ../../c-api/sys.rst:271 msgid "" "Function similar to PySys_WriteStdout() but format the message using :c:func:" "`PyUnicode_FromFormatV` and don't truncate the message to an arbitrary " "length." msgstr "" -#: ../../c-api/sys.rst:316 +#: ../../c-api/sys.rst:279 msgid "" "As :c:func:`PySys_FormatStdout`, but write to :data:`sys.stderr` or *stderr* " "instead." msgstr "" -#: ../../c-api/sys.rst:323 -msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"xoptions` should be used instead, see :ref:`Python Initialization " -"Configuration `." -msgstr "" - -#: ../../c-api/sys.rst:327 -msgid "" -"Parse *s* as a set of :option:`-X` options and add them to the current " -"options mapping as returned by :c:func:`PySys_GetXOptions`. This function " -"may be called prior to :c:func:`Py_Initialize`." -msgstr "" - -#: ../../c-api/sys.rst:337 +#: ../../c-api/sys.rst:286 msgid "" "Return the current dictionary of :option:`-X` options, similarly to :data:" "`sys._xoptions`. On error, ``NULL`` is returned and an exception is set." msgstr "" -#: ../../c-api/sys.rst:346 +#: ../../c-api/sys.rst:295 msgid "" "Raise an auditing event with any active hooks. Return zero for success and " "non-zero with an exception set on failure." msgstr "" -#: ../../c-api/sys.rst:349 +#: ../../c-api/sys.rst:298 +msgid "The *event* string argument must not be *NULL*." +msgstr "" + +#: ../../c-api/sys.rst:300 msgid "" "If any hooks have been added, *format* and other arguments will be used to " "construct a tuple to pass. Apart from ``N``, the same format characters as " "used in :c:func:`Py_BuildValue` are available. If the built value is not a " -"tuple, it will be added into a single-element tuple. (The ``N`` format " -"option 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.)" +"tuple, it will be added into a single-element tuple." msgstr "" -#: ../../c-api/sys.rst:357 +#: ../../c-api/sys.rst:305 +msgid "" +"The ``N`` format option must not be used. It consumes a reference, but since " +"there is no way to know whether arguments to this function will be consumed, " +"using it may cause reference leaks." +msgstr "" + +#: ../../c-api/sys.rst:309 msgid "" "Note that ``#`` format characters should always be treated as :c:type:" "`Py_ssize_t`, regardless of whether ``PY_SSIZE_T_CLEAN`` was defined." msgstr "" -#: ../../c-api/sys.rst:360 +#: ../../c-api/sys.rst:312 msgid ":func:`sys.audit` performs the same function from Python code." msgstr "" -#: ../../c-api/sys.rst:366 +#: ../../c-api/sys.rst:314 +msgid "See also :c:func:`PySys_AuditTuple`." +msgstr "請參閱 :c:func:`PySys_AuditTuple`。" + +#: ../../c-api/sys.rst:320 msgid "" "Require :c:type:`Py_ssize_t` for ``#`` format characters. Previously, an " "unavoidable deprecation warning was raised." msgstr "" -#: ../../c-api/sys.rst:372 +#: ../../c-api/sys.rst:326 +msgid "" +"Similar to :c:func:`PySys_Audit`, but pass arguments as a Python object. " +"*args* must be a :class:`tuple`. To pass no arguments, *args* can be *NULL*." +msgstr "" + +#: ../../c-api/sys.rst:334 msgid "" "Append the callable *hook* to the list of active auditing hooks. Return zero " "on success and non-zero on failure. If the runtime has been initialized, " @@ -426,14 +393,14 @@ msgid "" "all interpreters created by the runtime." msgstr "" -#: ../../c-api/sys.rst:378 +#: ../../c-api/sys.rst:340 msgid "" "The *userData* pointer is passed into the hook function. Since hook " "functions may be called from different runtimes, this pointer should not " "refer directly to Python state." msgstr "" -#: ../../c-api/sys.rst:382 +#: ../../c-api/sys.rst:344 msgid "" "This function is safe to call before :c:func:`Py_Initialize`. When called " "after runtime initialization, existing audit hooks are notified and may " @@ -441,20 +408,20 @@ msgid "" "`Exception` (other errors will not be silenced)." msgstr "" -#: ../../c-api/sys.rst:387 +#: ../../c-api/sys.rst:349 msgid "" "The hook function is always called with the GIL held by the Python " "interpreter that raised the event." msgstr "" -#: ../../c-api/sys.rst:390 +#: ../../c-api/sys.rst:352 msgid "" "See :pep:`578` for a detailed description of auditing. Functions in the " "runtime and standard library that raise events are listed in the :ref:`audit " "events table `. Details are in each function's documentation." msgstr "" -#: ../../c-api/sys.rst:395 ../../c-api/sys.rst:397 +#: ../../c-api/sys.rst:357 ../../c-api/sys.rst:359 msgid "" "If the interpreter is initialized, this function raises an auditing event " "``sys.addaudithook`` with no arguments. If any existing hooks raise an " @@ -463,18 +430,19 @@ msgid "" "hook has been added unless they control all existing hooks." msgstr "" -#: ../../c-api/sys.rst:406 +#: ../../c-api/sys.rst:368 msgid "" "The type of the hook function. *event* is the C string event argument passed " -"to :c:func:`PySys_Audit`. *args* is guaranteed to be a :c:type:" -"`PyTupleObject`. *userData* is the argument passed to PySys_AddAuditHook()." +"to :c:func:`PySys_Audit` or :c:func:`PySys_AuditTuple`. *args* is guaranteed " +"to be a :c:type:`PyTupleObject`. *userData* is the argument passed to " +"PySys_AddAuditHook()." msgstr "" -#: ../../c-api/sys.rst:417 +#: ../../c-api/sys.rst:380 msgid "Process Control" msgstr "行程控制" -#: ../../c-api/sys.rst:424 +#: ../../c-api/sys.rst:387 msgid "" "Print a fatal error message and kill the process. No cleanup is performed. " "This function should only be invoked when a condition is detected that would " @@ -484,29 +452,29 @@ msgid "" "file:`core` file." msgstr "" -#: ../../c-api/sys.rst:431 +#: ../../c-api/sys.rst:394 msgid "" "The ``Py_FatalError()`` function is replaced with a macro which logs " "automatically the name of the current function, unless the " "``Py_LIMITED_API`` macro is defined." msgstr "" -#: ../../c-api/sys.rst:435 +#: ../../c-api/sys.rst:398 msgid "Log the function name automatically." msgstr "" -#: ../../c-api/sys.rst:445 +#: ../../c-api/sys.rst:408 msgid "" "Exit the current process. This calls :c:func:`Py_FinalizeEx` and then calls " "the standard C library function ``exit(status)``. If :c:func:" "`Py_FinalizeEx` indicates an error, the exit status is set to 120." msgstr "" -#: ../../c-api/sys.rst:449 +#: ../../c-api/sys.rst:412 msgid "Errors from finalization no longer ignored." msgstr "" -#: ../../c-api/sys.rst:459 +#: ../../c-api/sys.rst:422 msgid "" "Register a cleanup function to be called by :c:func:`Py_FinalizeEx`. The " "cleanup function will be called with no arguments and should return no " @@ -518,22 +486,26 @@ msgid "" "should be called by *func*." msgstr "" +#: ../../c-api/sys.rst:432 +msgid ":c:func:`PyUnstable_AtExit` for passing a ``void *data`` argument." +msgstr "" + #: ../../c-api/sys.rst:101 msgid "USE_STACKCHECK (C macro)" msgstr "USE_STACKCHECK(C 巨集)" -#: ../../c-api/sys.rst:422 +#: ../../c-api/sys.rst:385 msgid "abort (C function)" msgstr "abort(C 函式)" -#: ../../c-api/sys.rst:441 ../../c-api/sys.rst:455 +#: ../../c-api/sys.rst:404 ../../c-api/sys.rst:418 msgid "Py_FinalizeEx (C function)" msgstr "Py_FinalizeEx(C 函式)" -#: ../../c-api/sys.rst:441 +#: ../../c-api/sys.rst:404 msgid "exit (C function)" msgstr "exit(C 函式)" -#: ../../c-api/sys.rst:455 +#: ../../c-api/sys.rst:418 msgid "cleanup functions" msgstr "cleanup functions(清理函式)" diff --git a/c-api/time.po b/c-api/time.po new file mode 100644 index 0000000000..401edfe389 --- /dev/null +++ b/c-api/time.po @@ -0,0 +1,189 @@ +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# +# Translators: +# Matt Wang , 2025 +msgid "" +msgstr "" +"Project-Id-Version: Python 3.13\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-09-24 07:20+0000\n" +"PO-Revision-Date: 2025-05-25 04:26+0800\n" +"Last-Translator: Matt Wang \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" +"Language: zh_TW\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../../c-api/time.rst:6 +msgid "PyTime C API" +msgstr "PyTime C API" + +#: ../../c-api/time.rst:10 +msgid "" +"The clock C API provides access to system clocks. It is similar to the " +"Python :mod:`time` module." +msgstr "時鐘 C API 提供對系統時鐘的存取。它類似於 Python 的 :mod:`time` 模組。" + +#: ../../c-api/time.rst:13 +msgid "" +"For C API related to the :mod:`datetime` module, see :ref:`datetimeobjects`." +msgstr "" +"對於與 :mod:`datetime` 模組相關的 C API,請參閱 :ref:`datetimeobjects`。" + +#: ../../c-api/time.rst:17 +msgid "Types" +msgstr "型別" + +#: ../../c-api/time.rst:21 +msgid "" +"A timestamp or duration in nanoseconds, represented as a signed 64-bit " +"integer." +msgstr "以奈秒為單位的時間戳記或持續時長,以有符號的 64 位元整數表示。" + +#: ../../c-api/time.rst:24 +msgid "" +"The reference point for timestamps depends on the clock used. For " +"example, :c:func:`PyTime_Time` returns timestamps relative to the UNIX epoch." +msgstr "" +"時間戳記的參照點取決於所使用的時鐘。例如 :c:func:`PyTime_Time` 回傳相對於 " +"UNIX 紀元 (UNIX epoch) 的時間戳記。" + +#: ../../c-api/time.rst:27 +msgid "" +"The supported range is around [-292.3 years; +292.3 years]. Using the Unix " +"epoch (January 1st, 1970) as reference, the supported date range is around " +"[1677-09-21; 2262-04-11]. The exact limits are exposed as constants:" +msgstr "" +"支援的範圍約為 [-292.3 年;+292.3 年]。以 Unix 紀元 (1970 年 1 月 1 日) 為參" +"照,支援的日期範圍約為 [1677-09-21; 2262-04-11]。確切的限制是以常數的形式公開" +"出來:" + +#: ../../c-api/time.rst:34 +msgid "Minimum value of :c:type:`PyTime_t`." +msgstr ":c:type:`PyTime_t` 的最小值。" + +#: ../../c-api/time.rst:38 +msgid "Maximum value of :c:type:`PyTime_t`." +msgstr ":c:type:`PyTime_t` 的最大值。" + +#: ../../c-api/time.rst:42 +msgid "Clock Functions" +msgstr "時鐘函式" + +#: ../../c-api/time.rst:44 +msgid "" +"The following functions take a pointer to a :c:expr:`PyTime_t` that they set " +"to the value of a particular clock. Details of each clock are given in the " +"documentation of the corresponding Python function." +msgstr "" +"以下的函式接受一個指向 :c:expr:`PyTime_t` 的指標,並將其設定為特定時鐘的值。" +"每個時鐘的詳細資訊紀錄在相對應的 Python 函式說明文件中。" + +#: ../../c-api/time.rst:49 +msgid "" +"The functions return ``0`` on success, or ``-1`` (with an exception set) on " +"failure." +msgstr "函式成功時會回傳 ``0`` 或在失敗時回傳 ``-1``\\ (並設定一個例外)。" + +#: ../../c-api/time.rst:52 +msgid "" +"On integer overflow, they set the :c:data:`PyExc_OverflowError` exception " +"and set ``*result`` to the value clamped to the ``[PyTime_MIN; PyTime_MAX]`` " +"range. (On current systems, integer overflows are likely caused by " +"misconfigured system time.)" +msgstr "" +"在整數溢位時,它們會設定 :c:data:`PyExc_OverflowError` 例外,並將 " +"``*result`` 設定為夾在 ``[PyTime_MIN; PyTime_MAX]`` 範圍內的值。(在目前的系" +"統上,整數溢位很可能是由於錯誤設定的系統時間所造成。)" + +#: ../../c-api/time.rst:58 +msgid "" +"As any other C API (unless otherwise specified), the functions must be " +"called with the :term:`GIL` held." +msgstr "" +"如同任何其他 C API(除非另有指定),必須在持有 :term:`GIL` 的情況下呼叫函式。" + +#: ../../c-api/time.rst:63 +msgid "" +"Read the monotonic clock. See :func:`time.monotonic` for important details " +"on this clock." +msgstr "讀取單調時鐘。請參閱 :func:`time.monotonic` 取得此時鐘的重要詳細資訊。" + +#: ../../c-api/time.rst:68 +msgid "" +"Read the performance counter. See :func:`time.perf_counter` for important " +"details on this clock." +msgstr "" +"讀取效能計數器。請參閱 :func:`time.perf_counter` 以取得此時鐘的重要詳細資訊。" + +#: ../../c-api/time.rst:73 +msgid "" +"Read the “wall clock” time. See :func:`time.time` for details important on " +"this clock." +msgstr "" +"讀取「牆上時鐘 (wall clock)」的時間。請參閱 :func:`time.time` 以取得詳細資" +"訊。" + +#: ../../c-api/time.rst:78 +msgid "Raw Clock Functions" +msgstr "原始時鐘函式" + +#: ../../c-api/time.rst:80 +msgid "" +"Similar to clock functions, but don't set an exception on error and don't " +"require the caller to hold the GIL." +msgstr "類似於時鐘函式,但不會在出錯時設定例外,也不需要讓呼叫者持有 GIL。" + +#: ../../c-api/time.rst:83 +msgid "On success, the functions return ``0``." +msgstr "成功時函式會回傳 ``0``。" + +#: ../../c-api/time.rst:85 +msgid "" +"On failure, they set ``*result`` to ``0`` and return ``-1``, *without* " +"setting an exception. To get the cause of the error, acquire the GIL and " +"call the regular (non-``Raw``) function. Note that the regular function may " +"succeed after the ``Raw`` one failed." +msgstr "" +"失敗時,它們會將 ``*result`` 設為 ``0`` 並回傳 ``-1``, 而\\ *不*\\ 設定例外。" +"要取得錯誤原因,請取得 GIL 並呼叫常規(非 ``Raw``)函式。請注意,常規函式可能" +"會在 ``Raw`` 的函式失敗後成功。" + +#: ../../c-api/time.rst:92 +msgid "" +"Similar to :c:func:`PyTime_Monotonic`, but don't set an exception on error " +"and don't require holding the GIL." +msgstr "" +"類似於 :c:func:`PyTime_Monotonic`,但不會在出錯時設定例外,也不需要持有 GIL。" + +#: ../../c-api/time.rst:97 +msgid "" +"Similar to :c:func:`PyTime_PerfCounter`, but don't set an exception on error " +"and don't require holding the GIL." +msgstr "" +"類似於 :c:func:`PyTime_PerfCounter`,但不會在出錯時設定例外,也不需要持有 " +"GIL。" + +#: ../../c-api/time.rst:102 +msgid "" +"Similar to :c:func:`PyTime_Time`, but don't set an exception on error and " +"don't require holding the GIL." +msgstr "" +"類似於 :c:func:`PyTime_Time`,但不會在出錯時設定例外,也不需要持有 GIL。" + +#: ../../c-api/time.rst:107 +msgid "Conversion functions" +msgstr "轉換函式" + +#: ../../c-api/time.rst:111 +msgid "Convert a timestamp to a number of seconds as a C :c:expr:`double`." +msgstr "將時間戳記轉換為 C :c:expr:`double` 的秒數。" + +#: ../../c-api/time.rst:113 +msgid "" +"The function cannot fail, but note that :c:expr:`double` has limited " +"accuracy for large values." +msgstr "此函式不會失敗,但請注意 :c:expr:`double` 對於大數值的精確度有限。" diff --git a/c-api/tuple.po b/c-api/tuple.po index 0d201d62fa..d70d49e967 100644 --- a/c-api/tuple.po +++ b/c-api/tuple.po @@ -6,9 +6,9 @@ # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-28 13:20+0000\n" +"POT-Creation-Date: 2024-10-08 00:13+0000\n" "PO-Revision-Date: 2017-09-22 18:26+0000\n" "Last-Translator: Leon H.\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -72,16 +72,16 @@ msgstr "" #: ../../c-api/tuple.rst:61 msgid "" "Return the object at position *pos* in the tuple pointed to by *p*. If " -"*pos* is negative or out of bounds, return ``NULL`` and set an :exc:" -"`IndexError` exception." +"*pos* is negative or out of bounds, return ``NULL`` and set " +"an :exc:`IndexError` exception." msgstr "" #: ../../c-api/tuple.rst:64 msgid "" "The returned reference is borrowed from the tuple *p* (that is: it is only " "valid as long as you hold a reference to *p*). To get a :term:`strong " -"reference`, use :c:func:`Py_NewRef(PyTuple_GetItem(...)) ` or :c:" -"func:`PySequence_GetItem`." +"reference`, use :c:func:`Py_NewRef(PyTuple_GetItem(...)) ` " +"or :c:func:`PySequence_GetItem`." msgstr "" #: ../../c-api/tuple.rst:73 @@ -119,14 +119,23 @@ msgid "" "*only* be used to fill in brand new tuples." msgstr "" -#: ../../c-api/tuple.rst:104 +#: ../../c-api/tuple.rst:102 ../../c-api/tuple.rst:218 +#: ../../c-api/tuple.rst:236 msgid "" -"This function \"steals\" a reference to *o*, and, unlike :c:func:" -"`PyTuple_SetItem`, does *not* discard a reference to any item that is being " -"replaced; any reference in the tuple at position *pos* will be leaked." +"Bounds checking is performed as an assertion if Python is built " +"in :ref:`debug mode ` or :option:`with assertions <--with-" +"assertions>`." msgstr "" -#: ../../c-api/tuple.rst:112 +#: ../../c-api/tuple.rst:107 +msgid "" +"This function \"steals\" a reference to *o*, and, " +"unlike :c:func:`PyTuple_SetItem`, does *not* discard a reference to any item " +"that is being replaced; any reference in the tuple at position *pos* will be " +"leaked." +msgstr "" + +#: ../../c-api/tuple.rst:115 msgid "" "Can be used to resize a tuple. *newsize* will be the new length of the " "tuple. Because tuples are *supposed* to be immutable, this should only be " @@ -137,121 +146,128 @@ msgid "" "Client code should never assume that the resulting value of ``*p`` will be " "the same as before calling this function. If the object referenced by ``*p`` " "is replaced, the original ``*p`` is destroyed. On failure, returns ``-1`` " -"and sets ``*p`` to ``NULL``, and raises :exc:`MemoryError` or :exc:" -"`SystemError`." +"and sets ``*p`` to ``NULL``, and raises :exc:`MemoryError` " +"or :exc:`SystemError`." msgstr "" -#: ../../c-api/tuple.rst:127 +#: ../../c-api/tuple.rst:130 msgid "Struct Sequence Objects" msgstr "" -#: ../../c-api/tuple.rst:129 +#: ../../c-api/tuple.rst:132 msgid "" -"Struct sequence objects are the C equivalent of :func:`~collections." -"namedtuple` objects, i.e. a sequence whose items can also be accessed " -"through attributes. To create a struct sequence, you first have to create a " -"specific struct sequence type." +"Struct sequence objects are the C equivalent " +"of :func:`~collections.namedtuple` objects, i.e. a sequence whose items can " +"also be accessed through attributes. To create a struct sequence, you first " +"have to create a specific struct sequence type." msgstr "" -#: ../../c-api/tuple.rst:136 +#: ../../c-api/tuple.rst:139 msgid "" "Create a new struct sequence type from the data in *desc*, described below. " -"Instances of the resulting type can be created with :c:func:" -"`PyStructSequence_New`." +"Instances of the resulting type can be created " +"with :c:func:`PyStructSequence_New`." msgstr "" -#: ../../c-api/tuple.rst:139 ../../c-api/tuple.rst:207 +#: ../../c-api/tuple.rst:142 ../../c-api/tuple.rst:211 msgid "Return ``NULL`` with an exception set on failure." -msgstr "" +msgstr "失敗時回傳 ``NULL`` 並設定例外。" -#: ../../c-api/tuple.rst:144 +#: ../../c-api/tuple.rst:147 msgid "Initializes a struct sequence type *type* from *desc* in place." msgstr "" -#: ../../c-api/tuple.rst:149 +#: ../../c-api/tuple.rst:152 msgid "" "Like :c:func:`PyStructSequence_InitType`, but returns ``0`` on success and " "``-1`` with an exception set on failure." msgstr "" -#: ../../c-api/tuple.rst:157 +#: ../../c-api/tuple.rst:160 msgid "Contains the meta information of a struct sequence type to create." msgstr "" -#: ../../c-api/tuple.rst:161 -msgid "Name of the struct sequence type." +#: ../../c-api/tuple.rst:164 +msgid "" +"Fully qualified name of the type; null-terminated UTF-8 encoded. The name " +"must contain the module name." msgstr "" -#: ../../c-api/tuple.rst:165 +#: ../../c-api/tuple.rst:169 msgid "Pointer to docstring for the type or ``NULL`` to omit." msgstr "" -#: ../../c-api/tuple.rst:169 +#: ../../c-api/tuple.rst:173 msgid "Pointer to ``NULL``-terminated array with field names of the new type." msgstr "" -#: ../../c-api/tuple.rst:173 +#: ../../c-api/tuple.rst:177 msgid "Number of fields visible to the Python side (if used as tuple)." msgstr "" -#: ../../c-api/tuple.rst:178 +#: ../../c-api/tuple.rst:182 msgid "" "Describes a field of a struct sequence. As a struct sequence is modeled as a " -"tuple, all fields are typed as :c:expr:`PyObject*`. The index in the :c:" -"member:`~PyStructSequence_Desc.fields` array of the :c:type:" -"`PyStructSequence_Desc` determines which field of the struct sequence is " -"described." +"tuple, all fields are typed as :c:expr:`PyObject*`. The index in " +"the :c:member:`~PyStructSequence_Desc.fields` array of " +"the :c:type:`PyStructSequence_Desc` determines which field of the struct " +"sequence is described." msgstr "" -#: ../../c-api/tuple.rst:186 +#: ../../c-api/tuple.rst:190 msgid "" -"Name for the field or ``NULL`` to end the list of named fields, set to :c:" -"data:`PyStructSequence_UnnamedField` to leave unnamed." +"Name for the field or ``NULL`` to end the list of named fields, set " +"to :c:data:`PyStructSequence_UnnamedField` to leave unnamed." msgstr "" -#: ../../c-api/tuple.rst:191 +#: ../../c-api/tuple.rst:195 msgid "Field docstring or ``NULL`` to omit." msgstr "" -#: ../../c-api/tuple.rst:196 +#: ../../c-api/tuple.rst:200 msgid "Special value for a field name to leave it unnamed." msgstr "" -#: ../../c-api/tuple.rst:198 +#: ../../c-api/tuple.rst:202 msgid "The type was changed from ``char *``." msgstr "" -#: ../../c-api/tuple.rst:204 +#: ../../c-api/tuple.rst:208 msgid "" -"Creates an instance of *type*, which must have been created with :c:func:" -"`PyStructSequence_NewType`." +"Creates an instance of *type*, which must have been created " +"with :c:func:`PyStructSequence_NewType`." msgstr "" -#: ../../c-api/tuple.rst:212 +#: ../../c-api/tuple.rst:216 msgid "" -"Return the object at position *pos* in the struct sequence pointed to by " -"*p*. No bounds checking is performed." +"Return the object at position *pos* in the struct sequence pointed to by *p*." +msgstr "" + +#: ../../c-api/tuple.rst:224 +msgid "Alias to :c:func:`PyStructSequence_GetItem`." msgstr "" -#: ../../c-api/tuple.rst:218 -msgid "Macro equivalent of :c:func:`PyStructSequence_GetItem`." +#: ../../c-api/tuple.rst:226 +msgid "Now implemented as an alias to :c:func:`PyStructSequence_GetItem`." msgstr "" -#: ../../c-api/tuple.rst:223 +#: ../../c-api/tuple.rst:232 msgid "" "Sets the field at index *pos* of the struct sequence *p* to value *o*. " "Like :c:func:`PyTuple_SET_ITEM`, this should only be used to fill in brand " "new instances." msgstr "" -#: ../../c-api/tuple.rst:229 ../../c-api/tuple.rst:239 +#: ../../c-api/tuple.rst:241 msgid "This function \"steals\" a reference to *o*." msgstr "" -#: ../../c-api/tuple.rst:234 -msgid "" -"Similar to :c:func:`PyStructSequence_SetItem`, but implemented as a static " -"inlined function." +#: ../../c-api/tuple.rst:246 +msgid "Alias to :c:func:`PyStructSequence_SetItem`." +msgstr "" + +#: ../../c-api/tuple.rst:248 +msgid "Now implemented as an alias to :c:func:`PyStructSequence_SetItem`." msgstr "" #: ../../c-api/tuple.rst:8 diff --git a/c-api/type.po b/c-api/type.po index 9cfbf0a947..3ddebe9e5c 100644 --- a/c-api/type.po +++ b/c-api/type.po @@ -4,9 +4,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-10-14 00:03+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2015-12-09 17:51+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -65,32 +65,32 @@ msgstr "" #: ../../c-api/type.rst:55 msgid "" "Return the type object's internal namespace, which is otherwise only exposed " -"via a read-only proxy (``cls.__dict__``). This is a replacement for " -"accessing :c:member:`~PyTypeObject.tp_dict` directly. The returned " -"dictionary must be treated as read-only." +"via a read-only proxy (:attr:`cls.__dict__ `). This is a " +"replacement for accessing :c:member:`~PyTypeObject.tp_dict` directly. The " +"returned dictionary must be treated as read-only." msgstr "" -#: ../../c-api/type.rst:60 +#: ../../c-api/type.rst:61 msgid "" "This function is meant for specific embedding and language-binding cases, " "where direct access to the dict is necessary and indirect access (e.g. via " "the proxy or :c:func:`PyObject_GetAttr`) isn't adequate." msgstr "" -#: ../../c-api/type.rst:64 +#: ../../c-api/type.rst:65 msgid "" "Extension modules should continue to use ``tp_dict``, directly or " "indirectly, when setting up their own types." msgstr "" -#: ../../c-api/type.rst:72 +#: ../../c-api/type.rst:73 msgid "" "Invalidate the internal lookup cache for the type and all of its subtypes. " "This function must be called after any manual modification of the attributes " "or base classes of the type." msgstr "" -#: ../../c-api/type.rst:79 +#: ../../c-api/type.rst:80 msgid "" "Register *callback* as a type watcher. Return a non-negative integer ID " "which must be passed to future calls to :c:func:`PyType_Watch`. In case of " @@ -98,21 +98,27 @@ msgid "" "exception." msgstr "" -#: ../../c-api/type.rst:89 +#: ../../c-api/type.rst:85 +msgid "" +"In free-threaded builds, :c:func:`PyType_AddWatcher` is not thread-safe, so " +"it must be called at start up (before spawning the first thread)." +msgstr "" + +#: ../../c-api/type.rst:93 msgid "" "Clear watcher identified by *watcher_id* (previously returned from :c:func:" "`PyType_AddWatcher`). Return ``0`` on success, ``-1`` on error (e.g. if " "*watcher_id* was never registered.)" msgstr "" -#: ../../c-api/type.rst:93 +#: ../../c-api/type.rst:97 msgid "" "An extension should never call ``PyType_ClearWatcher`` with a *watcher_id* " "that was not returned to it by a previous call to :c:func:" "`PyType_AddWatcher`." msgstr "" -#: ../../c-api/type.rst:102 +#: ../../c-api/type.rst:106 msgid "" "Mark *type* as watched. The callback granted *watcher_id* by :c:func:" "`PyType_AddWatcher` will be called whenever :c:func:`PyType_Modified` " @@ -122,61 +128,61 @@ msgid "" "detail and subject to change.)" msgstr "" -#: ../../c-api/type.rst:109 +#: ../../c-api/type.rst:113 msgid "" "An extension should never call ``PyType_Watch`` with a *watcher_id* that was " "not returned to it by a previous call to :c:func:`PyType_AddWatcher`." msgstr "" -#: ../../c-api/type.rst:117 +#: ../../c-api/type.rst:121 msgid "Type of a type-watcher callback function." msgstr "" -#: ../../c-api/type.rst:119 +#: ../../c-api/type.rst:123 msgid "" "The callback must not modify *type* or cause :c:func:`PyType_Modified` to be " "called on *type* or any type in its MRO; violating this rule could cause " "infinite recursion." msgstr "" -#: ../../c-api/type.rst:128 +#: ../../c-api/type.rst:132 msgid "" "Return non-zero if the type object *o* sets the feature *feature*. Type " "features are denoted by single bit flags." msgstr "" -#: ../../c-api/type.rst:134 +#: ../../c-api/type.rst:138 msgid "" "Return true if the type object includes support for the cycle detector; this " "tests the type flag :c:macro:`Py_TPFLAGS_HAVE_GC`." msgstr "" -#: ../../c-api/type.rst:140 +#: ../../c-api/type.rst:144 msgid "Return true if *a* is a subtype of *b*." msgstr "" -#: ../../c-api/type.rst:142 +#: ../../c-api/type.rst:146 msgid "" -"This function only checks for actual subtypes, which means that :meth:" -"`~class.__subclasscheck__` is not called on *b*. Call :c:func:" -"`PyObject_IsSubclass` to do the same check that :func:`issubclass` would do." +"This function only checks for actual subtypes, which means that :meth:`~type." +"__subclasscheck__` is not called on *b*. Call :c:func:`PyObject_IsSubclass` " +"to do the same check that :func:`issubclass` would do." msgstr "" -#: ../../c-api/type.rst:150 +#: ../../c-api/type.rst:154 msgid "" "Generic handler for the :c:member:`~PyTypeObject.tp_alloc` slot of a type " "object. Use Python's default memory allocation mechanism to allocate a new " "instance and initialize all its contents to ``NULL``." msgstr "" -#: ../../c-api/type.rst:156 +#: ../../c-api/type.rst:160 msgid "" "Generic handler for the :c:member:`~PyTypeObject.tp_new` slot of a type " "object. Create a new instance using the type's :c:member:`~PyTypeObject." "tp_alloc` slot." msgstr "" -#: ../../c-api/type.rst:161 +#: ../../c-api/type.rst:165 msgid "" "Finalize a type object. This should be called on all type objects to finish " "their initialization. This function is responsible for adding inherited " @@ -184,7 +190,7 @@ msgid "" "and sets an exception on error." msgstr "" -#: ../../c-api/type.rst:167 +#: ../../c-api/type.rst:171 msgid "" "If some of the base classes implements the GC protocol and the provided type " "does not include the :c:macro:`Py_TPFLAGS_HAVE_GC` in its flags, then the GC " @@ -195,19 +201,32 @@ msgid "" "handle." msgstr "" -#: ../../c-api/type.rst:177 +#: ../../c-api/type.rst:181 msgid "" -"Return the type's name. Equivalent to getting the type's ``__name__`` " -"attribute." +"Return the type's name. Equivalent to getting the type's :attr:`~type." +"__name__` attribute." msgstr "" -#: ../../c-api/type.rst:183 +#: ../../c-api/type.rst:188 msgid "" -"Return the type's qualified name. Equivalent to getting the type's " -"``__qualname__`` attribute." +"Return the type's qualified name. Equivalent to getting the type's :attr:" +"`~type.__qualname__` attribute." msgstr "" -#: ../../c-api/type.rst:190 +#: ../../c-api/type.rst:195 +msgid "" +"Return the type's fully qualified name. Equivalent to ``f\"{type.__module__}." +"{type.__qualname__}\"``, or :attr:`type.__qualname__` if :attr:`type." +"__module__` is not a string or is equal to ``\"builtins\"``." +msgstr "" + +#: ../../c-api/type.rst:203 +msgid "" +"Return the type's module name. Equivalent to getting the :attr:`type." +"__module__` attribute." +msgstr "" + +#: ../../c-api/type.rst:210 msgid "" "Return the function pointer stored in the given slot. If the result is " "``NULL``, this indicates that either the slot is ``NULL``, or that the " @@ -215,30 +234,30 @@ msgid "" "result pointer into the appropriate function type." msgstr "" -#: ../../c-api/type.rst:196 +#: ../../c-api/type.rst:216 msgid "" "See :c:member:`PyType_Slot.slot` for possible values of the *slot* argument." msgstr "" -#: ../../c-api/type.rst:200 +#: ../../c-api/type.rst:220 msgid "" ":c:func:`PyType_GetSlot` can now accept all types. Previously, it was " "limited to :ref:`heap types `." msgstr "" -#: ../../c-api/type.rst:206 +#: ../../c-api/type.rst:226 msgid "" "Return the module object associated with the given type when the type was " "created using :c:func:`PyType_FromModuleAndSpec`." msgstr "" -#: ../../c-api/type.rst:209 ../../c-api/type.rst:229 +#: ../../c-api/type.rst:229 ../../c-api/type.rst:249 msgid "" "If no module is associated with the given type, sets :py:class:`TypeError` " "and returns ``NULL``." msgstr "" -#: ../../c-api/type.rst:212 +#: ../../c-api/type.rst:232 msgid "" "This function is usually used to get the module in which a method is " "defined. Note that in such a method, ``PyType_GetModule(Py_TYPE(self))`` may " @@ -249,31 +268,31 @@ msgid "" "type:`!PyCMethod` cannot be used." msgstr "" -#: ../../c-api/type.rst:225 +#: ../../c-api/type.rst:245 msgid "" "Return the state of the module object associated with the given type. This " "is a shortcut for calling :c:func:`PyModule_GetState()` on the result of :c:" "func:`PyType_GetModule`." msgstr "" -#: ../../c-api/type.rst:232 +#: ../../c-api/type.rst:252 msgid "" "If the *type* has an associated module but its state is ``NULL``, returns " "``NULL`` without setting an exception." msgstr "" -#: ../../c-api/type.rst:239 +#: ../../c-api/type.rst:259 msgid "" "Find the first superclass whose module was created from the given :c:type:" "`PyModuleDef` *def*, and return that module." msgstr "" -#: ../../c-api/type.rst:242 +#: ../../c-api/type.rst:262 msgid "" "If no module is found, raises a :py:class:`TypeError` and returns ``NULL``." msgstr "" -#: ../../c-api/type.rst:244 +#: ../../c-api/type.rst:264 msgid "" "This function is intended to be used together with :c:func:" "`PyModule_GetState()` to get module state from slot methods (such as :c:" @@ -282,40 +301,47 @@ msgid "" "type:`PyCMethod` calling convention." msgstr "" -#: ../../c-api/type.rst:254 +#: ../../c-api/type.rst:270 +msgid "" +"The returned reference is :term:`borrowed ` from *type*, " +"and will be valid as long as you hold a reference to *type*. Do not release " +"it with :c:func:`Py_DECREF` or similar." +msgstr "" + +#: ../../c-api/type.rst:278 msgid "Attempt to assign a version tag to the given type." msgstr "" -#: ../../c-api/type.rst:256 +#: ../../c-api/type.rst:280 msgid "" "Returns 1 if the type already had a valid version tag or a new one was " "assigned, or 0 if a new tag could not be assigned." msgstr "" -#: ../../c-api/type.rst:263 +#: ../../c-api/type.rst:287 msgid "Creating Heap-Allocated Types" msgstr "" -#: ../../c-api/type.rst:265 +#: ../../c-api/type.rst:289 msgid "" "The following functions and structs are used to create :ref:`heap types " "`." msgstr "" -#: ../../c-api/type.rst:270 +#: ../../c-api/type.rst:294 msgid "" "Create and return a :ref:`heap type ` from the *spec* (see :c:" "macro:`Py_TPFLAGS_HEAPTYPE`)." msgstr "" -#: ../../c-api/type.rst:273 +#: ../../c-api/type.rst:297 msgid "" "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)." msgstr "" -#: ../../c-api/type.rst:277 +#: ../../c-api/type.rst:301 msgid "" "Metaclasses that override :c:member:`~PyTypeObject.tp_new` are not " "supported, except if ``tp_new`` is ``NULL``. (For backwards compatibility, " @@ -324,7 +350,7 @@ msgid "" "deprecated and in Python 3.14+ such metaclasses will not be supported.)" msgstr "" -#: ../../c-api/type.rst:284 +#: ../../c-api/type.rst:308 msgid "" "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 " @@ -333,7 +359,7 @@ msgid "" "derives from :class:`object`." msgstr "" -#: ../../c-api/type.rst:290 +#: ../../c-api/type.rst:314 msgid "" "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``, " @@ -342,11 +368,11 @@ msgid "" "subclasses; it must be specified for each class individually." msgstr "" -#: ../../c-api/type.rst:297 +#: ../../c-api/type.rst:321 msgid "This function calls :c:func:`PyType_Ready` on the new type." msgstr "" -#: ../../c-api/type.rst:299 +#: ../../c-api/type.rst:323 msgid "" "Note that this function does *not* fully match the behavior of calling :py:" "class:`type() ` or using the :keyword:`class` statement. With user-" @@ -355,41 +381,41 @@ msgid "" "Specifically:" msgstr "" -#: ../../c-api/type.rst:306 +#: ../../c-api/type.rst:330 msgid "" ":py:meth:`~object.__new__` is not called on the new class (and it must be " "set to ``type.__new__``)." msgstr "" -#: ../../c-api/type.rst:308 +#: ../../c-api/type.rst:332 msgid ":py:meth:`~object.__init__` is not called on the new class." msgstr "" -#: ../../c-api/type.rst:309 +#: ../../c-api/type.rst:333 msgid ":py:meth:`~object.__init_subclass__` is not called on any bases." msgstr "" -#: ../../c-api/type.rst:310 +#: ../../c-api/type.rst:334 msgid ":py:meth:`~object.__set_name__` is not called on new descriptors." msgstr "" -#: ../../c-api/type.rst:316 +#: ../../c-api/type.rst:340 msgid "Equivalent to ``PyType_FromMetaclass(NULL, module, spec, bases)``." msgstr "等價於 ``PyType_FromMetaclass(NULL, module, spec, bases)``。" -#: ../../c-api/type.rst:322 +#: ../../c-api/type.rst:346 msgid "" "The function now accepts a single class as the *bases* argument and ``NULL`` " "as the ``tp_doc`` slot." msgstr "" -#: ../../c-api/type.rst:327 ../../c-api/type.rst:344 +#: ../../c-api/type.rst:351 ../../c-api/type.rst:368 msgid "" "The function now finds and uses a metaclass corresponding to the provided " "base classes. Previously, only :class:`type` instances were returned." msgstr "" -#: ../../c-api/type.rst:330 ../../c-api/type.rst:347 ../../c-api/type.rst:363 +#: ../../c-api/type.rst:354 ../../c-api/type.rst:371 ../../c-api/type.rst:387 msgid "" "The :c:member:`~PyTypeObject.tp_new` of the metaclass is *ignored*. which " "may result in incomplete initialization. Creating classes whose metaclass " @@ -397,60 +423,62 @@ msgid "" "it will be no longer allowed." msgstr "" -#: ../../c-api/type.rst:338 +#: ../../c-api/type.rst:362 msgid "Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, bases)``." msgstr "等價於 ``PyType_FromMetaclass(NULL, NULL, spec, bases)``。" -#: ../../c-api/type.rst:355 +#: ../../c-api/type.rst:379 msgid "Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, NULL)``." msgstr "等價於 ``PyType_FromMetaclass(NULL, NULL, spec, NULL)``。" -#: ../../c-api/type.rst:359 +#: ../../c-api/type.rst:383 msgid "" "The function now finds and uses a metaclass corresponding to the base " "classes provided in *Py_tp_base[s]* slots. Previously, only :class:`type` " "instances were returned." msgstr "" -#: ../../c-api/type.rst:380 +#: ../../c-api/type.rst:404 msgid "Structure defining a type's behavior." msgstr "" -#: ../../c-api/type.rst:384 +#: ../../c-api/type.rst:408 msgid "Name of the type, used to set :c:member:`PyTypeObject.tp_name`." msgstr "" -#: ../../c-api/type.rst:388 +#: ../../c-api/type.rst:412 msgid "" "If positive, specifies the size of the instance in bytes. It is used to set :" "c:member:`PyTypeObject.tp_basicsize`." msgstr "" -#: ../../c-api/type.rst:391 +#: ../../c-api/type.rst:415 msgid "" "If zero, specifies that :c:member:`~PyTypeObject.tp_basicsize` should be " "inherited." msgstr "" -#: ../../c-api/type.rst:394 +#: ../../c-api/type.rst:418 msgid "" "If negative, the absolute value specifies how much space instances of the " "class need *in addition* to the superclass. Use :c:func:" "`PyObject_GetTypeData` to get a pointer to subclass-specific memory reserved " -"this way." +"this way. For negative :c:member:`!basicsize`, Python will insert padding " +"when needed to meet :c:member:`~PyTypeObject.tp_basicsize`'s alignment " +"requirements." msgstr "" -#: ../../c-api/type.rst:401 +#: ../../c-api/type.rst:428 msgid "Previously, this field could not be negative." msgstr "" -#: ../../c-api/type.rst:405 +#: ../../c-api/type.rst:432 msgid "" "Size of one element of a variable-size type, in bytes. Used to set :c:member:" "`PyTypeObject.tp_itemsize`. See ``tp_itemsize`` documentation for caveats." msgstr "" -#: ../../c-api/type.rst:409 +#: ../../c-api/type.rst:436 msgid "" "If zero, :c:member:`~PyTypeObject.tp_itemsize` is inherited. Extending " "arbitrary variable-sized classes is dangerous, since some types use a fixed " @@ -459,58 +487,58 @@ msgid "" "only possible in the following situations:" msgstr "" -#: ../../c-api/type.rst:416 +#: ../../c-api/type.rst:443 msgid "" "The base is not variable-sized (its :c:member:`~PyTypeObject.tp_itemsize`)." msgstr "" -#: ../../c-api/type.rst:418 +#: ../../c-api/type.rst:445 msgid "" "The requested :c:member:`PyType_Spec.basicsize` is positive, suggesting that " "the memory layout of the base class is known." msgstr "" -#: ../../c-api/type.rst:420 +#: ../../c-api/type.rst:447 msgid "" "The requested :c:member:`PyType_Spec.basicsize` is zero, suggesting that the " "subclass does not access the instance's memory directly." msgstr "" -#: ../../c-api/type.rst:423 +#: ../../c-api/type.rst:450 msgid "With the :c:macro:`Py_TPFLAGS_ITEMS_AT_END` flag." msgstr "" -#: ../../c-api/type.rst:427 +#: ../../c-api/type.rst:454 msgid "Type flags, used to set :c:member:`PyTypeObject.tp_flags`." msgstr "" -#: ../../c-api/type.rst:429 +#: ../../c-api/type.rst:456 msgid "" "If the ``Py_TPFLAGS_HEAPTYPE`` flag is not set, :c:func:" "`PyType_FromSpecWithBases` sets it automatically." msgstr "" -#: ../../c-api/type.rst:434 +#: ../../c-api/type.rst:461 msgid "" "Array of :c:type:`PyType_Slot` structures. Terminated by the special slot " "value ``{0, NULL}``." msgstr "" -#: ../../c-api/type.rst:437 +#: ../../c-api/type.rst:464 msgid "Each slot ID should be specified at most once." msgstr "" -#: ../../c-api/type.rst:447 +#: ../../c-api/type.rst:474 msgid "" "Structure defining optional functionality of a type, containing a slot ID " "and a value pointer." msgstr "" -#: ../../c-api/type.rst:452 +#: ../../c-api/type.rst:479 msgid "A slot ID." msgstr "" -#: ../../c-api/type.rst:454 +#: ../../c-api/type.rst:481 msgid "" "Slot IDs are named like the field names of the structures :c:type:" "`PyTypeObject`, :c:type:`PyNumberMethods`, :c:type:`PySequenceMethods`, :c:" @@ -518,30 +546,30 @@ msgid "" "prefix. For example, use:" msgstr "" -#: ../../c-api/type.rst:460 +#: ../../c-api/type.rst:487 msgid "``Py_tp_dealloc`` to set :c:member:`PyTypeObject.tp_dealloc`" msgstr "" -#: ../../c-api/type.rst:461 +#: ../../c-api/type.rst:488 msgid "``Py_nb_add`` to set :c:member:`PyNumberMethods.nb_add`" msgstr "" -#: ../../c-api/type.rst:462 +#: ../../c-api/type.rst:489 msgid "``Py_sq_length`` to set :c:member:`PySequenceMethods.sq_length`" msgstr "" -#: ../../c-api/type.rst:464 +#: ../../c-api/type.rst:491 msgid "" "The following “offset” fields cannot be set using :c:type:`PyType_Slot`:" msgstr "" -#: ../../c-api/type.rst:466 +#: ../../c-api/type.rst:493 msgid "" ":c:member:`~PyTypeObject.tp_weaklistoffset` (use :c:macro:" "`Py_TPFLAGS_MANAGED_WEAKREF` instead if possible)" msgstr "" -#: ../../c-api/type.rst:468 +#: ../../c-api/type.rst:495 msgid "" ":c:member:`~PyTypeObject.tp_dictoffset` (use :c:macro:" "`Py_TPFLAGS_MANAGED_DICT` instead if possible)" @@ -549,7 +577,7 @@ msgstr "" ":c:member:`~PyTypeObject.tp_dictoffset`\\ (如果可能,請改用 :c:macro:" "`Py_TPFLAGS_MANAGED_DICT`)" -#: ../../c-api/type.rst:470 +#: ../../c-api/type.rst:497 msgid "" ":c:member:`~PyTypeObject.tp_vectorcall_offset` (use " "``\"__vectorcalloffset__\"`` in :ref:`PyMemberDef `)" @@ -557,7 +585,7 @@ msgstr "" ":c:member:`~PyTypeObject.tp_vectorcall_offset`\\ (請用 :ref:`PyMemberDef " "` 中的 ``\"__vectorcalloffset__\"``)" -#: ../../c-api/type.rst:474 +#: ../../c-api/type.rst:501 msgid "" "If it is not possible to switch to a ``MANAGED`` flag (for example, for " "vectorcall or to support Python older than 3.12), specify the offset in :c:" @@ -565,48 +593,48 @@ msgid "" "documentation ` for details." msgstr "" -#: ../../c-api/type.rst:480 +#: ../../c-api/type.rst:507 msgid "The following fields cannot be set at all when creating a heap type:" msgstr "" -#: ../../c-api/type.rst:482 +#: ../../c-api/type.rst:509 msgid "" ":c:member:`~PyTypeObject.tp_vectorcall` (use :c:member:`~PyTypeObject." "tp_new` and/or :c:member:`~PyTypeObject.tp_init`)" msgstr "" -#: ../../c-api/type.rst:486 +#: ../../c-api/type.rst:513 msgid "" "Internal fields: :c:member:`~PyTypeObject.tp_dict`, :c:member:`~PyTypeObject." "tp_mro`, :c:member:`~PyTypeObject.tp_cache`, :c:member:`~PyTypeObject." "tp_subclasses`, and :c:member:`~PyTypeObject.tp_weaklist`." msgstr "" -#: ../../c-api/type.rst:493 +#: ../../c-api/type.rst:520 msgid "" "Setting :c:data:`Py_tp_bases` or :c:data:`Py_tp_base` may be problematic on " "some platforms. To avoid issues, use the *bases* argument of :c:func:" "`PyType_FromSpecWithBases` instead." msgstr "" -#: ../../c-api/type.rst:500 +#: ../../c-api/type.rst:525 msgid "Slots in :c:type:`PyBufferProcs` may be set in the unlimited API." msgstr "" -#: ../../c-api/type.rst:502 +#: ../../c-api/type.rst:528 msgid "" ":c:member:`~PyBufferProcs.bf_getbuffer` and :c:member:`~PyBufferProcs." "bf_releasebuffer` are now available under the :ref:`limited API `." msgstr "" -#: ../../c-api/type.rst:509 +#: ../../c-api/type.rst:535 msgid "" "The desired value of the slot. In most cases, this is a pointer to a " "function." msgstr "" -#: ../../c-api/type.rst:512 +#: ../../c-api/type.rst:538 msgid "Slots other than ``Py_tp_doc`` may not be ``NULL``." msgstr "" diff --git a/c-api/typehints.po b/c-api/typehints.po index 6849cd7da0..3e3361c14e 100644 --- a/c-api/typehints.po +++ b/c-api/typehints.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,7 +6,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-01 22:24+0800\n" "PO-Revision-Date: 2022-10-16 16:16+0800\n" @@ -72,6 +72,14 @@ msgid "" " ...\n" "}" msgstr "" +"...\n" +"static PyMethodDef my_obj_methods[] = {\n" +" // 其他方法。\n" +" ...\n" +" {\"__class_getitem__\", Py_GenericAlias, METH_O|METH_CLASS, \"See PEP " +"585\"}\n" +" ...\n" +"}" #: ../../c-api/typehints.rst:38 msgid "The data model method :meth:`~object.__class_getitem__`." diff --git a/c-api/typeobj.po b/c-api/typeobj.po index e9a2f100ef..7751ec68ce 100644 --- a/c-api/typeobj.po +++ b/c-api/typeobj.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 14:33+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -19,8 +18,8 @@ msgstr "" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/typeobj.rst:6 -msgid "Type Objects" -msgstr "型別物件" +msgid "Type Object Structures" +msgstr "型別物件結構" #: ../../c-api/typeobj.rst:8 msgid "" @@ -129,7 +128,7 @@ msgstr ":c:member:`~PyTypeObject.tp_basicsize`" #: ../../c-api/typeobj.rst:0 ../../c-api/typeobj.rst:46 #: ../../c-api/typeobj.rst:48 ../../c-api/typeobj.rst:52 #: ../../c-api/typeobj.rst:99 ../../c-api/typeobj.rst:120 -#: ../../c-api/typeobj.rst:416 +#: ../../c-api/typeobj.rst:417 msgid ":c:type:`Py_ssize_t`" msgstr ":c:type:`Py_ssize_t`" @@ -142,7 +141,7 @@ msgid ":c:member:`~PyTypeObject.tp_dealloc`" msgstr ":c:member:`~PyTypeObject.tp_dealloc`" #: ../../c-api/typeobj.rst:50 ../../c-api/typeobj.rst:142 -#: ../../c-api/typeobj.rst:146 ../../c-api/typeobj.rst:346 +#: ../../c-api/typeobj.rst:146 ../../c-api/typeobj.rst:347 msgid ":c:type:`destructor`" msgstr ":c:type:`destructor`" @@ -154,7 +153,7 @@ msgstr ":c:member:`~PyTypeObject.tp_vectorcall_offset`" msgid "(:c:member:`~PyTypeObject.tp_getattr`)" msgstr "(:c:member:`~PyTypeObject.tp_getattr`)" -#: ../../c-api/typeobj.rst:54 ../../c-api/typeobj.rst:370 +#: ../../c-api/typeobj.rst:54 ../../c-api/typeobj.rst:371 msgid ":c:type:`getattrfunc`" msgstr ":c:type:`getattrfunc`" @@ -173,7 +172,7 @@ msgstr "G" msgid "(:c:member:`~PyTypeObject.tp_setattr`)" msgstr "(:c:member:`~PyTypeObject.tp_setattr`)" -#: ../../c-api/typeobj.rst:57 ../../c-api/typeobj.rst:375 +#: ../../c-api/typeobj.rst:57 ../../c-api/typeobj.rst:376 msgid ":c:type:`setattrfunc`" msgstr ":c:type:`setattrfunc`" @@ -191,6 +190,7 @@ msgstr ":c:type:`PyAsyncMethods` *" #: ../../c-api/typeobj.rst:60 ../../c-api/typeobj.rst:64 #: ../../c-api/typeobj.rst:66 ../../c-api/typeobj.rst:68 +#: ../../c-api/typeobj.rst:82 msgid ":ref:`sub-slots`" msgstr ":ref:`sub-slots`" @@ -205,7 +205,7 @@ msgid ":c:member:`~PyTypeObject.tp_repr`" msgstr ":c:member:`~PyTypeObject.tp_repr`" #: ../../c-api/typeobj.rst:62 ../../c-api/typeobj.rst:74 -#: ../../c-api/typeobj.rst:368 +#: ../../c-api/typeobj.rst:369 msgid ":c:type:`reprfunc`" msgstr ":c:type:`reprfunc`" @@ -241,7 +241,7 @@ msgstr ":c:type:`PyMappingMethods` *" msgid ":c:member:`~PyTypeObject.tp_hash`" msgstr ":c:member:`~PyTypeObject.tp_hash`" -#: ../../c-api/typeobj.rst:70 ../../c-api/typeobj.rst:404 +#: ../../c-api/typeobj.rst:70 ../../c-api/typeobj.rst:405 msgid ":c:type:`hashfunc`" msgstr ":c:type:`hashfunc`" @@ -254,7 +254,7 @@ msgid ":c:member:`~PyTypeObject.tp_call`" msgstr ":c:member:`~PyTypeObject.tp_call`" #: ../../c-api/typeobj.rst:72 ../../c-api/typeobj.rst:237 -#: ../../c-api/typeobj.rst:240 ../../c-api/typeobj.rst:440 +#: ../../c-api/typeobj.rst:240 ../../c-api/typeobj.rst:441 msgid ":c:type:`ternaryfunc`" msgstr ":c:type:`ternaryfunc`" @@ -274,7 +274,7 @@ msgstr "__str__" msgid ":c:member:`~PyTypeObject.tp_getattro`" msgstr ":c:member:`~PyTypeObject.tp_getattro`" -#: ../../c-api/typeobj.rst:76 ../../c-api/typeobj.rst:381 +#: ../../c-api/typeobj.rst:76 ../../c-api/typeobj.rst:382 msgid ":c:type:`getattrofunc`" msgstr ":c:type:`getattrofunc`" @@ -282,7 +282,7 @@ msgstr ":c:type:`getattrofunc`" msgid ":c:member:`~PyTypeObject.tp_setattro`" msgstr ":c:member:`~PyTypeObject.tp_setattro`" -#: ../../c-api/typeobj.rst:79 ../../c-api/typeobj.rst:386 +#: ../../c-api/typeobj.rst:79 ../../c-api/typeobj.rst:387 msgid ":c:type:`setattrofunc`" msgstr ":c:type:`setattrofunc`" @@ -321,7 +321,7 @@ msgstr "__doc__" msgid ":c:member:`~PyTypeObject.tp_traverse`" msgstr ":c:member:`~PyTypeObject.tp_traverse`" -#: ../../c-api/typeobj.rst:88 ../../c-api/typeobj.rst:350 +#: ../../c-api/typeobj.rst:88 ../../c-api/typeobj.rst:351 msgid ":c:type:`traverseproc`" msgstr ":c:type:`traverseproc`" @@ -330,7 +330,7 @@ msgid ":c:member:`~PyTypeObject.tp_clear`" msgstr ":c:member:`~PyTypeObject.tp_clear`" #: ../../c-api/typeobj.rst:90 ../../c-api/typeobj.rst:130 -#: ../../c-api/typeobj.rst:248 ../../c-api/typeobj.rst:429 +#: ../../c-api/typeobj.rst:248 ../../c-api/typeobj.rst:430 msgid ":c:type:`inquiry`" msgstr ":c:type:`inquiry`" @@ -338,7 +338,7 @@ msgstr ":c:type:`inquiry`" msgid ":c:member:`~PyTypeObject.tp_richcompare`" msgstr ":c:member:`~PyTypeObject.tp_richcompare`" -#: ../../c-api/typeobj.rst:92 ../../c-api/typeobj.rst:406 +#: ../../c-api/typeobj.rst:92 ../../c-api/typeobj.rst:407 msgid ":c:type:`richcmpfunc`" msgstr ":c:type:`richcmpfunc`" @@ -354,7 +354,7 @@ msgstr "(:c:member:`~PyTypeObject.tp_weaklistoffset`)" msgid ":c:member:`~PyTypeObject.tp_iter`" msgstr ":c:member:`~PyTypeObject.tp_iter`" -#: ../../c-api/typeobj.rst:101 ../../c-api/typeobj.rst:412 +#: ../../c-api/typeobj.rst:101 ../../c-api/typeobj.rst:413 msgid ":c:type:`getiterfunc`" msgstr ":c:type:`getiterfunc`" @@ -366,7 +366,7 @@ msgstr "__iter__" msgid ":c:member:`~PyTypeObject.tp_iternext`" msgstr ":c:member:`~PyTypeObject.tp_iternext`" -#: ../../c-api/typeobj.rst:103 ../../c-api/typeobj.rst:414 +#: ../../c-api/typeobj.rst:103 ../../c-api/typeobj.rst:415 msgid ":c:type:`iternextfunc`" msgstr ":c:type:`iternextfunc`" @@ -417,15 +417,15 @@ msgstr ":c:member:`~PyTypeObject.tp_dict`" #: ../../c-api/typeobj.rst:0 ../../c-api/typeobj.rst:113 #: ../../c-api/typeobj.rst:132 ../../c-api/typeobj.rst:134 #: ../../c-api/typeobj.rst:136 ../../c-api/typeobj.rst:140 -#: ../../c-api/typeobj.rst:341 ../../c-api/typeobj.rst:346 -#: ../../c-api/typeobj.rst:356 ../../c-api/typeobj.rst:368 -#: ../../c-api/typeobj.rst:370 ../../c-api/typeobj.rst:381 -#: ../../c-api/typeobj.rst:392 ../../c-api/typeobj.rst:404 -#: ../../c-api/typeobj.rst:406 ../../c-api/typeobj.rst:412 -#: ../../c-api/typeobj.rst:414 ../../c-api/typeobj.rst:416 -#: ../../c-api/typeobj.rst:429 ../../c-api/typeobj.rst:431 -#: ../../c-api/typeobj.rst:435 ../../c-api/typeobj.rst:440 -#: ../../c-api/typeobj.rst:446 +#: ../../c-api/typeobj.rst:342 ../../c-api/typeobj.rst:347 +#: ../../c-api/typeobj.rst:357 ../../c-api/typeobj.rst:369 +#: ../../c-api/typeobj.rst:371 ../../c-api/typeobj.rst:382 +#: ../../c-api/typeobj.rst:393 ../../c-api/typeobj.rst:405 +#: ../../c-api/typeobj.rst:407 ../../c-api/typeobj.rst:413 +#: ../../c-api/typeobj.rst:415 ../../c-api/typeobj.rst:417 +#: ../../c-api/typeobj.rst:430 ../../c-api/typeobj.rst:432 +#: ../../c-api/typeobj.rst:436 ../../c-api/typeobj.rst:441 +#: ../../c-api/typeobj.rst:447 msgid ":c:type:`PyObject` *" msgstr ":c:type:`PyObject` *" @@ -437,7 +437,7 @@ msgstr "__dict__" msgid ":c:member:`~PyTypeObject.tp_descr_get`" msgstr ":c:member:`~PyTypeObject.tp_descr_get`" -#: ../../c-api/typeobj.rst:115 ../../c-api/typeobj.rst:392 +#: ../../c-api/typeobj.rst:115 ../../c-api/typeobj.rst:393 msgid ":c:type:`descrgetfunc`" msgstr ":c:type:`descrgetfunc`" @@ -449,7 +449,7 @@ msgstr "__get__" msgid ":c:member:`~PyTypeObject.tp_descr_set`" msgstr ":c:member:`~PyTypeObject.tp_descr_set`" -#: ../../c-api/typeobj.rst:117 ../../c-api/typeobj.rst:398 +#: ../../c-api/typeobj.rst:117 ../../c-api/typeobj.rst:399 msgid ":c:type:`descrsetfunc`" msgstr ":c:type:`descrsetfunc`" @@ -465,7 +465,7 @@ msgstr "(:c:member:`~PyTypeObject.tp_dictoffset`)" msgid ":c:member:`~PyTypeObject.tp_init`" msgstr ":c:member:`~PyTypeObject.tp_init`" -#: ../../c-api/typeobj.rst:122 ../../c-api/typeobj.rst:362 +#: ../../c-api/typeobj.rst:122 ../../c-api/typeobj.rst:363 msgid ":c:type:`initproc`" msgstr ":c:type:`initproc`" @@ -477,7 +477,7 @@ msgstr "__init__" msgid ":c:member:`~PyTypeObject.tp_alloc`" msgstr ":c:member:`~PyTypeObject.tp_alloc`" -#: ../../c-api/typeobj.rst:124 ../../c-api/typeobj.rst:341 +#: ../../c-api/typeobj.rst:124 ../../c-api/typeobj.rst:342 msgid ":c:type:`allocfunc`" msgstr ":c:type:`allocfunc`" @@ -485,7 +485,7 @@ msgstr ":c:type:`allocfunc`" msgid ":c:member:`~PyTypeObject.tp_new`" msgstr ":c:member:`~PyTypeObject.tp_new`" -#: ../../c-api/typeobj.rst:126 ../../c-api/typeobj.rst:356 +#: ../../c-api/typeobj.rst:126 ../../c-api/typeobj.rst:357 msgid ":c:type:`newfunc`" msgstr ":c:type:`newfunc`" @@ -497,7 +497,7 @@ msgstr "__new__" msgid ":c:member:`~PyTypeObject.tp_free`" msgstr ":c:member:`~PyTypeObject.tp_free`" -#: ../../c-api/typeobj.rst:128 ../../c-api/typeobj.rst:348 +#: ../../c-api/typeobj.rst:128 ../../c-api/typeobj.rst:349 msgid ":c:type:`freefunc`" msgstr ":c:type:`freefunc`" @@ -534,7 +534,7 @@ msgid "[:c:member:`~PyTypeObject.tp_subclasses`]" msgstr "[:c:member:`~PyTypeObject.tp_subclasses`]" #: ../../c-api/typeobj.rst:0 ../../c-api/typeobj.rst:138 -#: ../../c-api/typeobj.rst:279 ../../c-api/typeobj.rst:348 +#: ../../c-api/typeobj.rst:279 ../../c-api/typeobj.rst:349 msgid "void *" msgstr "void *" @@ -668,7 +668,7 @@ msgstr ":c:member:`~PyAsyncMethods.am_await`" #: ../../c-api/typeobj.rst:244 ../../c-api/typeobj.rst:246 #: ../../c-api/typeobj.rst:250 ../../c-api/typeobj.rst:277 #: ../../c-api/typeobj.rst:281 ../../c-api/typeobj.rst:291 -#: ../../c-api/typeobj.rst:431 +#: ../../c-api/typeobj.rst:432 msgid ":c:type:`unaryfunc`" msgstr ":c:type:`unaryfunc`" @@ -718,7 +718,7 @@ msgstr ":c:member:`~PyNumberMethods.nb_add`" #: ../../c-api/typeobj.rst:289 ../../c-api/typeobj.rst:293 #: ../../c-api/typeobj.rst:296 ../../c-api/typeobj.rst:302 #: ../../c-api/typeobj.rst:311 ../../c-api/typeobj.rst:322 -#: ../../c-api/typeobj.rst:435 +#: ../../c-api/typeobj.rst:436 msgid ":c:type:`binaryfunc`" msgstr ":c:type:`binaryfunc`" @@ -1007,7 +1007,7 @@ msgid ":c:member:`~PyMappingMethods.mp_length`" msgstr ":c:member:`~PyMappingMethods.mp_length`" #: ../../c-api/typeobj.rst:300 ../../c-api/typeobj.rst:309 -#: ../../c-api/typeobj.rst:416 +#: ../../c-api/typeobj.rst:417 msgid ":c:type:`lenfunc`" msgstr ":c:type:`lenfunc`" @@ -1027,7 +1027,7 @@ msgstr "__getitem__" msgid ":c:member:`~PyMappingMethods.mp_ass_subscript`" msgstr ":c:member:`~PyMappingMethods.mp_ass_subscript`" -#: ../../c-api/typeobj.rst:304 ../../c-api/typeobj.rst:462 +#: ../../c-api/typeobj.rst:304 ../../c-api/typeobj.rst:463 msgid ":c:type:`objobjargproc`" msgstr ":c:type:`objobjargproc`" @@ -1052,7 +1052,7 @@ msgid ":c:member:`~PySequenceMethods.sq_repeat`" msgstr ":c:member:`~PySequenceMethods.sq_repeat`" #: ../../c-api/typeobj.rst:313 ../../c-api/typeobj.rst:315 -#: ../../c-api/typeobj.rst:324 ../../c-api/typeobj.rst:446 +#: ../../c-api/typeobj.rst:324 ../../c-api/typeobj.rst:447 msgid ":c:type:`ssizeargfunc`" msgstr ":c:type:`ssizeargfunc`" @@ -1068,7 +1068,7 @@ msgstr ":c:member:`~PySequenceMethods.sq_item`" msgid ":c:member:`~PySequenceMethods.sq_ass_item`" msgstr ":c:member:`~PySequenceMethods.sq_ass_item`" -#: ../../c-api/typeobj.rst:317 ../../c-api/typeobj.rst:451 +#: ../../c-api/typeobj.rst:317 ../../c-api/typeobj.rst:452 msgid ":c:type:`ssizeobjargproc`" msgstr ":c:type:`ssizeobjargproc`" @@ -1080,7 +1080,7 @@ msgstr "__setitem__ __delitem__" msgid ":c:member:`~PySequenceMethods.sq_contains`" msgstr ":c:member:`~PySequenceMethods.sq_contains`" -#: ../../c-api/typeobj.rst:320 ../../c-api/typeobj.rst:457 +#: ../../c-api/typeobj.rst:320 ../../c-api/typeobj.rst:458 msgid ":c:type:`objobjproc`" msgstr ":c:type:`objobjproc`" @@ -1104,6 +1104,11 @@ msgstr ":c:member:`~PyBufferProcs.bf_getbuffer`" msgid ":c:func:`getbufferproc`" msgstr ":c:func:`getbufferproc`" +#: ../../c-api/typeobj.rst:328 +#, fuzzy +msgid "__buffer__" +msgstr "__buffer__" + #: ../../c-api/typeobj.rst:330 msgid ":c:member:`~PyBufferProcs.bf_releasebuffer`" msgstr ":c:member:`~PyBufferProcs.bf_releasebuffer`" @@ -1112,24 +1117,28 @@ msgstr ":c:member:`~PyBufferProcs.bf_releasebuffer`" msgid ":c:func:`releasebufferproc`" msgstr ":c:func:`releasebufferproc`" -#: ../../c-api/typeobj.rst:336 +#: ../../c-api/typeobj.rst:330 +msgid "__release_\\ buffer\\__" +msgstr "" + +#: ../../c-api/typeobj.rst:337 msgid "slot typedefs" msgstr "" -#: ../../c-api/typeobj.rst:339 +#: ../../c-api/typeobj.rst:340 msgid "typedef" msgstr "typedef" -#: ../../c-api/typeobj.rst:339 +#: ../../c-api/typeobj.rst:340 msgid "Parameter Types" msgstr "" -#: ../../c-api/typeobj.rst:339 +#: ../../c-api/typeobj.rst:340 msgid "Return Type" msgstr "" -#: ../../c-api/typeobj.rst:346 ../../c-api/typeobj.rst:348 -#: ../../c-api/typeobj.rst:424 +#: ../../c-api/typeobj.rst:347 ../../c-api/typeobj.rst:349 +#: ../../c-api/typeobj.rst:425 msgid "void" msgstr "void" @@ -1137,20 +1146,20 @@ msgstr "void" msgid ":c:type:`visitproc`" msgstr ":c:type:`visitproc`" -#: ../../c-api/typeobj.rst:0 ../../c-api/typeobj.rst:350 -#: ../../c-api/typeobj.rst:362 ../../c-api/typeobj.rst:375 -#: ../../c-api/typeobj.rst:386 ../../c-api/typeobj.rst:398 -#: ../../c-api/typeobj.rst:418 ../../c-api/typeobj.rst:429 -#: ../../c-api/typeobj.rst:451 ../../c-api/typeobj.rst:457 -#: ../../c-api/typeobj.rst:462 +#: ../../c-api/typeobj.rst:0 ../../c-api/typeobj.rst:351 +#: ../../c-api/typeobj.rst:363 ../../c-api/typeobj.rst:376 +#: ../../c-api/typeobj.rst:387 ../../c-api/typeobj.rst:399 +#: ../../c-api/typeobj.rst:419 ../../c-api/typeobj.rst:430 +#: ../../c-api/typeobj.rst:452 ../../c-api/typeobj.rst:458 +#: ../../c-api/typeobj.rst:463 msgid "int" msgstr "int" -#: ../../c-api/typeobj.rst:404 +#: ../../c-api/typeobj.rst:405 msgid "Py_hash_t" msgstr "Py_hash_t" -#: ../../c-api/typeobj.rst:418 +#: ../../c-api/typeobj.rst:419 msgid ":c:type:`getbufferproc`" msgstr ":c:type:`getbufferproc`" @@ -1158,26 +1167,26 @@ msgstr ":c:type:`getbufferproc`" msgid ":c:type:`Py_buffer` *" msgstr ":c:type:`Py_buffer` *" -#: ../../c-api/typeobj.rst:424 +#: ../../c-api/typeobj.rst:425 msgid ":c:type:`releasebufferproc`" msgstr ":c:type:`releasebufferproc`" -#: ../../c-api/typeobj.rst:469 +#: ../../c-api/typeobj.rst:470 msgid "See :ref:`slot-typedefs` below for more detail." msgstr "更多細節請見下方的 :ref:`slot-typedefs`。" -#: ../../c-api/typeobj.rst:473 +#: ../../c-api/typeobj.rst:474 msgid "PyTypeObject Definition" msgstr "" -#: ../../c-api/typeobj.rst:475 +#: ../../c-api/typeobj.rst:476 msgid "" "The structure definition for :c:type:`PyTypeObject` can be found in :file:" -"`Include/object.h`. For convenience of reference, this repeats the " +"`Include/cpython/object.h`. For convenience of reference, this repeats the " "definition found there:" msgstr "" -#: ../../c-api/typeobj.rst:481 +#: ../../c-api/typeobj.rst:482 msgid "" "typedef struct _typeobject {\n" " PyObject_VAR_HEAD\n" @@ -1267,11 +1276,11 @@ msgid "" "} PyTypeObject;\n" msgstr "" -#: ../../c-api/typeobj.rst:485 +#: ../../c-api/typeobj.rst:486 msgid "PyObject Slots" msgstr "" -#: ../../c-api/typeobj.rst:487 +#: ../../c-api/typeobj.rst:488 msgid "" "The type object structure extends the :c:type:`PyVarObject` structure. The :" "c:member:`~PyVarObject.ob_size` field is used for dynamic types (created by :" @@ -1281,7 +1290,7 @@ msgid "" "the :c:member:`~PyVarObject.ob_size` field." msgstr "" -#: ../../c-api/typeobj.rst:496 +#: ../../c-api/typeobj.rst:497 msgid "" "This is the type object's reference count, initialized to ``1`` by the " "``PyObject_HEAD_INIT`` macro. Note that for :ref:`statically allocated type " @@ -1291,48 +1300,47 @@ msgid "" "instances *do* count as references." msgstr "" -#: ../../c-api/typeobj.rst:503 ../../c-api/typeobj.rst:526 -#: ../../c-api/typeobj.rst:548 ../../c-api/typeobj.rst:562 -#: ../../c-api/typeobj.rst:606 ../../c-api/typeobj.rst:649 -#: ../../c-api/typeobj.rst:708 ../../c-api/typeobj.rst:749 -#: ../../c-api/typeobj.rst:766 ../../c-api/typeobj.rst:783 -#: ../../c-api/typeobj.rst:801 ../../c-api/typeobj.rst:825 -#: ../../c-api/typeobj.rst:842 ../../c-api/typeobj.rst:854 -#: ../../c-api/typeobj.rst:866 ../../c-api/typeobj.rst:899 -#: ../../c-api/typeobj.rst:917 ../../c-api/typeobj.rst:937 -#: ../../c-api/typeobj.rst:958 ../../c-api/typeobj.rst:984 -#: ../../c-api/typeobj.rst:1003 ../../c-api/typeobj.rst:1019 -#: ../../c-api/typeobj.rst:1058 ../../c-api/typeobj.rst:1069 -#: ../../c-api/typeobj.rst:1079 ../../c-api/typeobj.rst:1089 -#: ../../c-api/typeobj.rst:1103 ../../c-api/typeobj.rst:1121 -#: ../../c-api/typeobj.rst:1144 ../../c-api/typeobj.rst:1159 -#: ../../c-api/typeobj.rst:1172 ../../c-api/typeobj.rst:1194 -#: ../../c-api/typeobj.rst:1238 ../../c-api/typeobj.rst:1259 -#: ../../c-api/typeobj.rst:1278 ../../c-api/typeobj.rst:1308 -#: ../../c-api/typeobj.rst:1330 ../../c-api/typeobj.rst:1356 -#: ../../c-api/typeobj.rst:1424 ../../c-api/typeobj.rst:1492 -#: ../../c-api/typeobj.rst:1553 ../../c-api/typeobj.rst:1589 -#: ../../c-api/typeobj.rst:1614 ../../c-api/typeobj.rst:1637 -#: ../../c-api/typeobj.rst:1650 ../../c-api/typeobj.rst:1665 -#: ../../c-api/typeobj.rst:1679 ../../c-api/typeobj.rst:1709 -#: ../../c-api/typeobj.rst:1741 ../../c-api/typeobj.rst:1767 -#: ../../c-api/typeobj.rst:1785 ../../c-api/typeobj.rst:1814 -#: ../../c-api/typeobj.rst:1858 ../../c-api/typeobj.rst:1875 -#: ../../c-api/typeobj.rst:1916 ../../c-api/typeobj.rst:1938 -#: ../../c-api/typeobj.rst:1970 ../../c-api/typeobj.rst:1998 -#: ../../c-api/typeobj.rst:2011 ../../c-api/typeobj.rst:2021 -#: ../../c-api/typeobj.rst:2038 ../../c-api/typeobj.rst:2055 -#: ../../c-api/typeobj.rst:2069 ../../c-api/typeobj.rst:2115 -#: ../../c-api/typeobj.rst:2138 +#: ../../c-api/typeobj.rst:504 ../../c-api/typeobj.rst:527 +#: ../../c-api/typeobj.rst:544 ../../c-api/typeobj.rst:588 +#: ../../c-api/typeobj.rst:666 ../../c-api/typeobj.rst:742 +#: ../../c-api/typeobj.rst:783 ../../c-api/typeobj.rst:800 +#: ../../c-api/typeobj.rst:817 ../../c-api/typeobj.rst:835 +#: ../../c-api/typeobj.rst:859 ../../c-api/typeobj.rst:876 +#: ../../c-api/typeobj.rst:888 ../../c-api/typeobj.rst:900 +#: ../../c-api/typeobj.rst:933 ../../c-api/typeobj.rst:955 +#: ../../c-api/typeobj.rst:975 ../../c-api/typeobj.rst:996 +#: ../../c-api/typeobj.rst:1022 ../../c-api/typeobj.rst:1041 +#: ../../c-api/typeobj.rst:1057 ../../c-api/typeobj.rst:1096 +#: ../../c-api/typeobj.rst:1107 ../../c-api/typeobj.rst:1117 +#: ../../c-api/typeobj.rst:1127 ../../c-api/typeobj.rst:1141 +#: ../../c-api/typeobj.rst:1159 ../../c-api/typeobj.rst:1182 +#: ../../c-api/typeobj.rst:1200 ../../c-api/typeobj.rst:1213 +#: ../../c-api/typeobj.rst:1235 ../../c-api/typeobj.rst:1279 +#: ../../c-api/typeobj.rst:1300 ../../c-api/typeobj.rst:1319 +#: ../../c-api/typeobj.rst:1349 ../../c-api/typeobj.rst:1371 +#: ../../c-api/typeobj.rst:1397 ../../c-api/typeobj.rst:1482 +#: ../../c-api/typeobj.rst:1556 ../../c-api/typeobj.rst:1617 +#: ../../c-api/typeobj.rst:1653 ../../c-api/typeobj.rst:1678 +#: ../../c-api/typeobj.rst:1701 ../../c-api/typeobj.rst:1714 +#: ../../c-api/typeobj.rst:1729 ../../c-api/typeobj.rst:1743 +#: ../../c-api/typeobj.rst:1773 ../../c-api/typeobj.rst:1805 +#: ../../c-api/typeobj.rst:1831 ../../c-api/typeobj.rst:1849 +#: ../../c-api/typeobj.rst:1878 ../../c-api/typeobj.rst:1922 +#: ../../c-api/typeobj.rst:1939 ../../c-api/typeobj.rst:1980 +#: ../../c-api/typeobj.rst:2002 ../../c-api/typeobj.rst:2034 +#: ../../c-api/typeobj.rst:2062 ../../c-api/typeobj.rst:2075 +#: ../../c-api/typeobj.rst:2085 ../../c-api/typeobj.rst:2102 +#: ../../c-api/typeobj.rst:2119 ../../c-api/typeobj.rst:2133 +#: ../../c-api/typeobj.rst:2166 ../../c-api/typeobj.rst:2189 msgid "**Inheritance:**" msgstr "" -#: ../../c-api/typeobj.rst:505 ../../c-api/typeobj.rst:564 -#: ../../c-api/typeobj.rst:608 +#: ../../c-api/typeobj.rst:506 ../../c-api/typeobj.rst:546 +#: ../../c-api/typeobj.rst:590 msgid "This field is not inherited by subtypes." msgstr "" -#: ../../c-api/typeobj.rst:510 +#: ../../c-api/typeobj.rst:511 msgid "" "This is the type's type, in other words its metatype. It is initialized by " "the argument to the ``PyObject_HEAD_INIT`` macro, and its value should " @@ -1344,11 +1352,11 @@ msgid "" "doing anything else. This is typically done like this::" msgstr "" -#: ../../c-api/typeobj.rst:519 +#: ../../c-api/typeobj.rst:520 msgid "Foo_Type.ob_type = &PyType_Type;" msgstr "Foo_Type.ob_type = &PyType_Type;" -#: ../../c-api/typeobj.rst:521 +#: ../../c-api/typeobj.rst:522 msgid "" "This should be done before any instances of the type are created. :c:func:" "`PyType_Ready` checks if :c:member:`~PyObject.ob_type` is ``NULL``, and if " @@ -1356,58 +1364,37 @@ msgid "" "class. :c:func:`PyType_Ready` will not change this field if it is non-zero." msgstr "" -#: ../../c-api/typeobj.rst:528 ../../c-api/typeobj.rst:710 -#: ../../c-api/typeobj.rst:827 ../../c-api/typeobj.rst:919 -#: ../../c-api/typeobj.rst:939 ../../c-api/typeobj.rst:1616 -#: ../../c-api/typeobj.rst:1639 ../../c-api/typeobj.rst:1769 -#: ../../c-api/typeobj.rst:1787 ../../c-api/typeobj.rst:1860 -#: ../../c-api/typeobj.rst:1972 ../../c-api/typeobj.rst:2117 +#: ../../c-api/typeobj.rst:529 ../../c-api/typeobj.rst:744 +#: ../../c-api/typeobj.rst:861 ../../c-api/typeobj.rst:957 +#: ../../c-api/typeobj.rst:977 ../../c-api/typeobj.rst:1680 +#: ../../c-api/typeobj.rst:1703 ../../c-api/typeobj.rst:1833 +#: ../../c-api/typeobj.rst:1851 ../../c-api/typeobj.rst:1924 +#: ../../c-api/typeobj.rst:2036 ../../c-api/typeobj.rst:2168 msgid "This field is inherited by subtypes." msgstr "" -#: ../../c-api/typeobj.rst:534 -msgid "" -"These fields are only present when the macro ``Py_TRACE_REFS`` is defined " -"(see the :option:`configure --with-trace-refs option <--with-trace-refs>`)." +#: ../../c-api/typeobj.rst:533 +msgid "PyVarObject Slots" msgstr "" #: ../../c-api/typeobj.rst:537 msgid "" -"Their initialization to ``NULL`` is taken care of by the " -"``PyObject_HEAD_INIT`` macro. For :ref:`statically allocated objects " -"`, these fields always remain ``NULL``. For :ref:`dynamically " -"allocated objects `, these two fields are used to link the " -"object into a doubly linked list of *all* live objects on the heap." +"For :ref:`statically allocated type objects `, this should be " +"initialized to zero. For :ref:`dynamically allocated type objects `, this field has a special internal meaning." msgstr "" -#: ../../c-api/typeobj.rst:543 +#: ../../c-api/typeobj.rst:541 msgid "" -"This could be used for various debugging purposes; currently the only uses " -"are the :func:`sys.getobjects` function and to print the objects that are " -"still alive at the end of a run when the environment variable :envvar:" -"`PYTHONDUMPREFS` is set." +"This field should be accessed using the :c:func:`Py_SIZE()` and :c:func:" +"`Py_SET_SIZE()` macros." msgstr "" #: ../../c-api/typeobj.rst:550 -msgid "These fields are not inherited by subtypes." -msgstr "" - -#: ../../c-api/typeobj.rst:554 -msgid "PyVarObject Slots" -msgstr "" - -#: ../../c-api/typeobj.rst:558 -msgid "" -"For :ref:`statically allocated type objects `, this should be " -"initialized to zero. For :ref:`dynamically allocated type objects `, this field has a special internal meaning." -msgstr "" - -#: ../../c-api/typeobj.rst:568 msgid "PyTypeObject Slots" msgstr "" -#: ../../c-api/typeobj.rst:570 +#: ../../c-api/typeobj.rst:552 msgid "" "Each slot has a section describing inheritance. If :c:func:`PyType_Ready` " "may set a value when the field is set to ``NULL`` then there will also be a " @@ -1415,7 +1402,7 @@ msgid "" "`PyBaseObject_Type` and :c:data:`PyType_Type` effectively act as defaults.)" msgstr "" -#: ../../c-api/typeobj.rst:577 +#: ../../c-api/typeobj.rst:559 msgid "" "Pointer to a NUL-terminated string containing the name of the type. For " "types that are accessible as module globals, the string should be the full " @@ -1427,117 +1414,173 @@ msgid "" "tp_name` initializer ``\"P.Q.M.T\"``." msgstr "" -#: ../../c-api/typeobj.rst:585 +#: ../../c-api/typeobj.rst:567 msgid "" "For :ref:`dynamically allocated type objects `, this should just " "be the type name, and the module name explicitly stored in the type dict as " "the value for key ``'__module__'``." msgstr "" -#: ../../c-api/typeobj.rst:590 +#: ../../c-api/typeobj.rst:572 msgid "" "For :ref:`statically allocated type objects `, the *tp_name* " "field should contain a dot. Everything before the last dot is made " -"accessible as the :attr:`__module__` attribute, and everything after the " -"last dot is made accessible as the :attr:`~definition.__name__` attribute." +"accessible as the :attr:`~type.__module__` attribute, and everything after " +"the last dot is made accessible as the :attr:`~type.__name__` attribute." msgstr "" -#: ../../c-api/typeobj.rst:596 +#: ../../c-api/typeobj.rst:578 msgid "" "If no dot is present, the entire :c:member:`~PyTypeObject.tp_name` field is " -"made accessible as the :attr:`~definition.__name__` attribute, and the :attr:" -"`__module__` attribute is undefined (unless explicitly set in the " +"made accessible as the :attr:`~type.__name__` attribute, and the :attr:" +"`~type.__module__` 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." msgstr "" -#: ../../c-api/typeobj.rst:602 +#: ../../c-api/typeobj.rst:584 msgid "" "This field must not be ``NULL``. It is the only required field in :c:func:" "`PyTypeObject` (other than potentially :c:member:`~PyTypeObject." "tp_itemsize`)." msgstr "" -#: ../../c-api/typeobj.rst:614 +#: ../../c-api/typeobj.rst:596 msgid "" "These fields allow calculating the size in bytes of instances of the type." msgstr "" -#: ../../c-api/typeobj.rst:616 +#: ../../c-api/typeobj.rst:598 msgid "" "There are two kinds of types: types with fixed-length instances have a zero :" -"c:member:`~PyTypeObject.tp_itemsize` field, types with variable-length " -"instances have a non-zero :c:member:`~PyTypeObject.tp_itemsize` field. For " -"a type with fixed-length instances, all instances have the same size, given " -"in :c:member:`~PyTypeObject.tp_basicsize`." +"c:member:`!tp_itemsize` field, types with variable-length instances have a " +"non-zero :c:member:`!tp_itemsize` field. For a type with fixed-length " +"instances, all instances have the same size, given in :c:member:`!" +"tp_basicsize`. (Exceptions to this rule can be made using :c:func:" +"`PyUnstable_Object_GC_NewWithExtraData`.)" msgstr "" -#: ../../c-api/typeobj.rst:621 +#: ../../c-api/typeobj.rst:605 msgid "" "For a type with variable-length instances, the instances must have an :c:" -"member:`~PyVarObject.ob_size` field, and the instance size is :c:member:" -"`~PyTypeObject.tp_basicsize` plus N times :c:member:`~PyTypeObject." -"tp_itemsize`, where N is the \"length\" of the object. The value of N is " -"typically stored in the instance's :c:member:`~PyVarObject.ob_size` field. " -"There are exceptions: for example, ints use a negative :c:member:" -"`~PyVarObject.ob_size` to indicate a negative number, and N is " -"``abs(ob_size)`` there. Also, the presence of an :c:member:`~PyVarObject." -"ob_size` field in the instance layout doesn't mean that the instance " -"structure is variable-length (for example, the structure for the list type " -"has fixed-length instances, yet those instances have a meaningful :c:member:" -"`~PyVarObject.ob_size` field)." -msgstr "" - -#: ../../c-api/typeobj.rst:632 -msgid "" -"The basic size includes the fields in the instance declared by the macro :c:" -"macro:`PyObject_HEAD` or :c:macro:`PyObject_VAR_HEAD` (whichever is used to " -"declare the instance struct) and this in turn includes the :c:member:" -"`~PyObject._ob_prev` and :c:member:`~PyObject._ob_next` fields if they are " -"present. This means that the only correct way to get an initializer for " -"the :c:member:`~PyTypeObject.tp_basicsize` 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." +"member:`~PyVarObject.ob_size` field, and the instance size is :c:member:`!" +"tp_basicsize` plus N times :c:member:`!tp_itemsize`, where N is the " +"\"length\" of the object." +msgstr "" + +#: ../../c-api/typeobj.rst:610 +msgid "" +"Functions like :c:func:`PyObject_NewVar` will take the value of N as an " +"argument, and store in the instance's :c:member:`~PyVarObject.ob_size` " +"field. Note that the :c:member:`~PyVarObject.ob_size` field may later be " +"used for other purposes. For example, :py:type:`int` instances use the bits " +"of :c:member:`~PyVarObject.ob_size` in an implementation-defined way; the " +"underlying storage and its size should be accessed using :c:func:" +"`PyLong_Export`." +msgstr "" + +#: ../../c-api/typeobj.rst:620 +msgid "" +"The :c:member:`~PyVarObject.ob_size` field should be accessed using the :c:" +"func:`Py_SIZE()` and :c:func:`Py_SET_SIZE()` macros." +msgstr "" + +#: ../../c-api/typeobj.rst:623 +msgid "" +"Also, the presence of an :c:member:`~PyVarObject.ob_size` field in the " +"instance layout doesn't mean that the instance structure is variable-length. " +"For example, the :py:type:`list` type has fixed-length instances, yet those " +"instances have a :c:member:`~PyVarObject.ob_size` field. (As with :py:type:" +"`int`, avoid reading lists' :c:member:`!ob_size` directly. Call :c:func:" +"`PyList_Size` instead.)" +msgstr "" + +#: ../../c-api/typeobj.rst:630 +msgid "" +"The :c:member:`!tp_basicsize` includes size needed for data of the type's :c:" +"member:`~PyTypeObject.tp_base`, plus any extra data needed by each instance." +msgstr "" + +#: ../../c-api/typeobj.rst:634 +msgid "" +"The correct way to set :c:member:`!tp_basicsize` is to use the ``sizeof`` " +"operator on the struct used to declare the instance layout. This struct must " +"include the struct used to declare the base type. In other words, :c:member:" +"`!tp_basicsize` must be greater than or equal to the base's :c:member:`!" +"tp_basicsize`." msgstr "" #: ../../c-api/typeobj.rst:640 msgid "" -"A note about alignment: if the variable items require a particular " -"alignment, this should be taken care of by the value of :c:member:" -"`~PyTypeObject.tp_basicsize`. Example: suppose a type implements an array " -"of ``double``. :c:member:`~PyTypeObject.tp_itemsize` is ``sizeof(double)``. " -"It is the programmer's responsibility that :c:member:`~PyTypeObject." -"tp_basicsize` is a multiple of ``sizeof(double)`` (assuming this is the " -"alignment requirement for ``double``)." +"Since every type is a subtype of :py:type:`object`, this struct must " +"include :c:type:`PyObject` or :c:type:`PyVarObject` (depending on whether :c:" +"member:`~PyVarObject.ob_size` should be included). These are usually defined " +"by the macro :c:macro:`PyObject_HEAD` or :c:macro:`PyObject_VAR_HEAD`, " +"respectively." +msgstr "" + +#: ../../c-api/typeobj.rst:646 +msgid "" +"The basic size does not include the GC header size, as that header is not " +"part of :c:macro:`PyObject_HEAD`." msgstr "" -#: ../../c-api/typeobj.rst:647 +#: ../../c-api/typeobj.rst:649 msgid "" -"For any type with variable-length instances, this field must not be ``NULL``." +"For cases where struct used to declare the base type is unknown, see :c:" +"member:`PyType_Spec.basicsize` and :c:func:`PyType_FromMetaclass`." msgstr "" -#: ../../c-api/typeobj.rst:651 +#: ../../c-api/typeobj.rst:652 +msgid "Notes about alignment:" +msgstr "" + +#: ../../c-api/typeobj.rst:654 msgid "" -"These fields are inherited separately by subtypes. If the base type has a " -"non-zero :c:member:`~PyTypeObject.tp_itemsize`, it is generally not safe to " -"set :c:member:`~PyTypeObject.tp_itemsize` to a different non-zero value in a " -"subtype (though this depends on the implementation of the base type)." +":c:member:`!tp_basicsize` must be a multiple of ``_Alignof(PyObject)``. When " +"using ``sizeof`` on a ``struct`` that includes :c:macro:`PyObject_HEAD`, as " +"recommended, the compiler ensures this. When not using a C ``struct``, or " +"when using compiler extensions like ``__attribute__((packed))``, it is up to " +"you." msgstr "" #: ../../c-api/typeobj.rst:659 msgid "" +"If the variable items require a particular alignment, :c:member:`!" +"tp_basicsize` and :c:member:`!tp_itemsize` must each be a multiple of that " +"alignment. For example, if a type's variable part stores a ``double``, it is " +"your responsibility that both fields are a multiple of ``_Alignof(double)``." +msgstr "" + +#: ../../c-api/typeobj.rst:668 +msgid "" +"These fields are inherited separately by subtypes. (That is, if the field is " +"set to zero, :c:func:`PyType_Ready` will copy the value from the base type, " +"indicating that the instances do not need additional storage.)" +msgstr "" + +#: ../../c-api/typeobj.rst:673 +msgid "" +"If the base type has a non-zero :c:member:`~PyTypeObject.tp_itemsize`, it is " +"generally not safe to set :c:member:`~PyTypeObject.tp_itemsize` to a " +"different non-zero value in a subtype (though this depends on the " +"implementation of the base type)." +msgstr "" + +#: ../../c-api/typeobj.rst:680 +msgid "" "A pointer to the instance destructor function. This function must be " "defined unless the type guarantees that its instances will never be " "deallocated (as is the case for the singletons ``None`` and ``Ellipsis``). " "The function signature is::" msgstr "" -#: ../../c-api/typeobj.rst:663 +#: ../../c-api/typeobj.rst:684 msgid "void tp_dealloc(PyObject *self);" msgstr "void tp_dealloc(PyObject *self);" -#: ../../c-api/typeobj.rst:665 +#: ../../c-api/typeobj.rst:686 msgid "" "The destructor function is called by the :c:func:`Py_DECREF` and :c:func:" "`Py_XDECREF` macros when the new reference count is zero. At this point, " @@ -1555,14 +1598,14 @@ msgid "" "allocated using :c:macro:`PyObject_GC_New` or :c:macro:`PyObject_GC_NewVar`." msgstr "" -#: ../../c-api/typeobj.rst:680 +#: ../../c-api/typeobj.rst:701 msgid "" "If the type supports garbage collection (has the :c:macro:" "`Py_TPFLAGS_HAVE_GC` flag bit set), the destructor should call :c:func:" "`PyObject_GC_UnTrack` before clearing any member fields." msgstr "" -#: ../../c-api/typeobj.rst:684 +#: ../../c-api/typeobj.rst:705 msgid "" "static void foo_dealloc(foo_object *self) {\n" " PyObject_GC_UnTrack(self);\n" @@ -1576,7 +1619,7 @@ msgstr "" " Py_TYPE(self)->tp_free((PyObject *)self);\n" "}" -#: ../../c-api/typeobj.rst:692 +#: ../../c-api/typeobj.rst:713 msgid "" "Finally, if the type is heap allocated (:c:macro:`Py_TPFLAGS_HEAPTYPE`), the " "deallocator should release the owned reference to its type object (via :c:" @@ -1584,7 +1627,7 @@ msgid "" "dangling pointers, the recommended way to achieve this is:" msgstr "" -#: ../../c-api/typeobj.rst:698 +#: ../../c-api/typeobj.rst:719 msgid "" "static void foo_dealloc(foo_object *self) {\n" " PyTypeObject *tp = Py_TYPE(self);\n" @@ -1594,28 +1637,41 @@ msgid "" "}" msgstr "" -#: ../../c-api/typeobj.rst:715 +#: ../../c-api/typeobj.rst:730 +msgid "" +"In a garbage collected Python, :c:member:`!tp_dealloc` may be called from " +"any Python thread, not just the thread which created the object (if the " +"object becomes part of a refcount 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 :c:member:`!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 :c:" +"member:`!tp_dealloc` will not violate any assumptions of the library." +msgstr "" + +#: ../../c-api/typeobj.rst:749 msgid "" "An optional offset to a per-instance function that implements calling the " "object using the :ref:`vectorcall protocol `, a more efficient " "alternative of the simpler :c:member:`~PyTypeObject.tp_call`." msgstr "" -#: ../../c-api/typeobj.rst:720 +#: ../../c-api/typeobj.rst:754 msgid "" "This field is only used if the flag :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` is " "set. If so, this must be a positive integer containing the offset in the " "instance of a :c:type:`vectorcallfunc` pointer." msgstr "" -#: ../../c-api/typeobj.rst:724 +#: ../../c-api/typeobj.rst:758 msgid "" "The *vectorcallfunc* pointer may be ``NULL``, in which case the instance " "behaves as if :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` was not set: calling the " "instance falls back to :c:member:`~PyTypeObject.tp_call`." msgstr "" -#: ../../c-api/typeobj.rst:728 +#: ../../c-api/typeobj.rst:762 msgid "" "Any class that sets ``Py_TPFLAGS_HAVE_VECTORCALL`` must also set :c:member:" "`~PyTypeObject.tp_call` and make sure its behaviour is consistent with the " @@ -1623,13 +1679,13 @@ msgid "" "`PyVectorcall_Call`." msgstr "" -#: ../../c-api/typeobj.rst:735 +#: ../../c-api/typeobj.rst:769 msgid "" "Before version 3.8, this slot was named ``tp_print``. In Python 2.x, it was " "used for printing to a file. In Python 3.0 to 3.7, it was unused." msgstr "" -#: ../../c-api/typeobj.rst:741 +#: ../../c-api/typeobj.rst:775 msgid "" "Before version 3.12, it was not recommended for :ref:`mutable heap types " "` to implement the vectorcall protocol. When a user sets :attr:" @@ -1639,7 +1695,7 @@ msgid "" "`Py_TPFLAGS_HAVE_VECTORCALL` flag." msgstr "" -#: ../../c-api/typeobj.rst:751 +#: ../../c-api/typeobj.rst:785 msgid "" "This field is always inherited. However, the :c:macro:" "`Py_TPFLAGS_HAVE_VECTORCALL` flag is not always inherited. If it's not set, " @@ -1647,11 +1703,11 @@ msgid "" "func:`PyVectorcall_Call` is explicitly called." msgstr "" -#: ../../c-api/typeobj.rst:760 +#: ../../c-api/typeobj.rst:794 msgid "An optional pointer to the get-attribute-string function." msgstr "" -#: ../../c-api/typeobj.rst:762 +#: ../../c-api/typeobj.rst:796 msgid "" "This field is deprecated. When it is defined, it should point to a function " "that acts the same as the :c:member:`~PyTypeObject.tp_getattro` function, " @@ -1659,7 +1715,7 @@ msgid "" "attribute name." msgstr "" -#: ../../c-api/typeobj.rst:768 ../../c-api/typeobj.rst:960 +#: ../../c-api/typeobj.rst:802 ../../c-api/typeobj.rst:998 msgid "" "Group: :c:member:`~PyTypeObject.tp_getattr`, :c:member:`~PyTypeObject." "tp_getattro`" @@ -1667,7 +1723,7 @@ msgstr "" "群組::c:member:`~PyTypeObject.tp_getattr`、:c:member:`~PyTypeObject." "tp_getattro`" -#: ../../c-api/typeobj.rst:770 +#: ../../c-api/typeobj.rst:804 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_getattro`: a subtype inherits both :c:member:`~PyTypeObject.tp_getattr` " @@ -1676,12 +1732,12 @@ msgid "" "tp_getattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:777 ../../c-api/typeobj.rst:973 +#: ../../c-api/typeobj.rst:811 ../../c-api/typeobj.rst:1011 msgid "" "An optional pointer to the function for setting and deleting attributes." msgstr "" -#: ../../c-api/typeobj.rst:779 +#: ../../c-api/typeobj.rst:813 msgid "" "This field is deprecated. When it is defined, it should point to a function " "that acts the same as the :c:member:`~PyTypeObject.tp_setattro` function, " @@ -1689,7 +1745,7 @@ msgid "" "attribute name." msgstr "" -#: ../../c-api/typeobj.rst:785 ../../c-api/typeobj.rst:986 +#: ../../c-api/typeobj.rst:819 ../../c-api/typeobj.rst:1024 msgid "" "Group: :c:member:`~PyTypeObject.tp_setattr`, :c:member:`~PyTypeObject." "tp_setattro`" @@ -1697,7 +1753,7 @@ msgstr "" "群組::c:member:`~PyTypeObject.tp_setattr`、:c:member:`~PyTypeObject." "tp_setattro`" -#: ../../c-api/typeobj.rst:787 +#: ../../c-api/typeobj.rst:821 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_setattro`: a subtype inherits both :c:member:`~PyTypeObject.tp_setattr` " @@ -1706,38 +1762,38 @@ msgid "" "tp_setattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:794 +#: ../../c-api/typeobj.rst:828 msgid "" "Pointer to an additional structure that contains fields relevant only to " "objects which implement :term:`awaitable` and :term:`asynchronous iterator` " "protocols at the C-level. See :ref:`async-structs` for details." msgstr "" -#: ../../c-api/typeobj.rst:798 +#: ../../c-api/typeobj.rst:832 msgid "Formerly known as ``tp_compare`` and ``tp_reserved``." msgstr "" -#: ../../c-api/typeobj.rst:803 +#: ../../c-api/typeobj.rst:837 msgid "" "The :c:member:`~PyTypeObject.tp_as_async` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:811 +#: ../../c-api/typeobj.rst:845 msgid "" "An optional pointer to a function that implements the built-in function :" "func:`repr`." msgstr "" -#: ../../c-api/typeobj.rst:814 +#: ../../c-api/typeobj.rst:848 msgid "The signature is the same as for :c:func:`PyObject_Repr`::" msgstr "" -#: ../../c-api/typeobj.rst:816 +#: ../../c-api/typeobj.rst:850 msgid "PyObject *tp_repr(PyObject *self);" msgstr "PyObject *tp_repr(PyObject *self);" -#: ../../c-api/typeobj.rst:818 +#: ../../c-api/typeobj.rst:852 msgid "" "The function must return a string or a Unicode object. Ideally, this " "function should return a string that, when passed to :func:`eval`, given a " @@ -1746,85 +1802,85 @@ msgid "" "``'>'`` from which both the type and the value of the object can be deduced." msgstr "" -#: ../../c-api/typeobj.rst:829 ../../c-api/typeobj.rst:941 -#: ../../c-api/typeobj.rst:966 ../../c-api/typeobj.rst:992 -#: ../../c-api/typeobj.rst:1033 ../../c-api/typeobj.rst:1562 -#: ../../c-api/typeobj.rst:1596 ../../c-api/typeobj.rst:1713 -#: ../../c-api/typeobj.rst:1746 ../../c-api/typeobj.rst:1821 -#: ../../c-api/typeobj.rst:1862 ../../c-api/typeobj.rst:1880 -#: ../../c-api/typeobj.rst:1922 ../../c-api/typeobj.rst:1943 -#: ../../c-api/typeobj.rst:1974 +#: ../../c-api/typeobj.rst:863 ../../c-api/typeobj.rst:942 +#: ../../c-api/typeobj.rst:979 ../../c-api/typeobj.rst:1004 +#: ../../c-api/typeobj.rst:1030 ../../c-api/typeobj.rst:1071 +#: ../../c-api/typeobj.rst:1626 ../../c-api/typeobj.rst:1660 +#: ../../c-api/typeobj.rst:1777 ../../c-api/typeobj.rst:1810 +#: ../../c-api/typeobj.rst:1885 ../../c-api/typeobj.rst:1926 +#: ../../c-api/typeobj.rst:1944 ../../c-api/typeobj.rst:1986 +#: ../../c-api/typeobj.rst:2007 ../../c-api/typeobj.rst:2038 msgid "**Default:**" msgstr "**預設:**" -#: ../../c-api/typeobj.rst:831 +#: ../../c-api/typeobj.rst:865 msgid "" "When this field is not set, a string of the form ``<%s object at %p>`` is " "returned, where ``%s`` is replaced by the type name, and ``%p`` by the " "object's memory address." msgstr "" -#: ../../c-api/typeobj.rst:838 +#: ../../c-api/typeobj.rst:872 msgid "" "Pointer to an additional structure that contains fields relevant only to " "objects which implement the number protocol. These fields are documented " "in :ref:`number-structs`." msgstr "" -#: ../../c-api/typeobj.rst:844 +#: ../../c-api/typeobj.rst:878 msgid "" "The :c:member:`~PyTypeObject.tp_as_number` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:850 +#: ../../c-api/typeobj.rst:884 msgid "" "Pointer to an additional structure that contains fields relevant only to " "objects which implement the sequence protocol. These fields are documented " "in :ref:`sequence-structs`." msgstr "" -#: ../../c-api/typeobj.rst:856 +#: ../../c-api/typeobj.rst:890 msgid "" "The :c:member:`~PyTypeObject.tp_as_sequence` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:862 +#: ../../c-api/typeobj.rst:896 msgid "" "Pointer to an additional structure that contains fields relevant only to " "objects which implement the mapping protocol. These fields are documented " "in :ref:`mapping-structs`." msgstr "" -#: ../../c-api/typeobj.rst:868 +#: ../../c-api/typeobj.rst:902 msgid "" "The :c:member:`~PyTypeObject.tp_as_mapping` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:876 +#: ../../c-api/typeobj.rst:910 msgid "" "An optional pointer to a function that implements the built-in function :" "func:`hash`." msgstr "" -#: ../../c-api/typeobj.rst:879 +#: ../../c-api/typeobj.rst:913 msgid "The signature is the same as for :c:func:`PyObject_Hash`::" msgstr "" -#: ../../c-api/typeobj.rst:881 +#: ../../c-api/typeobj.rst:915 msgid "Py_hash_t tp_hash(PyObject *);" msgstr "Py_hash_t tp_hash(PyObject *);" -#: ../../c-api/typeobj.rst:883 +#: ../../c-api/typeobj.rst:917 msgid "" "The value ``-1`` should not be returned as a normal return value; when an " "error occurs during the computation of the hash value, the function should " "set an exception and return ``-1``." msgstr "" -#: ../../c-api/typeobj.rst:887 +#: ../../c-api/typeobj.rst:921 msgid "" "When this field is not set (*and* :c:member:`~PyTypeObject.tp_richcompare` " "is not set), an attempt to take the hash of the object raises :exc:" @@ -1832,7 +1888,7 @@ msgid "" "`PyObject_HashNotImplemented`." msgstr "" -#: ../../c-api/typeobj.rst:891 +#: ../../c-api/typeobj.rst:925 msgid "" "This field can be set explicitly to :c:func:`PyObject_HashNotImplemented` to " "block inheritance of the hash method from a parent type. This is interpreted " @@ -1843,7 +1899,7 @@ msgid "" "`PyObject_HashNotImplemented`." msgstr "" -#: ../../c-api/typeobj.rst:901 ../../c-api/typeobj.rst:1555 +#: ../../c-api/typeobj.rst:935 ../../c-api/typeobj.rst:1619 msgid "" "Group: :c:member:`~PyTypeObject.tp_hash`, :c:member:`~PyTypeObject." "tp_richcompare`" @@ -1851,7 +1907,7 @@ msgstr "" "群組::c:member:`~PyTypeObject.tp_hash`、:c:member:`~PyTypeObject." "tp_richcompare`" -#: ../../c-api/typeobj.rst:903 +#: ../../c-api/typeobj.rst:937 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_richcompare`: a subtype inherits both of :c:member:`~PyTypeObject." @@ -1860,18 +1916,22 @@ msgid "" "are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:911 +#: ../../c-api/typeobj.rst:944 +msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericHash`." +msgstr "" + +#: ../../c-api/typeobj.rst:949 msgid "" "An optional pointer to a function that implements calling the object. This " "should be ``NULL`` if the object is not callable. The signature is the same " "as for :c:func:`PyObject_Call`::" msgstr "" -#: ../../c-api/typeobj.rst:915 +#: ../../c-api/typeobj.rst:953 msgid "PyObject *tp_call(PyObject *self, PyObject *args, PyObject *kwargs);" msgstr "PyObject *tp_call(PyObject *self, PyObject *args, PyObject *kwargs);" -#: ../../c-api/typeobj.rst:924 +#: ../../c-api/typeobj.rst:962 msgid "" "An optional pointer to a function that implements the built-in operation :" "func:`str`. (Note that :class:`str` is a type now, and :func:`str` calls " @@ -1880,15 +1940,15 @@ msgid "" "this handler.)" msgstr "" -#: ../../c-api/typeobj.rst:929 +#: ../../c-api/typeobj.rst:967 msgid "The signature is the same as for :c:func:`PyObject_Str`::" msgstr "" -#: ../../c-api/typeobj.rst:931 +#: ../../c-api/typeobj.rst:969 msgid "PyObject *tp_str(PyObject *self);" msgstr "PyObject *tp_str(PyObject *self);" -#: ../../c-api/typeobj.rst:933 +#: ../../c-api/typeobj.rst:971 msgid "" "The function must return a string or a Unicode object. It should be a " "\"friendly\" string representation of the object, as this is the " @@ -1896,32 +1956,32 @@ msgid "" "function." msgstr "" -#: ../../c-api/typeobj.rst:943 +#: ../../c-api/typeobj.rst:981 msgid "" "When this field is not set, :c:func:`PyObject_Repr` is called to return a " "string representation." msgstr "" -#: ../../c-api/typeobj.rst:949 +#: ../../c-api/typeobj.rst:987 msgid "An optional pointer to the get-attribute function." msgstr "" -#: ../../c-api/typeobj.rst:951 +#: ../../c-api/typeobj.rst:989 msgid "The signature is the same as for :c:func:`PyObject_GetAttr`::" msgstr "" -#: ../../c-api/typeobj.rst:953 +#: ../../c-api/typeobj.rst:991 msgid "PyObject *tp_getattro(PyObject *self, PyObject *attr);" msgstr "PyObject *tp_getattro(PyObject *self, PyObject *attr);" -#: ../../c-api/typeobj.rst:955 +#: ../../c-api/typeobj.rst:993 msgid "" "It is usually convenient to set this field to :c:func:" "`PyObject_GenericGetAttr`, which implements the normal way of looking for " "object attributes." msgstr "" -#: ../../c-api/typeobj.rst:962 +#: ../../c-api/typeobj.rst:1000 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_getattr`: a subtype inherits both :c:member:`~PyTypeObject.tp_getattr` " @@ -1930,19 +1990,19 @@ msgid "" "tp_getattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:968 +#: ../../c-api/typeobj.rst:1006 msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericGetAttr`." msgstr "" -#: ../../c-api/typeobj.rst:975 +#: ../../c-api/typeobj.rst:1013 msgid "The signature is the same as for :c:func:`PyObject_SetAttr`::" msgstr "" -#: ../../c-api/typeobj.rst:977 +#: ../../c-api/typeobj.rst:1015 msgid "int tp_setattro(PyObject *self, PyObject *attr, PyObject *value);" msgstr "int tp_setattro(PyObject *self, PyObject *attr, PyObject *value);" -#: ../../c-api/typeobj.rst:979 +#: ../../c-api/typeobj.rst:1017 msgid "" "In addition, setting *value* to ``NULL`` to delete an attribute must be " "supported. It is usually convenient to set this field to :c:func:" @@ -1950,7 +2010,7 @@ msgid "" "attributes." msgstr "" -#: ../../c-api/typeobj.rst:988 +#: ../../c-api/typeobj.rst:1026 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_setattr`: a subtype inherits both :c:member:`~PyTypeObject.tp_setattr` " @@ -1959,24 +2019,24 @@ msgid "" "tp_setattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:994 +#: ../../c-api/typeobj.rst:1032 msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericSetAttr`." msgstr "" -#: ../../c-api/typeobj.rst:999 +#: ../../c-api/typeobj.rst:1037 msgid "" "Pointer to an additional structure that contains fields relevant only to " "objects which implement the buffer interface. These fields are documented " "in :ref:`buffer-structs`." msgstr "" -#: ../../c-api/typeobj.rst:1005 +#: ../../c-api/typeobj.rst:1043 msgid "" "The :c:member:`~PyTypeObject.tp_as_buffer` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:1011 +#: ../../c-api/typeobj.rst:1049 msgid "" "This field is a bit mask of various flags. Some flags indicate variant " "semantics for certain situations; others are used to indicate that certain " @@ -1988,7 +2048,7 @@ msgid "" "accessed and must be considered to have a zero or ``NULL`` value instead." msgstr "" -#: ../../c-api/typeobj.rst:1021 +#: ../../c-api/typeobj.rst:1059 msgid "" "Inheritance of this field is complicated. Most flag bits are inherited " "individually, i.e. if the base type has a flag bit set, the subtype inherits " @@ -2004,7 +2064,7 @@ msgid "" "*really* inherited individually?" msgstr "" -#: ../../c-api/typeobj.rst:1035 +#: ../../c-api/typeobj.rst:1073 msgid "" ":c:data:`PyBaseObject_Type` uses ``Py_TPFLAGS_DEFAULT | " "Py_TPFLAGS_BASETYPE``." @@ -2012,11 +2072,11 @@ msgstr "" ":c:data:`PyBaseObject_Type` 使用 ``Py_TPFLAGS_DEFAULT | " "Py_TPFLAGS_BASETYPE``。" -#: ../../c-api/typeobj.rst:1038 +#: ../../c-api/typeobj.rst:1076 msgid "**Bit Masks:**" msgstr "" -#: ../../c-api/typeobj.rst:1042 +#: ../../c-api/typeobj.rst:1080 msgid "" "The following bit masks are currently defined; these can be ORed together " "using the ``|`` operator to form the value of the :c:member:`~PyTypeObject." @@ -2025,7 +2085,7 @@ msgid "" "zero." msgstr "" -#: ../../c-api/typeobj.rst:1049 +#: ../../c-api/typeobj.rst:1087 msgid "" "This bit is set when the type object itself is allocated on the heap, for " "example, types created dynamically using :c:func:`PyType_FromSpec`. In this " @@ -2038,32 +2098,32 @@ msgid "" "reference cycle with their own module object." msgstr "" -#: ../../c-api/typeobj.rst:1060 ../../c-api/typeobj.rst:1071 -#: ../../c-api/typeobj.rst:1081 ../../c-api/typeobj.rst:1091 -#: ../../c-api/typeobj.rst:1123 +#: ../../c-api/typeobj.rst:1098 ../../c-api/typeobj.rst:1109 +#: ../../c-api/typeobj.rst:1119 ../../c-api/typeobj.rst:1129 +#: ../../c-api/typeobj.rst:1161 msgid "???" msgstr "???" -#: ../../c-api/typeobj.rst:1065 +#: ../../c-api/typeobj.rst:1103 msgid "" "This bit is set when the type can be used as the base type of another type. " "If this bit is clear, the type cannot be subtyped (similar to a \"final\" " "class in Java)." msgstr "" -#: ../../c-api/typeobj.rst:1076 +#: ../../c-api/typeobj.rst:1114 msgid "" "This bit is set when the type object has been fully initialized by :c:func:" "`PyType_Ready`." msgstr "" -#: ../../c-api/typeobj.rst:1086 +#: ../../c-api/typeobj.rst:1124 msgid "" "This bit is set while :c:func:`PyType_Ready` is in the process of " "initializing the type object." msgstr "" -#: ../../c-api/typeobj.rst:1096 +#: ../../c-api/typeobj.rst:1134 msgid "" "This bit is set when the object supports garbage collection. If this bit is " "set, instances must be created using :c:macro:`PyObject_GC_New` and " @@ -2073,14 +2133,14 @@ msgid "" "tp_clear` are present in the type object." msgstr "" -#: ../../c-api/typeobj.rst:1105 ../../c-api/typeobj.rst:1426 -#: ../../c-api/typeobj.rst:1494 +#: ../../c-api/typeobj.rst:1143 ../../c-api/typeobj.rst:1484 +#: ../../c-api/typeobj.rst:1558 msgid "" "Group: :c:macro:`Py_TPFLAGS_HAVE_GC`, :c:member:`~PyTypeObject." "tp_traverse`, :c:member:`~PyTypeObject.tp_clear`" msgstr "" -#: ../../c-api/typeobj.rst:1107 +#: ../../c-api/typeobj.rst:1145 msgid "" "The :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is inherited together with the :c:" "member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` " @@ -2090,99 +2150,106 @@ msgid "" "values." msgstr "" -#: ../../c-api/typeobj.rst:1117 +#: ../../c-api/typeobj.rst:1155 msgid "" "This is a bitmask of all the bits that pertain to the existence of certain " "fields in the type object and its extension structures. Currently, it " "includes the following bits: :c:macro:`Py_TPFLAGS_HAVE_STACKLESS_EXTENSION`." msgstr "" -#: ../../c-api/typeobj.rst:1128 +#: ../../c-api/typeobj.rst:1166 msgid "This bit indicates that objects behave like unbound methods." msgstr "" -#: ../../c-api/typeobj.rst:1130 +#: ../../c-api/typeobj.rst:1168 msgid "If this flag is set for ``type(meth)``, then:" msgstr "" -#: ../../c-api/typeobj.rst:1132 +#: ../../c-api/typeobj.rst:1170 msgid "" "``meth.__get__(obj, cls)(*args, **kwds)`` (with ``obj`` not None) must be " "equivalent to ``meth(obj, *args, **kwds)``." msgstr "" -#: ../../c-api/typeobj.rst:1135 +#: ../../c-api/typeobj.rst:1173 msgid "" "``meth.__get__(None, cls)(*args, **kwds)`` must be equivalent to " "``meth(*args, **kwds)``." msgstr "" -#: ../../c-api/typeobj.rst:1138 +#: ../../c-api/typeobj.rst:1176 msgid "" "This flag enables an optimization for typical method calls like ``obj." "meth()``: it avoids creating a temporary \"bound method\" object for ``obj." "meth``." msgstr "" -#: ../../c-api/typeobj.rst:1146 +#: ../../c-api/typeobj.rst:1184 msgid "" "This flag is never inherited by types without the :c:macro:" "`Py_TPFLAGS_IMMUTABLETYPE` flag set. For extension types, it is inherited " "whenever :c:member:`~PyTypeObject.tp_descr_get` is inherited." msgstr "" -#: ../../c-api/typeobj.rst:1152 +#: ../../c-api/typeobj.rst:1190 msgid "" -"This bit indicates that instances of the class have a ``__dict__`` " -"attribute, and that the space for the dictionary is managed by the VM." +"This bit indicates that instances of the class have a :attr:`~object." +"__dict__` attribute, and that the space for the dictionary is managed by the " +"VM." msgstr "" -#: ../../c-api/typeobj.rst:1155 +#: ../../c-api/typeobj.rst:1193 msgid "If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` should also be set." msgstr "" -#: ../../c-api/typeobj.rst:1161 +#: ../../c-api/typeobj.rst:1195 +msgid "" +"The type traverse function must call :c:func:`PyObject_VisitManagedDict` and " +"its clear function must call :c:func:`PyObject_ClearManagedDict`." +msgstr "" + +#: ../../c-api/typeobj.rst:1202 msgid "" "This flag is inherited unless the :c:member:`~PyTypeObject.tp_dictoffset` " "field is set in a superclass." msgstr "" -#: ../../c-api/typeobj.rst:1167 +#: ../../c-api/typeobj.rst:1208 msgid "" "This bit indicates that instances of the class should be weakly " "referenceable." msgstr "" -#: ../../c-api/typeobj.rst:1174 +#: ../../c-api/typeobj.rst:1215 msgid "" "This flag is inherited unless the :c:member:`~PyTypeObject." "tp_weaklistoffset` field is set in a superclass." msgstr "" -#: ../../c-api/typeobj.rst:1180 +#: ../../c-api/typeobj.rst:1221 msgid "" "Only usable with variable-size types, i.e. ones with non-zero :c:member:" "`~PyTypeObject.tp_itemsize`." msgstr "" -#: ../../c-api/typeobj.rst:1183 +#: ../../c-api/typeobj.rst:1224 msgid "" "Indicates that the variable-sized portion of an instance of this type is at " "the end of the instance's memory area, at an offset of ``Py_TYPE(obj)-" ">tp_basicsize`` (which may be different in each subclass)." msgstr "" -#: ../../c-api/typeobj.rst:1188 +#: ../../c-api/typeobj.rst:1229 msgid "" "When setting this flag, be sure that all superclasses either use this memory " "layout, or are not variable-sized. Python does not check this." msgstr "" -#: ../../c-api/typeobj.rst:1196 +#: ../../c-api/typeobj.rst:1237 msgid "This flag is inherited." msgstr "" -#: ../../c-api/typeobj.rst:1210 +#: ../../c-api/typeobj.rst:1251 msgid "" "These flags are used by functions such as :c:func:`PyLong_Check` to quickly " "determine if a type is a subclass of a built-in type; such specific checks " @@ -2192,90 +2259,90 @@ msgid "" "behave differently depending on what kind of check is used." msgstr "" -#: ../../c-api/typeobj.rst:1221 +#: ../../c-api/typeobj.rst:1262 msgid "" "This bit is set when the :c:member:`~PyTypeObject.tp_finalize` slot is " "present in the type structure." msgstr "" -#: ../../c-api/typeobj.rst:1226 +#: ../../c-api/typeobj.rst:1267 msgid "" "This flag isn't necessary anymore, as the interpreter assumes the :c:member:" "`~PyTypeObject.tp_finalize` slot is always present in the type structure." msgstr "" -#: ../../c-api/typeobj.rst:1234 +#: ../../c-api/typeobj.rst:1275 msgid "" "This bit is set when the class implements the :ref:`vectorcall protocol " "`. See :c:member:`~PyTypeObject.tp_vectorcall_offset` for " "details." msgstr "" -#: ../../c-api/typeobj.rst:1240 +#: ../../c-api/typeobj.rst:1281 msgid "" "This bit is inherited if :c:member:`~PyTypeObject.tp_call` is also inherited." msgstr "" -#: ../../c-api/typeobj.rst:1247 +#: ../../c-api/typeobj.rst:1288 msgid "" "This flag is now removed from a class when the class's :py:meth:`~object." "__call__` method is reassigned." msgstr "" -#: ../../c-api/typeobj.rst:1250 +#: ../../c-api/typeobj.rst:1291 msgid "This flag can now be inherited by mutable classes." msgstr "" -#: ../../c-api/typeobj.rst:1254 +#: ../../c-api/typeobj.rst:1295 msgid "" "This bit is set for type objects that are immutable: type attributes cannot " "be set nor deleted." msgstr "" -#: ../../c-api/typeobj.rst:1256 +#: ../../c-api/typeobj.rst:1297 msgid "" ":c:func:`PyType_Ready` automatically applies this flag to :ref:`static types " "`." msgstr "" -#: ../../c-api/typeobj.rst:1261 +#: ../../c-api/typeobj.rst:1302 msgid "This flag is not inherited." msgstr "" -#: ../../c-api/typeobj.rst:1267 +#: ../../c-api/typeobj.rst:1308 msgid "" "Disallow creating instances of the type: set :c:member:`~PyTypeObject." "tp_new` to NULL and don't create the ``__new__`` key in the type dictionary." msgstr "" -#: ../../c-api/typeobj.rst:1271 +#: ../../c-api/typeobj.rst:1312 msgid "" "The flag must be set before creating the type, not after. For example, it " "must be set before :c:func:`PyType_Ready` is called on the type." msgstr "" -#: ../../c-api/typeobj.rst:1274 +#: ../../c-api/typeobj.rst:1315 msgid "" "The flag is set automatically on :ref:`static types ` if :c:" "member:`~PyTypeObject.tp_base` is NULL or ``&PyBaseObject_Type`` and :c:" "member:`~PyTypeObject.tp_new` is NULL." msgstr "" -#: ../../c-api/typeobj.rst:1280 +#: ../../c-api/typeobj.rst:1321 msgid "" "This flag is not inherited. However, subclasses will not be instantiable " "unless they provide a non-NULL :c:member:`~PyTypeObject.tp_new` (which is " "only possible via the C API)." msgstr "" -#: ../../c-api/typeobj.rst:1287 +#: ../../c-api/typeobj.rst:1328 msgid "" "To disallow instantiating a class directly but allow instantiating its " "subclasses (e.g. for an :term:`abstract base class`), do not use this flag. " "Instead, make :c:member:`~PyTypeObject.tp_new` only succeed for subclasses." msgstr "" -#: ../../c-api/typeobj.rst:1298 +#: ../../c-api/typeobj.rst:1339 msgid "" "This bit indicates that instances of the class may match mapping patterns " "when used as the subject of a :keyword:`match` block. It is automatically " @@ -2283,23 +2350,23 @@ msgid "" "unset when registering :class:`collections.abc.Sequence`." msgstr "" -#: ../../c-api/typeobj.rst:1305 ../../c-api/typeobj.rst:1327 +#: ../../c-api/typeobj.rst:1346 ../../c-api/typeobj.rst:1368 msgid "" ":c:macro:`Py_TPFLAGS_MAPPING` and :c:macro:`Py_TPFLAGS_SEQUENCE` are " "mutually exclusive; it is an error to enable both flags simultaneously." msgstr "" -#: ../../c-api/typeobj.rst:1310 +#: ../../c-api/typeobj.rst:1351 msgid "" "This flag is inherited by types that do not already set :c:macro:" "`Py_TPFLAGS_SEQUENCE`." msgstr "" -#: ../../c-api/typeobj.rst:1313 ../../c-api/typeobj.rst:1335 +#: ../../c-api/typeobj.rst:1354 ../../c-api/typeobj.rst:1376 msgid ":pep:`634` -- Structural Pattern Matching: Specification" msgstr "" -#: ../../c-api/typeobj.rst:1320 +#: ../../c-api/typeobj.rst:1361 msgid "" "This bit indicates that instances of the class may match sequence patterns " "when used as the subject of a :keyword:`match` block. It is automatically " @@ -2307,53 +2374,53 @@ msgid "" "unset when registering :class:`collections.abc.Mapping`." msgstr "" -#: ../../c-api/typeobj.rst:1332 +#: ../../c-api/typeobj.rst:1373 msgid "" "This flag is inherited by types that do not already set :c:macro:" "`Py_TPFLAGS_MAPPING`." msgstr "" -#: ../../c-api/typeobj.rst:1342 +#: ../../c-api/typeobj.rst:1383 msgid "" "Internal. Do not set or unset this flag. To indicate that a class has " "changed call :c:func:`PyType_Modified`" msgstr "" -#: ../../c-api/typeobj.rst:1346 +#: ../../c-api/typeobj.rst:1387 msgid "" -"This flag is present in header files, but is an internal feature and should " -"not be used. It will be removed in a future version of CPython" +"This flag is present in header files, but is not be used. It will be removed " +"in a future version of CPython" msgstr "" -#: ../../c-api/typeobj.rst:1352 +#: ../../c-api/typeobj.rst:1393 msgid "" "An optional pointer to a NUL-terminated C string giving the docstring for " -"this type object. This is exposed as the :attr:`__doc__` attribute on the " -"type and instances of the type." +"this type object. This is exposed as the :attr:`~type.__doc__` attribute on " +"the type and instances of the type." msgstr "" -#: ../../c-api/typeobj.rst:1358 +#: ../../c-api/typeobj.rst:1399 msgid "This field is *not* inherited by subtypes." msgstr "" -#: ../../c-api/typeobj.rst:1363 +#: ../../c-api/typeobj.rst:1404 msgid "" "An optional pointer to a traversal function for the garbage collector. This " "is only used if the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is set. The " "signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1366 +#: ../../c-api/typeobj.rst:1407 msgid "int tp_traverse(PyObject *self, visitproc visit, void *arg);" msgstr "int tp_traverse(PyObject *self, visitproc visit, void *arg);" -#: ../../c-api/typeobj.rst:1368 ../../c-api/typeobj.rst:1489 +#: ../../c-api/typeobj.rst:1409 ../../c-api/typeobj.rst:1553 msgid "" "More information about Python's garbage collection scheme can be found in " "section :ref:`supporting-cycle-detection`." msgstr "" -#: ../../c-api/typeobj.rst:1371 +#: ../../c-api/typeobj.rst:1412 msgid "" "The :c:member:`~PyTypeObject.tp_traverse` pointer is used by the garbage " "collector to detect reference cycles. A typical implementation of a :c:" @@ -2363,7 +2430,7 @@ msgid "" "`!_thread` extension module::" msgstr "" -#: ../../c-api/typeobj.rst:1377 +#: ../../c-api/typeobj.rst:1418 msgid "" "static int\n" "local_traverse(localobject *self, visitproc visit, void *arg)\n" @@ -2383,7 +2450,7 @@ msgstr "" " return 0;\n" "}" -#: ../../c-api/typeobj.rst:1386 +#: ../../c-api/typeobj.rst:1427 msgid "" "Note that :c:func:`Py_VISIT` is called only on those members that can " "participate in reference cycles. Although there is also a ``self->key`` " @@ -2391,14 +2458,50 @@ msgid "" "part of a reference cycle." msgstr "" -#: ../../c-api/typeobj.rst:1390 +#: ../../c-api/typeobj.rst:1431 msgid "" "On the other hand, even if you know a member can never be part of a cycle, " "as a debugging aid you may want to visit it anyway just so the :mod:`gc` " "module's :func:`~gc.get_referents` function will include it." msgstr "" -#: ../../c-api/typeobj.rst:1395 +#: ../../c-api/typeobj.rst:1435 +msgid "" +"Heap types (:c:macro:`Py_TPFLAGS_HEAPTYPE`) must visit their type with::" +msgstr "" + +#: ../../c-api/typeobj.rst:1437 +msgid "Py_VISIT(Py_TYPE(self));" +msgstr "Py_VISIT(Py_TYPE(self));" + +#: ../../c-api/typeobj.rst:1439 +msgid "" +"It is only needed since Python 3.9. To support Python 3.8 and older, this " +"line must be conditional::" +msgstr "" + +#: ../../c-api/typeobj.rst:1442 +msgid "" +"#if PY_VERSION_HEX >= 0x03090000\n" +" Py_VISIT(Py_TYPE(self));\n" +"#endif" +msgstr "" +"#if PY_VERSION_HEX >= 0x03090000\n" +" Py_VISIT(Py_TYPE(self));\n" +"#endif" + +#: ../../c-api/typeobj.rst:1446 +msgid "" +"If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the :c:member:" +"`~PyTypeObject.tp_flags` field, the traverse function must call :c:func:" +"`PyObject_VisitManagedDict` like this::" +msgstr "" + +#: ../../c-api/typeobj.rst:1450 +msgid "PyObject_VisitManagedDict((PyObject*)self, visit, arg);" +msgstr "PyObject_VisitManagedDict((PyObject*)self, visit, arg);" + +#: ../../c-api/typeobj.rst:1453 msgid "" "When implementing :c:member:`~PyTypeObject.tp_traverse`, only the members " "that the instance *owns* (by having :term:`strong references ` hold a reference to " "their type. Their traversal function must therefore either visit :c:func:" @@ -2427,14 +2530,14 @@ msgid "" "superclass). If they do not, the type object may not be garbage-collected." msgstr "" -#: ../../c-api/typeobj.rst:1419 +#: ../../c-api/typeobj.rst:1477 msgid "" "Heap-allocated types are expected to visit ``Py_TYPE(self)`` in " "``tp_traverse``. In earlier versions of Python, due to `bug 40217 `_, doing this may lead to crashes in subclasses." msgstr "" -#: ../../c-api/typeobj.rst:1428 +#: ../../c-api/typeobj.rst:1486 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_clear` and the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :c:" @@ -2442,18 +2545,18 @@ msgid "" "are all inherited from the base type if they are all zero in the subtype." msgstr "" -#: ../../c-api/typeobj.rst:1436 +#: ../../c-api/typeobj.rst:1494 msgid "" "An optional pointer to a clear function for the garbage collector. This is " "only used if the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is set. The " "signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1439 +#: ../../c-api/typeobj.rst:1497 msgid "int tp_clear(PyObject *);" msgstr "int tp_clear(PyObject *);" -#: ../../c-api/typeobj.rst:1441 +#: ../../c-api/typeobj.rst:1499 msgid "" "The :c:member:`~PyTypeObject.tp_clear` member function is used to break " "reference cycles in cyclic garbage detected by the garbage collector. Taken " @@ -2468,7 +2571,7 @@ msgid "" "good reason to avoid implementing :c:member:`~PyTypeObject.tp_clear`." msgstr "" -#: ../../c-api/typeobj.rst:1451 +#: ../../c-api/typeobj.rst:1509 msgid "" "Implementations of :c:member:`~PyTypeObject.tp_clear` should drop the " "instance's references to those of its members that may be Python objects, " @@ -2476,7 +2579,7 @@ msgid "" "example::" msgstr "" -#: ../../c-api/typeobj.rst:1455 +#: ../../c-api/typeobj.rst:1513 msgid "" "static int\n" "local_clear(localobject *self)\n" @@ -2498,7 +2601,7 @@ msgstr "" " return 0;\n" "}" -#: ../../c-api/typeobj.rst:1465 +#: ../../c-api/typeobj.rst:1523 msgid "" "The :c:func:`Py_CLEAR` macro should be used, because clearing references is " "delicate: the reference to the contained object must not be released (via :" @@ -2513,7 +2616,18 @@ msgid "" "performs the operations in a safe order." msgstr "" -#: ../../c-api/typeobj.rst:1477 +#: ../../c-api/typeobj.rst:1535 +msgid "" +"If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the :c:member:" +"`~PyTypeObject.tp_flags` field, the traverse function must call :c:func:" +"`PyObject_ClearManagedDict` like this::" +msgstr "" + +#: ../../c-api/typeobj.rst:1539 +msgid "PyObject_ClearManagedDict((PyObject*)self);" +msgstr "PyObject_ClearManagedDict((PyObject*)self);" + +#: ../../c-api/typeobj.rst:1541 msgid "" "Note that :c:member:`~PyTypeObject.tp_clear` is not *always* called before " "an instance is deallocated. For example, when reference counting is enough " @@ -2521,7 +2635,7 @@ msgid "" "is not involved and :c:member:`~PyTypeObject.tp_dealloc` is called directly." msgstr "" -#: ../../c-api/typeobj.rst:1483 +#: ../../c-api/typeobj.rst:1547 msgid "" "Because the goal of :c:member:`~PyTypeObject.tp_clear` functions is to break " "reference cycles, it's not necessary to clear contained objects like Python " @@ -2531,7 +2645,7 @@ msgid "" "invoke :c:member:`~PyTypeObject.tp_clear`." msgstr "" -#: ../../c-api/typeobj.rst:1496 +#: ../../c-api/typeobj.rst:1560 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_traverse` and the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :" @@ -2539,22 +2653,22 @@ msgid "" "are all inherited from the base type if they are all zero in the subtype." msgstr "" -#: ../../c-api/typeobj.rst:1504 +#: ../../c-api/typeobj.rst:1568 msgid "" "An optional pointer to the rich comparison function, whose signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1506 +#: ../../c-api/typeobj.rst:1570 msgid "PyObject *tp_richcompare(PyObject *self, PyObject *other, int op);" msgstr "PyObject *tp_richcompare(PyObject *self, PyObject *other, int op);" -#: ../../c-api/typeobj.rst:1508 +#: ../../c-api/typeobj.rst:1572 msgid "" "The first parameter is guaranteed to be an instance of the type that is " "defined by :c:type:`PyTypeObject`." msgstr "" -#: ../../c-api/typeobj.rst:1511 +#: ../../c-api/typeobj.rst:1575 msgid "" "The function should return the result of the comparison (usually ``Py_True`` " "or ``Py_False``). If the comparison is undefined, it must return " @@ -2562,50 +2676,50 @@ msgid "" "set an exception condition." msgstr "" -#: ../../c-api/typeobj.rst:1516 +#: ../../c-api/typeobj.rst:1580 msgid "" "The following constants are defined to be used as the third argument for :c:" "member:`~PyTypeObject.tp_richcompare` and for :c:func:`PyObject_RichCompare`:" msgstr "" -#: ../../c-api/typeobj.rst:1522 +#: ../../c-api/typeobj.rst:1586 msgid "Constant" msgstr "常數" -#: ../../c-api/typeobj.rst:1522 +#: ../../c-api/typeobj.rst:1586 msgid "Comparison" msgstr "" -#: ../../c-api/typeobj.rst:1524 +#: ../../c-api/typeobj.rst:1588 msgid "``<``" msgstr "``<``" -#: ../../c-api/typeobj.rst:1526 +#: ../../c-api/typeobj.rst:1590 msgid "``<=``" msgstr "``<=``" -#: ../../c-api/typeobj.rst:1528 +#: ../../c-api/typeobj.rst:1592 msgid "``==``" msgstr "``==``" -#: ../../c-api/typeobj.rst:1530 +#: ../../c-api/typeobj.rst:1594 msgid "``!=``" msgstr "``!=``" -#: ../../c-api/typeobj.rst:1532 +#: ../../c-api/typeobj.rst:1596 msgid "``>``" msgstr "``>``" -#: ../../c-api/typeobj.rst:1534 +#: ../../c-api/typeobj.rst:1598 msgid "``>=``" msgstr "``>=``" -#: ../../c-api/typeobj.rst:1537 +#: ../../c-api/typeobj.rst:1601 msgid "" "The following macro is defined to ease writing rich comparison functions:" msgstr "" -#: ../../c-api/typeobj.rst:1541 +#: ../../c-api/typeobj.rst:1605 msgid "" "Return ``Py_True`` or ``Py_False`` from the function, depending on the " "result of a comparison. VAL_A and VAL_B must be orderable by C comparison " @@ -2613,15 +2727,15 @@ msgid "" "specifies the requested operation, as for :c:func:`PyObject_RichCompare`." msgstr "" -#: ../../c-api/typeobj.rst:1547 +#: ../../c-api/typeobj.rst:1611 msgid "The returned value is a new :term:`strong reference`." msgstr "" -#: ../../c-api/typeobj.rst:1549 +#: ../../c-api/typeobj.rst:1613 msgid "On error, sets an exception and returns ``NULL`` from the function." msgstr "" -#: ../../c-api/typeobj.rst:1557 +#: ../../c-api/typeobj.rst:1621 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_hash`: a subtype inherits :c:member:`~PyTypeObject.tp_richcompare` and :c:" @@ -2629,7 +2743,7 @@ msgid "" "tp_richcompare` and :c:member:`~PyTypeObject.tp_hash` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:1564 +#: ../../c-api/typeobj.rst:1628 msgid "" ":c:data:`PyBaseObject_Type` provides a :c:member:`~PyTypeObject." "tp_richcompare` implementation, which may be inherited. However, if only :c:" @@ -2638,13 +2752,13 @@ msgid "" "comparisons." msgstr "" -#: ../../c-api/typeobj.rst:1573 +#: ../../c-api/typeobj.rst:1637 msgid "" "While this field is still supported, :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` " "should be used instead, if at all possible." msgstr "" -#: ../../c-api/typeobj.rst:1576 +#: ../../c-api/typeobj.rst:1640 msgid "" "If the instances of this type are weakly referenceable, this field is " "greater than zero and contains the offset in the instance structure of the " @@ -2654,19 +2768,19 @@ msgid "" "`PyObject*` which is initialized to ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:1583 +#: ../../c-api/typeobj.rst:1647 msgid "" "Do not confuse this field with :c:member:`~PyTypeObject.tp_weaklist`; that " "is the list head for weak references to the type object itself." msgstr "" -#: ../../c-api/typeobj.rst:1586 +#: ../../c-api/typeobj.rst:1650 msgid "" "It is an error to set both the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit " "and :c:member:`~PyTypeObject.tp_weaklistoffset`." msgstr "" -#: ../../c-api/typeobj.rst:1591 +#: ../../c-api/typeobj.rst:1655 msgid "" "This field is inherited by subtypes, but see the rules listed below. A " "subtype may override this offset; this means that the subtype uses a " @@ -2675,7 +2789,7 @@ msgid "" "not be a problem." msgstr "" -#: ../../c-api/typeobj.rst:1598 +#: ../../c-api/typeobj.rst:1662 msgid "" "If the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit is set in the :c:member:" "`~PyTypeObject.tp_flags` field, then :c:member:`~PyTypeObject." @@ -2683,32 +2797,32 @@ msgid "" "unsafe to use this field." msgstr "" -#: ../../c-api/typeobj.rst:1606 +#: ../../c-api/typeobj.rst:1670 msgid "" "An optional pointer to a function that returns an :term:`iterator` for the " "object. Its presence normally signals that the instances of this type are :" "term:`iterable` (although sequences may be iterable without this function)." msgstr "" -#: ../../c-api/typeobj.rst:1610 +#: ../../c-api/typeobj.rst:1674 msgid "This function has the same signature as :c:func:`PyObject_GetIter`::" msgstr "" -#: ../../c-api/typeobj.rst:1612 +#: ../../c-api/typeobj.rst:1676 msgid "PyObject *tp_iter(PyObject *self);" msgstr "PyObject *tp_iter(PyObject *self);" -#: ../../c-api/typeobj.rst:1621 +#: ../../c-api/typeobj.rst:1685 msgid "" "An optional pointer to a function that returns the next item in an :term:" "`iterator`. The signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1624 +#: ../../c-api/typeobj.rst:1688 msgid "PyObject *tp_iternext(PyObject *self);" msgstr "PyObject *tp_iternext(PyObject *self);" -#: ../../c-api/typeobj.rst:1626 +#: ../../c-api/typeobj.rst:1690 msgid "" "When the iterator is exhausted, it must return ``NULL``; a :exc:" "`StopIteration` exception may or may not be set. When another error occurs, " @@ -2716,74 +2830,74 @@ msgid "" "this type are iterators." msgstr "" -#: ../../c-api/typeobj.rst:1631 +#: ../../c-api/typeobj.rst:1695 msgid "" "Iterator types should also define the :c:member:`~PyTypeObject.tp_iter` " "function, and that function should return the iterator instance itself (not " "a new iterator instance)." msgstr "" -#: ../../c-api/typeobj.rst:1635 +#: ../../c-api/typeobj.rst:1699 msgid "This function has the same signature as :c:func:`PyIter_Next`." msgstr "" -#: ../../c-api/typeobj.rst:1644 +#: ../../c-api/typeobj.rst:1708 msgid "" "An optional pointer to a static ``NULL``-terminated array of :c:type:" "`PyMethodDef` structures, declaring regular methods of this type." msgstr "" -#: ../../c-api/typeobj.rst:1647 +#: ../../c-api/typeobj.rst:1711 msgid "" "For each entry in the array, an entry is added to the type's dictionary " "(see :c:member:`~PyTypeObject.tp_dict` below) containing a method descriptor." msgstr "" -#: ../../c-api/typeobj.rst:1652 +#: ../../c-api/typeobj.rst:1716 msgid "" "This field is not inherited by subtypes (methods are inherited through a " "different mechanism)." msgstr "" -#: ../../c-api/typeobj.rst:1658 +#: ../../c-api/typeobj.rst:1722 msgid "" "An optional pointer to a static ``NULL``-terminated array of :c:type:" "`PyMemberDef` structures, declaring regular data members (fields or slots) " "of instances of this type." msgstr "" -#: ../../c-api/typeobj.rst:1662 +#: ../../c-api/typeobj.rst:1726 msgid "" "For each entry in the array, an entry is added to the type's dictionary " "(see :c:member:`~PyTypeObject.tp_dict` below) containing a member descriptor." msgstr "" -#: ../../c-api/typeobj.rst:1667 +#: ../../c-api/typeobj.rst:1731 msgid "" "This field is not inherited by subtypes (members are inherited through a " "different mechanism)." msgstr "" -#: ../../c-api/typeobj.rst:1673 +#: ../../c-api/typeobj.rst:1737 msgid "" "An optional pointer to a static ``NULL``-terminated array of :c:type:" "`PyGetSetDef` structures, declaring computed attributes of instances of this " "type." msgstr "" -#: ../../c-api/typeobj.rst:1676 +#: ../../c-api/typeobj.rst:1740 msgid "" "For each entry in the array, an entry is added to the type's dictionary " "(see :c:member:`~PyTypeObject.tp_dict` below) containing a getset descriptor." msgstr "" -#: ../../c-api/typeobj.rst:1681 +#: ../../c-api/typeobj.rst:1745 msgid "" "This field is not inherited by subtypes (computed attributes are inherited " "through a different mechanism)." msgstr "" -#: ../../c-api/typeobj.rst:1687 +#: ../../c-api/typeobj.rst:1751 msgid "" "An optional pointer to a base type from which type properties are " "inherited. At this level, only single inheritance is supported; multiple " @@ -2791,7 +2905,7 @@ msgid "" "metatype." msgstr "" -#: ../../c-api/typeobj.rst:1695 +#: ../../c-api/typeobj.rst:1759 msgid "" "Slot initialization is subject to the rules of initializing globals. C99 " "requires the initializers to be \"address constants\". Function designators " @@ -2799,7 +2913,7 @@ msgid "" "valid C99 address constants." msgstr "" -#: ../../c-api/typeobj.rst:1700 +#: ../../c-api/typeobj.rst:1764 msgid "" "However, the unary '&' operator applied to a non-static variable like :c:" "data:`PyBaseObject_Type` is not required to produce an address constant. " @@ -2807,27 +2921,27 @@ msgid "" "strictly standard conforming in this particular behavior." msgstr "" -#: ../../c-api/typeobj.rst:1706 +#: ../../c-api/typeobj.rst:1770 msgid "" "Consequently, :c:member:`~PyTypeObject.tp_base` should be set in the " "extension module's init function." msgstr "" -#: ../../c-api/typeobj.rst:1711 +#: ../../c-api/typeobj.rst:1775 msgid "This field is not inherited by subtypes (obviously)." msgstr "" -#: ../../c-api/typeobj.rst:1715 +#: ../../c-api/typeobj.rst:1779 msgid "" "This field defaults to ``&PyBaseObject_Type`` (which to Python programmers " "is known as the type :class:`object`)." msgstr "" -#: ../../c-api/typeobj.rst:1721 +#: ../../c-api/typeobj.rst:1785 msgid "The type's dictionary is stored here by :c:func:`PyType_Ready`." msgstr "" -#: ../../c-api/typeobj.rst:1723 +#: ../../c-api/typeobj.rst:1787 msgid "" "This field should normally be initialized to ``NULL`` before PyType_Ready is " "called; it may also be initialized to a dictionary containing initial " @@ -2838,73 +2952,73 @@ msgid "" "be treated as read-only." msgstr "" -#: ../../c-api/typeobj.rst:1731 +#: ../../c-api/typeobj.rst:1795 msgid "" "Some types may not store their dictionary in this slot. Use :c:func:" "`PyType_GetDict` to retrieve the dictionary for an arbitrary type." msgstr "" -#: ../../c-api/typeobj.rst:1737 +#: ../../c-api/typeobj.rst:1801 msgid "" "Internals detail: For static builtin types, this is always ``NULL``. " "Instead, the dict for such types is stored on ``PyInterpreterState``. Use :c:" "func:`PyType_GetDict` to get the dict for an arbitrary type." msgstr "" -#: ../../c-api/typeobj.rst:1743 +#: ../../c-api/typeobj.rst:1807 msgid "" "This field is not inherited by subtypes (though the attributes defined in " "here are inherited through a different mechanism)." msgstr "" -#: ../../c-api/typeobj.rst:1748 +#: ../../c-api/typeobj.rst:1812 msgid "" "If this field is ``NULL``, :c:func:`PyType_Ready` will assign a new " "dictionary to it." msgstr "" -#: ../../c-api/typeobj.rst:1753 +#: ../../c-api/typeobj.rst:1817 msgid "" "It is not safe to use :c:func:`PyDict_SetItem` on or otherwise modify :c:" "member:`~PyTypeObject.tp_dict` with the dictionary C-API." msgstr "" -#: ../../c-api/typeobj.rst:1759 +#: ../../c-api/typeobj.rst:1823 msgid "An optional pointer to a \"descriptor get\" function." msgstr "" -#: ../../c-api/typeobj.rst:1761 ../../c-api/typeobj.rst:1777 -#: ../../c-api/typeobj.rst:1841 ../../c-api/typeobj.rst:1871 -#: ../../c-api/typeobj.rst:1895 +#: ../../c-api/typeobj.rst:1825 ../../c-api/typeobj.rst:1841 +#: ../../c-api/typeobj.rst:1905 ../../c-api/typeobj.rst:1935 +#: ../../c-api/typeobj.rst:1959 msgid "The function signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1763 +#: ../../c-api/typeobj.rst:1827 msgid "PyObject * tp_descr_get(PyObject *self, PyObject *obj, PyObject *type);" msgstr "" "PyObject * tp_descr_get(PyObject *self, PyObject *obj, PyObject *type);" -#: ../../c-api/typeobj.rst:1774 +#: ../../c-api/typeobj.rst:1838 msgid "" "An optional pointer to a function for setting and deleting a descriptor's " "value." msgstr "" -#: ../../c-api/typeobj.rst:1779 +#: ../../c-api/typeobj.rst:1843 msgid "int tp_descr_set(PyObject *self, PyObject *obj, PyObject *value);" msgstr "int tp_descr_set(PyObject *self, PyObject *obj, PyObject *value);" -#: ../../c-api/typeobj.rst:1781 +#: ../../c-api/typeobj.rst:1845 msgid "The *value* argument is set to ``NULL`` to delete the value." msgstr "" -#: ../../c-api/typeobj.rst:1792 +#: ../../c-api/typeobj.rst:1856 msgid "" "While this field is still supported, :c:macro:`Py_TPFLAGS_MANAGED_DICT` " "should be used instead, if at all possible." msgstr "" -#: ../../c-api/typeobj.rst:1795 +#: ../../c-api/typeobj.rst:1859 msgid "" "If the instances of this type have a dictionary containing instance " "variables, this field is non-zero and contains the offset in the instances " @@ -2912,19 +3026,19 @@ msgid "" "func:`PyObject_GenericGetAttr`." msgstr "" -#: ../../c-api/typeobj.rst:1800 +#: ../../c-api/typeobj.rst:1864 msgid "" "Do not confuse this field with :c:member:`~PyTypeObject.tp_dict`; that is " "the dictionary for attributes of the type object itself." msgstr "" -#: ../../c-api/typeobj.rst:1803 +#: ../../c-api/typeobj.rst:1867 msgid "" "The value specifies the offset of the dictionary from the start of the " "instance structure." msgstr "" -#: ../../c-api/typeobj.rst:1805 +#: ../../c-api/typeobj.rst:1869 msgid "" "The :c:member:`~PyTypeObject.tp_dictoffset` should be regarded as write-" "only. To get the pointer to the dictionary call :c:func:" @@ -2933,13 +3047,13 @@ msgid "" "to call :c:func:`PyObject_GetAttr` when accessing an attribute on the object." msgstr "" -#: ../../c-api/typeobj.rst:1811 +#: ../../c-api/typeobj.rst:1875 msgid "" -"It is an error to set both the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit " -"and :c:member:`~PyTypeObject.tp_dictoffset`." +"It is an error to set both the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit and :c:" +"member:`~PyTypeObject.tp_dictoffset`." msgstr "" -#: ../../c-api/typeobj.rst:1816 +#: ../../c-api/typeobj.rst:1880 msgid "" "This field is inherited by subtypes. A subtype should not override this " "offset; doing so could be unsafe, if C code tries to access the dictionary " @@ -2947,25 +3061,25 @@ msgid "" "`Py_TPFLAGS_MANAGED_DICT`." msgstr "" -#: ../../c-api/typeobj.rst:1823 +#: ../../c-api/typeobj.rst:1887 msgid "" "This slot has no default. For :ref:`static types `, if the " "field is ``NULL`` then no :attr:`~object.__dict__` gets created for " "instances." msgstr "" -#: ../../c-api/typeobj.rst:1826 +#: ../../c-api/typeobj.rst:1890 msgid "" "If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the :c:member:" -"`~PyTypeObject.tp_dict` field, then :c:member:`~PyTypeObject.tp_dictoffset` " +"`~PyTypeObject.tp_flags` field, then :c:member:`~PyTypeObject.tp_dictoffset` " "will be set to ``-1``, to indicate that it is unsafe to use this field." msgstr "" -#: ../../c-api/typeobj.rst:1834 +#: ../../c-api/typeobj.rst:1898 msgid "An optional pointer to an instance initialization function." msgstr "" -#: ../../c-api/typeobj.rst:1836 +#: ../../c-api/typeobj.rst:1900 msgid "" "This function corresponds to the :meth:`~object.__init__` method of " "classes. Like :meth:`!__init__`, it is possible to create an instance " @@ -2973,18 +3087,18 @@ msgid "" "instance by calling its :meth:`!__init__` method again." msgstr "" -#: ../../c-api/typeobj.rst:1843 +#: ../../c-api/typeobj.rst:1907 msgid "int tp_init(PyObject *self, PyObject *args, PyObject *kwds);" msgstr "int tp_init(PyObject *self, PyObject *args, PyObject *kwds);" -#: ../../c-api/typeobj.rst:1845 +#: ../../c-api/typeobj.rst:1909 msgid "" "The self argument is the instance to be initialized; the *args* and *kwds* " "arguments represent positional and keyword arguments of the call to :meth:" "`~object.__init__`." msgstr "" -#: ../../c-api/typeobj.rst:1849 +#: ../../c-api/typeobj.rst:1913 msgid "" "The :c:member:`~PyTypeObject.tp_init` function, if not ``NULL``, is called " "when an instance is created normally by calling its type, after the type's :" @@ -2996,53 +3110,53 @@ msgid "" "subtype's :c:member:`~PyTypeObject.tp_init` is called." msgstr "" -#: ../../c-api/typeobj.rst:1856 +#: ../../c-api/typeobj.rst:1920 msgid "Returns ``0`` on success, ``-1`` and sets an exception on error." msgstr "" -#: ../../c-api/typeobj.rst:1864 +#: ../../c-api/typeobj.rst:1928 msgid "" "For :ref:`static types ` this field does not have a default." msgstr "" -#: ../../c-api/typeobj.rst:1869 +#: ../../c-api/typeobj.rst:1933 msgid "An optional pointer to an instance allocation function." msgstr "" -#: ../../c-api/typeobj.rst:1873 +#: ../../c-api/typeobj.rst:1937 msgid "PyObject *tp_alloc(PyTypeObject *self, Py_ssize_t nitems);" msgstr "PyObject *tp_alloc(PyTypeObject *self, Py_ssize_t nitems);" -#: ../../c-api/typeobj.rst:1877 +#: ../../c-api/typeobj.rst:1941 msgid "" "This field is inherited by static subtypes, but not by dynamic subtypes " "(subtypes created by a class statement)." msgstr "" -#: ../../c-api/typeobj.rst:1882 +#: ../../c-api/typeobj.rst:1946 msgid "" "For dynamic subtypes, this field is always set to :c:func:" "`PyType_GenericAlloc`, to force a standard heap allocation strategy." msgstr "" -#: ../../c-api/typeobj.rst:1886 +#: ../../c-api/typeobj.rst:1950 msgid "" "For static subtypes, :c:data:`PyBaseObject_Type` uses :c:func:" "`PyType_GenericAlloc`. That is the recommended value for all statically " "defined types." msgstr "" -#: ../../c-api/typeobj.rst:1893 +#: ../../c-api/typeobj.rst:1957 msgid "An optional pointer to an instance creation function." msgstr "" -#: ../../c-api/typeobj.rst:1897 +#: ../../c-api/typeobj.rst:1961 msgid "" "PyObject *tp_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds);" msgstr "" "PyObject *tp_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds);" -#: ../../c-api/typeobj.rst:1899 +#: ../../c-api/typeobj.rst:1963 msgid "" "The *subtype* argument is the type of the object being created; the *args* " "and *kwds* arguments represent positional and keyword arguments of the call " @@ -3051,7 +3165,7 @@ msgid "" "that type (but not an unrelated type)." msgstr "" -#: ../../c-api/typeobj.rst:1905 +#: ../../c-api/typeobj.rst:1969 msgid "" "The :c:member:`~PyTypeObject.tp_new` function should call ``subtype-" ">tp_alloc(subtype, nitems)`` to allocate space for the object, and then do " @@ -3063,20 +3177,20 @@ msgid "" "be deferred to :c:member:`~PyTypeObject.tp_init`." msgstr "" -#: ../../c-api/typeobj.rst:1913 +#: ../../c-api/typeobj.rst:1977 msgid "" "Set the :c:macro:`Py_TPFLAGS_DISALLOW_INSTANTIATION` flag to disallow " "creating instances of the type in Python." msgstr "" -#: ../../c-api/typeobj.rst:1918 +#: ../../c-api/typeobj.rst:1982 msgid "" "This field is inherited by subtypes, except it is not inherited by :ref:" "`static types ` whose :c:member:`~PyTypeObject.tp_base` is " "``NULL`` or ``&PyBaseObject_Type``." msgstr "" -#: ../../c-api/typeobj.rst:1924 +#: ../../c-api/typeobj.rst:1988 msgid "" "For :ref:`static types ` this field has no default. This means " "if the slot is defined as ``NULL``, the type cannot be called to create new " @@ -3084,44 +3198,44 @@ msgid "" "factory function." msgstr "" -#: ../../c-api/typeobj.rst:1932 +#: ../../c-api/typeobj.rst:1996 msgid "" "An optional pointer to an instance deallocation function. Its signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1934 +#: ../../c-api/typeobj.rst:1998 msgid "void tp_free(void *self);" msgstr "void tp_free(void *self);" -#: ../../c-api/typeobj.rst:1936 +#: ../../c-api/typeobj.rst:2000 msgid "" "An initializer that is compatible with this signature is :c:func:" "`PyObject_Free`." msgstr "" -#: ../../c-api/typeobj.rst:1940 +#: ../../c-api/typeobj.rst:2004 msgid "" "This field is inherited by static subtypes, but not by dynamic subtypes " "(subtypes created by a class statement)" msgstr "" -#: ../../c-api/typeobj.rst:1945 +#: ../../c-api/typeobj.rst:2009 msgid "" "In dynamic subtypes, this field is set to a deallocator suitable to match :c:" "func:`PyType_GenericAlloc` and the value of the :c:macro:" "`Py_TPFLAGS_HAVE_GC` flag bit." msgstr "" -#: ../../c-api/typeobj.rst:1949 +#: ../../c-api/typeobj.rst:2013 msgid "" "For static subtypes, :c:data:`PyBaseObject_Type` uses :c:func:`PyObject_Del`." msgstr "" -#: ../../c-api/typeobj.rst:1954 +#: ../../c-api/typeobj.rst:2018 msgid "An optional pointer to a function called by the garbage collector." msgstr "" -#: ../../c-api/typeobj.rst:1956 +#: ../../c-api/typeobj.rst:2020 msgid "" "The garbage collector needs to know whether a particular object is " "collectible or not. Normally, it is sufficient to look at the object's " @@ -3133,93 +3247,93 @@ msgid "" "instance. The signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1964 +#: ../../c-api/typeobj.rst:2028 msgid "int tp_is_gc(PyObject *self);" msgstr "int tp_is_gc(PyObject *self);" -#: ../../c-api/typeobj.rst:1966 +#: ../../c-api/typeobj.rst:2030 msgid "" "(The only example of this are types themselves. The metatype, :c:data:" "`PyType_Type`, defines this function to distinguish between statically and :" "ref:`dynamically allocated types `.)" msgstr "" -#: ../../c-api/typeobj.rst:1976 +#: ../../c-api/typeobj.rst:2040 msgid "" "This slot has no default. If this field is ``NULL``, :c:macro:" "`Py_TPFLAGS_HAVE_GC` is used as the functional equivalent." msgstr "" -#: ../../c-api/typeobj.rst:1982 +#: ../../c-api/typeobj.rst:2046 msgid "Tuple of base types." msgstr "" -#: ../../c-api/typeobj.rst:1984 ../../c-api/typeobj.rst:2008 +#: ../../c-api/typeobj.rst:2048 ../../c-api/typeobj.rst:2072 msgid "" "This field should be set to ``NULL`` and treated as read-only. Python will " "fill it in when the type is :c:func:`initialized `." msgstr "" -#: ../../c-api/typeobj.rst:1987 +#: ../../c-api/typeobj.rst:2051 msgid "" "For dynamically created classes, the ``Py_tp_bases`` :c:type:`slot " "` can be used instead of the *bases* argument of :c:func:" "`PyType_FromSpecWithBases`. The argument form is preferred." msgstr "" -#: ../../c-api/typeobj.rst:1994 +#: ../../c-api/typeobj.rst:2058 msgid "" "Multiple inheritance does not work well for statically defined types. If you " "set ``tp_bases`` to a tuple, Python will not raise an error, but some slots " "will only be inherited from the first base." msgstr "" -#: ../../c-api/typeobj.rst:2000 ../../c-api/typeobj.rst:2023 -#: ../../c-api/typeobj.rst:2040 ../../c-api/typeobj.rst:2057 -#: ../../c-api/typeobj.rst:2071 +#: ../../c-api/typeobj.rst:2064 ../../c-api/typeobj.rst:2087 +#: ../../c-api/typeobj.rst:2104 ../../c-api/typeobj.rst:2121 +#: ../../c-api/typeobj.rst:2135 msgid "This field is not inherited." msgstr "" -#: ../../c-api/typeobj.rst:2005 +#: ../../c-api/typeobj.rst:2069 msgid "" "Tuple containing the expanded set of base types, starting with the type " "itself and ending with :class:`object`, in Method Resolution Order." msgstr "" -#: ../../c-api/typeobj.rst:2013 +#: ../../c-api/typeobj.rst:2077 msgid "" "This field is not inherited; it is calculated fresh by :c:func:" "`PyType_Ready`." msgstr "" -#: ../../c-api/typeobj.rst:2019 +#: ../../c-api/typeobj.rst:2083 msgid "Unused. Internal use only." msgstr "" -#: ../../c-api/typeobj.rst:2028 +#: ../../c-api/typeobj.rst:2092 msgid "" "A collection of subclasses. Internal use only. May be an invalid pointer." msgstr "" -#: ../../c-api/typeobj.rst:2030 +#: ../../c-api/typeobj.rst:2094 msgid "" -"To get a list of subclasses, call the Python method :py:meth:`~class." +"To get a list of subclasses, call the Python method :py:meth:`~type." "__subclasses__`." msgstr "" -#: ../../c-api/typeobj.rst:2035 +#: ../../c-api/typeobj.rst:2099 msgid "" "For some types, this field does not hold a valid :c:expr:`PyObject*`. The " "type was changed to :c:expr:`void*` to indicate this." msgstr "" -#: ../../c-api/typeobj.rst:2045 +#: ../../c-api/typeobj.rst:2109 msgid "" "Weak reference list head, for weak references to this type object. Not " "inherited. Internal use only." msgstr "" -#: ../../c-api/typeobj.rst:2050 +#: ../../c-api/typeobj.rst:2114 msgid "" "Internals detail: For the static builtin types this is always ``NULL``, even " "if weakrefs are added. Instead, the weakrefs for each are stored on " @@ -3227,25 +3341,25 @@ msgid "" "``_PyObject_GET_WEAKREFS_LISTPTR()`` macro to avoid the distinction." msgstr "" -#: ../../c-api/typeobj.rst:2062 +#: ../../c-api/typeobj.rst:2126 msgid "" "This field is deprecated. Use :c:member:`~PyTypeObject.tp_finalize` instead." msgstr "" -#: ../../c-api/typeobj.rst:2067 +#: ../../c-api/typeobj.rst:2131 msgid "Used to index into the method cache. Internal use only." msgstr "" -#: ../../c-api/typeobj.rst:2076 +#: ../../c-api/typeobj.rst:2140 msgid "" "An optional pointer to an instance finalization function. Its signature is::" msgstr "" -#: ../../c-api/typeobj.rst:2078 +#: ../../c-api/typeobj.rst:2142 msgid "void tp_finalize(PyObject *self);" msgstr "void tp_finalize(PyObject *self);" -#: ../../c-api/typeobj.rst:2080 +#: ../../c-api/typeobj.rst:2144 msgid "" "If :c:member:`~PyTypeObject.tp_finalize` is set, the interpreter calls it " "once when finalizing an instance. It is called either from the garbage " @@ -3255,55 +3369,40 @@ msgid "" "object in a sane state." msgstr "" -#: ../../c-api/typeobj.rst:2087 +#: ../../c-api/typeobj.rst:2151 msgid "" ":c:member:`~PyTypeObject.tp_finalize` should not mutate the current " "exception status; therefore, a recommended way to write a non-trivial " "finalizer is::" msgstr "" -#: ../../c-api/typeobj.rst:2090 +#: ../../c-api/typeobj.rst:2154 msgid "" "static void\n" "local_finalize(PyObject *self)\n" "{\n" -" PyObject *error_type, *error_value, *error_traceback;\n" -"\n" " /* Save the current exception, if any. */\n" -" PyErr_Fetch(&error_type, &error_value, &error_traceback);\n" +" PyObject *exc = PyErr_GetRaisedException();\n" "\n" " /* ... */\n" "\n" " /* Restore the saved exception. */\n" -" PyErr_Restore(error_type, error_value, error_traceback);\n" +" PyErr_SetRaisedException(exc);\n" "}" msgstr "" -#: ../../c-api/typeobj.rst:2104 -msgid "" -"Also, note that, in a garbage collected Python, :c:member:`~PyTypeObject." -"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." -msgstr "" - -#: ../../c-api/typeobj.rst:2123 +#: ../../c-api/typeobj.rst:2174 msgid "" "Before version 3.8 it was necessary to set the :c:macro:" "`Py_TPFLAGS_HAVE_FINALIZE` flags bit in order for this field to be used. " "This is no longer required." msgstr "" -#: ../../c-api/typeobj.rst:2127 +#: ../../c-api/typeobj.rst:2178 msgid "\"Safe object finalization\" (:pep:`442`)" msgstr "" -#: ../../c-api/typeobj.rst:2132 +#: ../../c-api/typeobj.rst:2183 msgid "" "Vectorcall function to use for calls of this type object. In other words, it " "is used to implement :ref:`vectorcall ` for ``type.__call__``. " @@ -3311,65 +3410,65 @@ msgid "" "meth:`~object.__new__` and :meth:`~object.__init__` is used." msgstr "" -#: ../../c-api/typeobj.rst:2140 +#: ../../c-api/typeobj.rst:2191 msgid "This field is never inherited." msgstr "" -#: ../../c-api/typeobj.rst:2142 +#: ../../c-api/typeobj.rst:2193 msgid "(the field exists since 3.8 but it's only used since 3.9)" msgstr "" -#: ../../c-api/typeobj.rst:2147 +#: ../../c-api/typeobj.rst:2198 msgid "Internal. Do not use." msgstr "" -#: ../../c-api/typeobj.rst:2155 +#: ../../c-api/typeobj.rst:2206 msgid "Static Types" msgstr "" -#: ../../c-api/typeobj.rst:2157 +#: ../../c-api/typeobj.rst:2208 msgid "" "Traditionally, types defined in C code are *static*, that is, a static :c:" "type:`PyTypeObject` structure is defined directly in code and initialized " "using :c:func:`PyType_Ready`." msgstr "" -#: ../../c-api/typeobj.rst:2161 +#: ../../c-api/typeobj.rst:2212 msgid "" "This results in types that are limited relative to types defined in Python:" msgstr "" -#: ../../c-api/typeobj.rst:2163 +#: ../../c-api/typeobj.rst:2214 msgid "" "Static types are limited to one base, i.e. they cannot use multiple " "inheritance." msgstr "" -#: ../../c-api/typeobj.rst:2165 +#: ../../c-api/typeobj.rst:2216 msgid "" "Static type objects (but not necessarily their instances) are immutable. It " "is not possible to add or modify the type object's attributes from Python." msgstr "" -#: ../../c-api/typeobj.rst:2167 +#: ../../c-api/typeobj.rst:2218 msgid "" "Static type objects are shared across :ref:`sub-interpreters `, so they should not include any subinterpreter-" "specific state." msgstr "" -#: ../../c-api/typeobj.rst:2171 +#: ../../c-api/typeobj.rst:2222 msgid "" "Also, since :c:type:`PyTypeObject` is only part of the :ref:`Limited API " "` as an opaque struct, any extension modules using static " "types must be compiled for a specific Python minor version." msgstr "" -#: ../../c-api/typeobj.rst:2179 +#: ../../c-api/typeobj.rst:2230 msgid "Heap Types" msgstr "" -#: ../../c-api/typeobj.rst:2181 +#: ../../c-api/typeobj.rst:2232 msgid "" "An alternative to :ref:`static types ` is *heap-allocated " "types*, or *heap types* for short, which correspond closely to classes " @@ -3377,29 +3476,29 @@ msgid "" "`Py_TPFLAGS_HEAPTYPE` flag set." msgstr "" -#: ../../c-api/typeobj.rst:2186 +#: ../../c-api/typeobj.rst:2237 msgid "" "This is done by filling a :c:type:`PyType_Spec` structure and calling :c:" "func:`PyType_FromSpec`, :c:func:`PyType_FromSpecWithBases`, :c:func:" "`PyType_FromModuleAndSpec`, or :c:func:`PyType_FromMetaclass`." msgstr "" -#: ../../c-api/typeobj.rst:2194 +#: ../../c-api/typeobj.rst:2245 msgid "Number Object Structures" msgstr "" -#: ../../c-api/typeobj.rst:2201 +#: ../../c-api/typeobj.rst:2252 msgid "" "This structure holds pointers to the functions which an object uses to " "implement the number protocol. Each function is used by the function of " "similar name documented in the :ref:`number` section." msgstr "" -#: ../../c-api/typeobj.rst:2207 ../../c-api/typeobj.rst:2531 +#: ../../c-api/typeobj.rst:2258 ../../c-api/typeobj.rst:2582 msgid "Here is the structure definition::" msgstr "" -#: ../../c-api/typeobj.rst:2209 +#: ../../c-api/typeobj.rst:2260 msgid "" "typedef struct {\n" " binaryfunc nb_add;\n" @@ -3487,7 +3586,7 @@ msgstr "" " binaryfunc nb_inplace_matrix_multiply;\n" "} PyNumberMethods;" -#: ../../c-api/typeobj.rst:2254 +#: ../../c-api/typeobj.rst:2305 msgid "" "Binary and ternary functions must check the type of all their operands, and " "implement the necessary conversions (at least one of the operands is an " @@ -3497,31 +3596,31 @@ msgid "" "and set an exception." msgstr "" -#: ../../c-api/typeobj.rst:2263 +#: ../../c-api/typeobj.rst:2314 msgid "" "The :c:member:`~PyNumberMethods.nb_reserved` field should always be " "``NULL``. It was previously called :c:member:`!nb_long`, and was renamed in " "Python 3.0.1." msgstr "" -#: ../../c-api/typeobj.rst:2308 +#: ../../c-api/typeobj.rst:2359 msgid "Mapping Object Structures" msgstr "" -#: ../../c-api/typeobj.rst:2315 +#: ../../c-api/typeobj.rst:2366 msgid "" "This structure holds pointers to the functions which an object uses to " "implement the mapping protocol. It has three members:" msgstr "" -#: ../../c-api/typeobj.rst:2320 +#: ../../c-api/typeobj.rst:2371 msgid "" "This function is used by :c:func:`PyMapping_Size` and :c:func:" "`PyObject_Size`, and has the same signature. This slot may be set to " "``NULL`` if the object has no defined length." msgstr "" -#: ../../c-api/typeobj.rst:2326 +#: ../../c-api/typeobj.rst:2377 msgid "" "This function is used by :c:func:`PyObject_GetItem` and :c:func:" "`PySequence_GetSlice`, and has the same signature as :c:func:`!" @@ -3529,7 +3628,7 @@ msgid "" "`PyMapping_Check` function to return ``1``, it can be ``NULL`` otherwise." msgstr "" -#: ../../c-api/typeobj.rst:2334 +#: ../../c-api/typeobj.rst:2385 msgid "" "This function is used by :c:func:`PyObject_SetItem`, :c:func:" "`PyObject_DelItem`, :c:func:`PySequence_SetSlice` and :c:func:" @@ -3539,17 +3638,17 @@ msgid "" "deletion." msgstr "" -#: ../../c-api/typeobj.rst:2345 +#: ../../c-api/typeobj.rst:2396 msgid "Sequence Object Structures" msgstr "" -#: ../../c-api/typeobj.rst:2352 +#: ../../c-api/typeobj.rst:2403 msgid "" "This structure holds pointers to the functions which an object uses to " "implement the sequence protocol." msgstr "" -#: ../../c-api/typeobj.rst:2357 +#: ../../c-api/typeobj.rst:2408 msgid "" "This function is used by :c:func:`PySequence_Size` and :c:func:" "`PyObject_Size`, and has the same signature. It is also used for handling " @@ -3557,21 +3656,21 @@ msgid "" "member:`~PySequenceMethods.sq_ass_item` slots." msgstr "" -#: ../../c-api/typeobj.rst:2364 +#: ../../c-api/typeobj.rst:2415 msgid "" "This function is used by :c:func:`PySequence_Concat` and has the same " "signature. It is also used by the ``+`` operator, after trying the numeric " "addition via the :c:member:`~PyNumberMethods.nb_add` slot." msgstr "" -#: ../../c-api/typeobj.rst:2370 +#: ../../c-api/typeobj.rst:2421 msgid "" "This function is used by :c:func:`PySequence_Repeat` and has the same " "signature. It is also used by the ``*`` operator, after trying numeric " "multiplication via the :c:member:`~PyNumberMethods.nb_multiply` slot." msgstr "" -#: ../../c-api/typeobj.rst:2376 +#: ../../c-api/typeobj.rst:2427 msgid "" "This function is used by :c:func:`PySequence_GetItem` and has the same " "signature. It is also used by :c:func:`PyObject_GetItem`, after trying the " @@ -3580,7 +3679,7 @@ msgid "" "``1``, it can be ``NULL`` otherwise." msgstr "" -#: ../../c-api/typeobj.rst:2382 +#: ../../c-api/typeobj.rst:2433 msgid "" "Negative indexes are handled as follows: if the :c:member:" "`~PySequenceMethods.sq_length` slot is filled, it is called and the sequence " @@ -3589,7 +3688,7 @@ msgid "" "index is passed as is to the function." msgstr "" -#: ../../c-api/typeobj.rst:2389 +#: ../../c-api/typeobj.rst:2440 msgid "" "This function is used by :c:func:`PySequence_SetItem` and has the same " "signature. It is also used by :c:func:`PyObject_SetItem` and :c:func:" @@ -3598,14 +3697,14 @@ msgid "" "``NULL`` if the object does not support item assignment and deletion." msgstr "" -#: ../../c-api/typeobj.rst:2398 +#: ../../c-api/typeobj.rst:2449 msgid "" "This function may be used by :c:func:`PySequence_Contains` and has the same " "signature. This slot may be left to ``NULL``, in this case :c:func:`!" "PySequence_Contains` simply traverses the sequence until it finds a match." msgstr "" -#: ../../c-api/typeobj.rst:2405 +#: ../../c-api/typeobj.rst:2456 msgid "" "This function is used by :c:func:`PySequence_InPlaceConcat` and has the same " "signature. It should modify its first operand, and return it. This slot " @@ -3615,7 +3714,7 @@ msgid "" "c:member:`~PyNumberMethods.nb_inplace_add` slot." msgstr "" -#: ../../c-api/typeobj.rst:2414 +#: ../../c-api/typeobj.rst:2465 msgid "" "This function is used by :c:func:`PySequence_InPlaceRepeat` and has the same " "signature. It should modify its first operand, and return it. This slot " @@ -3625,76 +3724,76 @@ msgid "" "via the :c:member:`~PyNumberMethods.nb_inplace_multiply` slot." msgstr "" -#: ../../c-api/typeobj.rst:2425 +#: ../../c-api/typeobj.rst:2476 msgid "Buffer Object Structures" msgstr "" -#: ../../c-api/typeobj.rst:2433 +#: ../../c-api/typeobj.rst:2484 msgid "" "This structure holds pointers to the functions required by the :ref:`Buffer " "protocol `. The protocol defines how an exporter object can " "expose its internal data to consumer objects." msgstr "" -#: ../../c-api/typeobj.rst:2439 ../../c-api/typeobj.rst:2488 -#: ../../c-api/typeobj.rst:2542 ../../c-api/typeobj.rst:2553 -#: ../../c-api/typeobj.rst:2565 ../../c-api/typeobj.rst:2575 +#: ../../c-api/typeobj.rst:2490 ../../c-api/typeobj.rst:2539 +#: ../../c-api/typeobj.rst:2593 ../../c-api/typeobj.rst:2604 +#: ../../c-api/typeobj.rst:2616 ../../c-api/typeobj.rst:2626 msgid "The signature of this function is::" msgstr "" -#: ../../c-api/typeobj.rst:2441 +#: ../../c-api/typeobj.rst:2492 msgid "int (PyObject *exporter, Py_buffer *view, int flags);" msgstr "int (PyObject *exporter, Py_buffer *view, int flags);" -#: ../../c-api/typeobj.rst:2443 +#: ../../c-api/typeobj.rst:2494 msgid "" "Handle a request to *exporter* to fill in *view* as specified by *flags*. " "Except for point (3), an implementation of this function MUST take these " "steps:" msgstr "" -#: ../../c-api/typeobj.rst:2447 +#: ../../c-api/typeobj.rst:2498 msgid "" "Check if the request can be met. If not, raise :exc:`BufferError`, set :c:" "expr:`view->obj` to ``NULL`` and return ``-1``." msgstr "" -#: ../../c-api/typeobj.rst:2450 +#: ../../c-api/typeobj.rst:2501 msgid "Fill in the requested fields." msgstr "" -#: ../../c-api/typeobj.rst:2452 +#: ../../c-api/typeobj.rst:2503 msgid "Increment an internal counter for the number of exports." msgstr "" -#: ../../c-api/typeobj.rst:2454 +#: ../../c-api/typeobj.rst:2505 msgid "" "Set :c:expr:`view->obj` to *exporter* and increment :c:expr:`view->obj`." msgstr "" -#: ../../c-api/typeobj.rst:2456 +#: ../../c-api/typeobj.rst:2507 msgid "Return ``0``." msgstr "回傳 ``0``。" -#: ../../c-api/typeobj.rst:2458 +#: ../../c-api/typeobj.rst:2509 msgid "" "If *exporter* is part of a chain or tree of buffer providers, two main " "schemes can be used:" msgstr "" -#: ../../c-api/typeobj.rst:2461 +#: ../../c-api/typeobj.rst:2512 msgid "" "Re-export: Each member of the tree acts as the exporting object and sets :c:" "expr:`view->obj` to a new reference to itself." msgstr "" -#: ../../c-api/typeobj.rst:2464 +#: ../../c-api/typeobj.rst:2515 msgid "" "Redirect: The buffer request is redirected to the root object of the tree. " "Here, :c:expr:`view->obj` will be a new reference to the root object." msgstr "" -#: ../../c-api/typeobj.rst:2468 +#: ../../c-api/typeobj.rst:2519 msgid "" "The individual fields of *view* are described in section :ref:`Buffer " "structure `, the rules how an exporter must react to " @@ -3702,7 +3801,7 @@ msgid "" "types>`." msgstr "" -#: ../../c-api/typeobj.rst:2473 +#: ../../c-api/typeobj.rst:2524 msgid "" "All memory pointed to in the :c:type:`Py_buffer` structure belongs to the " "exporter and must remain valid until there are no consumers left. :c:member:" @@ -3711,23 +3810,23 @@ msgid "" "internal` are read-only for the consumer." msgstr "" -#: ../../c-api/typeobj.rst:2480 +#: ../../c-api/typeobj.rst:2531 msgid "" ":c:func:`PyBuffer_FillInfo` provides an easy way of exposing a simple bytes " "buffer while dealing correctly with all request types." msgstr "" -#: ../../c-api/typeobj.rst:2483 +#: ../../c-api/typeobj.rst:2534 msgid "" ":c:func:`PyObject_GetBuffer` is the interface for the consumer that wraps " "this function." msgstr "" -#: ../../c-api/typeobj.rst:2490 +#: ../../c-api/typeobj.rst:2541 msgid "void (PyObject *exporter, Py_buffer *view);" msgstr "void (PyObject *exporter, Py_buffer *view);" -#: ../../c-api/typeobj.rst:2492 +#: ../../c-api/typeobj.rst:2543 msgid "" "Handle a request to release the resources of the buffer. If no resources " "need to be released, :c:member:`PyBufferProcs.bf_releasebuffer` may be " @@ -3735,15 +3834,15 @@ msgid "" "these optional steps:" msgstr "" -#: ../../c-api/typeobj.rst:2497 +#: ../../c-api/typeobj.rst:2548 msgid "Decrement an internal counter for the number of exports." msgstr "" -#: ../../c-api/typeobj.rst:2499 +#: ../../c-api/typeobj.rst:2550 msgid "If the counter is ``0``, free all memory associated with *view*." msgstr "" -#: ../../c-api/typeobj.rst:2501 +#: ../../c-api/typeobj.rst:2552 msgid "" "The exporter MUST use the :c:member:`~Py_buffer.internal` field to keep " "track of buffer-specific resources. This field is guaranteed to remain " @@ -3751,30 +3850,30 @@ msgid "" "*view* argument." msgstr "" -#: ../../c-api/typeobj.rst:2507 +#: ../../c-api/typeobj.rst:2558 msgid "" "This function MUST NOT decrement :c:expr:`view->obj`, since that is done " "automatically in :c:func:`PyBuffer_Release` (this scheme is useful for " "breaking reference cycles)." msgstr "" -#: ../../c-api/typeobj.rst:2512 +#: ../../c-api/typeobj.rst:2563 msgid "" ":c:func:`PyBuffer_Release` is the interface for the consumer that wraps this " "function." msgstr "" -#: ../../c-api/typeobj.rst:2520 +#: ../../c-api/typeobj.rst:2571 msgid "Async Object Structures" msgstr "" -#: ../../c-api/typeobj.rst:2528 +#: ../../c-api/typeobj.rst:2579 msgid "" "This structure holds pointers to the functions required to implement :term:" "`awaitable` and :term:`asynchronous iterator` objects." msgstr "" -#: ../../c-api/typeobj.rst:2533 +#: ../../c-api/typeobj.rst:2584 msgid "" "typedef struct {\n" " unaryfunc am_await;\n" @@ -3790,62 +3889,62 @@ msgstr "" " sendfunc am_send;\n" "} PyAsyncMethods;" -#: ../../c-api/typeobj.rst:2544 +#: ../../c-api/typeobj.rst:2595 msgid "PyObject *am_await(PyObject *self);" msgstr "" -#: ../../c-api/typeobj.rst:2546 +#: ../../c-api/typeobj.rst:2597 msgid "" "The returned object must be an :term:`iterator`, i.e. :c:func:`PyIter_Check` " "must return ``1`` for it." msgstr "" -#: ../../c-api/typeobj.rst:2549 +#: ../../c-api/typeobj.rst:2600 msgid "" "This slot may be set to ``NULL`` if an object is not an :term:`awaitable`." msgstr "" -#: ../../c-api/typeobj.rst:2555 +#: ../../c-api/typeobj.rst:2606 msgid "PyObject *am_aiter(PyObject *self);" msgstr "PyObject *am_aiter(PyObject *self);" -#: ../../c-api/typeobj.rst:2557 +#: ../../c-api/typeobj.rst:2608 msgid "" "Must return an :term:`asynchronous iterator` object. See :meth:`~object." "__anext__` for details." msgstr "" -#: ../../c-api/typeobj.rst:2560 +#: ../../c-api/typeobj.rst:2611 msgid "" "This slot may be set to ``NULL`` if an object does not implement " "asynchronous iteration protocol." msgstr "" -#: ../../c-api/typeobj.rst:2567 +#: ../../c-api/typeobj.rst:2618 msgid "PyObject *am_anext(PyObject *self);" msgstr "PyObject *am_anext(PyObject *self);" -#: ../../c-api/typeobj.rst:2569 +#: ../../c-api/typeobj.rst:2620 msgid "" "Must return an :term:`awaitable` object. See :meth:`~object.__anext__` for " "details. This slot may be set to ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:2577 +#: ../../c-api/typeobj.rst:2628 msgid "PySendResult am_send(PyObject *self, PyObject *arg, PyObject **result);" msgstr "" "PySendResult am_send(PyObject *self, PyObject *arg, PyObject **result);" -#: ../../c-api/typeobj.rst:2579 +#: ../../c-api/typeobj.rst:2630 msgid "" "See :c:func:`PyIter_Send` for details. This slot may be set to ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:2588 +#: ../../c-api/typeobj.rst:2639 msgid "Slot Type typedefs" msgstr "" -#: ../../c-api/typeobj.rst:2592 +#: ../../c-api/typeobj.rst:2643 msgid "" "The purpose of this function is to separate memory allocation from memory " "initialization. It should return a pointer to a block of memory of adequate " @@ -3859,80 +3958,80 @@ msgid "" "length of the block should be :c:member:`~PyTypeObject.tp_basicsize`." msgstr "" -#: ../../c-api/typeobj.rst:2602 +#: ../../c-api/typeobj.rst:2653 msgid "" "This function should not do any other instance initialization, not even to " "allocate additional memory; that should be done by :c:member:`~PyTypeObject." "tp_new`." msgstr "" -#: ../../c-api/typeobj.rst:2609 +#: ../../c-api/typeobj.rst:2660 msgid "See :c:member:`~PyTypeObject.tp_free`." msgstr "請見 :c:member:`~PyTypeObject.tp_free`。" -#: ../../c-api/typeobj.rst:2613 +#: ../../c-api/typeobj.rst:2664 msgid "See :c:member:`~PyTypeObject.tp_new`." msgstr "請見 :c:member:`~PyTypeObject.tp_new`。" -#: ../../c-api/typeobj.rst:2617 +#: ../../c-api/typeobj.rst:2668 msgid "See :c:member:`~PyTypeObject.tp_init`." msgstr "請見 :c:member:`~PyTypeObject.tp_init`。" -#: ../../c-api/typeobj.rst:2621 +#: ../../c-api/typeobj.rst:2672 msgid "See :c:member:`~PyTypeObject.tp_repr`." msgstr "請見 :c:member:`~PyTypeObject.tp_repr`。" -#: ../../c-api/typeobj.rst:2625 ../../c-api/typeobj.rst:2634 +#: ../../c-api/typeobj.rst:2676 ../../c-api/typeobj.rst:2685 msgid "Return the value of the named attribute for the object." msgstr "" -#: ../../c-api/typeobj.rst:2629 ../../c-api/typeobj.rst:2640 +#: ../../c-api/typeobj.rst:2680 ../../c-api/typeobj.rst:2691 msgid "" "Set the value of the named attribute for the object. The value argument is " "set to ``NULL`` to delete the attribute." msgstr "" -#: ../../c-api/typeobj.rst:2636 +#: ../../c-api/typeobj.rst:2687 msgid "See :c:member:`~PyTypeObject.tp_getattro`." msgstr "請見 :c:member:`~PyTypeObject.tp_getattro`。" -#: ../../c-api/typeobj.rst:2643 +#: ../../c-api/typeobj.rst:2694 msgid "See :c:member:`~PyTypeObject.tp_setattro`." msgstr "請見 :c:member:`~PyTypeObject.tp_setattro`。" -#: ../../c-api/typeobj.rst:2647 +#: ../../c-api/typeobj.rst:2698 msgid "See :c:member:`~PyTypeObject.tp_descr_get`." msgstr "請見 :c:member:`~PyTypeObject.tp_descr_get`。" -#: ../../c-api/typeobj.rst:2651 +#: ../../c-api/typeobj.rst:2702 msgid "See :c:member:`~PyTypeObject.tp_descr_set`." msgstr "請見 :c:member:`~PyTypeObject.tp_descr_set`。" -#: ../../c-api/typeobj.rst:2655 +#: ../../c-api/typeobj.rst:2706 msgid "See :c:member:`~PyTypeObject.tp_hash`." msgstr "請見 :c:member:`~PyTypeObject.tp_hash`。" -#: ../../c-api/typeobj.rst:2659 +#: ../../c-api/typeobj.rst:2710 msgid "See :c:member:`~PyTypeObject.tp_richcompare`." msgstr "請見 :c:member:`~PyTypeObject.tp_richcompare`。" -#: ../../c-api/typeobj.rst:2663 +#: ../../c-api/typeobj.rst:2714 msgid "See :c:member:`~PyTypeObject.tp_iter`." msgstr "請見 :c:member:`~PyTypeObject.tp_iter`。" -#: ../../c-api/typeobj.rst:2667 +#: ../../c-api/typeobj.rst:2718 msgid "See :c:member:`~PyTypeObject.tp_iternext`." msgstr "請見 :c:member:`~PyTypeObject.tp_iternext`。" -#: ../../c-api/typeobj.rst:2681 +#: ../../c-api/typeobj.rst:2732 msgid "See :c:member:`~PyAsyncMethods.am_send`." msgstr "請見 :c:member:`~PyAsyncMethods.am_send`。" -#: ../../c-api/typeobj.rst:2697 +#: ../../c-api/typeobj.rst:2748 msgid "Examples" msgstr "範例" -#: ../../c-api/typeobj.rst:2699 +#: ../../c-api/typeobj.rst:2750 msgid "" "The following are simple examples of Python type definitions. They include " "common usage you may encounter. Some demonstrate tricky corner cases. For " @@ -3940,11 +4039,11 @@ msgid "" "and :ref:`new-types-topics`." msgstr "" -#: ../../c-api/typeobj.rst:2704 +#: ../../c-api/typeobj.rst:2755 msgid "A basic :ref:`static type `::" msgstr "" -#: ../../c-api/typeobj.rst:2706 +#: ../../c-api/typeobj.rst:2757 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -3962,13 +4061,13 @@ msgid "" "};" msgstr "" -#: ../../c-api/typeobj.rst:2721 +#: ../../c-api/typeobj.rst:2772 msgid "" "You may also find older code (especially in the CPython code base) with a " "more verbose initializer::" msgstr "" -#: ../../c-api/typeobj.rst:2724 +#: ../../c-api/typeobj.rst:2775 msgid "" "static PyTypeObject MyObject_Type = {\n" " PyVarObject_HEAD_INIT(NULL, 0)\n" @@ -4052,11 +4151,11 @@ msgstr "" " myobj_new, /* tp_new */\n" "};" -#: ../../c-api/typeobj.rst:2765 +#: ../../c-api/typeobj.rst:2816 msgid "A type that supports weakrefs, instance dicts, and hashing::" msgstr "" -#: ../../c-api/typeobj.rst:2767 +#: ../../c-api/typeobj.rst:2818 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -4082,14 +4181,14 @@ msgid "" "};" msgstr "" -#: ../../c-api/typeobj.rst:2790 +#: ../../c-api/typeobj.rst:2841 msgid "" "A str subclass that cannot be subclassed and cannot be called to create " "instances (e.g. uses a separate factory func) using :c:macro:" "`Py_TPFLAGS_DISALLOW_INSTANTIATION` flag::" msgstr "" -#: ../../c-api/typeobj.rst:2794 +#: ../../c-api/typeobj.rst:2845 msgid "" "typedef struct {\n" " PyUnicodeObject raw;\n" @@ -4107,12 +4206,12 @@ msgid "" "};" msgstr "" -#: ../../c-api/typeobj.rst:2809 +#: ../../c-api/typeobj.rst:2860 msgid "" "The simplest :ref:`static type ` with fixed-length instances::" msgstr "" -#: ../../c-api/typeobj.rst:2811 +#: ../../c-api/typeobj.rst:2862 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -4132,13 +4231,13 @@ msgstr "" " .tp_name = \"mymod.MyObject\",\n" "};" -#: ../../c-api/typeobj.rst:2820 +#: ../../c-api/typeobj.rst:2871 msgid "" "The simplest :ref:`static type ` with variable-length " "instances::" msgstr "" -#: ../../c-api/typeobj.rst:2822 +#: ../../c-api/typeobj.rst:2873 msgid "" "typedef struct {\n" " PyObject_VAR_HEAD\n" @@ -4164,14 +4263,14 @@ msgstr "" " .tp_itemsize = sizeof(char *),\n" "};" -#: ../../c-api/typeobj.rst:809 ../../c-api/typeobj.rst:874 +#: ../../c-api/typeobj.rst:843 ../../c-api/typeobj.rst:908 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../c-api/typeobj.rst:809 +#: ../../c-api/typeobj.rst:843 msgid "repr" msgstr "repr" -#: ../../c-api/typeobj.rst:874 +#: ../../c-api/typeobj.rst:908 msgid "hash" msgstr "hash(雜湊)" diff --git a/c-api/unicode.po b/c-api/unicode.po index 666d51aa2a..71b90e9650 100644 --- a/c-api/unicode.po +++ b/c-api/unicode.po @@ -7,9 +7,9 @@ # Liang-Bo Wang , 2016 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 14:08+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -41,23 +41,25 @@ msgstr "" #: ../../c-api/unicode.rst:20 msgid "" "UTF-8 representation is created on demand and cached in the Unicode object." -msgstr "" +msgstr "UTF-8 表示法會在需要時建立並快取在 Unicode 物件中。" #: ../../c-api/unicode.rst:23 msgid "" "The :c:type:`Py_UNICODE` representation has been removed since Python 3.12 " "with deprecated APIs. See :pep:`623` for more information." msgstr "" +"自 Python 3.12 起,已移除 :c:type:`Py_UNICODE` 表示法,並標示為已棄用的 API。" +"更多資訊請參閱 :pep:`623`。" #: ../../c-api/unicode.rst:29 msgid "Unicode Type" -msgstr "" +msgstr "Unicode 型別" #: ../../c-api/unicode.rst:31 msgid "" "These are the basic Unicode object types used for the Unicode implementation " "in Python:" -msgstr "" +msgstr "這些是 Python 中用於 Unicode 實作的基本 Unicode 物件型別:" #: ../../c-api/unicode.rst:38 msgid "" @@ -79,52 +81,58 @@ msgid "" "build time." msgstr "" -#: ../../c-api/unicode.rst:60 +#: ../../c-api/unicode.rst:62 msgid "" "These subtypes of :c:type:`PyObject` represent a Python Unicode object. In " "almost all cases, they shouldn't be used directly, since all API functions " "that deal with Unicode objects take and return :c:type:`PyObject` pointers." msgstr "" -#: ../../c-api/unicode.rst:69 +#: ../../c-api/unicode.rst:71 msgid "" -"This instance of :c:type:`PyTypeObject` represents the Python Unicode type. " +"This instance of :c:type:`PyTypeObject` represents the Python Unicode type. " "It is exposed to Python code as ``str``." msgstr "" -#: ../../c-api/unicode.rst:73 +#: ../../c-api/unicode.rst:77 +msgid "" +"This instance of :c:type:`PyTypeObject` represents the Python Unicode " +"iterator type. It is used to iterate over Unicode string objects." +msgstr "" + +#: ../../c-api/unicode.rst:81 msgid "" "The following APIs are C macros and static inlined functions for fast checks " "and access to internal read-only data of Unicode objects:" msgstr "" -#: ../../c-api/unicode.rst:78 +#: ../../c-api/unicode.rst:86 msgid "" "Return true if the object *obj* is a Unicode object or an instance of a " "Unicode subtype. This function always succeeds." msgstr "" -#: ../../c-api/unicode.rst:84 +#: ../../c-api/unicode.rst:92 msgid "" "Return true if the object *obj* is a Unicode object, but not an instance of " "a subtype. This function always succeeds." msgstr "" -#: ../../c-api/unicode.rst:90 +#: ../../c-api/unicode.rst:98 msgid "Returns ``0``. This API is kept only for backward compatibility." -msgstr "" +msgstr "回傳 ``0``。此 API 僅保留以維持向後相容性。" -#: ../../c-api/unicode.rst:94 +#: ../../c-api/unicode.rst:102 msgid "This API does nothing since Python 3.12." -msgstr "" +msgstr "自 Python 3.12 起,此 API 不再執行任何動作。" -#: ../../c-api/unicode.rst:100 +#: ../../c-api/unicode.rst:108 msgid "" "Return the length of the Unicode string, in code points. *unicode* has to " "be a Unicode object in the \"canonical\" representation (not checked)." msgstr "" -#: ../../c-api/unicode.rst:110 +#: ../../c-api/unicode.rst:118 msgid "" "Return a pointer to the canonical representation cast to UCS1, UCS2 or UCS4 " "integer types for direct character access. No checks are performed if the " @@ -132,15 +140,15 @@ msgid "" "`PyUnicode_KIND` to select the right function." msgstr "" -#: ../../c-api/unicode.rst:122 +#: ../../c-api/unicode.rst:130 msgid "Return values of the :c:func:`PyUnicode_KIND` macro." msgstr "" -#: ../../c-api/unicode.rst:126 +#: ../../c-api/unicode.rst:134 msgid "``PyUnicode_WCHAR_KIND`` has been removed." msgstr "``PyUnicode_WCHAR_KIND`` 已被移除。" -#: ../../c-api/unicode.rst:132 +#: ../../c-api/unicode.rst:140 msgid "" "Return one of the PyUnicode kind constants (see above) that indicate how " "many bytes per character this Unicode object uses to store its data. " @@ -148,13 +156,13 @@ msgid "" "(not checked)." msgstr "" -#: ../../c-api/unicode.rst:141 +#: ../../c-api/unicode.rst:149 msgid "" "Return a void pointer to the raw Unicode buffer. *unicode* has to be a " "Unicode object in the \"canonical\" representation (not checked)." msgstr "" -#: ../../c-api/unicode.rst:150 +#: ../../c-api/unicode.rst:158 msgid "" "Write into a canonical representation *data* (as obtained with :c:func:" "`PyUnicode_DATA`). This function performs no sanity checks, and is intended " @@ -164,194 +172,198 @@ msgid "" "written to that location." msgstr "" -#: ../../c-api/unicode.rst:163 +#: ../../c-api/unicode.rst:171 msgid "" "Read a code point from a canonical representation *data* (as obtained with :" "c:func:`PyUnicode_DATA`). No checks or ready calls are performed." msgstr "" -#: ../../c-api/unicode.rst:171 +#: ../../c-api/unicode.rst:179 msgid "" "Read a character from a Unicode object *unicode*, which must be in the " "\"canonical\" representation. This is less efficient than :c:func:" "`PyUnicode_READ` if you do multiple consecutive reads." msgstr "" -#: ../../c-api/unicode.rst:180 +#: ../../c-api/unicode.rst:188 msgid "" "Return the maximum code point that is suitable for creating another string " "based on *unicode*, which must be in the \"canonical\" representation. This " "is always an approximation but more efficient than iterating over the string." msgstr "" -#: ../../c-api/unicode.rst:189 +#: ../../c-api/unicode.rst:197 msgid "" "Return ``1`` if the string is a valid identifier according to the language " "definition, section :ref:`identifiers`. Return ``0`` otherwise." msgstr "" -#: ../../c-api/unicode.rst:192 +#: ../../c-api/unicode.rst:200 msgid "" "The function does not call :c:func:`Py_FatalError` anymore if the string is " "not ready." msgstr "" -#: ../../c-api/unicode.rst:198 +#: ../../c-api/unicode.rst:206 msgid "Unicode Character Properties" msgstr "" -#: ../../c-api/unicode.rst:200 +#: ../../c-api/unicode.rst:208 msgid "" "Unicode provides many different character properties. The most often needed " "ones are available through these macros which are mapped to C functions " "depending on the Python configuration." msgstr "" -#: ../../c-api/unicode.rst:207 +#: ../../c-api/unicode.rst:215 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is a whitespace character." -msgstr "" +msgstr "根據 *ch* 是否為空白字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:212 +#: ../../c-api/unicode.rst:220 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is a lowercase character." -msgstr "" +msgstr "根據 *ch* 是否為小寫字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:217 +#: ../../c-api/unicode.rst:225 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is an uppercase character." -msgstr "" +msgstr "根據 *ch* 是否為大寫字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:222 +#: ../../c-api/unicode.rst:230 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is a titlecase character." -msgstr "" +msgstr "根據 *ch* 是否為首字大寫字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:227 +#: ../../c-api/unicode.rst:235 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is a linebreak character." -msgstr "" +msgstr "根據 *ch* 是否為換行字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:232 +#: ../../c-api/unicode.rst:240 msgid "Return ``1`` or ``0`` depending on whether *ch* is a decimal character." -msgstr "" +msgstr "根據 *ch* 是否為十進位字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:237 +#: ../../c-api/unicode.rst:245 msgid "Return ``1`` or ``0`` depending on whether *ch* is a digit character." -msgstr "" +msgstr "根據 *ch* 是否為數字 (digit) 字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:242 +#: ../../c-api/unicode.rst:250 msgid "Return ``1`` or ``0`` depending on whether *ch* is a numeric character." -msgstr "" +msgstr "根據 *ch* 是否為數值 (numeric) 字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:247 +#: ../../c-api/unicode.rst:255 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is an alphabetic character." -msgstr "" +msgstr "根據 *ch* 是否為字母字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:252 +#: ../../c-api/unicode.rst:260 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is an alphanumeric character." -msgstr "" +msgstr "根據 *ch* 是否為字母數字 (alphanumeric) 字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:257 +#: ../../c-api/unicode.rst:265 msgid "" -"Return ``1`` or ``0`` depending on whether *ch* is a printable character. " -"Nonprintable characters are those characters defined in the Unicode " -"character database as \"Other\" or \"Separator\", excepting the ASCII space " -"(0x20) which is considered printable. (Note that printable characters in " -"this context are those which should not be escaped when :func:`repr` is " -"invoked on a string. It has no bearing on the handling of strings written " -"to :data:`sys.stdout` or :data:`sys.stderr`.)" +"Return ``1`` or ``0`` depending on whether *ch* is a printable character, in " +"the sense of :meth:`str.isprintable`." msgstr "" +"根據 *ch* 是否為可列印字元(如 :meth:`str.isprintable` 所定義)來回傳 ``1`` " +"或 ``0``。" -#: ../../c-api/unicode.rst:266 +#: ../../c-api/unicode.rst:269 msgid "These APIs can be used for fast direct character conversions:" -msgstr "" +msgstr "這些 API 可用於快速直接字元轉換:" -#: ../../c-api/unicode.rst:271 +#: ../../c-api/unicode.rst:274 msgid "Return the character *ch* converted to lower case." -msgstr "" - -#: ../../c-api/unicode.rst:273 ../../c-api/unicode.rst:281 -#: ../../c-api/unicode.rst:289 -msgid "This function uses simple case mappings." -msgstr "" +msgstr "回傳轉換為小寫的 *ch* 字元。" #: ../../c-api/unicode.rst:279 msgid "Return the character *ch* converted to upper case." -msgstr "" +msgstr "回傳轉換為大寫的 *ch* 字元。" -#: ../../c-api/unicode.rst:287 +#: ../../c-api/unicode.rst:284 msgid "Return the character *ch* converted to title case." -msgstr "" +msgstr "回傳轉換為首字大寫的 *ch* 字元。" -#: ../../c-api/unicode.rst:295 +#: ../../c-api/unicode.rst:289 msgid "" "Return the character *ch* converted to a decimal positive integer. Return " "``-1`` if this is not possible. This function does not raise exceptions." msgstr "" +"回傳轉換為十進位正整數的 *ch* 字元,若無法轉換則回傳 ``-1``。此函式不會引發例" +"外。" -#: ../../c-api/unicode.rst:301 +#: ../../c-api/unicode.rst:295 msgid "" "Return the character *ch* converted to a single digit integer. Return ``-1`` " "if this is not possible. This function does not raise exceptions." msgstr "" +"回傳轉換為單一數字整數的 *ch* 字元,若無法轉換則回傳 ``-1``。此函式不會引發例" +"外。" -#: ../../c-api/unicode.rst:307 +#: ../../c-api/unicode.rst:301 msgid "" "Return the character *ch* converted to a double. Return ``-1.0`` if this is " "not possible. This function does not raise exceptions." msgstr "" +"回傳轉換為雙精度浮點數 (double) 的 *ch* 字元,若無法轉換則回傳 ``-1.0``。此函" +"式不會引發例外。" -#: ../../c-api/unicode.rst:311 +#: ../../c-api/unicode.rst:305 msgid "These APIs can be used to work with surrogates:" -msgstr "" +msgstr "這些 API 可用於處理代理字元:" -#: ../../c-api/unicode.rst:315 +#: ../../c-api/unicode.rst:309 msgid "Check if *ch* is a surrogate (``0xD800 <= ch <= 0xDFFF``)." -msgstr "" +msgstr "檢查 *ch* 是否為代理字元 (surrogate, ``0xD800 <= ch <= 0xDFFF``)。" -#: ../../c-api/unicode.rst:319 +#: ../../c-api/unicode.rst:313 msgid "Check if *ch* is a high surrogate (``0xD800 <= ch <= 0xDBFF``)." msgstr "" +"檢查 *ch* 是否為高代理字元 (high surrogate, ``0xD800 <= ch <= 0xDBFF``)。" -#: ../../c-api/unicode.rst:323 +#: ../../c-api/unicode.rst:317 msgid "Check if *ch* is a low surrogate (``0xDC00 <= ch <= 0xDFFF``)." msgstr "" +"檢查 *ch* 是否為低代理字元 (low surrogate, ``0xDC00 <= ch <= 0xDFFF``)。" -#: ../../c-api/unicode.rst:327 +#: ../../c-api/unicode.rst:321 msgid "" -"Join two surrogate characters and return a single :c:type:`Py_UCS4` value. " +"Join two surrogate code points and return a single :c:type:`Py_UCS4` value. " "*high* and *low* are respectively the leading and trailing surrogates in a " "surrogate pair. *high* must be in the range [0xD800; 0xDBFF] and *low* must " "be in the range [0xDC00; 0xDFFF]." msgstr "" -#: ../../c-api/unicode.rst:334 +#: ../../c-api/unicode.rst:328 msgid "Creating and accessing Unicode strings" msgstr "" -#: ../../c-api/unicode.rst:336 +#: ../../c-api/unicode.rst:330 msgid "" "To create Unicode objects and access their basic sequence properties, use " "these APIs:" msgstr "" -#: ../../c-api/unicode.rst:341 +#: ../../c-api/unicode.rst:335 msgid "" "Create a new Unicode object. *maxchar* should be the true maximum code " "point to be placed in the string. As an approximation, it can be rounded up " "to the nearest value in the sequence 127, 255, 65535, 1114111." msgstr "" -#: ../../c-api/unicode.rst:345 +#: ../../c-api/unicode.rst:339 msgid "" "This is the recommended way to allocate a new Unicode object. Objects " "created using this function are not resizable." msgstr "" -#: ../../c-api/unicode.rst:354 +#: ../../c-api/unicode.rst:342 +msgid "On error, set an exception and return ``NULL``." +msgstr "" + +#: ../../c-api/unicode.rst:350 msgid "" "Create a new Unicode object with the given *kind* (possible values are :c:" "macro:`PyUnicode_1BYTE_KIND` etc., as returned by :c:func:" @@ -359,7 +371,7 @@ msgid "" "1, 2 or 4 bytes per character, as given by the kind." msgstr "" -#: ../../c-api/unicode.rst:359 +#: ../../c-api/unicode.rst:355 msgid "" "If necessary, the input *buffer* is copied and transformed into the " "canonical representation. For example, if the *buffer* is a UCS4 string (:c:" @@ -367,7 +379,7 @@ msgid "" "range, it will be transformed into UCS1 (:c:macro:`PyUnicode_1BYTE_KIND`)." msgstr "" -#: ../../c-api/unicode.rst:370 +#: ../../c-api/unicode.rst:366 msgid "" "Create a Unicode object from the char buffer *str*. The bytes will be " "interpreted as being UTF-8 encoded. The buffer is copied into the new " @@ -375,29 +387,29 @@ msgid "" "data is not allowed." msgstr "" -#: ../../c-api/unicode.rst:376 +#: ../../c-api/unicode.rst:372 msgid "This function raises :exc:`SystemError` when:" -msgstr "" +msgstr "此函式在以下情況下會引發 :exc:`SystemError`:" -#: ../../c-api/unicode.rst:378 +#: ../../c-api/unicode.rst:374 msgid "*size* < 0," -msgstr "" +msgstr "*size* < 0," -#: ../../c-api/unicode.rst:379 +#: ../../c-api/unicode.rst:375 msgid "*str* is ``NULL`` and *size* > 0" -msgstr "" +msgstr "*str* 為 ``NULL`` 且 *size* > 0" -#: ../../c-api/unicode.rst:381 +#: ../../c-api/unicode.rst:377 msgid "*str* == ``NULL`` with *size* > 0 is not allowed anymore." -msgstr "" +msgstr "*str* == ``NULL`` 且 *size* > 0 不再被允許。" -#: ../../c-api/unicode.rst:387 +#: ../../c-api/unicode.rst:383 msgid "" "Create a Unicode object from a UTF-8 encoded null-terminated char buffer " "*str*." msgstr "" -#: ../../c-api/unicode.rst:393 +#: ../../c-api/unicode.rst:389 msgid "" "Take a C :c:func:`printf`\\ -style *format* string and a variable number of " "arguments, calculate the size of the resulting Python Unicode string and " @@ -406,23 +418,23 @@ msgid "" "*format* ASCII-encoded string." msgstr "" -#: ../../c-api/unicode.rst:399 +#: ../../c-api/unicode.rst:395 msgid "" "A conversion specifier contains two or more characters and has the following " "components, which must occur in this order:" msgstr "" -#: ../../c-api/unicode.rst:402 +#: ../../c-api/unicode.rst:398 msgid "The ``'%'`` character, which marks the start of the specifier." msgstr "" -#: ../../c-api/unicode.rst:404 +#: ../../c-api/unicode.rst:400 msgid "" "Conversion flags (optional), which affect the result of some conversion " "types." msgstr "" -#: ../../c-api/unicode.rst:407 +#: ../../c-api/unicode.rst:403 msgid "" "Minimum field width (optional). If specified as an ``'*'`` (asterisk), the " "actual width is given in the next argument, which must be of type :c:expr:" @@ -430,7 +442,7 @@ msgid "" "optional precision." msgstr "" -#: ../../c-api/unicode.rst:412 +#: ../../c-api/unicode.rst:408 msgid "" "Precision (optional), given as a ``'.'`` (dot) followed by the precision. If " "specified as ``'*'`` (an asterisk), the actual precision is given in the " @@ -438,271 +450,316 @@ msgid "" "comes after the precision." msgstr "" -#: ../../c-api/unicode.rst:417 +#: ../../c-api/unicode.rst:413 msgid "Length modifier (optional)." msgstr "" -#: ../../c-api/unicode.rst:419 +#: ../../c-api/unicode.rst:415 msgid "Conversion type." msgstr "" -#: ../../c-api/unicode.rst:421 +#: ../../c-api/unicode.rst:417 msgid "The conversion flag characters are:" msgstr "" -#: ../../c-api/unicode.rst:426 +#: ../../c-api/unicode.rst:422 msgid "Flag" msgstr "旗標" -#: ../../c-api/unicode.rst:426 +#: ../../c-api/unicode.rst:422 msgid "Meaning" msgstr "含義" -#: ../../c-api/unicode.rst:428 +#: ../../c-api/unicode.rst:424 msgid "``0``" msgstr "``0``" -#: ../../c-api/unicode.rst:428 +#: ../../c-api/unicode.rst:424 msgid "The conversion will be zero padded for numeric values." msgstr "" -#: ../../c-api/unicode.rst:430 +#: ../../c-api/unicode.rst:426 msgid "``-``" msgstr "``-``" -#: ../../c-api/unicode.rst:430 +#: ../../c-api/unicode.rst:426 msgid "" "The converted value is left adjusted (overrides the ``0`` flag if both are " "given)." msgstr "" -#: ../../c-api/unicode.rst:434 +#: ../../c-api/unicode.rst:430 msgid "" "The length modifiers for following integer conversions (``d``, ``i``, ``o``, " "``u``, ``x``, or ``X``) specify the type of the argument (:c:expr:`int` by " "default):" msgstr "" -#: ../../c-api/unicode.rst:441 +#: ../../c-api/unicode.rst:437 msgid "Modifier" msgstr "" -#: ../../c-api/unicode.rst:441 +#: ../../c-api/unicode.rst:437 msgid "Types" msgstr "" -#: ../../c-api/unicode.rst:443 +#: ../../c-api/unicode.rst:439 msgid "``l``" msgstr "``l``" -#: ../../c-api/unicode.rst:443 +#: ../../c-api/unicode.rst:439 msgid ":c:expr:`long` or :c:expr:`unsigned long`" msgstr ":c:expr:`long` 或 :c:expr:`unsigned long`" -#: ../../c-api/unicode.rst:445 +#: ../../c-api/unicode.rst:441 msgid "``ll``" msgstr "``ll``" -#: ../../c-api/unicode.rst:445 +#: ../../c-api/unicode.rst:441 msgid ":c:expr:`long long` or :c:expr:`unsigned long long`" msgstr ":c:expr:`long long` 或 :c:expr:`unsigned long long`" -#: ../../c-api/unicode.rst:447 +#: ../../c-api/unicode.rst:443 msgid "``j``" msgstr "``j``" -#: ../../c-api/unicode.rst:447 +#: ../../c-api/unicode.rst:443 msgid ":c:type:`intmax_t` or :c:type:`uintmax_t`" msgstr ":c:type:`intmax_t` 或 :c:type:`uintmax_t`" -#: ../../c-api/unicode.rst:449 +#: ../../c-api/unicode.rst:445 msgid "``z``" msgstr "``z``" -#: ../../c-api/unicode.rst:449 +#: ../../c-api/unicode.rst:445 msgid ":c:type:`size_t` or :c:type:`ssize_t`" msgstr ":c:type:`size_t` 或 :c:type:`ssize_t`" -#: ../../c-api/unicode.rst:451 +#: ../../c-api/unicode.rst:447 msgid "``t``" msgstr "``t``" -#: ../../c-api/unicode.rst:451 +#: ../../c-api/unicode.rst:447 msgid ":c:type:`ptrdiff_t`" msgstr ":c:type:`ptrdiff_t`" -#: ../../c-api/unicode.rst:454 +#: ../../c-api/unicode.rst:450 msgid "" "The length modifier ``l`` for following conversions ``s`` or ``V`` specify " "that the type of the argument is :c:expr:`const wchar_t*`." msgstr "" -#: ../../c-api/unicode.rst:457 +#: ../../c-api/unicode.rst:453 msgid "The conversion specifiers are:" msgstr "" -#: ../../c-api/unicode.rst:463 +#: ../../c-api/unicode.rst:459 msgid "Conversion Specifier" msgstr "" -#: ../../c-api/unicode.rst:464 +#: ../../c-api/unicode.rst:460 msgid "Type" msgstr "" -#: ../../c-api/unicode.rst:465 +#: ../../c-api/unicode.rst:461 msgid "Comment" msgstr "" -#: ../../c-api/unicode.rst:467 +#: ../../c-api/unicode.rst:463 msgid "``%``" msgstr "``%``" -#: ../../c-api/unicode.rst:468 +#: ../../c-api/unicode.rst:464 msgid "*n/a*" msgstr "*n/a*" -#: ../../c-api/unicode.rst:469 +#: ../../c-api/unicode.rst:465 msgid "The literal ``%`` character." -msgstr "" +msgstr "字面 ``%`` 字元。" -#: ../../c-api/unicode.rst:471 +#: ../../c-api/unicode.rst:467 msgid "``d``, ``i``" msgstr "``d``, ``i``" -#: ../../c-api/unicode.rst:472 ../../c-api/unicode.rst:476 -#: ../../c-api/unicode.rst:480 ../../c-api/unicode.rst:484 -#: ../../c-api/unicode.rst:488 +#: ../../c-api/unicode.rst:468 ../../c-api/unicode.rst:472 +#: ../../c-api/unicode.rst:476 ../../c-api/unicode.rst:480 +#: ../../c-api/unicode.rst:484 msgid "Specified by the length modifier" msgstr "" -#: ../../c-api/unicode.rst:473 +#: ../../c-api/unicode.rst:469 msgid "The decimal representation of a signed C integer." -msgstr "" +msgstr "一個有符號 C 整數的十進位表示法。" -#: ../../c-api/unicode.rst:475 +#: ../../c-api/unicode.rst:471 msgid "``u``" msgstr "``u``" -#: ../../c-api/unicode.rst:477 +#: ../../c-api/unicode.rst:473 msgid "The decimal representation of an unsigned C integer." -msgstr "" +msgstr "一個無符號 C 整數的十進位表示法。" -#: ../../c-api/unicode.rst:479 +#: ../../c-api/unicode.rst:475 msgid "``o``" msgstr "``o``" -#: ../../c-api/unicode.rst:481 +#: ../../c-api/unicode.rst:477 msgid "The octal representation of an unsigned C integer." -msgstr "" +msgstr "一個無符號 C 整數的八進位表示法。" -#: ../../c-api/unicode.rst:483 +#: ../../c-api/unicode.rst:479 msgid "``x``" msgstr "``x``" -#: ../../c-api/unicode.rst:485 +#: ../../c-api/unicode.rst:481 msgid "The hexadecimal representation of an unsigned C integer (lowercase)." -msgstr "" +msgstr "一個無符號 C 整數的十六進位表示法(小寫)。" -#: ../../c-api/unicode.rst:487 +#: ../../c-api/unicode.rst:483 msgid "``X``" msgstr "``X``" -#: ../../c-api/unicode.rst:489 +#: ../../c-api/unicode.rst:485 msgid "The hexadecimal representation of an unsigned C integer (uppercase)." -msgstr "" +msgstr "一個無符號 C 整數的十六進位表示法(大寫)。" -#: ../../c-api/unicode.rst:491 +#: ../../c-api/unicode.rst:487 msgid "``c``" msgstr "``c``" -#: ../../c-api/unicode.rst:492 +#: ../../c-api/unicode.rst:488 msgid ":c:expr:`int`" msgstr ":c:expr:`int`" -#: ../../c-api/unicode.rst:493 +#: ../../c-api/unicode.rst:489 msgid "A single character." -msgstr "" +msgstr "一個單一字元。" -#: ../../c-api/unicode.rst:495 +#: ../../c-api/unicode.rst:491 msgid "``s``" msgstr "``s``" -#: ../../c-api/unicode.rst:496 +#: ../../c-api/unicode.rst:492 msgid ":c:expr:`const char*` or :c:expr:`const wchar_t*`" msgstr ":c:expr:`const char*` 或 :c:expr:`const wchar_t*`" -#: ../../c-api/unicode.rst:497 +#: ../../c-api/unicode.rst:493 msgid "A null-terminated C character array." -msgstr "" +msgstr "一個以 null 結尾的 C 字元陣列。" -#: ../../c-api/unicode.rst:499 +#: ../../c-api/unicode.rst:495 msgid "``p``" msgstr "``p``" -#: ../../c-api/unicode.rst:500 +#: ../../c-api/unicode.rst:496 msgid ":c:expr:`const void*`" msgstr ":c:expr:`const void*`" -#: ../../c-api/unicode.rst:501 +#: ../../c-api/unicode.rst:497 msgid "" "The hex representation of a C pointer. Mostly equivalent to " "``printf(\"%p\")`` except that it is guaranteed to start with the literal " "``0x`` regardless of what the platform's ``printf`` yields." msgstr "" -#: ../../c-api/unicode.rst:506 +#: ../../c-api/unicode.rst:502 msgid "``A``" msgstr "``A``" -#: ../../c-api/unicode.rst:507 ../../c-api/unicode.rst:511 -#: ../../c-api/unicode.rst:521 ../../c-api/unicode.rst:525 +#: ../../c-api/unicode.rst:503 ../../c-api/unicode.rst:507 +#: ../../c-api/unicode.rst:517 ../../c-api/unicode.rst:521 +#: ../../c-api/unicode.rst:525 ../../c-api/unicode.rst:530 msgid ":c:expr:`PyObject*`" msgstr ":c:expr:`PyObject*`" -#: ../../c-api/unicode.rst:508 +#: ../../c-api/unicode.rst:504 msgid "The result of calling :func:`ascii`." -msgstr "" +msgstr "呼叫 :func:`ascii` 的結果。" -#: ../../c-api/unicode.rst:510 +#: ../../c-api/unicode.rst:506 msgid "``U``" msgstr "``U``" -#: ../../c-api/unicode.rst:512 +#: ../../c-api/unicode.rst:508 msgid "A Unicode object." -msgstr "一 Unicode 物件。" +msgstr "一個 Unicode 物件。" -#: ../../c-api/unicode.rst:514 +#: ../../c-api/unicode.rst:510 msgid "``V``" msgstr "``V``" -#: ../../c-api/unicode.rst:515 +#: ../../c-api/unicode.rst:511 msgid ":c:expr:`PyObject*`, :c:expr:`const char*` or :c:expr:`const wchar_t*`" msgstr ":c:expr:`PyObject*`、:c:expr:`const char*` 或 :c:expr:`const wchar_t*`" -#: ../../c-api/unicode.rst:516 +#: ../../c-api/unicode.rst:512 msgid "" "A Unicode object (which may be ``NULL``) and a null-terminated C character " "array as a second parameter (which will be used, if the first parameter is " "``NULL``)." msgstr "" -#: ../../c-api/unicode.rst:520 +#: ../../c-api/unicode.rst:516 msgid "``S``" msgstr "``S``" -#: ../../c-api/unicode.rst:522 +#: ../../c-api/unicode.rst:518 msgid "The result of calling :c:func:`PyObject_Str`." -msgstr "" +msgstr "呼叫 :c:func:`PyObject_Str` 的結果。" -#: ../../c-api/unicode.rst:524 +#: ../../c-api/unicode.rst:520 msgid "``R``" msgstr "``R``" -#: ../../c-api/unicode.rst:526 +#: ../../c-api/unicode.rst:522 msgid "The result of calling :c:func:`PyObject_Repr`." +msgstr "呼叫 :c:func:`PyObject_Repr` 的結果。" + +#: ../../c-api/unicode.rst:524 +msgid "``T``" +msgstr "``T``" + +#: ../../c-api/unicode.rst:526 +msgid "" +"Get the fully qualified name of an object type; call :c:func:" +"`PyType_GetFullyQualifiedName`." msgstr "" #: ../../c-api/unicode.rst:529 +msgid "``#T``" +msgstr "``#T``" + +#: ../../c-api/unicode.rst:531 +msgid "" +"Similar to ``T`` format, but use a colon (``:``) as separator between the " +"module name and the qualified name." +msgstr "" + +#: ../../c-api/unicode.rst:534 +msgid "``N``" +msgstr "``N``" + +#: ../../c-api/unicode.rst:535 ../../c-api/unicode.rst:540 +msgid ":c:expr:`PyTypeObject*`" +msgstr ":c:expr:`PyTypeObject*`" + +#: ../../c-api/unicode.rst:536 +msgid "" +"Get the fully qualified name of a type; call :c:func:" +"`PyType_GetFullyQualifiedName`." +msgstr "" + +#: ../../c-api/unicode.rst:539 +msgid "``#N``" +msgstr "``#N``" + +#: ../../c-api/unicode.rst:541 +msgid "" +"Similar to ``N`` format, but use a colon (``:``) as separator between the " +"module name and the qualified name." +msgstr "" + +#: ../../c-api/unicode.rst:545 msgid "" "The width formatter unit is number of characters rather than bytes. The " "precision formatter unit is number of bytes or :c:type:`wchar_t` items (if " @@ -712,28 +769,30 @@ msgid "" "``PyObject*`` argument is not ``NULL``)." msgstr "" -#: ../../c-api/unicode.rst:537 +#: ../../c-api/unicode.rst:553 msgid "" "Unlike to C :c:func:`printf` the ``0`` flag has effect even when a precision " "is given for integer conversions (``d``, ``i``, ``u``, ``o``, ``x``, or " "``X``)." msgstr "" -#: ../../c-api/unicode.rst:541 +#: ../../c-api/unicode.rst:557 msgid "Support for ``\"%lld\"`` and ``\"%llu\"`` added." -msgstr "" +msgstr "新增對 ``\"%lld\"`` 和 ``\"%llu\"`` 的支援。" -#: ../../c-api/unicode.rst:544 +#: ../../c-api/unicode.rst:560 msgid "Support for ``\"%li\"``, ``\"%lli\"`` and ``\"%zi\"`` added." -msgstr "" +msgstr "新增對 ``\"%li\"``、``\"%lli\"`` 和 ``\"%zi\"`` 的支援。" -#: ../../c-api/unicode.rst:547 +#: ../../c-api/unicode.rst:563 msgid "" "Support width and precision formatter for ``\"%s\"``, ``\"%A\"``, " "``\"%U\"``, ``\"%V\"``, ``\"%S\"``, ``\"%R\"`` added." msgstr "" +"新增對 ``\"%s\"``、``\"%A\"``、``\"%U\"``、``\"%V\"``、``\"%S\"``、" +"``\"%R\"`` 的寬度和精確度格式化支援。" -#: ../../c-api/unicode.rst:551 +#: ../../c-api/unicode.rst:567 msgid "" "Support for conversion specifiers ``o`` and ``X``. Support for length " "modifiers ``j`` and ``t``. Length modifiers are now applied to all integer " @@ -742,36 +801,50 @@ msgid "" "flag ``-``." msgstr "" -#: ../../c-api/unicode.rst:559 +#: ../../c-api/unicode.rst:575 msgid "" "An unrecognized format character now sets a :exc:`SystemError`. In previous " "versions it caused all the rest of the format string to be copied as-is to " "the result string, and any extra arguments discarded." msgstr "" -#: ../../c-api/unicode.rst:566 +#: ../../c-api/unicode.rst:579 +msgid "Support for ``%T``, ``%#T``, ``%N`` and ``%#N`` formats added." +msgstr "新增對 ``%T``、``%#T``、``%N`` 和 ``%#N`` 格式的支援。" + +#: ../../c-api/unicode.rst:585 msgid "" "Identical to :c:func:`PyUnicode_FromFormat` except that it takes exactly two " "arguments." msgstr "" -#: ../../c-api/unicode.rst:572 +#: ../../c-api/unicode.rst:591 msgid "" "Copy an instance of a Unicode subtype to a new true Unicode object if " "necessary. If *obj* is already a true Unicode object (not a subtype), return " "a new :term:`strong reference` to the object." msgstr "" -#: ../../c-api/unicode.rst:576 +#: ../../c-api/unicode.rst:595 msgid "" "Objects other than Unicode or its subtypes will cause a :exc:`TypeError`." msgstr "" -#: ../../c-api/unicode.rst:582 +#: ../../c-api/unicode.rst:600 +msgid "Create a Unicode Object from the given Unicode code point *ordinal*." +msgstr "" + +#: ../../c-api/unicode.rst:602 +msgid "" +"The ordinal must be in ``range(0x110000)``. A :exc:`ValueError` is raised in " +"the case it is not." +msgstr "" + +#: ../../c-api/unicode.rst:609 msgid "Decode an encoded object *obj* to a Unicode object." msgstr "" -#: ../../c-api/unicode.rst:584 +#: ../../c-api/unicode.rst:611 msgid "" ":class:`bytes`, :class:`bytearray` and other :term:`bytes-like objects " "` are decoded according to the given *encoding* and using " @@ -779,23 +852,48 @@ msgid "" "interface use the default values (see :ref:`builtincodecs` for details)." msgstr "" -#: ../../c-api/unicode.rst:590 +#: ../../c-api/unicode.rst:617 msgid "" "All other objects, including Unicode objects, cause a :exc:`TypeError` to be " "set." msgstr "" -#: ../../c-api/unicode.rst:593 +#: ../../c-api/unicode.rst:620 msgid "" "The API returns ``NULL`` if there was an error. The caller is responsible " "for decref'ing the returned objects." msgstr "" -#: ../../c-api/unicode.rst:599 +#: ../../c-api/unicode.rst:626 +msgid "" +"Return a mapping suitable for decoding a custom single-byte encoding. Given " +"a Unicode string *string* of up to 256 characters representing an encoding " +"table, returns either a compact internal mapping object or a dictionary " +"mapping character ordinals to byte values. Raises a :exc:`TypeError` and " +"return ``NULL`` on invalid input. .. versionadded:: 3.2" +msgstr "" + +#: ../../c-api/unicode.rst:636 +msgid "" +"Return the name of the default string encoding, ``\"utf-8\"``. See :func:" +"`sys.getdefaultencoding`." +msgstr "" + +#: ../../c-api/unicode.rst:639 +msgid "" +"The returned string does not need to be freed, and is valid until " +"interpreter shutdown." +msgstr "" + +#: ../../c-api/unicode.rst:645 msgid "Return the length of the Unicode object, in code points." msgstr "" -#: ../../c-api/unicode.rst:610 +#: ../../c-api/unicode.rst:647 +msgid "On error, set an exception and return ``-1``." +msgstr "發生錯誤時,設定例外並回傳 ``-1``。" + +#: ../../c-api/unicode.rst:658 msgid "" "Copy characters from one Unicode object into another. This function " "performs character conversion when necessary and falls back to :c:func:`!" @@ -803,52 +901,61 @@ msgid "" "otherwise returns the number of copied characters." msgstr "" -#: ../../c-api/unicode.rst:621 +#: ../../c-api/unicode.rst:669 msgid "" "Fill a string with a character: write *fill_char* into ``unicode[start:" "start+length]``." msgstr "" -#: ../../c-api/unicode.rst:624 +#: ../../c-api/unicode.rst:672 msgid "" "Fail if *fill_char* is bigger than the string maximum character, or if the " "string has more than 1 reference." msgstr "" -#: ../../c-api/unicode.rst:627 +#: ../../c-api/unicode.rst:675 msgid "" "Return the number of written character, or return ``-1`` and raise an " "exception on error." msgstr "" -#: ../../c-api/unicode.rst:636 +#: ../../c-api/unicode.rst:684 msgid "" "Write a character to a string. The string must have been created through :c:" "func:`PyUnicode_New`. Since Unicode strings are supposed to be immutable, " "the string must not be shared, or have been hashed yet." msgstr "" -#: ../../c-api/unicode.rst:640 +#: ../../c-api/unicode.rst:688 msgid "" "This function checks that *unicode* is a Unicode object, that the index is " "not out of bounds, and that the object can be modified safely (i.e. that it " "its reference count is one)." msgstr "" -#: ../../c-api/unicode.rst:649 +#: ../../c-api/unicode.rst:692 +msgid "Return ``0`` on success, ``-1`` on error with an exception set." +msgstr "成功時回傳 ``0``,發生錯誤時設定例外並回傳 ``-1``。" + +#: ../../c-api/unicode.rst:699 msgid "" "Read a character from a string. This function checks that *unicode* is a " "Unicode object and the index is not out of bounds, in contrast to :c:func:" "`PyUnicode_READ_CHAR`, which performs no error checking." msgstr "" -#: ../../c-api/unicode.rst:659 +#: ../../c-api/unicode.rst:703 +msgid "Return character on success, ``-1`` on error with an exception set." +msgstr "成功時回傳字元,發生錯誤時設定例外並回傳 ``-1``。" + +#: ../../c-api/unicode.rst:711 msgid "" "Return a substring of *unicode*, from character index *start* (included) to " -"character index *end* (excluded). Negative indices are not supported." +"character index *end* (excluded). Negative indices are not supported. On " +"error, set an exception and return ``NULL``." msgstr "" -#: ../../c-api/unicode.rst:668 +#: ../../c-api/unicode.rst:721 msgid "" "Copy the string *unicode* into a UCS4 buffer, including a null character, if " "*copy_null* is set. Returns ``NULL`` and sets an exception on error (in " @@ -856,7 +963,7 @@ msgid "" "*unicode*). *buffer* is returned on success." msgstr "" -#: ../../c-api/unicode.rst:678 +#: ../../c-api/unicode.rst:731 msgid "" "Copy the string *unicode* into a new UCS4 buffer that is allocated using :c:" "func:`PyMem_Malloc`. If this fails, ``NULL`` is returned with a :exc:" @@ -864,17 +971,17 @@ msgid "" "appended." msgstr "" -#: ../../c-api/unicode.rst:687 +#: ../../c-api/unicode.rst:740 msgid "Locale Encoding" msgstr "" -#: ../../c-api/unicode.rst:689 +#: ../../c-api/unicode.rst:742 msgid "" "The current locale encoding can be used to decode text from the operating " "system." msgstr "" -#: ../../c-api/unicode.rst:696 +#: ../../c-api/unicode.rst:749 msgid "" "Decode a string from UTF-8 on Android and VxWorks, or from the current " "locale encoding on other platforms. The supported error handlers are " @@ -883,21 +990,21 @@ msgid "" "null character but cannot contain embedded null characters." msgstr "" -#: ../../c-api/unicode.rst:703 +#: ../../c-api/unicode.rst:756 msgid "" "Use :c:func:`PyUnicode_DecodeFSDefaultAndSize` to decode a string from the :" "term:`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/unicode.rst:706 ../../c-api/unicode.rst:741 +#: ../../c-api/unicode.rst:759 ../../c-api/unicode.rst:794 msgid "This function ignores the :ref:`Python UTF-8 Mode `." -msgstr "" +msgstr "此函式會忽略 :ref:`Python UTF-8 模式 `。" -#: ../../c-api/unicode.rst:710 ../../c-api/unicode.rst:807 +#: ../../c-api/unicode.rst:763 ../../c-api/unicode.rst:879 msgid "The :c:func:`Py_DecodeLocale` function." msgstr ":c:func:`Py_DecodeLocale` 函式。" -#: ../../c-api/unicode.rst:714 +#: ../../c-api/unicode.rst:767 msgid "" "The function now also uses the current locale encoding for the " "``surrogateescape`` error handler, except on Android. Previously, :c:func:" @@ -905,13 +1012,15 @@ msgid "" "locale encoding was used for ``strict``." msgstr "" -#: ../../c-api/unicode.rst:723 +#: ../../c-api/unicode.rst:776 msgid "" "Similar to :c:func:`PyUnicode_DecodeLocaleAndSize`, but compute the string " "length using :c:func:`!strlen`." msgstr "" +"類似於 :c:func:`PyUnicode_DecodeLocaleAndSize`,但使用 :c:func:`!strlen` 計算" +"字串長度。" -#: ../../c-api/unicode.rst:731 +#: ../../c-api/unicode.rst:784 msgid "" "Encode a Unicode object to UTF-8 on Android and VxWorks, or to the current " "locale encoding on other platforms. The supported error handlers are " @@ -920,17 +1029,17 @@ msgid "" "`bytes` object. *unicode* cannot contain embedded null characters." msgstr "" -#: ../../c-api/unicode.rst:738 +#: ../../c-api/unicode.rst:791 msgid "" "Use :c:func:`PyUnicode_EncodeFSDefault` to encode a string to the :term:" "`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/unicode.rst:745 ../../c-api/unicode.rst:838 +#: ../../c-api/unicode.rst:798 ../../c-api/unicode.rst:910 msgid "The :c:func:`Py_EncodeLocale` function." msgstr ":c:func:`Py_EncodeLocale` 函式。" -#: ../../c-api/unicode.rst:749 +#: ../../c-api/unicode.rst:802 msgid "" "The function now also uses the current locale encoding for the " "``surrogateescape`` error handler, except on Android. Previously, :c:func:" @@ -938,103 +1047,124 @@ msgid "" "locale encoding was used for ``strict``." msgstr "" -#: ../../c-api/unicode.rst:758 +#: ../../c-api/unicode.rst:811 msgid "File System Encoding" -msgstr "" +msgstr "檔案系統編碼" -#: ../../c-api/unicode.rst:760 +#: ../../c-api/unicode.rst:813 msgid "" "Functions encoding to and decoding from the :term:`filesystem encoding and " "error handler` (:pep:`383` and :pep:`529`)." msgstr "" -#: ../../c-api/unicode.rst:763 +#: ../../c-api/unicode.rst:816 msgid "" "To encode file names to :class:`bytes` during argument parsing, the " -"``\"O&\"`` converter should be used, passing :c:func:`PyUnicode_FSConverter` " -"as the conversion function:" +"``\"O&\"`` converter should be used, passing :c:func:`!" +"PyUnicode_FSConverter` as the conversion function:" msgstr "" -#: ../../c-api/unicode.rst:769 +#: ../../c-api/unicode.rst:822 msgid "" -"ParseTuple converter: encode :class:`str` objects -- obtained directly or " -"through the :class:`os.PathLike` interface -- to :class:`bytes` using :c:" -"func:`PyUnicode_EncodeFSDefault`; :class:`bytes` objects are output as-is. " -"*result* must be a :c:expr:`PyBytesObject*` which must be released when it " -"is no longer used." +":ref:`PyArg_Parse\\* converter `: encode :class:`str` objects " +"-- obtained directly or through the :class:`os.PathLike` interface -- to :" +"class:`bytes` using :c:func:`PyUnicode_EncodeFSDefault`; :class:`bytes` " +"objects are output as-is. *result* must be an address of a C variable of " +"type :c:expr:`PyObject*` (or :c:expr:`PyBytesObject*`). On success, set the " +"variable to a new :term:`strong reference` to a :ref:`bytes object " +"` which must be released when it is no longer used and return " +"a non-zero value (:c:macro:`Py_CLEANUP_SUPPORTED`). Embedded null bytes are " +"not allowed in the result. On failure, return ``0`` with an exception set." msgstr "" -#: ../../c-api/unicode.rst:777 ../../c-api/unicode.rst:794 -msgid "Accepts a :term:`path-like object`." +#: ../../c-api/unicode.rst:834 +msgid "" +"If *obj* is ``NULL``, the function releases a strong reference stored in the " +"variable referred by *result* and returns ``1``." msgstr "" -#: ../../c-api/unicode.rst:780 +#: ../../c-api/unicode.rst:839 ../../c-api/unicode.rst:866 +msgid "Accepts a :term:`path-like object`." +msgstr "接受一個 :term:`path-like object`。" + +#: ../../c-api/unicode.rst:842 msgid "" "To decode file names to :class:`str` during argument parsing, the ``\"O&\"`` " -"converter should be used, passing :c:func:`PyUnicode_FSDecoder` as the " +"converter should be used, passing :c:func:`!PyUnicode_FSDecoder` as the " "conversion function:" msgstr "" -#: ../../c-api/unicode.rst:786 +#: ../../c-api/unicode.rst:848 +msgid "" +":ref:`PyArg_Parse\\* converter `: decode :class:`bytes` objects " +"-- obtained either directly or indirectly through the :class:`os.PathLike` " +"interface -- to :class:`str` using :c:func:" +"`PyUnicode_DecodeFSDefaultAndSize`; :class:`str` objects are output as-is. " +"*result* must be an address of a C variable of type :c:expr:`PyObject*` (or :" +"c:expr:`PyUnicodeObject*`). On success, set the variable to a new :term:" +"`strong reference` to a :ref:`Unicode object ` which must be " +"released when it is no longer used and return a non-zero value (:c:macro:" +"`Py_CLEANUP_SUPPORTED`). Embedded null characters are not allowed in the " +"result. On failure, return ``0`` with an exception set." +msgstr "" + +#: ../../c-api/unicode.rst:861 msgid "" -"ParseTuple converter: decode :class:`bytes` objects -- obtained either " -"directly or indirectly through the :class:`os.PathLike` interface -- to :" -"class:`str` using :c:func:`PyUnicode_DecodeFSDefaultAndSize`; :class:`str` " -"objects are output as-is. *result* must be a :c:expr:`PyUnicodeObject*` " -"which must be released when it is no longer used." +"If *obj* is ``NULL``, release the strong reference to the object referred to " +"by *result* and return ``1``." msgstr "" -#: ../../c-api/unicode.rst:800 +#: ../../c-api/unicode.rst:872 msgid "Decode a string from the :term:`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/unicode.rst:802 +#: ../../c-api/unicode.rst:874 msgid "" "If you need to decode a string from the current locale encoding, use :c:func:" "`PyUnicode_DecodeLocaleAndSize`." msgstr "" -#: ../../c-api/unicode.rst:809 ../../c-api/unicode.rst:822 -#: ../../c-api/unicode.rst:842 +#: ../../c-api/unicode.rst:881 ../../c-api/unicode.rst:894 +#: ../../c-api/unicode.rst:914 msgid "" "The :term:`filesystem error handler ` " "is now used." msgstr "" -#: ../../c-api/unicode.rst:816 +#: ../../c-api/unicode.rst:888 msgid "" "Decode a null-terminated string from the :term:`filesystem encoding and " "error handler`." msgstr "" -#: ../../c-api/unicode.rst:819 +#: ../../c-api/unicode.rst:891 msgid "" "If the string length is known, use :c:func:" "`PyUnicode_DecodeFSDefaultAndSize`." -msgstr "" +msgstr "如果字串長度已知,請使用 :c:func:`PyUnicode_DecodeFSDefaultAndSize`。" -#: ../../c-api/unicode.rst:829 +#: ../../c-api/unicode.rst:901 msgid "" "Encode a Unicode object to the :term:`filesystem encoding and error " "handler`, and return :class:`bytes`. Note that the resulting :class:`bytes` " "object can contain null bytes." msgstr "" -#: ../../c-api/unicode.rst:833 +#: ../../c-api/unicode.rst:905 msgid "" "If you need to encode a string to the current locale encoding, use :c:func:" "`PyUnicode_EncodeLocale`." msgstr "" -#: ../../c-api/unicode.rst:847 +#: ../../c-api/unicode.rst:919 msgid "wchar_t Support" msgstr "wchar_t 支援" -#: ../../c-api/unicode.rst:849 +#: ../../c-api/unicode.rst:921 msgid ":c:type:`wchar_t` support for platforms which support it:" -msgstr "" +msgstr "對支援 :c:type:`wchar_t` 的平台提供支援:" -#: ../../c-api/unicode.rst:853 +#: ../../c-api/unicode.rst:925 msgid "" "Create a Unicode object from the :c:type:`wchar_t` buffer *wstr* of the " "given *size*. Passing ``-1`` as the *size* indicates that the function must " @@ -1042,7 +1172,7 @@ msgid "" "failure." msgstr "" -#: ../../c-api/unicode.rst:861 +#: ../../c-api/unicode.rst:933 msgid "" "Copy the Unicode object contents into the :c:type:`wchar_t` buffer *wstr*. " "At most *size* :c:type:`wchar_t` characters are copied (excluding a possibly " @@ -1050,13 +1180,13 @@ msgid "" "`wchar_t` characters copied or ``-1`` in case of an error." msgstr "" -#: ../../c-api/unicode.rst:866 +#: ../../c-api/unicode.rst:938 msgid "" "When *wstr* is ``NULL``, instead return the *size* that would be required to " "store all of *unicode* including a terminating null." msgstr "" -#: ../../c-api/unicode.rst:869 +#: ../../c-api/unicode.rst:941 msgid "" "Note that the resulting :c:expr:`wchar_t*` string may or may not be null-" "terminated. It is the responsibility of the caller to make sure that the :c:" @@ -1066,7 +1196,7 @@ msgid "" "most C functions." msgstr "" -#: ../../c-api/unicode.rst:879 +#: ../../c-api/unicode.rst:951 msgid "" "Convert the Unicode object to a wide character string. The output string " "always ends with a null character. If *size* is not ``NULL``, write the " @@ -1077,37 +1207,37 @@ msgid "" "`wchar_t*` string contains null characters a :exc:`ValueError` is raised." msgstr "" -#: ../../c-api/unicode.rst:887 +#: ../../c-api/unicode.rst:959 msgid "" "Returns a buffer allocated by :c:macro:`PyMem_New` (use :c:func:`PyMem_Free` " "to free it) on success. On error, returns ``NULL`` and *\\*size* is " "undefined. Raises a :exc:`MemoryError` if memory allocation is failed." msgstr "" -#: ../../c-api/unicode.rst:894 +#: ../../c-api/unicode.rst:966 msgid "" "Raises a :exc:`ValueError` if *size* is ``NULL`` and the :c:expr:`wchar_t*` " "string contains null characters." msgstr "" -#: ../../c-api/unicode.rst:902 +#: ../../c-api/unicode.rst:974 msgid "Built-in Codecs" -msgstr "" +msgstr "內建編解碼器" -#: ../../c-api/unicode.rst:904 +#: ../../c-api/unicode.rst:976 msgid "" "Python provides a set of built-in codecs which are written in C for speed. " "All of these codecs are directly usable via the following functions." msgstr "" -#: ../../c-api/unicode.rst:907 +#: ../../c-api/unicode.rst:979 msgid "" "Many of the following APIs take two arguments encoding and errors, and they " "have the same semantics as the ones of the built-in :func:`str` string " "object constructor." msgstr "" -#: ../../c-api/unicode.rst:911 +#: ../../c-api/unicode.rst:983 msgid "" "Setting encoding to ``NULL`` causes the default encoding to be used which is " "UTF-8. The file system calls should use :c:func:`PyUnicode_FSConverter` for " @@ -1115,28 +1245,28 @@ msgid "" "handler` internally." msgstr "" -#: ../../c-api/unicode.rst:916 +#: ../../c-api/unicode.rst:988 msgid "" "Error handling is set by errors which may also be set to ``NULL`` meaning to " "use the default handling defined for the codec. Default error handling for " "all built-in codecs is \"strict\" (:exc:`ValueError` is raised)." msgstr "" -#: ../../c-api/unicode.rst:920 +#: ../../c-api/unicode.rst:992 msgid "" "The codecs all use a similar interface. Only deviations from the following " "generic ones are documented for simplicity." msgstr "" -#: ../../c-api/unicode.rst:925 +#: ../../c-api/unicode.rst:997 msgid "Generic Codecs" -msgstr "" +msgstr "泛用編解碼器" -#: ../../c-api/unicode.rst:927 +#: ../../c-api/unicode.rst:999 msgid "These are the generic codec APIs:" -msgstr "" +msgstr "這些是泛用編解碼器的 API:" -#: ../../c-api/unicode.rst:933 +#: ../../c-api/unicode.rst:1005 msgid "" "Create a Unicode object by decoding *size* bytes of the encoded string " "*str*. *encoding* and *errors* have the same meaning as the parameters of " @@ -1145,7 +1275,7 @@ msgid "" "was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:943 +#: ../../c-api/unicode.rst:1015 msgid "" "Encode a Unicode object and return the result as Python bytes object. " "*encoding* and *errors* have the same meaning as the parameters of the same " @@ -1154,21 +1284,21 @@ msgid "" "was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:951 +#: ../../c-api/unicode.rst:1023 msgid "UTF-8 Codecs" msgstr "UTF-8 編解碼器" -#: ../../c-api/unicode.rst:953 +#: ../../c-api/unicode.rst:1025 msgid "These are the UTF-8 codec APIs:" -msgstr "" +msgstr "這些是 UTF-8 編解碼器的 API:" -#: ../../c-api/unicode.rst:958 +#: ../../c-api/unicode.rst:1030 msgid "" "Create a Unicode object by decoding *size* bytes of the UTF-8 encoded string " "*str*. Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:965 +#: ../../c-api/unicode.rst:1037 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF8`. If " "*consumed* is not ``NULL``, trailing incomplete UTF-8 byte sequences will " @@ -1176,14 +1306,20 @@ msgid "" "of bytes that have been decoded will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:973 +#: ../../c-api/unicode.rst:1045 msgid "" "Encode a Unicode object using UTF-8 and return the result as Python bytes " "object. Error handling is \"strict\". Return ``NULL`` if an exception was " "raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:980 +#: ../../c-api/unicode.rst:1049 ../../c-api/unicode.rst:1064 +msgid "" +"The function fails if the string contains surrogate code points (``U+D800`` " +"- ``U+DFFF``)." +msgstr "" + +#: ../../c-api/unicode.rst:1055 msgid "" "Return a pointer to the UTF-8 encoding of the Unicode object, and store the " "size of the encoded representation (in bytes) in *size*. The *size* " @@ -1192,13 +1328,15 @@ msgid "" "regardless of whether there are any other null code points." msgstr "" -#: ../../c-api/unicode.rst:986 +#: ../../c-api/unicode.rst:1061 msgid "" -"In the case of an error, ``NULL`` is returned with an exception set and no " -"*size* is stored." +"On error, set an exception, set *size* to ``-1`` (if it's not NULL) and " +"return ``NULL``." msgstr "" +"發生錯誤時,設定例外並將 *size* 設為 ``-1``\\ (如果不是 NULL),並回傳 " +"``NULL``。" -#: ../../c-api/unicode.rst:989 +#: ../../c-api/unicode.rst:1067 msgid "" "This caches the UTF-8 representation of the string in the Unicode object, " "and subsequent calls will return a pointer to the same buffer. The caller " @@ -1207,47 +1345,57 @@ msgid "" "collected." msgstr "" -#: ../../c-api/unicode.rst:996 ../../c-api/unicode.rst:1009 +#: ../../c-api/unicode.rst:1074 ../../c-api/unicode.rst:1096 msgid "The return type is now ``const char *`` rather of ``char *``." -msgstr "" +msgstr "回傳型別現在是 ``const char *`` 而不是 ``char *``。" -#: ../../c-api/unicode.rst:999 +#: ../../c-api/unicode.rst:1077 msgid "This function is a part of the :ref:`limited API `." msgstr "" -#: ../../c-api/unicode.rst:1005 +#: ../../c-api/unicode.rst:1083 msgid "As :c:func:`PyUnicode_AsUTF8AndSize`, but does not store the size." +msgstr "與 :c:func:`PyUnicode_AsUTF8AndSize` 類似,但不儲存大小。" + +#: ../../c-api/unicode.rst:1087 +msgid "" +"This function does not have any special behavior for `null characters " +"`_ embedded within *unicode*. " +"As a result, strings containing null characters will remain in the returned " +"string, which some C functions might interpret as the end of the string, " +"leading to truncation. If truncation is an issue, it is recommended to use :" +"c:func:`PyUnicode_AsUTF8AndSize` instead." msgstr "" -#: ../../c-api/unicode.rst:1014 +#: ../../c-api/unicode.rst:1101 msgid "UTF-32 Codecs" msgstr "UTF-32 編解碼器" -#: ../../c-api/unicode.rst:1016 +#: ../../c-api/unicode.rst:1103 msgid "These are the UTF-32 codec APIs:" -msgstr "" +msgstr "這些是 UTF-32 編解碼器的 API:" -#: ../../c-api/unicode.rst:1022 +#: ../../c-api/unicode.rst:1109 msgid "" "Decode *size* bytes from a UTF-32 encoded buffer string and return the " "corresponding Unicode object. *errors* (if non-``NULL``) defines the error " "handling. It defaults to \"strict\"." msgstr "" -#: ../../c-api/unicode.rst:1026 ../../c-api/unicode.rst:1076 +#: ../../c-api/unicode.rst:1113 ../../c-api/unicode.rst:1163 msgid "" "If *byteorder* is non-``NULL``, the decoder starts decoding using the given " "byte order::" msgstr "" -#: ../../c-api/unicode.rst:1029 ../../c-api/unicode.rst:1079 +#: ../../c-api/unicode.rst:1116 ../../c-api/unicode.rst:1166 msgid "" "*byteorder == -1: little endian\n" "*byteorder == 0: native order\n" "*byteorder == 1: big endian" msgstr "" -#: ../../c-api/unicode.rst:1033 +#: ../../c-api/unicode.rst:1120 msgid "" "If ``*byteorder`` is zero, and the first four bytes of the input data are a " "byte order mark (BOM), the decoder switches to this byte order and the BOM " @@ -1255,21 +1403,21 @@ msgid "" "``-1`` or ``1``, any byte order mark is copied to the output." msgstr "" -#: ../../c-api/unicode.rst:1038 +#: ../../c-api/unicode.rst:1125 msgid "" "After completion, *\\*byteorder* is set to the current byte order at the end " "of input data." msgstr "" -#: ../../c-api/unicode.rst:1041 ../../c-api/unicode.rst:1092 +#: ../../c-api/unicode.rst:1128 ../../c-api/unicode.rst:1179 msgid "If *byteorder* is ``NULL``, the codec starts in native order mode." msgstr "" -#: ../../c-api/unicode.rst:1043 ../../c-api/unicode.rst:1094 +#: ../../c-api/unicode.rst:1130 ../../c-api/unicode.rst:1181 msgid "Return ``NULL`` if an exception was raised by the codec." -msgstr "" +msgstr "如果編解碼器引發例外則回傳 ``NULL``。" -#: ../../c-api/unicode.rst:1049 +#: ../../c-api/unicode.rst:1136 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF32`. If " "*consumed* is not ``NULL``, :c:func:`PyUnicode_DecodeUTF32Stateful` will not " @@ -1278,29 +1426,29 @@ msgid "" "number of bytes that have been decoded will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:1058 +#: ../../c-api/unicode.rst:1145 msgid "" "Return a Python byte string using the UTF-32 encoding in native byte order. " "The string always starts with a BOM mark. Error handling is \"strict\". " "Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1064 +#: ../../c-api/unicode.rst:1151 msgid "UTF-16 Codecs" msgstr "UTF-16 編解碼器" -#: ../../c-api/unicode.rst:1066 +#: ../../c-api/unicode.rst:1153 msgid "These are the UTF-16 codec APIs:" -msgstr "" +msgstr "這些是 UTF-16 編解碼器的 API:" -#: ../../c-api/unicode.rst:1072 +#: ../../c-api/unicode.rst:1159 msgid "" "Decode *size* bytes from a UTF-16 encoded buffer string and return the " "corresponding Unicode object. *errors* (if non-``NULL``) defines the error " "handling. It defaults to \"strict\"." msgstr "" -#: ../../c-api/unicode.rst:1083 +#: ../../c-api/unicode.rst:1170 msgid "" "If ``*byteorder`` is zero, and the first two bytes of the input data are a " "byte order mark (BOM), the decoder switches to this byte order and the BOM " @@ -1309,13 +1457,13 @@ msgid "" "result in either a ``\\ufeff`` or a ``\\ufffe`` character)." msgstr "" -#: ../../c-api/unicode.rst:1089 +#: ../../c-api/unicode.rst:1176 msgid "" "After completion, ``*byteorder`` is set to the current byte order at the end " "of input data." msgstr "" -#: ../../c-api/unicode.rst:1100 +#: ../../c-api/unicode.rst:1187 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF16`. If " "*consumed* is not ``NULL``, :c:func:`PyUnicode_DecodeUTF16Stateful` will not " @@ -1325,28 +1473,28 @@ msgid "" "*consumed*." msgstr "" -#: ../../c-api/unicode.rst:1109 +#: ../../c-api/unicode.rst:1196 msgid "" "Return a Python byte string using the UTF-16 encoding in native byte order. " "The string always starts with a BOM mark. Error handling is \"strict\". " "Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1115 +#: ../../c-api/unicode.rst:1202 msgid "UTF-7 Codecs" msgstr "UTF-7 編解碼器" -#: ../../c-api/unicode.rst:1117 +#: ../../c-api/unicode.rst:1204 msgid "These are the UTF-7 codec APIs:" -msgstr "" +msgstr "這些是 UTF-7 編解碼器的 API:" -#: ../../c-api/unicode.rst:1122 +#: ../../c-api/unicode.rst:1209 msgid "" "Create a Unicode object by decoding *size* bytes of the UTF-7 encoded string " "*str*. Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1129 +#: ../../c-api/unicode.rst:1216 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF7`. If " "*consumed* is not ``NULL``, trailing incomplete UTF-7 base-64 sections will " @@ -1354,101 +1502,101 @@ msgid "" "of bytes that have been decoded will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:1136 +#: ../../c-api/unicode.rst:1223 msgid "Unicode-Escape Codecs" msgstr "" -#: ../../c-api/unicode.rst:1138 +#: ../../c-api/unicode.rst:1225 msgid "These are the \"Unicode Escape\" codec APIs:" msgstr "" -#: ../../c-api/unicode.rst:1144 +#: ../../c-api/unicode.rst:1231 msgid "" "Create a Unicode object by decoding *size* bytes of the Unicode-Escape " "encoded string *str*. Return ``NULL`` if an exception was raised by the " "codec." msgstr "" -#: ../../c-api/unicode.rst:1150 +#: ../../c-api/unicode.rst:1237 msgid "" "Encode a Unicode object using Unicode-Escape and return the result as a " "bytes object. Error handling is \"strict\". Return ``NULL`` if an " "exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1156 +#: ../../c-api/unicode.rst:1243 msgid "Raw-Unicode-Escape Codecs" msgstr "" -#: ../../c-api/unicode.rst:1158 +#: ../../c-api/unicode.rst:1245 msgid "These are the \"Raw Unicode Escape\" codec APIs:" msgstr "" -#: ../../c-api/unicode.rst:1164 +#: ../../c-api/unicode.rst:1251 msgid "" "Create a Unicode object by decoding *size* bytes of the Raw-Unicode-Escape " "encoded string *str*. Return ``NULL`` if an exception was raised by the " "codec." msgstr "" -#: ../../c-api/unicode.rst:1170 +#: ../../c-api/unicode.rst:1257 msgid "" "Encode a Unicode object using Raw-Unicode-Escape and return the result as a " "bytes object. Error handling is \"strict\". Return ``NULL`` if an " "exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1176 +#: ../../c-api/unicode.rst:1263 msgid "Latin-1 Codecs" msgstr "Latin-1 編解碼器" -#: ../../c-api/unicode.rst:1178 +#: ../../c-api/unicode.rst:1265 msgid "" "These are the Latin-1 codec APIs: Latin-1 corresponds to the first 256 " "Unicode ordinals and only these are accepted by the codecs during encoding." msgstr "" -#: ../../c-api/unicode.rst:1184 +#: ../../c-api/unicode.rst:1271 msgid "" "Create a Unicode object by decoding *size* bytes of the Latin-1 encoded " "string *str*. Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1190 +#: ../../c-api/unicode.rst:1277 msgid "" "Encode a Unicode object using Latin-1 and return the result as Python bytes " "object. Error handling is \"strict\". Return ``NULL`` if an exception was " "raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1196 +#: ../../c-api/unicode.rst:1283 msgid "ASCII Codecs" msgstr "ASCII 編解碼器" -#: ../../c-api/unicode.rst:1198 +#: ../../c-api/unicode.rst:1285 msgid "" "These are the ASCII codec APIs. Only 7-bit ASCII data is accepted. All " "other codes generate errors." msgstr "" -#: ../../c-api/unicode.rst:1204 +#: ../../c-api/unicode.rst:1291 msgid "" "Create a Unicode object by decoding *size* bytes of the ASCII encoded string " "*str*. Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1210 +#: ../../c-api/unicode.rst:1297 msgid "" "Encode a Unicode object using ASCII and return the result as Python bytes " "object. Error handling is \"strict\". Return ``NULL`` if an exception was " "raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1216 +#: ../../c-api/unicode.rst:1303 msgid "Character Map Codecs" msgstr "" -#: ../../c-api/unicode.rst:1218 +#: ../../c-api/unicode.rst:1305 msgid "" "This codec is special in that it can be used to implement many different " "codecs (and this is in fact what was done to obtain most of the standard " @@ -1458,18 +1606,18 @@ msgid "" "sequences work well." msgstr "" -#: ../../c-api/unicode.rst:1224 +#: ../../c-api/unicode.rst:1311 msgid "These are the mapping codec APIs:" -msgstr "" +msgstr "這些是對映編解碼器的 API:" -#: ../../c-api/unicode.rst:1229 +#: ../../c-api/unicode.rst:1316 msgid "" "Create a Unicode object by decoding *size* bytes of the encoded string *str* " "using the given *mapping* object. Return ``NULL`` if an exception was " "raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1233 +#: ../../c-api/unicode.rst:1320 msgid "" "If *mapping* is ``NULL``, Latin-1 decoding will be applied. Else *mapping* " "must map bytes ordinals (integers in the range from 0 to 255) to Unicode " @@ -1479,14 +1627,14 @@ msgid "" "treated as undefined mappings and cause an error." msgstr "" -#: ../../c-api/unicode.rst:1244 +#: ../../c-api/unicode.rst:1331 msgid "" "Encode a Unicode object using the given *mapping* object and return the " "result as a bytes object. Error handling is \"strict\". Return ``NULL`` if " "an exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1248 +#: ../../c-api/unicode.rst:1335 msgid "" "The *mapping* object must map Unicode ordinal integers to bytes objects, " "integers in the range from 0 to 255 or ``None``. Unmapped character " @@ -1494,41 +1642,41 @@ msgid "" "``None`` are treated as \"undefined mapping\" and cause an error." msgstr "" -#: ../../c-api/unicode.rst:1254 +#: ../../c-api/unicode.rst:1341 msgid "The following codec API is special in that maps Unicode to Unicode." msgstr "" -#: ../../c-api/unicode.rst:1258 +#: ../../c-api/unicode.rst:1345 msgid "" "Translate a string by applying a character mapping table to it and return " "the resulting Unicode object. Return ``NULL`` if an exception was raised by " "the codec." msgstr "" -#: ../../c-api/unicode.rst:1262 +#: ../../c-api/unicode.rst:1349 msgid "" "The mapping table must map Unicode ordinal integers to Unicode ordinal " "integers or ``None`` (causing deletion of the character)." msgstr "" -#: ../../c-api/unicode.rst:1265 +#: ../../c-api/unicode.rst:1352 msgid "" "Mapping tables need only provide the :meth:`~object.__getitem__` interface; " "dictionaries and sequences work well. Unmapped character ordinals (ones " "which cause a :exc:`LookupError`) are left untouched and are copied as-is." msgstr "" -#: ../../c-api/unicode.rst:1269 +#: ../../c-api/unicode.rst:1356 msgid "" "*errors* has the usual meaning for codecs. It may be ``NULL`` which " "indicates to use the default error handling." msgstr "" -#: ../../c-api/unicode.rst:1274 +#: ../../c-api/unicode.rst:1361 msgid "MBCS codecs for Windows" -msgstr "" +msgstr "Windows 的 MBCS 編解碼器" -#: ../../c-api/unicode.rst:1276 +#: ../../c-api/unicode.rst:1363 msgid "" "These are the MBCS codec APIs. They are currently only available on Windows " "and use the Win32 MBCS converters to implement the conversions. Note that " @@ -1536,13 +1684,13 @@ msgid "" "is defined by the user settings on the machine running the codec." msgstr "" -#: ../../c-api/unicode.rst:1283 +#: ../../c-api/unicode.rst:1370 msgid "" "Create a Unicode object by decoding *size* bytes of the MBCS encoded string " "*str*. Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1290 +#: ../../c-api/unicode.rst:1377 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeMBCS`. If " "*consumed* is not ``NULL``, :c:func:`PyUnicode_DecodeMBCSStateful` will not " @@ -1550,44 +1698,46 @@ msgid "" "will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:1298 +#: ../../c-api/unicode.rst:1386 +msgid "" +"Similar to :c:func:`PyUnicode_DecodeMBCSStateful`, except uses the code page " +"specified by *code_page*." +msgstr "" + +#: ../../c-api/unicode.rst:1392 msgid "" "Encode a Unicode object using MBCS and return the result as Python bytes " "object. Error handling is \"strict\". Return ``NULL`` if an exception was " "raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1305 +#: ../../c-api/unicode.rst:1399 msgid "" "Encode the Unicode object using the specified code page and return a Python " "bytes object. Return ``NULL`` if an exception was raised by the codec. Use :" "c:macro:`!CP_ACP` code page to get the MBCS encoder." msgstr "" -#: ../../c-api/unicode.rst:1313 -msgid "Methods & Slots" -msgstr "" - -#: ../../c-api/unicode.rst:1319 +#: ../../c-api/unicode.rst:1409 msgid "Methods and Slot Functions" msgstr "" -#: ../../c-api/unicode.rst:1321 +#: ../../c-api/unicode.rst:1411 msgid "" "The following APIs are capable of handling Unicode objects and strings on " "input (we refer to them as strings in the descriptions) and return Unicode " "objects or integers as appropriate." msgstr "" -#: ../../c-api/unicode.rst:1325 +#: ../../c-api/unicode.rst:1415 msgid "They all return ``NULL`` or ``-1`` if an exception occurs." -msgstr "" +msgstr "如果發生例外,則回傳 ``NULL`` 或 ``-1``。" -#: ../../c-api/unicode.rst:1330 +#: ../../c-api/unicode.rst:1420 msgid "Concat two strings giving a new Unicode string." msgstr "" -#: ../../c-api/unicode.rst:1335 +#: ../../c-api/unicode.rst:1425 msgid "" "Split a string giving a list of Unicode strings. If *sep* is ``NULL``, " "splitting will be done at all whitespace substrings. Otherwise, splits " @@ -1596,27 +1746,73 @@ msgid "" "list." msgstr "" -#: ../../c-api/unicode.rst:1343 +#: ../../c-api/unicode.rst:1430 ../../c-api/unicode.rst:1440 +#: ../../c-api/unicode.rst:1461 ../../c-api/unicode.rst:1474 +msgid "On error, return ``NULL`` with an exception set." +msgstr "於錯誤發生時回傳 ``NULL`` 並設定例外。" + +#: ../../c-api/unicode.rst:1432 +msgid "Equivalent to :py:meth:`str.split`." +msgstr "等價於 :py:meth:`str.split`。" + +#: ../../c-api/unicode.rst:1437 +msgid "" +"Similar to :c:func:`PyUnicode_Split`, but splitting will be done beginning " +"at the end of the string." +msgstr "" + +#: ../../c-api/unicode.rst:1442 +msgid "Equivalent to :py:meth:`str.rsplit`." +msgstr "等價於 :py:meth:`str.rsplit`。" + +#: ../../c-api/unicode.rst:1447 msgid "" "Split a Unicode string at line breaks, returning a list of Unicode strings. " "CRLF is considered to be one line break. If *keepends* is ``0``, the Line " "break characters are not included in the resulting strings." msgstr "" -#: ../../c-api/unicode.rst:1350 +#: ../../c-api/unicode.rst:1454 +msgid "" +"Split a Unicode string at the first occurrence of *sep*, and return a 3-" +"tuple containing the part before the separator, the separator itself, and " +"the part after the separator. If the separator is not found, return a 3-" +"tuple containing the string itself, followed by two empty strings." +msgstr "" + +#: ../../c-api/unicode.rst:1459 ../../c-api/unicode.rst:1472 +msgid "*sep* must not be empty." +msgstr "*sep* 不得為空。" + +#: ../../c-api/unicode.rst:1463 +msgid "Equivalent to :py:meth:`str.partition`." +msgstr "等價於 :py:meth:`str.partition`。" + +#: ../../c-api/unicode.rst:1468 +msgid "" +"Similar to :c:func:`PyUnicode_Partition`, but split a Unicode string at the " +"last occurrence of *sep*. If the separator is not found, return a 3-tuple " +"containing two empty strings, followed by the string itself." +msgstr "" + +#: ../../c-api/unicode.rst:1476 +msgid "Equivalent to :py:meth:`str.rpartition`." +msgstr "等價於 :py:meth:`str.rpartition`。" + +#: ../../c-api/unicode.rst:1481 msgid "" "Join a sequence of strings using the given *separator* and return the " "resulting Unicode string." msgstr "" -#: ../../c-api/unicode.rst:1357 +#: ../../c-api/unicode.rst:1488 msgid "" "Return ``1`` if *substr* matches ``unicode[start:end]`` at the given tail " "end (*direction* == ``-1`` means to do a prefix match, *direction* == ``1`` " "a suffix match), ``0`` otherwise. Return ``-1`` if an error occurred." msgstr "" -#: ../../c-api/unicode.rst:1365 +#: ../../c-api/unicode.rst:1496 msgid "" "Return the first position of *substr* in ``unicode[start:end]`` using the " "given *direction* (*direction* == ``1`` means to do a forward search, " @@ -1625,7 +1821,7 @@ msgid "" "``-2`` indicates that an error occurred and an exception has been set." msgstr "" -#: ../../c-api/unicode.rst:1375 +#: ../../c-api/unicode.rst:1506 msgid "" "Return the first position of the character *ch* in ``unicode[start:end]`` " "using the given *direction* (*direction* == ``1`` means to do a forward " @@ -1635,37 +1831,57 @@ msgid "" "set." msgstr "" -#: ../../c-api/unicode.rst:1383 +#: ../../c-api/unicode.rst:1514 msgid "" "*start* and *end* are now adjusted to behave like ``unicode[start:end]``." msgstr "" -#: ../../c-api/unicode.rst:1390 +#: ../../c-api/unicode.rst:1521 msgid "" "Return the number of non-overlapping occurrences of *substr* in " "``unicode[start:end]``. Return ``-1`` if an error occurred." msgstr "" -#: ../../c-api/unicode.rst:1397 +#: ../../c-api/unicode.rst:1528 msgid "" "Replace at most *maxcount* occurrences of *substr* in *unicode* with " "*replstr* and return the resulting Unicode object. *maxcount* == ``-1`` " "means replace all occurrences." msgstr "" -#: ../../c-api/unicode.rst:1404 +#: ../../c-api/unicode.rst:1535 msgid "" "Compare two strings and return ``-1``, ``0``, ``1`` for less than, equal, " "and greater than, respectively." msgstr "" -#: ../../c-api/unicode.rst:1407 +#: ../../c-api/unicode.rst:1538 msgid "" "This function returns ``-1`` upon failure, so one should call :c:func:" "`PyErr_Occurred` to check for errors." msgstr "" -#: ../../c-api/unicode.rst:1413 +#: ../../c-api/unicode.rst:1544 +msgid "" +"Compare a Unicode object with a char buffer which is interpreted as being " +"UTF-8 or ASCII encoded and return true (``1``) if they are equal, or false " +"(``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." +msgstr "" + +#: ../../c-api/unicode.rst:1551 ../../c-api/unicode.rst:1572 +msgid "This function does not raise exceptions." +msgstr "此函式不會引發例外。" + +#: ../../c-api/unicode.rst:1558 +msgid "" +"Similar to :c:func:`PyUnicode_EqualToUTF8AndSize`, but compute *string* " +"length using :c:func:`!strlen`. If the Unicode object contains null " +"characters, false (``0``) is returned." +msgstr "" + +#: ../../c-api/unicode.rst:1567 msgid "" "Compare a Unicode object, *unicode*, with *string* and return ``-1``, ``0``, " "``1`` for less than, equal, and greater than, respectively. It is best to " @@ -1673,51 +1889,47 @@ msgid "" "string as ISO-8859-1 if it contains non-ASCII characters." msgstr "" -#: ../../c-api/unicode.rst:1418 -msgid "This function does not raise exceptions." -msgstr "" - -#: ../../c-api/unicode.rst:1423 +#: ../../c-api/unicode.rst:1577 msgid "Rich compare two Unicode strings and return one of the following:" msgstr "" -#: ../../c-api/unicode.rst:1425 +#: ../../c-api/unicode.rst:1579 msgid "``NULL`` in case an exception was raised" msgstr "" -#: ../../c-api/unicode.rst:1426 +#: ../../c-api/unicode.rst:1580 msgid ":c:data:`Py_True` or :c:data:`Py_False` for successful comparisons" msgstr "" -#: ../../c-api/unicode.rst:1427 +#: ../../c-api/unicode.rst:1581 msgid ":c:data:`Py_NotImplemented` in case the type combination is unknown" msgstr "" -#: ../../c-api/unicode.rst:1429 +#: ../../c-api/unicode.rst:1583 msgid "" "Possible values for *op* are :c:macro:`Py_GT`, :c:macro:`Py_GE`, :c:macro:" "`Py_EQ`, :c:macro:`Py_NE`, :c:macro:`Py_LT`, and :c:macro:`Py_LE`." msgstr "" -#: ../../c-api/unicode.rst:1435 +#: ../../c-api/unicode.rst:1589 msgid "" "Return a new string object from *format* and *args*; this is analogous to " "``format % args``." msgstr "" -#: ../../c-api/unicode.rst:1441 +#: ../../c-api/unicode.rst:1595 msgid "" "Check whether *substr* is contained in *unicode* and return true or false " "accordingly." msgstr "" -#: ../../c-api/unicode.rst:1444 +#: ../../c-api/unicode.rst:1598 msgid "" "*substr* has to coerce to a one element Unicode string. ``-1`` is returned " "if there was an error." msgstr "" -#: ../../c-api/unicode.rst:1450 +#: ../../c-api/unicode.rst:1604 msgid "" "Intern the argument :c:expr:`*p_unicode` in place. The argument must be the " "address of a pointer variable pointing to a Python Unicode string object. " @@ -1725,16 +1937,54 @@ msgid "" "`*p_unicode`, it sets :c:expr:`*p_unicode` to it (releasing the reference to " "the old string object and creating a new :term:`strong reference` to the " "interned string object), otherwise it leaves :c:expr:`*p_unicode` alone and " -"interns it (creating a new :term:`strong reference`). (Clarification: even " -"though there is a lot of talk about references, think of this function as " -"reference-neutral; you own the object after the call if and only if you " -"owned it before the call.)" +"interns it." msgstr "" -#: ../../c-api/unicode.rst:1463 +#: ../../c-api/unicode.rst:1611 +msgid "" +"(Clarification: even though there is a lot of talk about references, think " +"of this function as reference-neutral. You must own the object you pass in; " +"after the call you no longer own the passed-in reference, but you newly own " +"the result.)" +msgstr "" + +#: ../../c-api/unicode.rst:1616 +msgid "" +"This function never raises an exception. On error, it leaves its argument " +"unchanged without interning it." +msgstr "" + +#: ../../c-api/unicode.rst:1619 +msgid "" +"Instances of subclasses of :py:class:`str` may not be interned, that is, :c:" +"expr:`PyUnicode_CheckExact(*p_unicode)` must be true. If it is not, then -- " +"as with any other error -- the argument is left unchanged." +msgstr "" + +#: ../../c-api/unicode.rst:1623 +msgid "" +"Note that interned strings are not “immortal”. You must keep a reference to " +"the result to benefit from interning." +msgstr "" + +#: ../../c-api/unicode.rst:1629 msgid "" "A combination of :c:func:`PyUnicode_FromString` and :c:func:" -"`PyUnicode_InternInPlace`, returning either a new Unicode string object that " -"has been interned, or a new (\"owned\") reference to an earlier interned " -"string object with the same value." +"`PyUnicode_InternInPlace`, meant for statically allocated strings." +msgstr "" + +#: ../../c-api/unicode.rst:1632 +msgid "" +"Return a new (\"owned\") reference to either a new Unicode string object " +"that has been interned, or an earlier interned string object with the same " +"value." +msgstr "" + +#: ../../c-api/unicode.rst:1636 +msgid "" +"Python may keep a reference to the result, or make it :term:`immortal`, " +"preventing it from being garbage-collected promptly. For interning an " +"unbounded number of different strings, such as ones coming from user input, " +"prefer calling :c:func:`PyUnicode_FromString` and :c:func:" +"`PyUnicode_InternInPlace` directly." msgstr "" diff --git a/c-api/utilities.po b/c-api/utilities.po index 71b6b1c0b7..4775a245ec 100644 --- a/c-api/utilities.po +++ b/c-api/utilities.po @@ -8,7 +8,7 @@ # Phil Lin , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2022-01-31 17:38+0800\n" diff --git a/c-api/veryhigh.po b/c-api/veryhigh.po index 10005e654d..80cabb8b50 100644 --- a/c-api/veryhigh.po +++ b/c-api/veryhigh.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-02-12 00:03+0000\n" +"POT-Creation-Date: 2025-01-22 00:13+0000\n" "PO-Revision-Date: 2018-05-23 14:08+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -51,47 +51,23 @@ msgstr "" #: ../../c-api/veryhigh.rst:30 msgid "" -"The main program for the standard interpreter. This is made available for " -"programs which embed Python. The *argc* and *argv* parameters should be " -"prepared exactly as those which are passed to a C program's :c:func:`main` " -"function (converted to wchar_t according to the user's locale). It is " -"important to note that the argument list may be modified (but the contents " -"of the strings pointed to by the argument list are not). 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 parameter list does not represent a valid Python command line." -msgstr "" - -#: ../../c-api/veryhigh.rst:40 -msgid "" -"Note that if an otherwise unhandled :exc:`SystemExit` is raised, this " -"function will not return ``1``, but exit the process, as long as :c:member:" -"`PyConfig.inspect` is zero." -msgstr "" - -#: ../../c-api/veryhigh.rst:47 -msgid "Similar to :c:func:`Py_Main` but *argv* is an array of bytes strings." -msgstr "" - -#: ../../c-api/veryhigh.rst:54 -msgid "" "This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, " "leaving *closeit* set to ``0`` and *flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:60 +#: ../../c-api/veryhigh.rst:36 msgid "" "This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, " "leaving the *closeit* argument set to ``0``." msgstr "" -#: ../../c-api/veryhigh.rst:66 +#: ../../c-api/veryhigh.rst:42 msgid "" "This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, " "leaving the *flags* argument set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:72 +#: ../../c-api/veryhigh.rst:48 msgid "" "If *fp* refers to a file associated with an interactive device (console or " "terminal input or Unix pseudo-terminal), return the value of :c:func:" @@ -102,13 +78,13 @@ msgid "" "before ``PyRun_SimpleFileExFlags()`` returns." msgstr "" -#: ../../c-api/veryhigh.rst:84 +#: ../../c-api/veryhigh.rst:60 msgid "" "This is a simplified interface to :c:func:`PyRun_SimpleStringFlags` below, " "leaving the :c:struct:`PyCompilerFlags`\\* argument set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:90 +#: ../../c-api/veryhigh.rst:66 msgid "" "Executes the Python source code from *command* in the :mod:`__main__` module " "according to the *flags* argument. If :mod:`__main__` does not already " @@ -117,26 +93,26 @@ msgid "" "information. For the meaning of *flags*, see below." msgstr "" -#: ../../c-api/veryhigh.rst:96 +#: ../../c-api/veryhigh.rst:72 msgid "" "Note that if an otherwise unhandled :exc:`SystemExit` is raised, this " "function will not return ``-1``, but exit the process, as long as :c:member:" "`PyConfig.inspect` is zero." msgstr "" -#: ../../c-api/veryhigh.rst:103 +#: ../../c-api/veryhigh.rst:79 msgid "" "This is a simplified interface to :c:func:`PyRun_SimpleFileExFlags` below, " "leaving *closeit* set to ``0`` and *flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:109 +#: ../../c-api/veryhigh.rst:85 msgid "" "This is a simplified interface to :c:func:`PyRun_SimpleFileExFlags` below, " "leaving *flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:115 +#: ../../c-api/veryhigh.rst:91 msgid "" "Similar to :c:func:`PyRun_SimpleStringFlags`, but the Python source code is " "read from *fp* instead of an in-memory string. *filename* should be the name " @@ -145,20 +121,20 @@ msgid "" "``PyRun_SimpleFileExFlags()`` returns." msgstr "" -#: ../../c-api/veryhigh.rst:122 +#: ../../c-api/veryhigh.rst:98 msgid "" "On Windows, *fp* should be opened as binary mode (e.g. ``fopen(filename, " "\"rb\")``). Otherwise, Python may not handle script file with LF line ending " "correctly." msgstr "" -#: ../../c-api/veryhigh.rst:128 +#: ../../c-api/veryhigh.rst:104 msgid "" "This is a simplified interface to :c:func:`PyRun_InteractiveOneFlags` below, " "leaving *flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:134 +#: ../../c-api/veryhigh.rst:110 msgid "" "Read and execute a single statement from a file associated with an " "interactive device according to the *flags* argument. The user will be " @@ -166,7 +142,7 @@ msgid "" "term:`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/veryhigh.rst:139 +#: ../../c-api/veryhigh.rst:115 msgid "" "Returns ``0`` when the input was executed successfully, ``-1`` if there was " "an exception, or an error code from the :file:`errcode.h` include file " @@ -175,13 +151,13 @@ msgid "" "specifically if needed.)" msgstr "" -#: ../../c-api/veryhigh.rst:148 +#: ../../c-api/veryhigh.rst:124 msgid "" "This is a simplified interface to :c:func:`PyRun_InteractiveLoopFlags` " "below, leaving *flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:154 +#: ../../c-api/veryhigh.rst:130 msgid "" "Read and execute statements from a file associated with an interactive " "device until EOF is reached. The user will be prompted using ``sys.ps1`` " @@ -189,7 +165,7 @@ msgid "" "and error handler`. Returns ``0`` at EOF or a negative number upon failure." msgstr "" -#: ../../c-api/veryhigh.rst:162 +#: ../../c-api/veryhigh.rst:138 msgid "" "Can be set to point to a function with the prototype ``int func(void)``. " "The function will be called when Python's interpreter prompt is about to " @@ -199,13 +175,13 @@ msgid "" "the Python source code." msgstr "" -#: ../../c-api/veryhigh.rst:170 ../../c-api/veryhigh.rst:194 +#: ../../c-api/veryhigh.rst:146 ../../c-api/veryhigh.rst:170 msgid "" "This function is only called from the :ref:`main interpreter `." msgstr "" -#: ../../c-api/veryhigh.rst:177 +#: ../../c-api/veryhigh.rst:153 msgid "" "Can be set to point to a function with the prototype ``char *func(FILE " "*stdin, FILE *stdout, char *prompt)``, overriding the default function used " @@ -216,26 +192,26 @@ msgid "" "line-editing and tab-completion features." msgstr "" -#: ../../c-api/veryhigh.rst:186 +#: ../../c-api/veryhigh.rst:162 msgid "" "The result must be a string allocated by :c:func:`PyMem_RawMalloc` or :c:" "func:`PyMem_RawRealloc`, or ``NULL`` if an error occurred." msgstr "" -#: ../../c-api/veryhigh.rst:189 +#: ../../c-api/veryhigh.rst:165 msgid "" "The result must be allocated by :c:func:`PyMem_RawMalloc` or :c:func:" "`PyMem_RawRealloc`, instead of being allocated by :c:func:`PyMem_Malloc` or :" "c:func:`PyMem_Realloc`." msgstr "" -#: ../../c-api/veryhigh.rst:200 +#: ../../c-api/veryhigh.rst:176 msgid "" "This is a simplified interface to :c:func:`PyRun_StringFlags` below, leaving " "*flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:206 +#: ../../c-api/veryhigh.rst:182 msgid "" "Execute Python source code from *str* in the context specified by the " "objects *globals* and *locals* with the compiler flags specified by " @@ -244,31 +220,31 @@ msgid "" "token that should be used to parse the source code." msgstr "" -#: ../../c-api/veryhigh.rst:212 +#: ../../c-api/veryhigh.rst:188 msgid "" "Returns the result of executing the code as a Python object, or ``NULL`` if " "an exception was raised." msgstr "" -#: ../../c-api/veryhigh.rst:218 +#: ../../c-api/veryhigh.rst:194 msgid "" "This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving " "*closeit* set to ``0`` and *flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:224 +#: ../../c-api/veryhigh.rst:200 msgid "" "This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving " "*flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:230 +#: ../../c-api/veryhigh.rst:206 msgid "" "This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving " "*closeit* set to ``0``." msgstr "" -#: ../../c-api/veryhigh.rst:236 +#: ../../c-api/veryhigh.rst:212 msgid "" "Similar to :c:func:`PyRun_StringFlags`, but the Python source code is read " "from *fp* instead of an in-memory string. *filename* should be the name of " @@ -277,19 +253,19 @@ msgid "" "`PyRun_FileExFlags` returns." msgstr "" -#: ../../c-api/veryhigh.rst:245 +#: ../../c-api/veryhigh.rst:221 msgid "" "This is a simplified interface to :c:func:`Py_CompileStringFlags` below, " "leaving *flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:251 +#: ../../c-api/veryhigh.rst:227 msgid "" "This is a simplified interface to :c:func:`Py_CompileStringExFlags` below, " "with *optimize* set to ``-1``." msgstr "" -#: ../../c-api/veryhigh.rst:257 +#: ../../c-api/veryhigh.rst:233 msgid "" "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 " @@ -300,7 +276,7 @@ msgid "" "returns ``NULL`` if the code cannot be parsed or compiled." msgstr "" -#: ../../c-api/veryhigh.rst:265 +#: ../../c-api/veryhigh.rst:241 msgid "" "The integer *optimize* specifies the optimization level of the compiler; a " "value of ``-1`` selects the optimization level of the interpreter as given " @@ -309,20 +285,20 @@ msgid "" "or ``2`` (docstrings are removed too)." msgstr "" -#: ../../c-api/veryhigh.rst:276 +#: ../../c-api/veryhigh.rst:252 msgid "" "Like :c:func:`Py_CompileStringObject`, but *filename* is a byte string " "decoded from the :term:`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/veryhigh.rst:283 +#: ../../c-api/veryhigh.rst:259 msgid "" "This is a simplified interface to :c:func:`PyEval_EvalCodeEx`, with just the " "code object, and global and local variables. The other arguments are set to " "``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:290 +#: ../../c-api/veryhigh.rst:266 msgid "" "Evaluate a precompiled code object, given a particular environment for its " "evaluation. This environment consists of a dictionary of global variables, " @@ -331,13 +307,13 @@ msgid "" "only_parameter>` arguments and a closure tuple of cells." msgstr "" -#: ../../c-api/veryhigh.rst:299 +#: ../../c-api/veryhigh.rst:275 msgid "" "Evaluate an execution frame. This is a simplified interface to :c:func:" "`PyEval_EvalFrameEx`, for backward compatibility." msgstr "" -#: ../../c-api/veryhigh.rst:305 +#: ../../c-api/veryhigh.rst:281 msgid "" "This is the main, unvarnished function of Python interpretation. The code " "object associated with the execution frame *f* is executed, interpreting " @@ -347,39 +323,39 @@ msgid "" "of generator objects." msgstr "" -#: ../../c-api/veryhigh.rst:312 +#: ../../c-api/veryhigh.rst:288 msgid "" "This function now includes a debug assertion to help ensure that it does not " "silently discard an active exception." msgstr "" -#: ../../c-api/veryhigh.rst:319 +#: ../../c-api/veryhigh.rst:295 msgid "" "This function changes the flags of the current evaluation frame, and returns " "true on success, false on failure." msgstr "" -#: ../../c-api/veryhigh.rst:327 +#: ../../c-api/veryhigh.rst:303 msgid "" "The start symbol from the Python grammar for isolated expressions; for use " "with :c:func:`Py_CompileString`." msgstr "" -#: ../../c-api/veryhigh.rst:335 +#: ../../c-api/veryhigh.rst:311 msgid "" "The start symbol from the Python grammar for sequences of statements as read " "from a file or other source; for use with :c:func:`Py_CompileString`. This " "is the symbol to use when compiling arbitrarily long Python source code." msgstr "" -#: ../../c-api/veryhigh.rst:344 +#: ../../c-api/veryhigh.rst:320 msgid "" "The start symbol from the Python grammar for a single statement; for use " "with :c:func:`Py_CompileString`. This is the symbol used for the interactive " "interpreter loop." msgstr "" -#: ../../c-api/veryhigh.rst:351 +#: ../../c-api/veryhigh.rst:327 msgid "" "This is the structure used to hold compiler flags. In cases where code is " "only being compiled, it is passed as ``int flags``, and in cases where code " @@ -387,40 +363,50 @@ msgid "" "case, ``from __future__ import`` can modify *flags*." msgstr "" -#: ../../c-api/veryhigh.rst:356 +#: ../../c-api/veryhigh.rst:332 msgid "" "Whenever ``PyCompilerFlags *flags`` is ``NULL``, :c:member:`~PyCompilerFlags." "cf_flags` is treated as equal to ``0``, and any modification due to ``from " "__future__ import`` is discarded." msgstr "" -#: ../../c-api/veryhigh.rst:362 +#: ../../c-api/veryhigh.rst:338 msgid "Compiler flags." msgstr "" -#: ../../c-api/veryhigh.rst:366 +#: ../../c-api/veryhigh.rst:342 msgid "" "*cf_feature_version* is the minor Python version. It should be initialized " "to ``PY_MINOR_VERSION``." msgstr "" -#: ../../c-api/veryhigh.rst:369 +#: ../../c-api/veryhigh.rst:345 msgid "" "The field is ignored by default, it is used if and only if ``PyCF_ONLY_AST`` " "flag is set in :c:member:`~PyCompilerFlags.cf_flags`." msgstr "" -#: ../../c-api/veryhigh.rst:372 +#: ../../c-api/veryhigh.rst:348 msgid "Added *cf_feature_version* field." msgstr "新增 *cf_feature_version* 欄位。" -#: ../../c-api/veryhigh.rst:378 +#: ../../c-api/veryhigh.rst:351 +msgid "The available compiler flags are accessible as macros:" +msgstr "" + +#: ../../c-api/veryhigh.rst:360 +msgid "" +"See :ref:`compiler flags ` in documentation of the :py:" +"mod:`!ast` Python module, which exports these constants under the same names." +msgstr "" + +#: ../../c-api/veryhigh.rst:366 msgid "" "This bit can be set in *flags* to cause division operator ``/`` to be " "interpreted as \"true division\" according to :pep:`238`." msgstr "" -#: ../../c-api/veryhigh.rst:325 ../../c-api/veryhigh.rst:333 -#: ../../c-api/veryhigh.rst:342 +#: ../../c-api/veryhigh.rst:301 ../../c-api/veryhigh.rst:309 +#: ../../c-api/veryhigh.rst:318 msgid "Py_CompileString (C function)" msgstr "Py_CompileString(C 函式)" diff --git a/c-api/weakref.po b/c-api/weakref.po index 9217888102..7bbbcb9f44 100644 --- a/c-api/weakref.po +++ b/c-api/weakref.po @@ -6,9 +6,9 @@ # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-27 00:03+0000\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2017-09-22 18:26+0000\n" "Last-Translator: Leon H.\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -33,17 +33,19 @@ msgstr "" #: ../../c-api/weakref.rst:16 msgid "" -"Return true if *ob* is either a reference or proxy object. This function " -"always succeeds." +"Return non-zero if *ob* is either a reference or proxy object. This " +"function always succeeds." msgstr "" #: ../../c-api/weakref.rst:22 msgid "" -"Return true if *ob* is a reference object. This function always succeeds." +"Return non-zero if *ob* is a reference object. This function always " +"succeeds." msgstr "" #: ../../c-api/weakref.rst:27 -msgid "Return true if *ob* is a proxy object. This function always succeeds." +msgid "" +"Return non-zero if *ob* is a proxy object. This function always succeeds." msgstr "" #: ../../c-api/weakref.rst:32 @@ -72,11 +74,31 @@ msgstr "" #: ../../c-api/weakref.rst:56 msgid "" -"Return the referenced object from a weak reference, *ref*. If the referent " -"is no longer live, returns ``Py_None``." +"Get a :term:`strong reference` to the referenced object from a weak " +"reference, *ref*, into *\\*pobj*." +msgstr "" + +#: ../../c-api/weakref.rst:59 +msgid "" +"On success, set *\\*pobj* to a new :term:`strong reference` to the " +"referenced object and return 1." msgstr "" #: ../../c-api/weakref.rst:61 +msgid "If the reference is dead, set *\\*pobj* to ``NULL`` and return 0." +msgstr "" + +#: ../../c-api/weakref.rst:62 +msgid "On error, raise an exception and return -1." +msgstr "" + +#: ../../c-api/weakref.rst:69 +msgid "" +"Return a :term:`borrowed reference` to the referenced object from a weak " +"reference, *ref*. If the referent is no longer live, returns ``Py_None``." +msgstr "" + +#: ../../c-api/weakref.rst:74 msgid "" "This function returns a :term:`borrowed reference` to the referenced object. " "This means that you should always call :c:func:`Py_INCREF` on the object " @@ -84,19 +106,42 @@ msgid "" "reference." msgstr "" -#: ../../c-api/weakref.rst:69 +#: ../../c-api/weakref.rst:79 ../../c-api/weakref.rst:87 +msgid "Use :c:func:`PyWeakref_GetRef` instead." +msgstr "" + +#: ../../c-api/weakref.rst:85 msgid "Similar to :c:func:`PyWeakref_GetObject`, but does no error checking." msgstr "" -#: ../../c-api/weakref.rst:74 +#: ../../c-api/weakref.rst:93 msgid "" "This function is called by the :c:member:`~PyTypeObject.tp_dealloc` handler " "to clear weak references." msgstr "" -#: ../../c-api/weakref.rst:77 +#: ../../c-api/weakref.rst:96 msgid "" "This iterates through the weak references for *object* and calls callbacks " "for those references which have one. It returns when all callbacks have been " "attempted." msgstr "" + +#: ../../c-api/weakref.rst:103 +msgid "Clears the weakrefs for *object* without calling the callbacks." +msgstr "" + +#: ../../c-api/weakref.rst:105 +msgid "" +"This function is called by the :c:member:`~PyTypeObject.tp_dealloc` handler " +"for types with finalizers (i.e., :meth:`~object.__del__`). The handler for " +"those objects first calls :c:func:`PyObject_ClearWeakRefs` 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." +msgstr "" + +#: ../../c-api/weakref.rst:111 +msgid "" +"In most circumstances, it's more appropriate to use :c:func:" +"`PyObject_ClearWeakRefs` to clear weakrefs instead of this function." +msgstr "" diff --git a/contents.po b/contents.po index 6a7a4c49cb..3312166d6f 100644 --- a/contents.po +++ b/contents.po @@ -7,7 +7,7 @@ # Liang-Bo Wang , 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2017-09-22 18:26+0000\n" diff --git a/copyright.po b/copyright.po index add619c6e3..50a39fdee2 100644 --- a/copyright.po +++ b/copyright.po @@ -9,9 +9,9 @@ # meowmeowcat , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-01-10 00:17+0000\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2021-06-25 20:17+0800\n" "Last-Translator: meowmeowcat \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -32,8 +32,8 @@ msgid "Python and this documentation is:" msgstr "Python 和這份說明文件的版權:" #: ../../copyright.rst:7 -msgid "Copyright © 2001-2023 Python Software Foundation. All rights reserved." -msgstr "Copyright © 2001-2023 Python Software Foundation 保留一切權利。" +msgid "Copyright © 2001-2024 Python Software Foundation. All rights reserved." +msgstr "Copyright © 2001-2024 Python Software Foundation. All rights reserved." #: ../../copyright.rst:9 msgid "Copyright © 2000 BeOpen.com. All rights reserved." diff --git a/deprecations/c-api-pending-removal-in-3.14.po b/deprecations/c-api-pending-removal-in-3.14.po index a8d1a702cf..8541753787 100644 --- a/deprecations/c-api-pending-removal-in-3.14.po +++ b/deprecations/c-api-pending-removal-in-3.14.po @@ -1,15 +1,15 @@ # Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. -# FIRST AUTHOR , YEAR. # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-17 00:03+0000\n" +"POT-Creation-Date: 2024-09-24 07:20+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -24,16 +24,16 @@ msgid "" "The ``ma_version_tag`` field in :c:type:`PyDictObject` for extension modules " "(:pep:`699`; :gh:`101193`)." msgstr "" -":c:type:`PyDictObject` 中的 ``ma_version_tag`` 欄位,用於擴充模組 (:pep:" -"`699`;:gh:`101193`)。" +":c:type:`PyDictObject` 中的 ``ma_version_tag`` 欄位,用於擴充模組 " +"(:pep:`699`;:gh:`101193`)。" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:7 msgid "" "Creating :c:data:`immutable types ` with mutable " "bases (:gh:`95388`)." msgstr "" -"使用可變基底建立\\ :c:data:`不可變型別 ` (:gh:" -"`95388`)。" +"使用可變基底建立\\ :c:data:`不可變型別 ` " +"(:gh:`95388`)。" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:10 msgid "" @@ -41,165 +41,168 @@ msgid "" msgstr "設定 Python 初始化的函式,Python 3.11 中已被棄用:" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:12 -msgid "``PySys_SetArgvEx()``: set :c:member:`PyConfig.argv` instead." -msgstr "``PySys_SetArgvEx()``:請改以 :c:member:`PyConfig.argv` 設定。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:13 -msgid "``PySys_SetArgv()``: set :c:member:`PyConfig.argv` instead." -msgstr "``PySys_SetArgv()``:請改以 :c:member:`PyConfig.argv` 設定。" +msgid ":c:func:`!PySys_SetArgvEx()`: Set :c:member:`PyConfig.argv` instead." +msgstr ":c:func:`!PySys_SetArgvEx()`:請改以 :c:member:`PyConfig.argv` 設定。" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:14 -msgid "``Py_SetProgramName()``: set :c:member:`PyConfig.program_name` instead." +msgid ":c:func:`!PySys_SetArgv()`: Set :c:member:`PyConfig.argv` instead." +msgstr ":c:func:`!PySys_SetArgv()`:請改以 :c:member:`PyConfig.argv` 設定。" + +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:16 +msgid "" +":c:func:`!Py_SetProgramName()`: Set :c:member:`PyConfig.program_name` " +"instead." msgstr "" -"``Py_SetProgramName()``:請改以 :c:member:`PyConfig.program_name` 設定。" +":c:func:`!Py_SetProgramName()``:請改以 :c:member:`PyConfig.program_name` 設" +"定。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:15 -msgid "``Py_SetPythonHome()``: set :c:member:`PyConfig.home` instead." -msgstr "``Py_SetPythonHome()``:請改以 :c:member:`PyConfig.home` 設定。" +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:18 +msgid ":c:func:`!Py_SetPythonHome()`: Set :c:member:`PyConfig.home` instead." +msgstr ":c:func:`!Py_SetPythonHome()`:請改以 :c:member:`PyConfig.home` 設定。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:17 -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:45 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:21 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:71 msgid "" -"The :c:func:`Py_InitializeFromConfig` API should be used with :c:type:" -"`PyConfig` instead." +"The :c:func:`Py_InitializeFromConfig` API should be used " +"with :c:type:`PyConfig` instead." msgstr "" ":c:func:`Py_InitializeFromConfig` API 應該與 :c:type:`PyConfig` 一起使用。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:20 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:24 msgid "Global configuration variables:" msgstr "全域設定變數:" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:22 -msgid ":c:var:`Py_DebugFlag`: use :c:member:`PyConfig.parser_debug` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:26 +msgid ":c:var:`Py_DebugFlag`: Use :c:member:`PyConfig.parser_debug` instead." msgstr ":c:var:`Py_DebugFlag`:請改用 :c:member:`PyConfig.parser_debug`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:23 -msgid ":c:var:`Py_VerboseFlag`: use :c:member:`PyConfig.verbose` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:28 +msgid ":c:var:`Py_VerboseFlag`: Use :c:member:`PyConfig.verbose` instead." msgstr ":c:var:`Py_VerboseFlag`:請改用 :c:member:`PyConfig.verbose`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:24 -msgid ":c:var:`Py_QuietFlag`: use :c:member:`PyConfig.quiet` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:30 +msgid ":c:var:`Py_QuietFlag`: Use :c:member:`PyConfig.quiet` instead." msgstr ":c:var:`Py_QuietFlag`:請改用 :c:member:`PyConfig.quiet`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:25 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:32 msgid "" -":c:var:`Py_InteractiveFlag`: use :c:member:`PyConfig.interactive` instead." +":c:var:`Py_InteractiveFlag`: Use :c:member:`PyConfig.interactive` instead." msgstr ":c:var:`Py_InteractiveFlag`:請改用 :c:member:`PyConfig.interactive`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:26 -msgid ":c:var:`Py_InspectFlag`: use :c:member:`PyConfig.inspect` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:34 +msgid ":c:var:`Py_InspectFlag`: Use :c:member:`PyConfig.inspect` instead." msgstr ":c:var:`Py_InspectFlag`:請改用 :c:member:`PyConfig.inspect`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:27 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:36 msgid "" -":c:var:`Py_OptimizeFlag`: use :c:member:`PyConfig.optimization_level` " +":c:var:`Py_OptimizeFlag`: Use :c:member:`PyConfig.optimization_level` " "instead." msgstr "" ":c:var:`Py_OptimizeFlag`:請改用 :c:member:`PyConfig.optimization_level`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:28 -msgid ":c:var:`Py_NoSiteFlag`: use :c:member:`PyConfig.site_import` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:38 +msgid ":c:var:`Py_NoSiteFlag`: Use :c:member:`PyConfig.site_import` instead." msgstr ":c:var:`Py_NoSiteFlag`:請改用 :c:member:`PyConfig.site_import`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:29 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:40 msgid "" -":c:var:`Py_BytesWarningFlag`: use :c:member:`PyConfig.bytes_warning` instead." +":c:var:`Py_BytesWarningFlag`: Use :c:member:`PyConfig.bytes_warning` instead." msgstr "" ":c:var:`Py_BytesWarningFlag`:請改用 :c:member:`PyConfig.bytes_warning`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:30 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:42 msgid "" -":c:var:`Py_FrozenFlag`: use :c:member:`PyConfig.pathconfig_warnings` instead." +":c:var:`Py_FrozenFlag`: Use :c:member:`PyConfig.pathconfig_warnings` instead." msgstr "" ":c:var:`Py_FrozenFlag`:請改用 :c:member:`PyConfig.pathconfig_warnings`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:31 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:44 msgid "" -":c:var:`Py_IgnoreEnvironmentFlag`: use :c:member:`PyConfig.use_environment` " +":c:var:`Py_IgnoreEnvironmentFlag`: Use :c:member:`PyConfig.use_environment` " "instead." msgstr "" -":c:var:`Py_IgnoreEnvironmentFlag`:請改用 :c:member:`PyConfig." -"use_environment`。" +":c:var:`Py_IgnoreEnvironmentFlag`:請改" +"用 :c:member:`PyConfig.use_environment`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:32 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:46 msgid "" -":c:var:`Py_DontWriteBytecodeFlag`: use :c:member:`PyConfig.write_bytecode` " +":c:var:`Py_DontWriteBytecodeFlag`: Use :c:member:`PyConfig.write_bytecode` " "instead." msgstr "" -":c:var:`Py_DontWriteBytecodeFlag`:請改用 :c:member:`PyConfig." -"write_bytecode`。" +":c:var:`Py_DontWriteBytecodeFlag`:請改" +"用 :c:member:`PyConfig.write_bytecode`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:33 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:48 msgid "" -":c:var:`Py_NoUserSiteDirectory`: use :c:member:`PyConfig." -"user_site_directory` instead." +":c:var:`Py_NoUserSiteDirectory`: " +"Use :c:member:`PyConfig.user_site_directory` instead." msgstr "" -":c:var:`Py_NoUserSiteDirectory`:請改用 :c:member:`PyConfig." -"user_site_directory`。" +":c:var:`Py_NoUserSiteDirectory`:請改" +"用 :c:member:`PyConfig.user_site_directory`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:34 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:50 msgid "" -":c:var:`Py_UnbufferedStdioFlag`: use :c:member:`PyConfig.buffered_stdio` " +":c:var:`Py_UnbufferedStdioFlag`: Use :c:member:`PyConfig.buffered_stdio` " "instead." msgstr "" ":c:var:`Py_UnbufferedStdioFlag`:請改用 :c:member:`PyConfig.buffered_stdio`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:35 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:52 msgid "" -":c:var:`Py_HashRandomizationFlag`: use :c:member:`PyConfig.use_hash_seed` " +":c:var:`Py_HashRandomizationFlag`: Use :c:member:`PyConfig.use_hash_seed` " "and :c:member:`PyConfig.hash_seed` instead." msgstr "" ":c:var:`Py_HashRandomizationFlag`:請改用 :c:member:`PyConfig.use_hash_seed` " "和 :c:member:`PyConfig.hash_seed`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:37 -msgid ":c:var:`Py_IsolatedFlag`: use :c:member:`PyConfig.isolated` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:55 +msgid ":c:var:`Py_IsolatedFlag`: Use :c:member:`PyConfig.isolated` instead." msgstr ":c:var:`Py_IsolatedFlag`:請改用 :c:member:`PyConfig.isolated`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:38 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:57 msgid "" -":c:var:`Py_LegacyWindowsFSEncodingFlag`: use :c:member:`PyPreConfig." -"legacy_windows_fs_encoding` instead." +":c:var:`Py_LegacyWindowsFSEncodingFlag`: " +"Use :c:member:`PyPreConfig.legacy_windows_fs_encoding` instead." msgstr "" -":c:var:`Py_LegacyWindowsFSEncodingFlag`:請改用 :c:member:`PyPreConfig." -"legacy_windows_fs_encoding`。" +":c:var:`Py_LegacyWindowsFSEncodingFlag`:請改" +"用 :c:member:`PyPreConfig.legacy_windows_fs_encoding`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:39 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:59 msgid "" -":c:var:`Py_LegacyWindowsStdioFlag`: use :c:member:`PyConfig." -"legacy_windows_stdio` instead." +":c:var:`Py_LegacyWindowsStdioFlag`: " +"Use :c:member:`PyConfig.legacy_windows_stdio` instead." msgstr "" -":c:var:`Py_LegacyWindowsStdioFlag`:請改用 :c:member:`PyConfig." -"legacy_windows_stdio`。" +":c:var:`Py_LegacyWindowsStdioFlag`:請改" +"用 :c:member:`PyConfig.legacy_windows_stdio`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:40 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:61 msgid "" -":c:var:`!Py_FileSystemDefaultEncoding`: use :c:member:`PyConfig." -"filesystem_encoding` instead." +":c:var:`!Py_FileSystemDefaultEncoding`: " +"Use :c:member:`PyConfig.filesystem_encoding` instead." msgstr "" -":c:var:`!Py_FileSystemDefaultEncoding`:請改用 :c:member:`PyConfig." -"filesystem_encoding`。" +":c:var:`!Py_FileSystemDefaultEncoding`:請改" +"用 :c:member:`PyConfig.filesystem_encoding`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:41 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:63 msgid "" -":c:var:`!Py_HasFileSystemDefaultEncoding`: use :c:member:`PyConfig." -"filesystem_encoding` instead." +":c:var:`!Py_HasFileSystemDefaultEncoding`: " +"Use :c:member:`PyConfig.filesystem_encoding` instead." msgstr "" -":c:var:`!Py_HasFileSystemDefaultEncoding`:請改用 :c:member:`PyConfig." -"filesystem_encoding`。" +":c:var:`!Py_HasFileSystemDefaultEncoding`:請改" +"用 :c:member:`PyConfig.filesystem_encoding`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:42 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:65 msgid "" -":c:var:`!Py_FileSystemDefaultEncodeErrors`: use :c:member:`PyConfig." -"filesystem_errors` instead." +":c:var:`!Py_FileSystemDefaultEncodeErrors`: " +"Use :c:member:`PyConfig.filesystem_errors` instead." msgstr "" -":c:var:`!Py_FileSystemDefaultEncodeErrors`:請改用 :c:member:`PyConfig." -"filesystem_errors`。" +":c:var:`!Py_FileSystemDefaultEncodeErrors`:請改" +"用 :c:member:`PyConfig.filesystem_errors`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:43 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:67 msgid "" -":c:var:`!Py_UTF8Mode`: use :c:member:`PyPreConfig.utf8_mode` instead. (see :" -"c:func:`Py_PreInitialize`)" +":c:var:`!Py_UTF8Mode`: Use :c:member:`PyPreConfig.utf8_mode` instead. " +"(see :c:func:`Py_PreInitialize`)" msgstr "" -":c:var:`!Py_UTF8Mode`:請改用 :c:member:`PyPreConfig.utf8_mode`。(請見 :c:" -"func:`Py_PreInitialize`)" +":c:var:`!Py_UTF8Mode`:請改用 :c:member:`PyPreConfig.utf8_mode`。(請" +"見 :c:func:`Py_PreInitialize`)" diff --git a/deprecations/c-api-pending-removal-in-3.15.po b/deprecations/c-api-pending-removal-in-3.15.po index f9978c5575..362a44992b 100644 --- a/deprecations/c-api-pending-removal-in-3.15.po +++ b/deprecations/c-api-pending-removal-in-3.15.po @@ -1,16 +1,15 @@ -# SOME DESCRIPTIVE TITLE. # Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. -# FIRST AUTHOR , YEAR. # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-17 00:03+0000\n" +"POT-Creation-Date: 2025-07-03 00:17+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -21,33 +20,28 @@ msgid "Pending Removal in Python 3.15" msgstr "Python 3.15 中待移除的項目" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:4 -msgid "The bundled copy of ``libmpdecimal``." -msgstr "``libmpdecimal`` 的打包副本 (bundled copy)。" - -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:5 msgid "" -":c:func:`PyImport_ImportModuleNoBlock`: use :c:func:`PyImport_ImportModule` " -"instead." +"The :c:func:`PyImport_ImportModuleNoBlock`: Use :c:func:" +"`PyImport_ImportModule` instead." msgstr "" ":c:func:`PyImport_ImportModuleNoBlock`:請改用 :c:func:" "`PyImport_ImportModule`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:6 msgid "" -":c:func:`PyWeakref_GET_OBJECT`: use :c:func:`!PyWeakref_GetRef` instead." -msgstr ":c:func:`PyWeakref_GET_OBJECT`:請改用 :c:func:`!PyWeakref_GetRef`。" - -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:7 -msgid ":c:func:`PyWeakref_GetObject`: use :c:func:`!PyWeakref_GetRef` instead." -msgstr ":c:func:`PyWeakref_GetObject`:請改用 :c:func:`!PyWeakref_GetRef`。" +":c:func:`PyWeakref_GetObject` and :c:func:`PyWeakref_GET_OBJECT`: Use :c:" +"func:`PyWeakref_GetRef` instead." +msgstr "" +":c:func:`PyWeakref_GetObject` 和 :c:func:`PyWeakref_GET_OBJECT`:請改用 :c:" +"func:`PyWeakref_GetRef`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:8 -msgid ":c:type:`!Py_UNICODE_WIDE` type: use :c:type:`wchar_t` instead." -msgstr ":c:type:`!Py_UNICODE_WIDE` type:請改用 :c:type:`wchar_t`。" - -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:9 -msgid ":c:type:`Py_UNICODE` type: use :c:type:`wchar_t` instead." -msgstr ":c:type:`Py_UNICODE` type:請改用 :c:type:`wchar_t`。" +msgid "" +":c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: Use :c:" +"type:`wchar_t` instead." +msgstr "" +":c:type:`Py_UNICODE` 型別與 :c:macro:`!Py_UNICODE_WIDE` 巨集:請改用 :c:type:" +"`wchar_t`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:10 msgid "Python initialization functions:" @@ -55,35 +49,43 @@ msgstr "Python 初始化函式:" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:12 msgid "" -":c:func:`PySys_ResetWarnOptions`: clear :data:`sys.warnoptions` and :data:`!" +":c:func:`PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" "warnings.filters` instead." msgstr "" ":c:func:`PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` 和 :" "data:`!warnings.filters`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:14 -msgid ":c:func:`Py_GetExecPrefix`: get :data:`sys.exec_prefix` instead." -msgstr ":c:func:`Py_GetExecPrefix`:請改用 :data:`sys.exec_prefix`。" +msgid "" +":c:func:`Py_GetExecPrefix`: Get :data:`sys.base_exec_prefix` and :data:`sys." +"exec_prefix` instead." +msgstr "" +":c:func:`Py_GetExecPrefix`:請改用 :data:`sys.base_exec_prefix` 與 :data:" +"`sys.exec_prefix`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:15 -msgid ":c:func:`Py_GetPath`: get :data:`sys.path` instead." +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:16 +msgid ":c:func:`Py_GetPath`: Get :data:`sys.path` instead." msgstr ":c:func:`Py_GetPath`:請改用 :data:`sys.path`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:16 -msgid ":c:func:`Py_GetPrefix`: get :data:`sys.prefix` instead." -msgstr ":c:func:`Py_GetPrefix`:請改用 :data:`sys.prefix`。" +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:18 +msgid "" +":c:func:`Py_GetPrefix`: Get :data:`sys.base_prefix` and :data:`sys.prefix` " +"instead." +msgstr "" +":c:func:`Py_GetPrefix`:請改用 :data:`sys.base_prefix` 與 :data:`sys." +"prefix`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 -msgid ":c:func:`Py_GetProgramFullPath`: get :data:`sys.executable` instead." +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:20 +msgid ":c:func:`Py_GetProgramFullPath`: Get :data:`sys.executable` instead." msgstr ":c:func:`Py_GetProgramFullPath`:請改用 :data:`sys.executable`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:18 -msgid ":c:func:`Py_GetProgramName`: get :data:`sys.executable` instead." +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:22 +msgid ":c:func:`Py_GetProgramName`: Get :data:`sys.executable` instead." msgstr ":c:func:`Py_GetProgramName`:請改用 :data:`sys.executable`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:19 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:24 msgid "" -":c:func:`Py_GetPythonHome`: get :c:member:`PyConfig.home` or the :envvar:" +":c:func:`Py_GetPythonHome`: Get :c:member:`PyConfig.home` or the :envvar:" "`PYTHONHOME` environment variable instead." msgstr "" ":c:func:`Py_GetPythonHome`:請改用 :c:member:`PyConfig.home` 或 :envvar:" diff --git a/deprecations/c-api-pending-removal-in-3.16.po b/deprecations/c-api-pending-removal-in-3.16.po new file mode 100644 index 0000000000..adc146223c --- /dev/null +++ b/deprecations/c-api-pending-removal-in-3.16.po @@ -0,0 +1,24 @@ +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# +msgid "" +msgstr "" +"Project-Id-Version: Python 3.13\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-07-03 00:17+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" +"Language: zh_TW\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../../deprecations/c-api-pending-removal-in-3.16.rst:2 +msgid "Pending removal in Python 3.16" +msgstr "Python 3.16 中待移除的項目" + +#: ../../deprecations/c-api-pending-removal-in-3.16.rst:4 +msgid "The bundled copy of ``libmpdec``." +msgstr "``libmpdecimal`` 的打包副本 (bundled copy)。" diff --git a/deprecations/c-api-pending-removal-in-future.po b/deprecations/c-api-pending-removal-in-future.po index 3dc787ba8d..a9930288d2 100644 --- a/deprecations/c-api-pending-removal-in-future.po +++ b/deprecations/c-api-pending-removal-in-future.po @@ -1,16 +1,15 @@ -# SOME DESCRIPTIVE TITLE. # Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. -# FIRST AUTHOR , YEAR. # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-17 00:03+0000\n" +"POT-Creation-Date: 2024-09-24 07:20+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -27,125 +26,126 @@ msgid "" msgstr "下列 API 已被棄用並將會被移除,不過目前尚未訂定移除日期。" #: ../../deprecations/c-api-pending-removal-in-future.rst:7 -msgid ":c:macro:`Py_TPFLAGS_HAVE_FINALIZE`: unneeded since Python 3.8." +msgid ":c:macro:`Py_TPFLAGS_HAVE_FINALIZE`: Unneeded since Python 3.8." msgstr ":c:macro:`Py_TPFLAGS_HAVE_FINALIZE`:自 Python 3.8 起不再需要" -#: ../../deprecations/c-api-pending-removal-in-future.rst:8 -msgid ":c:func:`PyErr_Fetch`: use :c:func:`PyErr_GetRaisedException` instead." +#: ../../deprecations/c-api-pending-removal-in-future.rst:9 +msgid ":c:func:`PyErr_Fetch`: Use :c:func:`PyErr_GetRaisedException` instead." msgstr ":c:func:`PyErr_Fetch`:請改用 :c:func:`PyErr_GetRaisedException`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:9 +#: ../../deprecations/c-api-pending-removal-in-future.rst:11 msgid "" -":c:func:`PyErr_NormalizeException`: use :c:func:`PyErr_GetRaisedException` " +":c:func:`PyErr_NormalizeException`: Use :c:func:`PyErr_GetRaisedException` " "instead." msgstr "" -":c:func:`PyErr_NormalizeException`:請改用 :c:func:" -"`PyErr_GetRaisedException`。" +":c:func:`PyErr_NormalizeException`:請改" +"用 :c:func:`PyErr_GetRaisedException`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:10 +#: ../../deprecations/c-api-pending-removal-in-future.rst:13 msgid "" -":c:func:`PyErr_Restore`: use :c:func:`PyErr_SetRaisedException` instead." +":c:func:`PyErr_Restore`: Use :c:func:`PyErr_SetRaisedException` instead." msgstr ":c:func:`PyErr_Restore`:請改用 :c:func:`PyErr_SetRaisedException`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:11 +#: ../../deprecations/c-api-pending-removal-in-future.rst:15 msgid "" -":c:func:`PyModule_GetFilename`: use :c:func:`PyModule_GetFilenameObject` " +":c:func:`PyModule_GetFilename`: Use :c:func:`PyModule_GetFilenameObject` " "instead." msgstr "" ":c:func:`PyModule_GetFilename`:請改用 :c:func:`PyModule_GetFilenameObject`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:12 -msgid ":c:func:`PyOS_AfterFork`: use :c:func:`PyOS_AfterFork_Child` instead." +#: ../../deprecations/c-api-pending-removal-in-future.rst:17 +msgid ":c:func:`PyOS_AfterFork`: Use :c:func:`PyOS_AfterFork_Child` instead." msgstr ":c:func:`PyOS_AfterFork`:請改用 :c:func:`PyOS_AfterFork_Child`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:13 +#: ../../deprecations/c-api-pending-removal-in-future.rst:19 msgid "" -":c:func:`PySlice_GetIndicesEx`: use :c:func:`PySlice_Unpack` and :c:func:" -"`PySlice_AdjustIndices` instead." +":c:func:`PySlice_GetIndicesEx`: Use :c:func:`PySlice_Unpack` " +"and :c:func:`PySlice_AdjustIndices` instead." msgstr "" -":c:func:`PySlice_GetIndicesEx`:請改用 :c:func:`PySlice_Unpack` 和 :c:func:" -"`PySlice_AdjustIndices`。" +":c:func:`PySlice_GetIndicesEx`:請改用 :c:func:`PySlice_Unpack` " +"和 :c:func:`PySlice_AdjustIndices`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:14 +#: ../../deprecations/c-api-pending-removal-in-future.rst:21 msgid "" -":c:func:`!PyUnicode_AsDecodedObject`: use :c:func:`PyCodec_Decode` instead." +":c:func:`!PyUnicode_AsDecodedObject`: Use :c:func:`PyCodec_Decode` instead." msgstr "" ":c:func:`!PyUnicode_AsDecodedObject`:請改用 :c:func:`PyCodec_Decode`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:15 +#: ../../deprecations/c-api-pending-removal-in-future.rst:23 msgid "" -":c:func:`!PyUnicode_AsDecodedUnicode`: use :c:func:`PyCodec_Decode` instead." +":c:func:`!PyUnicode_AsDecodedUnicode`: Use :c:func:`PyCodec_Decode` instead." msgstr "" ":c:func:`!PyUnicode_AsDecodedUnicode`:請改用 :c:func:`PyCodec_Decode`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:16 +#: ../../deprecations/c-api-pending-removal-in-future.rst:25 msgid "" -":c:func:`!PyUnicode_AsEncodedObject`: use :c:func:`PyCodec_Encode` instead." +":c:func:`!PyUnicode_AsEncodedObject`: Use :c:func:`PyCodec_Encode` instead." msgstr "" ":c:func:`!PyUnicode_AsEncodedObject`:請改用 :c:func:`PyCodec_Encode`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:17 +#: ../../deprecations/c-api-pending-removal-in-future.rst:27 msgid "" -":c:func:`!PyUnicode_AsEncodedUnicode`: use :c:func:`PyCodec_Encode` instead." +":c:func:`!PyUnicode_AsEncodedUnicode`: Use :c:func:`PyCodec_Encode` instead." msgstr "" ":c:func:`!PyUnicode_AsEncodedUnicode`:請改用 :c:func:`PyCodec_Encode`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:18 -msgid ":c:func:`PyUnicode_READY`: unneeded since Python 3.12" +#: ../../deprecations/c-api-pending-removal-in-future.rst:29 +msgid ":c:func:`PyUnicode_READY`: Unneeded since Python 3.12" msgstr ":c:func:`PyUnicode_READY`:自 Python 3.12 起不再需要" -#: ../../deprecations/c-api-pending-removal-in-future.rst:19 -msgid ":c:func:`!PyErr_Display`: use :c:func:`PyErr_DisplayException` instead." +#: ../../deprecations/c-api-pending-removal-in-future.rst:31 +msgid ":c:func:`!PyErr_Display`: Use :c:func:`PyErr_DisplayException` instead." msgstr ":c:func:`!PyErr_Display`:請改用 :c:func:`PyErr_DisplayException`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:20 +#: ../../deprecations/c-api-pending-removal-in-future.rst:33 msgid "" -":c:func:`!_PyErr_ChainExceptions`: use ``_PyErr_ChainExceptions1`` instead." +":c:func:`!_PyErr_ChainExceptions`: Use :c:func:`!_PyErr_ChainExceptions1` " +"instead." msgstr "" ":c:func:`!_PyErr_ChainExceptions`:請改用 ``_PyErr_ChainExceptions1``。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:21 +#: ../../deprecations/c-api-pending-removal-in-future.rst:35 msgid "" ":c:member:`!PyBytesObject.ob_shash` member: call :c:func:`PyObject_Hash` " "instead." msgstr "" -":c:member:`!PyBytesObject.ob_shash` 成員:請改為呼叫 :c:func:" -"`PyObject_Hash`。" +":c:member:`!PyBytesObject.ob_shash` 成員:請改為呼" +"叫 :c:func:`PyObject_Hash`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:23 +#: ../../deprecations/c-api-pending-removal-in-future.rst:37 msgid ":c:member:`!PyDictObject.ma_version_tag` member." msgstr ":c:member:`!PyDictObject.ma_version_tag` 成員。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:24 +#: ../../deprecations/c-api-pending-removal-in-future.rst:38 msgid "Thread Local Storage (TLS) API:" msgstr "執行緒局部儲存 (Thread Local Storage, TLS) API:" -#: ../../deprecations/c-api-pending-removal-in-future.rst:26 +#: ../../deprecations/c-api-pending-removal-in-future.rst:40 msgid "" -":c:func:`PyThread_create_key`: use :c:func:`PyThread_tss_alloc` instead." +":c:func:`PyThread_create_key`: Use :c:func:`PyThread_tss_alloc` instead." msgstr ":c:func:`PyThread_create_key`:請改用 :c:func:`PyThread_tss_alloc`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:27 -msgid ":c:func:`PyThread_delete_key`: use :c:func:`PyThread_tss_free` instead." +#: ../../deprecations/c-api-pending-removal-in-future.rst:42 +msgid ":c:func:`PyThread_delete_key`: Use :c:func:`PyThread_tss_free` instead." msgstr ":c:func:`PyThread_delete_key`:請改用 :c:func:`PyThread_tss_free`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:28 +#: ../../deprecations/c-api-pending-removal-in-future.rst:44 msgid "" -":c:func:`PyThread_set_key_value`: use :c:func:`PyThread_tss_set` instead." +":c:func:`PyThread_set_key_value`: Use :c:func:`PyThread_tss_set` instead." msgstr ":c:func:`PyThread_set_key_value`:請改用 :c:func:`PyThread_tss_set`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:29 +#: ../../deprecations/c-api-pending-removal-in-future.rst:46 msgid "" -":c:func:`PyThread_get_key_value`: use :c:func:`PyThread_tss_get` instead." +":c:func:`PyThread_get_key_value`: Use :c:func:`PyThread_tss_get` instead." msgstr ":c:func:`PyThread_get_key_value`:請改用 :c:func:`PyThread_tss_get`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:30 +#: ../../deprecations/c-api-pending-removal-in-future.rst:48 msgid "" -":c:func:`PyThread_delete_key_value`: use :c:func:`PyThread_tss_delete` " +":c:func:`PyThread_delete_key_value`: Use :c:func:`PyThread_tss_delete` " "instead." msgstr "" ":c:func:`PyThread_delete_key_value`:請改用 :c:func:`PyThread_tss_delete`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:31 -msgid ":c:func:`PyThread_ReInitTLS`: unneeded since Python 3.7." +#: ../../deprecations/c-api-pending-removal-in-future.rst:50 +msgid ":c:func:`PyThread_ReInitTLS`: Unneeded since Python 3.7." msgstr ":c:func:`PyThread_ReInitTLS`:自 Python 3.7 起不再需要。" diff --git a/deprecations/index.po b/deprecations/index.po index 96ef5f4c93..0b75d47190 100644 --- a/deprecations/index.po +++ b/deprecations/index.po @@ -1,16 +1,15 @@ # Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. -# FIRST AUTHOR , YEAR. # -#, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-30 18:24+0000\n" +"POT-Creation-Date: 2025-07-03 00:17+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -20,180 +19,6 @@ msgstr "" msgid "Deprecations" msgstr "已棄用項目" -#: ../../deprecations/pending-removal-in-3.13.rst:2 -msgid "Pending Removal in Python 3.13" -msgstr "Python 3.13 中待移除的項目" - -#: ../../deprecations/pending-removal-in-3.13.rst:4 -msgid "Modules (see :pep:`594`):" -msgstr "模組(請見 :pep:`594`):" - -#: ../../deprecations/pending-removal-in-3.13.rst:6 -msgid ":mod:`aifc`" -msgstr ":mod:`aifc`" - -#: ../../deprecations/pending-removal-in-3.13.rst:7 -msgid ":mod:`audioop`" -msgstr ":mod:`audioop`" - -#: ../../deprecations/pending-removal-in-3.13.rst:8 -msgid ":mod:`cgi`" -msgstr ":mod:`cgi`" - -#: ../../deprecations/pending-removal-in-3.13.rst:9 -msgid ":mod:`cgitb`" -msgstr ":mod:`cgitb`" - -#: ../../deprecations/pending-removal-in-3.13.rst:10 -msgid ":mod:`chunk`" -msgstr ":mod:`chunk`" - -#: ../../deprecations/pending-removal-in-3.13.rst:11 -msgid ":mod:`crypt`" -msgstr ":mod:`crypt`" - -#: ../../deprecations/pending-removal-in-3.13.rst:12 -msgid ":mod:`imghdr`" -msgstr ":mod:`imghdr`" - -#: ../../deprecations/pending-removal-in-3.13.rst:13 -msgid ":mod:`mailcap`" -msgstr ":mod:`mailcap`" - -#: ../../deprecations/pending-removal-in-3.13.rst:14 -msgid ":mod:`msilib`" -msgstr ":mod:`msilib`" - -#: ../../deprecations/pending-removal-in-3.13.rst:15 -msgid ":mod:`nis`" -msgstr ":mod:`nis`" - -#: ../../deprecations/pending-removal-in-3.13.rst:16 -msgid ":mod:`nntplib`" -msgstr ":mod:`nntplib`" - -#: ../../deprecations/pending-removal-in-3.13.rst:17 -msgid ":mod:`ossaudiodev`" -msgstr ":mod:`ossaudiodev`" - -#: ../../deprecations/pending-removal-in-3.13.rst:18 -msgid ":mod:`pipes`" -msgstr ":mod:`pipes`" - -#: ../../deprecations/pending-removal-in-3.13.rst:19 -msgid ":mod:`sndhdr`" -msgstr ":mod:`sndhdr`" - -#: ../../deprecations/pending-removal-in-3.13.rst:20 -msgid ":mod:`spwd`" -msgstr ":mod:`spwd`" - -#: ../../deprecations/pending-removal-in-3.13.rst:21 -msgid ":mod:`sunau`" -msgstr ":mod:`sunau`" - -#: ../../deprecations/pending-removal-in-3.13.rst:22 -msgid ":mod:`telnetlib`" -msgstr ":mod:`telnetlib`" - -#: ../../deprecations/pending-removal-in-3.13.rst:23 -msgid ":mod:`uu`" -msgstr ":mod:`uu`" - -#: ../../deprecations/pending-removal-in-3.13.rst:24 -msgid ":mod:`xdrlib`" -msgstr ":mod:`xdrlib`" - -#: ../../deprecations/pending-removal-in-3.13.rst:26 -msgid "Other modules:" -msgstr "其他模組:" - -#: ../../deprecations/pending-removal-in-3.13.rst:28 -msgid ":mod:`!lib2to3`, and the :program:`2to3` program (:gh:`84540`)" -msgstr ":mod:`!lib2to3` 和 :program:`2to3` 程式 (:gh:`84540`)" - -#: ../../deprecations/pending-removal-in-3.13.rst:30 -msgid "APIs:" -msgstr "API:" - -#: ../../deprecations/pending-removal-in-3.13.rst:32 -msgid ":class:`!configparser.LegacyInterpolation` (:gh:`90765`)" -msgstr ":class:`!configparser.LegacyInterpolation` (:gh:`90765`)" - -#: ../../deprecations/pending-removal-in-3.13.rst:33 -msgid "``locale.resetlocale()`` (:gh:`90817`)" -msgstr "``locale.resetlocale()`` (:gh:`90817`)" - -#: ../../deprecations/pending-removal-in-3.13.rst:34 -msgid ":meth:`!turtle.RawTurtle.settiltangle` (:gh:`50096`)" -msgstr ":meth:`!turtle.RawTurtle.settiltangle` (:gh:`50096`)" - -#: ../../deprecations/pending-removal-in-3.13.rst:35 -msgid ":func:`!unittest.findTestCases` (:gh:`50096`)" -msgstr ":func:`!unittest.findTestCases` (:gh:`50096`)" - -#: ../../deprecations/pending-removal-in-3.13.rst:36 -msgid ":func:`!unittest.getTestCaseNames` (:gh:`50096`)" -msgstr ":func:`!unittest.getTestCaseNames` (:gh:`50096`)" - -#: ../../deprecations/pending-removal-in-3.13.rst:37 -msgid ":func:`!unittest.makeSuite` (:gh:`50096`)" -msgstr ":func:`!unittest.makeSuite` (:gh:`50096`)" - -#: ../../deprecations/pending-removal-in-3.13.rst:38 -msgid ":meth:`!unittest.TestProgram.usageExit` (:gh:`67048`)" -msgstr ":meth:`!unittest.TestProgram.usageExit` (:gh:`67048`)" - -#: ../../deprecations/pending-removal-in-3.13.rst:39 -msgid ":class:`!webbrowser.MacOSX` (:gh:`86421`)" -msgstr ":class:`!webbrowser.MacOSX` (:gh:`86421`)" - -#: ../../deprecations/pending-removal-in-3.13.rst:40 -msgid ":class:`classmethod` descriptor chaining (:gh:`89519`)" -msgstr ":class:`classmethod` 描述器鏈接 (:gh:`89519`)" - -#: ../../deprecations/pending-removal-in-3.13.rst:41 -msgid ":mod:`importlib.resources` deprecated methods:" -msgstr ":mod:`importlib.resources` 的已棄用方法:" - -#: ../../deprecations/pending-removal-in-3.13.rst:43 -msgid "``contents()``" -msgstr "``contents()``" - -#: ../../deprecations/pending-removal-in-3.13.rst:44 -msgid "``is_resource()``" -msgstr "``is_resource()``" - -#: ../../deprecations/pending-removal-in-3.13.rst:45 -msgid "``open_binary()``" -msgstr "``open_binary()``" - -#: ../../deprecations/pending-removal-in-3.13.rst:46 -msgid "``open_text()``" -msgstr "``open_text()``" - -#: ../../deprecations/pending-removal-in-3.13.rst:47 -msgid "``path()``" -msgstr "``path()``" - -#: ../../deprecations/pending-removal-in-3.13.rst:48 -msgid "``read_binary()``" -msgstr "``read_binary()``" - -#: ../../deprecations/pending-removal-in-3.13.rst:49 -msgid "``read_text()``" -msgstr "``read_text()``" - -#: ../../deprecations/pending-removal-in-3.13.rst:51 -msgid "" -"Use :func:`importlib.resources.files` instead. Refer to `importlib-" -"resources: Migrating from Legacy `_ (:gh:`106531`)" -msgstr "" -"請改用 :func:`importlib.resources.files`。請參閱 `importlib-resources: " -"Migrating from Legacy `_ (:gh:`106531`)" - #: ../../deprecations/c-api-pending-removal-in-3.14.rst:2 #: ../../deprecations/pending-removal-in-3.14.rst:2 msgid "Pending Removal in Python 3.14" @@ -246,6 +71,7 @@ msgstr "" "請改用 :class:`ast.Constant`。(由 Serhiy Storchaka 於 :gh:`90953` 貢獻。)" #: ../../deprecations/pending-removal-in-3.14.rst:22 +#: ../../deprecations/pending-removal-in-3.16.rst:19 msgid ":mod:`asyncio`:" msgstr ":mod:`asyncio`:" @@ -305,46 +131,38 @@ msgstr "" "Alan Williams 於 :gh:`72346` 貢獻。)" #: ../../deprecations/pending-removal-in-3.14.rst:50 -msgid "" -":mod:`importlib`: ``__package__`` and ``__cached__`` will cease to be set or " -"taken into consideration by the import system (:gh:`97879`)." -msgstr "" -":mod:`importlib`:``__package__`` 和 ``__cached__`` 將不再被設定或被 import " -"系統考慮。 (:gh:`97879`)" - -#: ../../deprecations/pending-removal-in-3.14.rst:53 msgid ":mod:`importlib.abc` deprecated classes:" msgstr ":mod:`importlib.abc` 的已棄用類別:" -#: ../../deprecations/pending-removal-in-3.14.rst:55 +#: ../../deprecations/pending-removal-in-3.14.rst:52 msgid ":class:`!importlib.abc.ResourceReader`" msgstr ":class:`!importlib.abc.ResourceReader`" -#: ../../deprecations/pending-removal-in-3.14.rst:56 +#: ../../deprecations/pending-removal-in-3.14.rst:53 msgid ":class:`!importlib.abc.Traversable`" msgstr ":class:`!importlib.abc.Traversable`" -#: ../../deprecations/pending-removal-in-3.14.rst:57 +#: ../../deprecations/pending-removal-in-3.14.rst:54 msgid ":class:`!importlib.abc.TraversableResources`" msgstr ":class:`!importlib.abc.TraversableResources`" -#: ../../deprecations/pending-removal-in-3.14.rst:59 +#: ../../deprecations/pending-removal-in-3.14.rst:56 msgid "Use :mod:`importlib.resources.abc` classes instead:" msgstr "請改用 :mod:`importlib.resources.abc` 類別:" -#: ../../deprecations/pending-removal-in-3.14.rst:61 +#: ../../deprecations/pending-removal-in-3.14.rst:58 msgid ":class:`importlib.resources.abc.Traversable`" msgstr ":class:`importlib.resources.abc.Traversable`" -#: ../../deprecations/pending-removal-in-3.14.rst:62 +#: ../../deprecations/pending-removal-in-3.14.rst:59 msgid ":class:`importlib.resources.abc.TraversableResources`" msgstr ":class:`importlib.resources.abc.TraversableResources`" -#: ../../deprecations/pending-removal-in-3.14.rst:64 +#: ../../deprecations/pending-removal-in-3.14.rst:61 msgid "(Contributed by Jason R. Coombs and Hugo van Kemenade in :gh:`93963`.)" msgstr "(由 Jason R. Coombs 和 Hugo van Kemenade 貢獻於 :gh:`93963`。)" -#: ../../deprecations/pending-removal-in-3.14.rst:66 +#: ../../deprecations/pending-removal-in-3.14.rst:63 msgid "" ":mod:`itertools` had undocumented, inefficient, historically buggy, and " "inconsistent support for copy, deepcopy, and pickle operations. This will be " @@ -355,7 +173,7 @@ msgstr "" "deepcopy 和 pickle 操作支援。將在 3.14 中移除以大幅減少程式碼量和維護負擔。 " "(由 Raymond Hettinger 於 :gh:`101588` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.14.rst:72 +#: ../../deprecations/pending-removal-in-3.14.rst:69 msgid "" ":mod:`multiprocessing`: The default start method will change to a safer one " "on Linux, BSDs, and other non-macOS POSIX platforms where ``'fork'`` is " @@ -372,7 +190,7 @@ msgstr "" "API 來明確指定你的程式碼何時\\ *需要* ``'fork'``。請參閱 :ref:" "`multiprocessing-start-methods`。" -#: ../../deprecations/pending-removal-in-3.14.rst:80 +#: ../../deprecations/pending-removal-in-3.14.rst:77 msgid "" ":mod:`pathlib`: :meth:`~pathlib.PurePath.is_relative_to` and :meth:`~pathlib." "PurePath.relative_to`: passing additional arguments is deprecated." @@ -380,7 +198,7 @@ msgstr "" ":mod:`pathlib`:已棄用 :meth:`~pathlib.PurePath.is_relative_to` 和 :meth:" "`~pathlib.PurePath.relative_to`:額外引數的傳遞已被棄用。" -#: ../../deprecations/pending-removal-in-3.14.rst:84 +#: ../../deprecations/pending-removal-in-3.14.rst:81 msgid "" ":mod:`pkgutil`: :func:`~pkgutil.find_loader` and :func:`~pkgutil.get_loader` " "now raise :exc:`DeprecationWarning`; use :func:`importlib.util.find_spec` " @@ -390,27 +208,27 @@ msgstr "" "現在會引發 :exc:`DeprecationWarning`;請改用 :func:`importlib.util." "find_spec`。 (由 Nikita Sobolev 於 :gh:`97850` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.14.rst:89 +#: ../../deprecations/pending-removal-in-3.14.rst:86 msgid ":mod:`pty`:" msgstr ":mod:`pty`:" -#: ../../deprecations/pending-removal-in-3.14.rst:91 +#: ../../deprecations/pending-removal-in-3.14.rst:88 msgid "``master_open()``: use :func:`pty.openpty`." msgstr "``master_open()``:請用 :func:`pty.openpty`。" -#: ../../deprecations/pending-removal-in-3.14.rst:92 +#: ../../deprecations/pending-removal-in-3.14.rst:89 msgid "``slave_open()``: use :func:`pty.openpty`." msgstr "``slave_open()``:請用 :func:`pty.openpty`。" -#: ../../deprecations/pending-removal-in-3.14.rst:94 +#: ../../deprecations/pending-removal-in-3.14.rst:91 msgid ":mod:`sqlite3`:" msgstr ":mod:`sqlite3`:" -#: ../../deprecations/pending-removal-in-3.14.rst:96 +#: ../../deprecations/pending-removal-in-3.14.rst:93 msgid ":data:`~sqlite3.version` and :data:`~sqlite3.version_info`." msgstr ":data:`~sqlite3.version` 和 :data:`~sqlite3.version_info`。" -#: ../../deprecations/pending-removal-in-3.14.rst:98 +#: ../../deprecations/pending-removal-in-3.14.rst:95 msgid "" ":meth:`~sqlite3.Cursor.execute` and :meth:`~sqlite3.Cursor.executemany` if :" "ref:`named placeholders ` are used and *parameters* is " @@ -420,27 +238,7 @@ msgstr "" "使用 :ref:`named placeholders ` 且 *parameters* 是序列" "而不是 :class:`dict`。" -#: ../../deprecations/pending-removal-in-3.14.rst:102 -msgid "" -"date and datetime adapter, date and timestamp converter: see the :mod:" -"`sqlite3` documentation for suggested replacement recipes." -msgstr "" -"date 和 datetime 的適配器 (adapter)、date 和 timestamp 轉換器 (converter):請" -"參閱 :mod:`sqlite3` 文件以獲得建議的替代方案。" - -#: ../../deprecations/pending-removal-in-3.14.rst:105 -msgid "" -":class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was " -"deprecated in :pep:`626` since 3.10 and was planned to be removed in 3.12, " -"but it only got a proper :exc:`DeprecationWarning` in 3.12. May be removed " -"in 3.14. (Contributed by Nikita Sobolev in :gh:`101866`.)" -msgstr "" -":class:`types.CodeType`:自 3.10 起,存取 :attr:`~codeobject.co_lnotab` 已" -"在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但只在 3.12 中於適當時發出 :" -"exc:`DeprecationWarning`。可能在 3.14 中移除。(由 Nikita Sobolev 於 :gh:" -"`101866` 貢獻。)" - -#: ../../deprecations/pending-removal-in-3.14.rst:112 +#: ../../deprecations/pending-removal-in-3.14.rst:99 msgid "" ":mod:`typing`: :class:`~typing.ByteString`, deprecated since Python 3.9, now " "causes a :exc:`DeprecationWarning` to be emitted when it is used." @@ -448,7 +246,7 @@ msgstr "" ":mod:`typing`:自 Python 3.9 起已被棄用的 :class:`~typing.ByteString` 現在在" "使用時會發出 :exc:`DeprecationWarning`。" -#: ../../deprecations/pending-removal-in-3.14.rst:115 +#: ../../deprecations/pending-removal-in-3.14.rst:102 msgid "" ":mod:`urllib`: :class:`!urllib.parse.Quoter` is deprecated: it was not " "intended to be a public API. (Contributed by Gregory P. Smith in :gh:" @@ -463,143 +261,317 @@ msgid "Pending Removal in Python 3.15" msgstr "Python 3.15 中待移除的項目" #: ../../deprecations/pending-removal-in-3.15.rst:4 +#: ../../deprecations/pending-removal-in-3.16.rst:4 +msgid "The import system:" +msgstr "引入系統 (import system):" + +#: ../../deprecations/pending-removal-in-3.15.rst:6 msgid "" -":class:`http.server.CGIHTTPRequestHandler` will be removed along with its " -"related ``--cgi`` flag to ``python -m http.server``. It was obsolete and " -"rarely used. No direct replacement exists. *Anything* is better than CGI " -"to interface a web server with a request handler." +"Setting :attr:`~module.__cached__` on a module while failing to set :attr:" +"`__spec__.cached ` is deprecated. In " +"Python 3.15, :attr:`!__cached__` will cease to be set or take into " +"consideration by the import system or standard library. (:gh:`97879`)" msgstr "" -":class:`http.server.CGIHTTPRequestHandler` 將會被移除,連同其相關的 ``--" -"cgi`` 旗標到 ``python -m http.server``。它已經過時且很少被使用。沒有直接的替" -"代方案。*任何東西*\\ 都比 CGI 更好的來介接一個帶有請求處理器的網頁伺服器。" +"在模組上設定 :attr:`~module.__cached__` 而沒有設定 :attr:`__spec__.cached " +"` 的做法已被棄用。在 Python 3.15 中," +"引入系統或標準函式庫將不再設定或考慮 :attr:`!__cached__`。(:gh:`97879`)" -#: ../../deprecations/pending-removal-in-3.15.rst:9 +#: ../../deprecations/pending-removal-in-3.15.rst:11 msgid "" -":class:`locale`: :func:`locale.getdefaultlocale` was deprecated in Python " -"3.11 and originally planned for removal in Python 3.13 (:gh:`90817`), but " -"removal has been postponed to Python 3.15. Use :func:`locale.setlocale`, :" -"func:`locale.getencoding` and :func:`locale.getlocale` instead. (Contributed " -"by Hugo van Kemenade in :gh:`111187`.)" +"Setting :attr:`~module.__package__` on a module while failing to set :attr:" +"`__spec__.parent ` is deprecated. In " +"Python 3.15, :attr:`!__package__` will cease to be set or take into " +"consideration by the import system or standard library. (:gh:`97879`)" msgstr "" -":class:`locale`::func:`locale.getdefaultlocale` 已在 Python 3.11 中被棄用," -"原本計劃在 Python 3.13 中移除 (:gh:`90817`),但被延後至 Python 3.15。請改用 :" -"func:`locale.setlocale`、:func:`locale.getencoding` 和 :func:`locale." -"getlocale`。 (由 Hugo van Kemenade 於 :gh:`111187` 貢獻。)" +"在模組上設定 :attr:`~module.__package__` 而沒有設定 :attr:`__spec__.parent " +"` 的做法已被棄用。在 Python 3.15 中," +"引入系統或標準函式庫將不再設定或考慮 :attr:`!__package__`。(:gh:`97879`)" #: ../../deprecations/pending-removal-in-3.15.rst:16 +msgid ":mod:`ctypes`:" +msgstr ":mod:`ctypes`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:18 msgid "" -":mod:`pathlib`: :meth:`pathlib.PurePath.is_reserved` is deprecated and " -"scheduled for removal in Python 3.15. From Python 3.13 onwards, use ``os." -"path.isreserved`` to detect reserved paths on Windows." +"The undocumented :func:`!ctypes.SetPointerType` function has been deprecated " +"since Python 3.13." msgstr "" -":mod:`pathlib`::meth:`pathlib.PurePath.is_reserved` 已被棄用並計劃在 Python " -"3.15 中移除。從 Python 3.13 開始,請用 ``os.path.isreserved`` 來偵測 Windows " -"上的保留路徑。" +"自 Python 3.13 起,未記錄的 :func:`!ctypes.SetPointerType` 函式已被棄用。" #: ../../deprecations/pending-removal-in-3.15.rst:21 +msgid ":mod:`http.server`:" +msgstr ":mod:`http.server`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:23 msgid "" -":mod:`platform`: :func:`~platform.java_ver` is deprecated and will be " -"removed in 3.15. It was largely untested, had a confusing API, and was only " -"useful for Jython support. (Contributed by Nikita Sobolev in :gh:`116349`.)" +"The obsolete and rarely used :class:`~http.server.CGIHTTPRequestHandler` has " +"been deprecated since Python 3.13. No direct replacement exists. *Anything* " +"is better than CGI to interface a web server with a request handler." msgstr "" -":mod:`platform`::func:`~platform.java_ver` 已被棄用並將在 3.15 中移除。它幾" -"乎沒有被測試過,API 令人困惑並且只對 Jython 支援有用。 (由 Nikita Sobolev " -"於 :gh:`116349` 貢獻。)" +"過時且很少使用的 :class:`~http.server.CGIHTTPRequestHandler` 自 Python 3.13 " +"起已被棄用。不存在直接的替代。*任何東西*\\ 都比 CGI 更好地將 Web 伺服器與請求" +"處理程序介接起來。" -#: ../../deprecations/pending-removal-in-3.15.rst:27 +#: ../../deprecations/pending-removal-in-3.15.rst:29 msgid "" -":mod:`threading`: Passing any arguments to :func:`threading.RLock` is now " -"deprecated. C version allows any numbers of args and kwargs, but they are " -"just ignored. Python version does not allow any arguments. All arguments " -"will be removed from :func:`threading.RLock` in Python 3.15. (Contributed by " -"Nikita Sobolev in :gh:`102029`.)" +"The :option:`!--cgi` flag to the :program:`python -m http.server` command-" +"line interface has been deprecated since Python 3.13." msgstr "" -":mod:`threading`:對 :func:`threading.RLock` 傳遞任何引數現在已被棄用。C 版本" -"允許任意數量的引數和關鍵字引數,但它們會被忽略。Python 版本不允許任何引數。所" -"有引數將在 Python 3.15 中從 :func:`threading.RLock` 中移除。 (由 Nikita " -"Sobolev 於 :gh:`102029` 貢獻。)" +"自 Python 3.13 起,:program:`python -m http.server` 命令列介面的 :option:`!--" +"cgi` 旗標已被棄用。" + +#: ../../deprecations/pending-removal-in-3.15.rst:32 +#: ../../deprecations/pending-removal-in-future.rst:56 +msgid ":mod:`importlib`:" +msgstr ":mod:`importlib`:" #: ../../deprecations/pending-removal-in-3.15.rst:34 -msgid ":class:`typing.NamedTuple`:" -msgstr ":class:`typing.NamedTuple`:" +msgid "``load_module()`` method: use ``exec_module()`` instead." +msgstr "``load_module()`` method:請改用 ``exec_module()``。" #: ../../deprecations/pending-removal-in-3.15.rst:36 +msgid ":class:`locale`:" +msgstr ":class:`locale`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:38 msgid "" -"The undocumented keyword argument syntax for creating :class:`!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." +"The :func:`~locale.getdefaultlocale` function has been deprecated since " +"Python 3.11. Its removal was originally planned for Python 3.13 (:gh:" +"`90817`), but has been postponed to Python 3.15. Use :func:`~locale." +"getlocale`, :func:`~locale.setlocale`, and :func:`~locale.getencoding` " +"instead. (Contributed by Hugo van Kemenade in :gh:`111187`.)" +msgstr "" +":func:`~locale.getdefaultlocale` 已在 Python 3.11 中被棄用,原本計劃在 " +"Python 3.13 中移除 (:gh:`90817`),但被延後至 Python 3.15。請改用 :func:" +"`~locale.getlocale`、:func:`~locale.setlocale` 和 :func:`~locale." +"getencoding`。 (由 Hugo van Kemenade 於 :gh:`111187` 貢獻。)" + +#: ../../deprecations/pending-removal-in-3.15.rst:46 +msgid ":mod:`pathlib`:" +msgstr ":mod:`pathlib`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:48 +msgid "" +":meth:`.PurePath.is_reserved` has been deprecated since Python 3.13. Use :" +"func:`os.path.isreserved` to detect reserved paths on Windows." msgstr "" -"用於建立 :class:`!NamedTuple` 類別的未以文件記錄之關鍵字引數語法 (``NT = " -"NamedTuple(\"NT\", x=int)``) 已棄用,並將在 3.15 中被禁止。請改用基於類別的語" -"法或函式語法 (functional syntax)。" - -#: ../../deprecations/pending-removal-in-3.15.rst:40 -msgid "" -"When using the functional syntax to create a :class:`!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 :class:`!NamedTuple` class with 0 " -"fields, use ``class NT(NamedTuple): pass`` or ``NT = NamedTuple(\"NT\", " -"[])``." -msgstr "" -"當使用函式語法來建立 :class:`!NamedTuple` 類別時,沒將值傳遞給 *fields* 參數" -"的方式 (``NT = NamedTuple(\"NT\")``) 已被棄用,將 ``None`` 傳遞給 *fields* 參" -"數(``NT = NamedTuple(\"NT\", None)``)也已被棄用。這兩者將在 Python 3.15 中" -"會被禁止。要建立一個沒有欄位的 :class:`!NamedTuple` 類別,請使用 ``class " -"NT(NamedTuple): pass`` 或 ``NT = NamedTuple(\"NT\", [])``。" - -#: ../../deprecations/pending-removal-in-3.15.rst:47 -msgid "" -":class:`typing.TypedDict`: When using the functional syntax to create a :" -"class:`!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 :class:`!TypedDict` class with 0 " -"fields, use ``class TD(TypedDict): pass`` or ``TD = TypedDict(\"TD\", {})``." -msgstr "" -":class:`typing.TypedDict`:當使用函式語法來建立 :class:`!TypedDict` 類別時," -"沒將值傳遞給 *fields* 參數的方式(``TD = TypedDict(\"TD\")``)已被棄用,將 " -"``None`` 傳遞給 *fields* 參數(``TD = TypedDict(\"TD\", None)``)也已被棄用。" -"這兩者將在 Python 3.15 中會被禁止。要建立一個沒有欄位的 :class:`!TypedDict` " -"類別,請使用 ``class TD(TypedDict): pass`` 或 ``TD = TypedDict(\"TD\", " -"{})``。" +":meth:`.PurePath.is_reserved` 已自 Python 3.13 被棄用。請用 :func:`os.path." +"isreserved` 來偵測 Windows 上的保留路徑。" + +#: ../../deprecations/pending-removal-in-3.15.rst:52 +msgid ":mod:`platform`:" +msgstr ":mod:`platform`:" #: ../../deprecations/pending-removal-in-3.15.rst:54 msgid "" -":mod:`wave`: Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()`` " -"methods of the :class:`wave.Wave_read` and :class:`wave.Wave_write` classes. " -"They will be removed in Python 3.15. (Contributed by Victor Stinner in :gh:" -"`105096`.)" +":func:`~platform.java_ver` has been deprecated since Python 3.13. This " +"function is only useful for Jython support, has a confusing API, and is " +"largely untested." +msgstr "" +"自 Python 3.13 起,:func:`~platform.java_ver` 已被棄用。此函式僅對 Jython 支" +"援有用,具有令人困惑的 API,基本上未經測試。" + +#: ../../deprecations/pending-removal-in-3.15.rst:58 +msgid ":mod:`sysconfig`:" +msgstr ":mod:`sysconfig`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:60 +msgid "" +"The *check_home* argument of :func:`sysconfig.is_python_build` has been " +"deprecated since Python 3.12." +msgstr "" +":func:`sysconfig.is_python_build` 的 *check_home* 引數自 Python 3.12 起已被棄" +"用。" + +#: ../../deprecations/pending-removal-in-3.15.rst:63 +msgid ":mod:`threading`:" +msgstr ":mod:`threading`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:65 +msgid "" +":func:`~threading.RLock` will take no arguments in Python 3.15. Passing any " +"arguments has been deprecated since Python 3.14, as the Python version does " +"not permit any arguments, but the C version allows any number of positional " +"or keyword arguments, ignoring every argument." +msgstr "" +":func:`~threading.RLock` 在 Python 3.15 中將不接受任何引數。自 Python 3.14 " +"起,傳遞任何引數的用法已被棄用,因為 Python 版本不允許任何引數,但 C 版本允許" +"任意數量的位置或關鍵字引數,並忽略每個引數。" + +#: ../../deprecations/pending-removal-in-3.15.rst:71 +msgid ":mod:`types`:" +msgstr ":mod:`types`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:73 +msgid "" +":class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was " +"deprecated in :pep:`626` since 3.10 and was planned to be removed in 3.12, " +"but it only got a proper :exc:`DeprecationWarning` in 3.12. May be removed " +"in 3.15. (Contributed by Nikita Sobolev in :gh:`101866`.)" +msgstr "" +":class:`types.CodeType`:自 3.10 起,存取 :attr:`~codeobject.co_lnotab` 已" +"在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但只在 3.12 中於適當時發出 :" +"exc:`DeprecationWarning`。可能在 3.15 中移除。(由 Nikita Sobolev 於 :gh:" +"`101866` 貢獻。)" + +#: ../../deprecations/pending-removal-in-3.15.rst:80 +msgid ":mod:`typing`:" +msgstr ":mod:`typing`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:82 +msgid "" +"The undocumented keyword argument syntax for creating :class:`~typing." +"NamedTuple` 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." +msgstr "" +"用於建立 :class:`~typing.NamedTuple` 類別的未以文件記錄之關鍵字引數語法 " +"(``Point = NamedTuple(\"Point\", x=int, y=int)``) 已自 Python 3.13 棄用。請改" +"用基於類別的語法或函式語法 (functional syntax)。" + +#: ../../deprecations/pending-removal-in-3.15.rst:88 +msgid "" +"When using the functional syntax of :class:`~typing.TypedDict`\\s, failing " +"to pass a value to the *fields* parameter (``TD = TypedDict(\"TD\")``) or " +"passing ``None`` (``TD = TypedDict(\"TD\", None)``) has been deprecated " +"since Python 3.13. Use ``class TD(TypedDict): pass`` or ``TD = " +"TypedDict(\"TD\", {})`` to create a TypedDict with zero field." +msgstr "" +"當使用 :class:`~typing.TypedDict` 的函式語法時,未傳遞值給 *fields* 參數 " +"(``TD = TypedDict(\"TD\")``) 或傳遞 ``None`` (``TD = TypedDict(\"TD\", " +"None)``) 的做法自 Python 3.13 起已被棄用。請使用 ``class TD(TypedDict): " +"pass`` 或 ``TD = TypedDict(\"TD\", {})`` 來建立具有零個欄位的 TypedDict。" + +#: ../../deprecations/pending-removal-in-3.15.rst:95 +msgid "" +"The :func:`typing.no_type_check_decorator` decorator function has been " +"deprecated since Python 3.13. After eight years in the :mod:`typing` module, " +"it has yet to be supported by any major type checker." +msgstr "" +"自 Python 3.13 起,:func:`typing.no_type_check_decorator` 裝飾器函式已被棄" +"用。在 :mod:`typing` 模組中使用了八年之後,它尚未得到任何主要型別檢查器的支" +"援。" + +#: ../../deprecations/pending-removal-in-3.15.rst:100 +msgid ":mod:`wave`:" +msgstr ":mod:`wave`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:102 +msgid "" +"The :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`, and :meth:`~wave." +"Wave_read.getmarkers` methods of the :class:`~wave.Wave_read` and :class:" +"`~wave.Wave_write` classes have been deprecated since Python 3.13." msgstr "" -":mod:`wave`:已棄用 :class:`wave.Wave_read` 和 :class:`wave.Wave_write` 類別" -"的 ``getmark()``、``setmark()`` 和 ``getmarkers()`` 方法。它們將在 Python " -"3.15 中被移除。 (由 Victor Stinner 於 :gh:`105096` 貢獻。)" +"已棄用 :class:`~wave.Wave_read` 和 :class:`~wave.Wave_write` 類別的 :meth:" +"`~wave.Wave_read.getmark`、:meth:`!setmark` 和 :meth:`~wave.Wave_read." +"getmarkers` 方法自 Python 3.13 被棄用。" #: ../../deprecations/pending-removal-in-3.16.rst:2 -msgid "Pending Removal in Python 3.16" +msgid "Pending removal in Python 3.16" msgstr "Python 3.16 中待移除的項目" -#: ../../deprecations/pending-removal-in-3.16.rst:4 +#: ../../deprecations/pending-removal-in-3.16.rst:6 msgid "" -":mod:`array`: :class:`array.array` ``'u'`` type (:c:type:`wchar_t`): use the " -"``'w'`` type instead (``Py_UCS4``)." +"Setting :attr:`~module.__loader__` on a module while failing to set :attr:" +"`__spec__.loader ` is deprecated. In " +"Python 3.16, :attr:`!__loader__` will cease to be set or taken into " +"consideration by the import system or the standard library." msgstr "" -":mod:`array`::class:`array.array` ``'u'`` 型別 (:c:type:`wchar_t`):請改用 " -"``'w'`` 型別 (``Py_UCS4``)。" - -#: ../../deprecations/pending-removal-in-3.16.rst:8 -msgid ":mod:`builtins`: ``~bool``, bitwise inversion on bool." -msgstr ":mod:`builtins`:``~bool``,對 bool 進行位元反轉。" +"在模組上設定 :attr:`~module.__loader__` 而沒有設定 :attr:`__spec__.loader " +"` 的做法將於 Python 3.16 被棄用。在 " +"Python 3.16 中,引入系統或標準函式庫將不再設定或考慮 :attr:`!__loader__`。" #: ../../deprecations/pending-removal-in-3.16.rst:11 +msgid ":mod:`array`:" +msgstr ":mod:`array`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:13 +msgid "" +"The ``'u'`` format code (:c:type:`wchar_t`) has been deprecated in " +"documentation since Python 3.3 and at runtime since Python 3.13. Use the " +"``'w'`` format code (:c:type:`Py_UCS4`) for Unicode characters instead." +msgstr "" +"自 Python 3.3 起,``'u'`` 格式碼 (:c:type:`wchar_t`) 在文件中已被棄用,自 " +"Python 3.13 起在 runtime 已被棄用。請使用 ``'w'`` 格式碼 (:c:type:`Py_UCS4`) " +"來取代 Unicode 字元。" + +#: ../../deprecations/pending-removal-in-3.16.rst:21 +msgid "" +":func:`!asyncio.iscoroutinefunction` is deprecated and will be removed in " +"Python 3.16, use :func:`inspect.iscoroutinefunction` instead. (Contributed " +"by Jiahao Li and Kumar Aditya in :gh:`122875`.)" +msgstr "" +":func:`!asyncio.iscoroutinefunction` 已被棄用並將在 Python 3.16 中移除,請改" +"用 :func:`inspect.iscoroutinefunction`。(由 Jiahao Li 和 Kumar Aditya 於 :" +"gh:`122875` 貢獻。)" + +#: ../../deprecations/pending-removal-in-3.16.rst:26 +#: ../../deprecations/pending-removal-in-future.rst:10 +msgid ":mod:`builtins`:" +msgstr ":mod:`builtins`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:28 +msgid "" +"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)``)." +msgstr "" +"自 Python 3.12 起,布林型別的位元反轉 ``~True`` 或 ``~False`` 已被棄用,因為" +"它會產生不預期且不直觀的結果(``-2`` 和 ``-1``)。使用 ``not x`` 代替布林值的" +"邏輯否定。在極少數情況下,你需要對底層的整數進行位元反轉,請明確轉換為 " +"``~int(x)`` (``~int(x)``)。" + +#: ../../deprecations/pending-removal-in-3.16.rst:35 +msgid ":mod:`shutil`:" +msgstr ":mod:`shutil`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:37 +msgid "" +"The :class:`!ExecError` exception has been deprecated since Python 3.14. It " +"has not been used by any function in :mod:`!shutil` since Python 3.4, and is " +"now an alias of :exc:`RuntimeError`." +msgstr "" +"自 Python 3.14 起,:class:`!ExecError` 例外已被棄用。自 Python 3.4 以來,它尚" +"未被 :mod:`!shutil` 中的任何函式使用,現在是 :exc:`RuntimeError` 的別名。" + +#: ../../deprecations/pending-removal-in-3.16.rst:42 +msgid ":mod:`symtable`:" +msgstr ":mod:`symtable`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:44 +msgid "" +"The :meth:`Class.get_methods ` method has been " +"deprecated since Python 3.14." +msgstr "" +"自 Python 3.14 起,:meth:`Class.get_methods ` 方" +"法已被棄用。" + +#: ../../deprecations/pending-removal-in-3.16.rst:47 +msgid ":mod:`sys`:" +msgstr ":mod:`sys`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:49 +msgid "" +"The :func:`~sys._enablelegacywindowsfsencoding` function has been deprecated " +"since Python 3.13. Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` " +"environment variable instead." +msgstr "" +"自 Python 3.13 起,:func:`~sys._enablelegacywindowsfsencoding` 函式已被棄用。" +"請改用 :envvar:`PYTHONLEGACYWINDOWSFSENCODING` 環境變數。" + +#: ../../deprecations/pending-removal-in-3.16.rst:53 +msgid ":mod:`tarfile`:" +msgstr ":mod:`tarfile`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:55 msgid "" -":mod:`symtable`: Deprecate :meth:`symtable.Class.get_methods` due to the " -"lack of interest. (Contributed by Bénédikt Tran in :gh:`119698`.)" +"The undocumented and unused :attr:`!TarFile.tarfile` attribute has been " +"deprecated since Python 3.13." msgstr "" -":mod:`symtable`:由於並沒有太多關注,已棄用 :meth:`symtable.Class." -"get_methods`。 (由 Bénédikt Tran 於 :gh:`119698` 貢獻。)" +"自 Python 3.13 起,未以文件記錄和未被使用的 :attr:`!TarFile.tarfile` 屬性已被" +"棄用。" #: ../../deprecations/c-api-pending-removal-in-future.rst:2 #: ../../deprecations/pending-removal-in-future.rst:2 @@ -618,19 +590,11 @@ msgid "" "groups are deprecated." msgstr ":mod:`argparse`:已棄用巢狀引數群組和巢狀互斥群組。" -#: ../../deprecations/pending-removal-in-future.rst:10 -msgid ":mod:`array`'s ``'u'`` format code (:gh:`57281`)" -msgstr ":mod:`array` 的 ``'u'`` 格式碼 (:gh:`57281`)" - #: ../../deprecations/pending-removal-in-future.rst:12 -msgid ":mod:`builtins`:" -msgstr ":mod:`builtins`:" - -#: ../../deprecations/pending-removal-in-future.rst:14 msgid "``bool(NotImplemented)``." msgstr "``bool(NotImplemented)``。" -#: ../../deprecations/pending-removal-in-future.rst:15 +#: ../../deprecations/pending-removal-in-future.rst:13 msgid "" "Generators: ``throw(type, exc, tb)`` and ``athrow(type, exc, tb)`` signature " "is deprecated: use ``throw(exc)`` and ``athrow(exc)`` instead, the single " @@ -639,7 +603,7 @@ msgstr "" "產生器:``throw(type, exc, tb)`` 和 ``athrow(type, exc, tb)`` 簽名已被棄用:" "請改用 ``throw(exc)`` 和 ``athrow(exc)``,為單引數簽名。" -#: ../../deprecations/pending-removal-in-future.rst:18 +#: ../../deprecations/pending-removal-in-future.rst:16 msgid "" "Currently Python accepts numeric literals immediately followed by keywords, " "for example ``0in x``, ``1or x``, ``0if 1else 2``. It allows confusing and " @@ -657,7 +621,7 @@ msgstr "" "`in`、:keyword:`is` 和 :keyword:`or` 之一的關鍵字,則會引發語法警告。在未來版" "本中,它將被更改為語法錯誤。(:gh:`87999`)" -#: ../../deprecations/pending-removal-in-future.rst:26 +#: ../../deprecations/pending-removal-in-future.rst:24 msgid "" "Support for ``__index__()`` and ``__int__()`` method returning non-int type: " "these methods will be required to return an instance of a strict subclass " @@ -666,7 +630,7 @@ msgstr "" "``__index__()`` 和 ``__int__()`` 方法回傳非 int 型別的支援:這些方法將需要回" "傳 :class:`int` 的嚴格子類別實例。" -#: ../../deprecations/pending-removal-in-future.rst:29 +#: ../../deprecations/pending-removal-in-future.rst:27 msgid "" "Support for ``__float__()`` method returning a strict subclass of :class:" "`float`: these methods will be required to return an instance of :class:" @@ -675,7 +639,7 @@ msgstr "" "回傳 :class:`float` 嚴格子類別 ``__float__()`` 方法的支援:這些方法將需要回" "傳 :class:`float` 的實例。" -#: ../../deprecations/pending-removal-in-future.rst:32 +#: ../../deprecations/pending-removal-in-future.rst:30 msgid "" "Support for ``__complex__()`` method returning a strict subclass of :class:" "`complex`: these methods will be required to return an instance of :class:" @@ -684,11 +648,11 @@ msgstr "" "回傳 :class:`complex` 嚴格子類別 ``__complex__()`` 方法的支援:這些方法將需要" "回傳 :class:`complex` 的實例。" -#: ../../deprecations/pending-removal-in-future.rst:35 +#: ../../deprecations/pending-removal-in-future.rst:33 msgid "Delegation of ``int()`` to ``__trunc__()`` method." msgstr "將 ``int()`` 委派給 ``__trunc__()`` 方法。" -#: ../../deprecations/pending-removal-in-future.rst:36 +#: ../../deprecations/pending-removal-in-future.rst:34 msgid "" "Passing a complex number as the *real* or *imag* argument in the :func:" "`complex` constructor is now deprecated; it should only be passed as a " @@ -698,7 +662,7 @@ msgstr "" "在 :func:`complex` 建構子中將複數作為 *real* 或 *imag* 引數傳遞現在已被棄用;" "它應該只作為單個位置引數傳遞。 (由 Serhiy Storchaka 於 :gh:`109218` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:41 +#: ../../deprecations/pending-removal-in-future.rst:39 msgid "" ":mod:`calendar`: ``calendar.January`` and ``calendar.February`` constants " "are deprecated and replaced by :data:`calendar.JANUARY` and :data:`calendar." @@ -708,18 +672,18 @@ msgstr "" "被 :data:`calendar.JANUARY` 和 :data:`calendar.FEBRUARY` 取代。 (由 Prince " "Roshan 於 :gh:`103636` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:46 +#: ../../deprecations/pending-removal-in-future.rst:44 msgid "" ":attr:`codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method " "instead." msgstr "" ":attr:`codeobject.co_lnotab`:請改用 :meth:`codeobject.co_lines` 方法。" -#: ../../deprecations/pending-removal-in-future.rst:49 +#: ../../deprecations/pending-removal-in-future.rst:47 msgid ":mod:`datetime`:" msgstr ":mod:`datetime`:" -#: ../../deprecations/pending-removal-in-future.rst:51 +#: ../../deprecations/pending-removal-in-future.rst:49 msgid "" ":meth:`~datetime.datetime.utcnow`: use ``datetime.datetime.now(tz=datetime." "UTC)``." @@ -727,7 +691,7 @@ msgstr "" ":meth:`~datetime.datetime.utcnow`:請改用 ``datetime.datetime." "now(tz=datetime.UTC)``。" -#: ../../deprecations/pending-removal-in-future.rst:53 +#: ../../deprecations/pending-removal-in-future.rst:51 msgid "" ":meth:`~datetime.datetime.utcfromtimestamp`: use ``datetime.datetime." "fromtimestamp(timestamp, tz=datetime.UTC)``." @@ -735,19 +699,11 @@ msgstr "" ":meth:`~datetime.datetime.utcfromtimestamp`:請改用 ``datetime.datetime." "fromtimestamp(timestamp, tz=datetime.UTC)``。" -#: ../../deprecations/pending-removal-in-future.rst:56 +#: ../../deprecations/pending-removal-in-future.rst:54 msgid ":mod:`gettext`: Plural value must be an integer." msgstr ":mod:`gettext`:複數值必須是整數。" #: ../../deprecations/pending-removal-in-future.rst:58 -msgid ":mod:`importlib`:" -msgstr ":mod:`importlib`:" - -#: ../../deprecations/pending-removal-in-future.rst:60 -msgid "``load_module()`` method: use ``exec_module()`` instead." -msgstr "``load_module()`` method:請改用 ``exec_module()``。" - -#: ../../deprecations/pending-removal-in-future.rst:61 msgid "" ":func:`~importlib.util.cache_from_source` *debug_override* parameter is " "deprecated: use the *optimization* parameter instead." @@ -755,18 +711,26 @@ msgstr "" ":func:`~importlib.util.cache_from_source` *debug_override* 參數已被棄用:請改" "用 *optimization* 參數。" -#: ../../deprecations/pending-removal-in-future.rst:64 +#: ../../deprecations/pending-removal-in-future.rst:61 msgid ":mod:`importlib.metadata`:" msgstr ":mod:`importlib.metadata`:" -#: ../../deprecations/pending-removal-in-future.rst:66 +#: ../../deprecations/pending-removal-in-future.rst:63 msgid "``EntryPoints`` tuple interface." msgstr "``EntryPoints`` 元組介面。" -#: ../../deprecations/pending-removal-in-future.rst:67 +#: ../../deprecations/pending-removal-in-future.rst:64 msgid "Implicit ``None`` on return values." msgstr "回傳值上的隱式 ``None``。" +#: ../../deprecations/pending-removal-in-future.rst:66 +msgid "" +":mod:`logging`: the ``warn()`` method has been deprecated since Python 3.3, " +"use :meth:`~logging.warning` instead." +msgstr "" +":mod:`logging`:自 Python 3.3 起,``warn()`` 方法已被棄用,請改用 :meth:" +"`~logging.warning`。" + #: ../../deprecations/pending-removal-in-future.rst:69 msgid "" ":mod:`mailbox`: Use of StringIO input and text mode is deprecated, use " @@ -869,17 +833,10 @@ msgid "``ssl.TLSVersion.TLSv1_1``" msgstr "``ssl.TLSVersion.TLSv1_1``" #: ../../deprecations/pending-removal-in-future.rst:106 -msgid "" -":func:`sysconfig.is_python_build` *check_home* parameter is deprecated and " -"ignored." -msgstr "" -":func:`sysconfig.is_python_build` 的 *check_home* 參數已被棄用並被忽略。" - -#: ../../deprecations/pending-removal-in-future.rst:109 msgid ":mod:`threading` methods:" msgstr ":mod:`threading` 方法:" -#: ../../deprecations/pending-removal-in-future.rst:111 +#: ../../deprecations/pending-removal-in-future.rst:108 msgid "" ":meth:`!threading.Condition.notifyAll`: use :meth:`~threading.Condition." "notify_all`." @@ -887,11 +844,11 @@ msgstr "" ":meth:`!threading.Condition.notifyAll`:請用 :meth:`~threading.Condition." "notify_all`。" -#: ../../deprecations/pending-removal-in-future.rst:112 +#: ../../deprecations/pending-removal-in-future.rst:109 msgid ":meth:`!threading.Event.isSet`: use :meth:`~threading.Event.is_set`." msgstr ":meth:`!threading.Event.isSet`:請用 :meth:`~threading.Event.is_set`。" -#: ../../deprecations/pending-removal-in-future.rst:113 +#: ../../deprecations/pending-removal-in-future.rst:110 msgid "" ":meth:`!threading.Thread.isDaemon`, :meth:`threading.Thread.setDaemon`: use :" "attr:`threading.Thread.daemon` attribute." @@ -899,7 +856,7 @@ msgstr "" ":meth:`!threading.Thread.isDaemon`、:meth:`threading.Thread.setDaemon`:請" "用 :attr:`threading.Thread.daemon` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:115 +#: ../../deprecations/pending-removal-in-future.rst:112 msgid "" ":meth:`!threading.Thread.getName`, :meth:`threading.Thread.setName`: use :" "attr:`threading.Thread.name` attribute." @@ -907,20 +864,20 @@ msgstr "" ":meth:`!threading.Thread.getName`、:meth:`threading.Thread.setName`:請用 :" "attr:`threading.Thread.name` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:117 +#: ../../deprecations/pending-removal-in-future.rst:114 msgid ":meth:`!threading.currentThread`: use :meth:`threading.current_thread`." msgstr "" ":meth:`!threading.currentThread`:請用 :meth:`threading.current_thread`。" -#: ../../deprecations/pending-removal-in-future.rst:118 +#: ../../deprecations/pending-removal-in-future.rst:115 msgid ":meth:`!threading.activeCount`: use :meth:`threading.active_count`." msgstr ":meth:`!threading.activeCount`:請用 :meth:`threading.active_count`。" -#: ../../deprecations/pending-removal-in-future.rst:120 +#: ../../deprecations/pending-removal-in-future.rst:117 msgid ":class:`typing.Text` (:gh:`92332`)." msgstr ":class:`typing.Text` (:gh:`92332`)。" -#: ../../deprecations/pending-removal-in-future.rst:122 +#: ../../deprecations/pending-removal-in-future.rst:119 msgid "" ":class:`unittest.IsolatedAsyncioTestCase`: it is deprecated to return a " "value that is not ``None`` from a test case." @@ -928,58 +885,58 @@ msgstr "" ":class:`unittest.IsolatedAsyncioTestCase`:從測試案例中回傳非 ``None`` 的值已" "被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:125 +#: ../../deprecations/pending-removal-in-future.rst:122 msgid "" ":mod:`urllib.parse` deprecated functions: :func:`~urllib.parse.urlparse` " "instead" msgstr "" ":mod:`urllib.parse` 已棄用函式:請改用 :func:`~urllib.parse.urlparse`。" -#: ../../deprecations/pending-removal-in-future.rst:127 +#: ../../deprecations/pending-removal-in-future.rst:124 msgid "``splitattr()``" msgstr "``splitattr()``" -#: ../../deprecations/pending-removal-in-future.rst:128 +#: ../../deprecations/pending-removal-in-future.rst:125 msgid "``splithost()``" msgstr "``splithost()``" -#: ../../deprecations/pending-removal-in-future.rst:129 +#: ../../deprecations/pending-removal-in-future.rst:126 msgid "``splitnport()``" msgstr "``splitnport()``" -#: ../../deprecations/pending-removal-in-future.rst:130 +#: ../../deprecations/pending-removal-in-future.rst:127 msgid "``splitpasswd()``" msgstr "``splitpasswd()``" -#: ../../deprecations/pending-removal-in-future.rst:131 +#: ../../deprecations/pending-removal-in-future.rst:128 msgid "``splitport()``" msgstr "``splitport()``" -#: ../../deprecations/pending-removal-in-future.rst:132 +#: ../../deprecations/pending-removal-in-future.rst:129 msgid "``splitquery()``" msgstr "``splitquery()``" -#: ../../deprecations/pending-removal-in-future.rst:133 +#: ../../deprecations/pending-removal-in-future.rst:130 msgid "``splittag()``" msgstr "``splittag()``" -#: ../../deprecations/pending-removal-in-future.rst:134 +#: ../../deprecations/pending-removal-in-future.rst:131 msgid "``splittype()``" msgstr "``splittype()``" -#: ../../deprecations/pending-removal-in-future.rst:135 +#: ../../deprecations/pending-removal-in-future.rst:132 msgid "``splituser()``" msgstr "``splituser()``" -#: ../../deprecations/pending-removal-in-future.rst:136 +#: ../../deprecations/pending-removal-in-future.rst:133 msgid "``splitvalue()``" msgstr "``splitvalue()``" -#: ../../deprecations/pending-removal-in-future.rst:137 +#: ../../deprecations/pending-removal-in-future.rst:134 msgid "``to_bytes()``" msgstr "``to_bytes()``" -#: ../../deprecations/pending-removal-in-future.rst:139 +#: ../../deprecations/pending-removal-in-future.rst:136 msgid "" ":mod:`urllib.request`: :class:`~urllib.request.URLopener` and :class:" "`~urllib.request.FancyURLopener` style of invoking requests is deprecated. " @@ -989,13 +946,13 @@ msgstr "" "class:`~urllib.request.FancyURLopener` 風格已被棄用。請改用更新的 :func:" "`~urllib.request.urlopen` 函式和方法。" -#: ../../deprecations/pending-removal-in-future.rst:143 +#: ../../deprecations/pending-removal-in-future.rst:140 msgid "" ":mod:`wsgiref`: ``SimpleHandler.stdout.write()`` should not do partial " "writes." msgstr ":mod:`wsgiref`:``SimpleHandler.stdout.write()`` 不應該進行部分寫入。" -#: ../../deprecations/pending-removal-in-future.rst:146 +#: ../../deprecations/pending-removal-in-future.rst:143 msgid "" ":mod:`xml.etree.ElementTree`: Testing the truth value of an :class:`~xml." "etree.ElementTree.Element` is deprecated. In a future release it will always " @@ -1006,7 +963,7 @@ msgstr "" "Element` 的真值測試。在未來版本中,它將始終回傳 ``True``。請改用明確的 " "``len(elem)`` 或 ``elem is not None`` 測試。" -#: ../../deprecations/pending-removal-in-future.rst:151 +#: ../../deprecations/pending-removal-in-future.rst:148 msgid "" ":meth:`zipimport.zipimporter.load_module` is deprecated: use :meth:" "`~zipimport.zipimporter.exec_module` instead." @@ -1014,7 +971,7 @@ msgstr "" ":meth:`zipimport.zipimporter.load_module` 已被棄用:請改用 :meth:`~zipimport." "zipimporter.exec_module`。" -#: ../../deprecations/index.rst:15 +#: ../../deprecations/index.rst:13 msgid "C API Deprecations" msgstr "C API 的棄用項目" @@ -1040,197 +997,195 @@ msgid "" msgstr "設定 Python 初始化的函式,Python 3.11 中已被棄用:" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:12 -msgid "``PySys_SetArgvEx()``: set :c:member:`PyConfig.argv` instead." -msgstr "``PySys_SetArgvEx()``:請改以 :c:member:`PyConfig.argv` 設定。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:13 -msgid "``PySys_SetArgv()``: set :c:member:`PyConfig.argv` instead." -msgstr "``PySys_SetArgv()``:請改以 :c:member:`PyConfig.argv` 設定。" +msgid ":c:func:`!PySys_SetArgvEx()`: Set :c:member:`PyConfig.argv` instead." +msgstr ":c:func:`!PySys_SetArgvEx()`:請改以 :c:member:`PyConfig.argv` 設定。" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:14 -msgid "``Py_SetProgramName()``: set :c:member:`PyConfig.program_name` instead." +msgid ":c:func:`!PySys_SetArgv()`: Set :c:member:`PyConfig.argv` instead." +msgstr ":c:func:`!PySys_SetArgv()`:請改以 :c:member:`PyConfig.argv` 設定。" + +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:16 +msgid "" +":c:func:`!Py_SetProgramName()`: Set :c:member:`PyConfig.program_name` " +"instead." msgstr "" -"``Py_SetProgramName()``:請改以 :c:member:`PyConfig.program_name` 設定。" +":c:func:`!Py_SetProgramName()``:請改以 :c:member:`PyConfig.program_name` 設" +"定。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:15 -msgid "``Py_SetPythonHome()``: set :c:member:`PyConfig.home` instead." -msgstr "``Py_SetPythonHome()``:請改以 :c:member:`PyConfig.home` 設定。" +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:18 +msgid ":c:func:`!Py_SetPythonHome()`: Set :c:member:`PyConfig.home` instead." +msgstr ":c:func:`!Py_SetPythonHome()`:請改以 :c:member:`PyConfig.home` 設定。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:17 -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:45 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:21 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:71 msgid "" "The :c:func:`Py_InitializeFromConfig` API should be used with :c:type:" "`PyConfig` instead." msgstr "" ":c:func:`Py_InitializeFromConfig` API 應該與 :c:type:`PyConfig` 一起使用。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:20 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:24 msgid "Global configuration variables:" msgstr "全域設定變數:" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:22 -msgid ":c:var:`Py_DebugFlag`: use :c:member:`PyConfig.parser_debug` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:26 +msgid ":c:var:`Py_DebugFlag`: Use :c:member:`PyConfig.parser_debug` instead." msgstr ":c:var:`Py_DebugFlag`:請改用 :c:member:`PyConfig.parser_debug`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:23 -msgid ":c:var:`Py_VerboseFlag`: use :c:member:`PyConfig.verbose` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:28 +msgid ":c:var:`Py_VerboseFlag`: Use :c:member:`PyConfig.verbose` instead." msgstr ":c:var:`Py_VerboseFlag`:請改用 :c:member:`PyConfig.verbose`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:24 -msgid ":c:var:`Py_QuietFlag`: use :c:member:`PyConfig.quiet` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:30 +msgid ":c:var:`Py_QuietFlag`: Use :c:member:`PyConfig.quiet` instead." msgstr ":c:var:`Py_QuietFlag`:請改用 :c:member:`PyConfig.quiet`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:25 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:32 msgid "" -":c:var:`Py_InteractiveFlag`: use :c:member:`PyConfig.interactive` instead." +":c:var:`Py_InteractiveFlag`: Use :c:member:`PyConfig.interactive` instead." msgstr ":c:var:`Py_InteractiveFlag`:請改用 :c:member:`PyConfig.interactive`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:26 -msgid ":c:var:`Py_InspectFlag`: use :c:member:`PyConfig.inspect` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:34 +msgid ":c:var:`Py_InspectFlag`: Use :c:member:`PyConfig.inspect` instead." msgstr ":c:var:`Py_InspectFlag`:請改用 :c:member:`PyConfig.inspect`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:27 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:36 msgid "" -":c:var:`Py_OptimizeFlag`: use :c:member:`PyConfig.optimization_level` " +":c:var:`Py_OptimizeFlag`: Use :c:member:`PyConfig.optimization_level` " "instead." msgstr "" ":c:var:`Py_OptimizeFlag`:請改用 :c:member:`PyConfig.optimization_level`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:28 -msgid ":c:var:`Py_NoSiteFlag`: use :c:member:`PyConfig.site_import` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:38 +msgid ":c:var:`Py_NoSiteFlag`: Use :c:member:`PyConfig.site_import` instead." msgstr ":c:var:`Py_NoSiteFlag`:請改用 :c:member:`PyConfig.site_import`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:29 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:40 msgid "" -":c:var:`Py_BytesWarningFlag`: use :c:member:`PyConfig.bytes_warning` instead." +":c:var:`Py_BytesWarningFlag`: Use :c:member:`PyConfig.bytes_warning` instead." msgstr "" ":c:var:`Py_BytesWarningFlag`:請改用 :c:member:`PyConfig.bytes_warning`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:30 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:42 msgid "" -":c:var:`Py_FrozenFlag`: use :c:member:`PyConfig.pathconfig_warnings` instead." +":c:var:`Py_FrozenFlag`: Use :c:member:`PyConfig.pathconfig_warnings` instead." msgstr "" ":c:var:`Py_FrozenFlag`:請改用 :c:member:`PyConfig.pathconfig_warnings`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:31 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:44 msgid "" -":c:var:`Py_IgnoreEnvironmentFlag`: use :c:member:`PyConfig.use_environment` " +":c:var:`Py_IgnoreEnvironmentFlag`: Use :c:member:`PyConfig.use_environment` " "instead." msgstr "" ":c:var:`Py_IgnoreEnvironmentFlag`:請改用 :c:member:`PyConfig." "use_environment`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:32 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:46 msgid "" -":c:var:`Py_DontWriteBytecodeFlag`: use :c:member:`PyConfig.write_bytecode` " +":c:var:`Py_DontWriteBytecodeFlag`: Use :c:member:`PyConfig.write_bytecode` " "instead." msgstr "" ":c:var:`Py_DontWriteBytecodeFlag`:請改用 :c:member:`PyConfig." "write_bytecode`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:33 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:48 msgid "" -":c:var:`Py_NoUserSiteDirectory`: use :c:member:`PyConfig." +":c:var:`Py_NoUserSiteDirectory`: Use :c:member:`PyConfig." "user_site_directory` instead." msgstr "" ":c:var:`Py_NoUserSiteDirectory`:請改用 :c:member:`PyConfig." "user_site_directory`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:34 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:50 msgid "" -":c:var:`Py_UnbufferedStdioFlag`: use :c:member:`PyConfig.buffered_stdio` " +":c:var:`Py_UnbufferedStdioFlag`: Use :c:member:`PyConfig.buffered_stdio` " "instead." msgstr "" ":c:var:`Py_UnbufferedStdioFlag`:請改用 :c:member:`PyConfig.buffered_stdio`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:35 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:52 msgid "" -":c:var:`Py_HashRandomizationFlag`: use :c:member:`PyConfig.use_hash_seed` " +":c:var:`Py_HashRandomizationFlag`: Use :c:member:`PyConfig.use_hash_seed` " "and :c:member:`PyConfig.hash_seed` instead." msgstr "" ":c:var:`Py_HashRandomizationFlag`:請改用 :c:member:`PyConfig.use_hash_seed` " "和 :c:member:`PyConfig.hash_seed`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:37 -msgid ":c:var:`Py_IsolatedFlag`: use :c:member:`PyConfig.isolated` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:55 +msgid ":c:var:`Py_IsolatedFlag`: Use :c:member:`PyConfig.isolated` instead." msgstr ":c:var:`Py_IsolatedFlag`:請改用 :c:member:`PyConfig.isolated`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:38 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:57 msgid "" -":c:var:`Py_LegacyWindowsFSEncodingFlag`: use :c:member:`PyPreConfig." +":c:var:`Py_LegacyWindowsFSEncodingFlag`: Use :c:member:`PyPreConfig." "legacy_windows_fs_encoding` instead." msgstr "" ":c:var:`Py_LegacyWindowsFSEncodingFlag`:請改用 :c:member:`PyPreConfig." "legacy_windows_fs_encoding`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:39 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:59 msgid "" -":c:var:`Py_LegacyWindowsStdioFlag`: use :c:member:`PyConfig." +":c:var:`Py_LegacyWindowsStdioFlag`: Use :c:member:`PyConfig." "legacy_windows_stdio` instead." msgstr "" ":c:var:`Py_LegacyWindowsStdioFlag`:請改用 :c:member:`PyConfig." "legacy_windows_stdio`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:40 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:61 msgid "" -":c:var:`!Py_FileSystemDefaultEncoding`: use :c:member:`PyConfig." +":c:var:`!Py_FileSystemDefaultEncoding`: Use :c:member:`PyConfig." "filesystem_encoding` instead." msgstr "" ":c:var:`!Py_FileSystemDefaultEncoding`:請改用 :c:member:`PyConfig." "filesystem_encoding`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:41 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:63 msgid "" -":c:var:`!Py_HasFileSystemDefaultEncoding`: use :c:member:`PyConfig." +":c:var:`!Py_HasFileSystemDefaultEncoding`: Use :c:member:`PyConfig." "filesystem_encoding` instead." msgstr "" ":c:var:`!Py_HasFileSystemDefaultEncoding`:請改用 :c:member:`PyConfig." "filesystem_encoding`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:42 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:65 msgid "" -":c:var:`!Py_FileSystemDefaultEncodeErrors`: use :c:member:`PyConfig." +":c:var:`!Py_FileSystemDefaultEncodeErrors`: Use :c:member:`PyConfig." "filesystem_errors` instead." msgstr "" ":c:var:`!Py_FileSystemDefaultEncodeErrors`:請改用 :c:member:`PyConfig." "filesystem_errors`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:43 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:67 msgid "" -":c:var:`!Py_UTF8Mode`: use :c:member:`PyPreConfig.utf8_mode` instead. (see :" +":c:var:`!Py_UTF8Mode`: Use :c:member:`PyPreConfig.utf8_mode` instead. (see :" "c:func:`Py_PreInitialize`)" msgstr "" ":c:var:`!Py_UTF8Mode`:請改用 :c:member:`PyPreConfig.utf8_mode`。(請見 :c:" "func:`Py_PreInitialize`)" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:4 -msgid "The bundled copy of ``libmpdecimal``." -msgstr "``libmpdecimal`` 的打包副本 (bundled copy)。" - -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:5 msgid "" -":c:func:`PyImport_ImportModuleNoBlock`: use :c:func:`PyImport_ImportModule` " -"instead." +"The :c:func:`PyImport_ImportModuleNoBlock`: Use :c:func:" +"`PyImport_ImportModule` instead." msgstr "" ":c:func:`PyImport_ImportModuleNoBlock`:請改用 :c:func:" "`PyImport_ImportModule`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:6 msgid "" -":c:func:`PyWeakref_GET_OBJECT`: use :c:func:`!PyWeakref_GetRef` instead." -msgstr ":c:func:`PyWeakref_GET_OBJECT`:請改用 :c:func:`!PyWeakref_GetRef`。" - -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:7 -msgid ":c:func:`PyWeakref_GetObject`: use :c:func:`!PyWeakref_GetRef` instead." -msgstr ":c:func:`PyWeakref_GetObject`:請改用 :c:func:`!PyWeakref_GetRef`。" +":c:func:`PyWeakref_GetObject` and :c:func:`PyWeakref_GET_OBJECT`: Use :c:" +"func:`PyWeakref_GetRef` instead." +msgstr "" +":c:func:`PyWeakref_GetObject` 和 :c:func:`PyWeakref_GET_OBJECT`:請改用 :c:" +"func:`PyWeakref_GetRef`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:8 -msgid ":c:type:`!Py_UNICODE_WIDE` type: use :c:type:`wchar_t` instead." -msgstr ":c:type:`!Py_UNICODE_WIDE` type:請改用 :c:type:`wchar_t`。" - -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:9 -msgid ":c:type:`Py_UNICODE` type: use :c:type:`wchar_t` instead." -msgstr ":c:type:`Py_UNICODE` type:請改用 :c:type:`wchar_t`。" +msgid "" +":c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: Use :c:" +"type:`wchar_t` instead." +msgstr "" +":c:type:`Py_UNICODE` 型別與 :c:macro:`!Py_UNICODE_WIDE` 巨集:請改用 :c:type:" +"`wchar_t`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:10 msgid "Python initialization functions:" @@ -1238,35 +1193,43 @@ msgstr "Python 初始化函式:" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:12 msgid "" -":c:func:`PySys_ResetWarnOptions`: clear :data:`sys.warnoptions` and :data:`!" +":c:func:`PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" "warnings.filters` instead." msgstr "" ":c:func:`PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` 和 :" "data:`!warnings.filters`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:14 -msgid ":c:func:`Py_GetExecPrefix`: get :data:`sys.exec_prefix` instead." -msgstr ":c:func:`Py_GetExecPrefix`:請改用 :data:`sys.exec_prefix`。" +msgid "" +":c:func:`Py_GetExecPrefix`: Get :data:`sys.base_exec_prefix` and :data:`sys." +"exec_prefix` instead." +msgstr "" +":c:func:`Py_GetExecPrefix`:請改用 :data:`sys.base_exec_prefix` 與 :data:" +"`sys.exec_prefix`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:15 -msgid ":c:func:`Py_GetPath`: get :data:`sys.path` instead." +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:16 +msgid ":c:func:`Py_GetPath`: Get :data:`sys.path` instead." msgstr ":c:func:`Py_GetPath`:請改用 :data:`sys.path`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:16 -msgid ":c:func:`Py_GetPrefix`: get :data:`sys.prefix` instead." -msgstr ":c:func:`Py_GetPrefix`:請改用 :data:`sys.prefix`。" +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:18 +msgid "" +":c:func:`Py_GetPrefix`: Get :data:`sys.base_prefix` and :data:`sys.prefix` " +"instead." +msgstr "" +":c:func:`Py_GetPrefix`:請改用 :data:`sys.base_prefix` 與 :data:`sys." +"prefix`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 -msgid ":c:func:`Py_GetProgramFullPath`: get :data:`sys.executable` instead." +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:20 +msgid ":c:func:`Py_GetProgramFullPath`: Get :data:`sys.executable` instead." msgstr ":c:func:`Py_GetProgramFullPath`:請改用 :data:`sys.executable`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:18 -msgid ":c:func:`Py_GetProgramName`: get :data:`sys.executable` instead." +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:22 +msgid ":c:func:`Py_GetProgramName`: Get :data:`sys.executable` instead." msgstr ":c:func:`Py_GetProgramName`:請改用 :data:`sys.executable`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:19 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:24 msgid "" -":c:func:`Py_GetPythonHome`: get :c:member:`PyConfig.home` or the :envvar:" +":c:func:`Py_GetPythonHome`: Get :c:member:`PyConfig.home` or the :envvar:" "`PYTHONHOME` environment variable instead." msgstr "" ":c:func:`Py_GetPythonHome`:請改用 :c:member:`PyConfig.home` 或 :envvar:" @@ -1279,84 +1242,85 @@ msgid "" msgstr "下列 API 已被棄用並將會被移除,不過目前尚未訂定移除日期。" #: ../../deprecations/c-api-pending-removal-in-future.rst:7 -msgid ":c:macro:`Py_TPFLAGS_HAVE_FINALIZE`: unneeded since Python 3.8." +msgid ":c:macro:`Py_TPFLAGS_HAVE_FINALIZE`: Unneeded since Python 3.8." msgstr ":c:macro:`Py_TPFLAGS_HAVE_FINALIZE`:自 Python 3.8 起不再需要" -#: ../../deprecations/c-api-pending-removal-in-future.rst:8 -msgid ":c:func:`PyErr_Fetch`: use :c:func:`PyErr_GetRaisedException` instead." +#: ../../deprecations/c-api-pending-removal-in-future.rst:9 +msgid ":c:func:`PyErr_Fetch`: Use :c:func:`PyErr_GetRaisedException` instead." msgstr ":c:func:`PyErr_Fetch`:請改用 :c:func:`PyErr_GetRaisedException`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:9 +#: ../../deprecations/c-api-pending-removal-in-future.rst:11 msgid "" -":c:func:`PyErr_NormalizeException`: use :c:func:`PyErr_GetRaisedException` " +":c:func:`PyErr_NormalizeException`: Use :c:func:`PyErr_GetRaisedException` " "instead." msgstr "" ":c:func:`PyErr_NormalizeException`:請改用 :c:func:" "`PyErr_GetRaisedException`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:10 +#: ../../deprecations/c-api-pending-removal-in-future.rst:13 msgid "" -":c:func:`PyErr_Restore`: use :c:func:`PyErr_SetRaisedException` instead." +":c:func:`PyErr_Restore`: Use :c:func:`PyErr_SetRaisedException` instead." msgstr ":c:func:`PyErr_Restore`:請改用 :c:func:`PyErr_SetRaisedException`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:11 +#: ../../deprecations/c-api-pending-removal-in-future.rst:15 msgid "" -":c:func:`PyModule_GetFilename`: use :c:func:`PyModule_GetFilenameObject` " +":c:func:`PyModule_GetFilename`: Use :c:func:`PyModule_GetFilenameObject` " "instead." msgstr "" ":c:func:`PyModule_GetFilename`:請改用 :c:func:`PyModule_GetFilenameObject`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:12 -msgid ":c:func:`PyOS_AfterFork`: use :c:func:`PyOS_AfterFork_Child` instead." +#: ../../deprecations/c-api-pending-removal-in-future.rst:17 +msgid ":c:func:`PyOS_AfterFork`: Use :c:func:`PyOS_AfterFork_Child` instead." msgstr ":c:func:`PyOS_AfterFork`:請改用 :c:func:`PyOS_AfterFork_Child`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:13 +#: ../../deprecations/c-api-pending-removal-in-future.rst:19 msgid "" -":c:func:`PySlice_GetIndicesEx`: use :c:func:`PySlice_Unpack` and :c:func:" +":c:func:`PySlice_GetIndicesEx`: Use :c:func:`PySlice_Unpack` and :c:func:" "`PySlice_AdjustIndices` instead." msgstr "" ":c:func:`PySlice_GetIndicesEx`:請改用 :c:func:`PySlice_Unpack` 和 :c:func:" "`PySlice_AdjustIndices`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:14 +#: ../../deprecations/c-api-pending-removal-in-future.rst:21 msgid "" -":c:func:`!PyUnicode_AsDecodedObject`: use :c:func:`PyCodec_Decode` instead." +":c:func:`!PyUnicode_AsDecodedObject`: Use :c:func:`PyCodec_Decode` instead." msgstr "" ":c:func:`!PyUnicode_AsDecodedObject`:請改用 :c:func:`PyCodec_Decode`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:15 +#: ../../deprecations/c-api-pending-removal-in-future.rst:23 msgid "" -":c:func:`!PyUnicode_AsDecodedUnicode`: use :c:func:`PyCodec_Decode` instead." +":c:func:`!PyUnicode_AsDecodedUnicode`: Use :c:func:`PyCodec_Decode` instead." msgstr "" ":c:func:`!PyUnicode_AsDecodedUnicode`:請改用 :c:func:`PyCodec_Decode`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:16 +#: ../../deprecations/c-api-pending-removal-in-future.rst:25 msgid "" -":c:func:`!PyUnicode_AsEncodedObject`: use :c:func:`PyCodec_Encode` instead." +":c:func:`!PyUnicode_AsEncodedObject`: Use :c:func:`PyCodec_Encode` instead." msgstr "" ":c:func:`!PyUnicode_AsEncodedObject`:請改用 :c:func:`PyCodec_Encode`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:17 +#: ../../deprecations/c-api-pending-removal-in-future.rst:27 msgid "" -":c:func:`!PyUnicode_AsEncodedUnicode`: use :c:func:`PyCodec_Encode` instead." +":c:func:`!PyUnicode_AsEncodedUnicode`: Use :c:func:`PyCodec_Encode` instead." msgstr "" ":c:func:`!PyUnicode_AsEncodedUnicode`:請改用 :c:func:`PyCodec_Encode`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:18 -msgid ":c:func:`PyUnicode_READY`: unneeded since Python 3.12" +#: ../../deprecations/c-api-pending-removal-in-future.rst:29 +msgid ":c:func:`PyUnicode_READY`: Unneeded since Python 3.12" msgstr ":c:func:`PyUnicode_READY`:自 Python 3.12 起不再需要" -#: ../../deprecations/c-api-pending-removal-in-future.rst:19 -msgid ":c:func:`!PyErr_Display`: use :c:func:`PyErr_DisplayException` instead." +#: ../../deprecations/c-api-pending-removal-in-future.rst:31 +msgid ":c:func:`!PyErr_Display`: Use :c:func:`PyErr_DisplayException` instead." msgstr ":c:func:`!PyErr_Display`:請改用 :c:func:`PyErr_DisplayException`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:20 +#: ../../deprecations/c-api-pending-removal-in-future.rst:33 msgid "" -":c:func:`!_PyErr_ChainExceptions`: use ``_PyErr_ChainExceptions1`` instead." +":c:func:`!_PyErr_ChainExceptions`: Use :c:func:`!_PyErr_ChainExceptions1` " +"instead." msgstr "" ":c:func:`!_PyErr_ChainExceptions`:請改用 ``_PyErr_ChainExceptions1``。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:21 +#: ../../deprecations/c-api-pending-removal-in-future.rst:35 msgid "" ":c:member:`!PyBytesObject.ob_shash` member: call :c:func:`PyObject_Hash` " "instead." @@ -1364,40 +1328,46 @@ msgstr "" ":c:member:`!PyBytesObject.ob_shash` 成員:請改為呼叫 :c:func:" "`PyObject_Hash`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:23 +#: ../../deprecations/c-api-pending-removal-in-future.rst:37 msgid ":c:member:`!PyDictObject.ma_version_tag` member." msgstr ":c:member:`!PyDictObject.ma_version_tag` 成員。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:24 +#: ../../deprecations/c-api-pending-removal-in-future.rst:38 msgid "Thread Local Storage (TLS) API:" msgstr "執行緒局部儲存 (Thread Local Storage, TLS) API:" -#: ../../deprecations/c-api-pending-removal-in-future.rst:26 +#: ../../deprecations/c-api-pending-removal-in-future.rst:40 msgid "" -":c:func:`PyThread_create_key`: use :c:func:`PyThread_tss_alloc` instead." +":c:func:`PyThread_create_key`: Use :c:func:`PyThread_tss_alloc` instead." msgstr ":c:func:`PyThread_create_key`:請改用 :c:func:`PyThread_tss_alloc`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:27 -msgid ":c:func:`PyThread_delete_key`: use :c:func:`PyThread_tss_free` instead." +#: ../../deprecations/c-api-pending-removal-in-future.rst:42 +msgid ":c:func:`PyThread_delete_key`: Use :c:func:`PyThread_tss_free` instead." msgstr ":c:func:`PyThread_delete_key`:請改用 :c:func:`PyThread_tss_free`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:28 +#: ../../deprecations/c-api-pending-removal-in-future.rst:44 msgid "" -":c:func:`PyThread_set_key_value`: use :c:func:`PyThread_tss_set` instead." +":c:func:`PyThread_set_key_value`: Use :c:func:`PyThread_tss_set` instead." msgstr ":c:func:`PyThread_set_key_value`:請改用 :c:func:`PyThread_tss_set`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:29 +#: ../../deprecations/c-api-pending-removal-in-future.rst:46 msgid "" -":c:func:`PyThread_get_key_value`: use :c:func:`PyThread_tss_get` instead." +":c:func:`PyThread_get_key_value`: Use :c:func:`PyThread_tss_get` instead." msgstr ":c:func:`PyThread_get_key_value`:請改用 :c:func:`PyThread_tss_get`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:30 +#: ../../deprecations/c-api-pending-removal-in-future.rst:48 msgid "" -":c:func:`PyThread_delete_key_value`: use :c:func:`PyThread_tss_delete` " +":c:func:`PyThread_delete_key_value`: Use :c:func:`PyThread_tss_delete` " "instead." msgstr "" ":c:func:`PyThread_delete_key_value`:請改用 :c:func:`PyThread_tss_delete`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:31 -msgid ":c:func:`PyThread_ReInitTLS`: unneeded since Python 3.7." +#: ../../deprecations/c-api-pending-removal-in-future.rst:50 +msgid ":c:func:`PyThread_ReInitTLS`: Unneeded since Python 3.7." msgstr ":c:func:`PyThread_ReInitTLS`:自 Python 3.7 起不再需要。" + +#~ msgid "The bundled copy of ``libmpdecimal``." +#~ msgstr "``libmpdecimal`` 的打包副本 (bundled copy)。" + +#~ msgid ":mod:`array`'s ``'u'`` format code (:gh:`57281`)" +#~ msgstr ":mod:`array` 的 ``'u'`` 格式碼 (:gh:`57281`)" diff --git a/deprecations/pending-removal-in-3.13.po b/deprecations/pending-removal-in-3.13.po index 75c25c93be..6e382beeb8 100644 --- a/deprecations/pending-removal-in-3.13.po +++ b/deprecations/pending-removal-in-3.13.po @@ -1,15 +1,15 @@ # Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. -# FIRST AUTHOR , YEAR. # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-30 18:24+0000\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -24,80 +24,80 @@ msgid "Modules (see :pep:`594`):" msgstr "模組(請見 :pep:`594`):" #: ../../deprecations/pending-removal-in-3.13.rst:6 -msgid ":mod:`aifc`" -msgstr ":mod:`aifc`" +msgid ":mod:`!aifc`" +msgstr ":mod:`!aifc`" #: ../../deprecations/pending-removal-in-3.13.rst:7 -msgid ":mod:`audioop`" -msgstr ":mod:`audioop`" +msgid ":mod:`!audioop`" +msgstr ":mod:`!audioop`" #: ../../deprecations/pending-removal-in-3.13.rst:8 -msgid ":mod:`cgi`" -msgstr ":mod:`cgi`" +msgid ":mod:`!cgi`" +msgstr ":mod:`!cgi`" #: ../../deprecations/pending-removal-in-3.13.rst:9 -msgid ":mod:`cgitb`" -msgstr ":mod:`cgitb`" +msgid ":mod:`!cgitb`" +msgstr ":mod:`!cgitb`" #: ../../deprecations/pending-removal-in-3.13.rst:10 -msgid ":mod:`chunk`" -msgstr ":mod:`chunk`" +msgid ":mod:`!chunk`" +msgstr ":mod:`!chunk`" #: ../../deprecations/pending-removal-in-3.13.rst:11 -msgid ":mod:`crypt`" -msgstr ":mod:`crypt`" +msgid ":mod:`!crypt`" +msgstr ":mod:`!crypt`" #: ../../deprecations/pending-removal-in-3.13.rst:12 -msgid ":mod:`imghdr`" -msgstr ":mod:`imghdr`" +msgid ":mod:`!imghdr`" +msgstr ":mod:`!imghdr`" #: ../../deprecations/pending-removal-in-3.13.rst:13 -msgid ":mod:`mailcap`" -msgstr ":mod:`mailcap`" +msgid ":mod:`!mailcap`" +msgstr ":mod:`!mailcap`" #: ../../deprecations/pending-removal-in-3.13.rst:14 -msgid ":mod:`msilib`" -msgstr ":mod:`msilib`" +msgid ":mod:`!msilib`" +msgstr ":mod:`!msilib`" #: ../../deprecations/pending-removal-in-3.13.rst:15 -msgid ":mod:`nis`" -msgstr ":mod:`nis`" +msgid ":mod:`!nis`" +msgstr ":mod:`!nis`" #: ../../deprecations/pending-removal-in-3.13.rst:16 -msgid ":mod:`nntplib`" -msgstr ":mod:`nntplib`" +msgid ":mod:`!nntplib`" +msgstr ":mod:`!nntplib`" #: ../../deprecations/pending-removal-in-3.13.rst:17 -msgid ":mod:`ossaudiodev`" -msgstr ":mod:`ossaudiodev`" +msgid ":mod:`!ossaudiodev`" +msgstr ":mod:`!ossaudiodev`" #: ../../deprecations/pending-removal-in-3.13.rst:18 -msgid ":mod:`pipes`" -msgstr ":mod:`pipes`" +msgid ":mod:`!pipes`" +msgstr ":mod:`!pipes`" #: ../../deprecations/pending-removal-in-3.13.rst:19 -msgid ":mod:`sndhdr`" -msgstr ":mod:`sndhdr`" +msgid ":mod:`!sndhdr`" +msgstr ":mod:`!sndhdr`" #: ../../deprecations/pending-removal-in-3.13.rst:20 -msgid ":mod:`spwd`" -msgstr ":mod:`spwd`" +msgid ":mod:`!spwd`" +msgstr ":mod:`!spwd`" #: ../../deprecations/pending-removal-in-3.13.rst:21 -msgid ":mod:`sunau`" -msgstr ":mod:`sunau`" +msgid ":mod:`!sunau`" +msgstr ":mod:`!sunau`" #: ../../deprecations/pending-removal-in-3.13.rst:22 -msgid ":mod:`telnetlib`" -msgstr ":mod:`telnetlib`" +msgid ":mod:`!telnetlib`" +msgstr ":mod:`!telnetlib`" #: ../../deprecations/pending-removal-in-3.13.rst:23 -msgid ":mod:`uu`" -msgstr ":mod:`uu`" +msgid ":mod:`!uu`" +msgstr ":mod:`!uu`" #: ../../deprecations/pending-removal-in-3.13.rst:24 -msgid ":mod:`xdrlib`" -msgstr ":mod:`xdrlib`" +msgid ":mod:`!xdrlib`" +msgstr ":mod:`!xdrlib`" #: ../../deprecations/pending-removal-in-3.13.rst:26 msgid "Other modules:" diff --git a/deprecations/pending-removal-in-3.14.po b/deprecations/pending-removal-in-3.14.po index 85e1f5f2be..bd8e164bd3 100644 --- a/deprecations/pending-removal-in-3.14.po +++ b/deprecations/pending-removal-in-3.14.po @@ -1,16 +1,15 @@ -# SOME DESCRIPTIVE TITLE. # Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. -# FIRST AUTHOR , YEAR. # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-17 00:03+0000\n" +"POT-Creation-Date: 2024-11-10 17:21+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -61,8 +60,8 @@ msgstr ":class:`!ast.Ellipsis`" #: ../../deprecations/pending-removal-in-3.14.rst:19 msgid "" -"Use :class:`ast.Constant` instead. (Contributed by Serhiy Storchaka in :gh:" -"`90953`.)" +"Use :class:`ast.Constant` instead. (Contributed by Serhiy Storchaka " +"in :gh:`90953`.)" msgstr "" "請改用 :class:`ast.Constant`。(由 Serhiy Storchaka 於 :gh:`90953` 貢獻。)" @@ -72,27 +71,26 @@ msgstr ":mod:`asyncio`:" #: ../../deprecations/pending-removal-in-3.14.rst:24 msgid "" -"The child watcher classes :class:`~asyncio.MultiLoopChildWatcher`, :class:" -"`~asyncio.FastChildWatcher`, :class:`~asyncio.AbstractChildWatcher` and :" -"class:`~asyncio.SafeChildWatcher` are deprecated and will be removed in " +"The child watcher " +"classes :class:`~asyncio.MultiLoopChildWatcher`, :class:`~asyncio.FastChildWatcher`, :class:`~asyncio.AbstractChildWatcher` " +"and :class:`~asyncio.SafeChildWatcher` are deprecated and will be removed in " "Python 3.14. (Contributed by Kumar Aditya in :gh:`94597`.)" msgstr "" -"已棄用並將在 Python 3.14 中移除的 child watcher 類別::class:`~asyncio." -"MultiLoopChildWatcher`、:class:`~asyncio.FastChildWatcher`、:class:`~asyncio." -"AbstractChildWatcher` 和 :class:`~asyncio.SafeChildWatcher`。 (由 Kumar " -"Aditya 於 :gh:`94597` 貢獻。)" +"已棄用並將在 Python 3.14 中移除的 child watcher 類" +"別::class:`~asyncio.MultiLoopChildWatcher`、:class:`~asyncio.FastChildWatcher`、:class:`~asyncio.AbstractChildWatcher` " +"和 :class:`~asyncio.SafeChildWatcher`。 (由 Kumar Aditya 於 :gh:`94597` 貢" +"獻。)" #: ../../deprecations/pending-removal-in-3.14.rst:30 msgid "" -":func:`asyncio.set_child_watcher`, :func:`asyncio.get_child_watcher`, :meth:" -"`asyncio.AbstractEventLoopPolicy.set_child_watcher` and :meth:`asyncio." -"AbstractEventLoopPolicy.get_child_watcher` are deprecated and will be " -"removed in Python 3.14. (Contributed by Kumar Aditya in :gh:`94597`.)" +":func:`asyncio.set_child_watcher`, :func:`asyncio.get_child_watcher`, :meth:`asyncio.AbstractEventLoopPolicy.set_child_watcher` " +"and :meth:`asyncio.AbstractEventLoopPolicy.get_child_watcher` are deprecated " +"and will be removed in Python 3.14. (Contributed by Kumar Aditya " +"in :gh:`94597`.)" msgstr "" -":func:`asyncio.set_child_watcher`、:func:`asyncio.get_child_watcher`、:meth:" -"`asyncio.AbstractEventLoopPolicy.set_child_watcher` 和 :meth:`asyncio." -"AbstractEventLoopPolicy.get_child_watcher` 已被棄用並將在 Python 3.14 中移" -"除。(由 Kumar Aditya 於 :gh:`94597` 貢獻。)" +":func:`asyncio.set_child_watcher`、:func:`asyncio.get_child_watcher`、:meth:`asyncio.AbstractEventLoopPolicy.set_child_watcher` " +"和 :meth:`asyncio.AbstractEventLoopPolicy.get_child_watcher` 已被棄用並將在 " +"Python 3.14 中移除。(由 Kumar Aditya 於 :gh:`94597` 貢獻。)" #: ../../deprecations/pending-removal-in-3.14.rst:36 msgid "" @@ -109,63 +107,58 @@ msgstr "" msgid "" ":mod:`collections.abc`: Deprecated :class:`~collections.abc.ByteString`. " "Prefer :class:`!Sequence` or :class:`~collections.abc.Buffer`. For use in " -"typing, prefer a union, like ``bytes | bytearray``, or :class:`collections." -"abc.Buffer`. (Contributed by Shantanu Jain in :gh:`91896`.)" +"typing, prefer a union, like ``bytes | bytearray``, " +"or :class:`collections.abc.Buffer`. (Contributed by Shantanu Jain " +"in :gh:`91896`.)" msgstr "" -":mod:`collections.abc`:已棄用 :class:`~collections.abc.ByteString`。請改用 :" -"class:`!Sequence` 或 :class:`~collections.abc.Buffer`。在 typing 中使用時,請" -"改用聯集,如 ``bytes | bytearray``,或 :class:`collections.abc.Buffer`。(由 " -"Shantanu Jain 於 :gh:`91896` 貢獻。)" +":mod:`collections.abc`:已棄用 :class:`~collections.abc.ByteString`。請改" +"用 :class:`!Sequence` 或 :class:`~collections.abc.Buffer`。在 typing 中使用" +"時,請改用聯集,如 ``bytes | bytearray``," +"或 :class:`collections.abc.Buffer`。(由 Shantanu Jain 於 :gh:`91896` 貢" +"獻。)" #: ../../deprecations/pending-removal-in-3.14.rst:47 msgid "" -":mod:`email`: Deprecated the *isdst* parameter in :func:`email.utils." -"localtime`. (Contributed by Alan Williams in :gh:`72346`.)" +":mod:`email`: Deprecated the *isdst* parameter " +"in :func:`email.utils.localtime`. (Contributed by Alan Williams " +"in :gh:`72346`.)" msgstr "" ":mod:`email`:已棄用 :func:`email.utils.localtime` 中的 *isdst* 參數。(由 " "Alan Williams 於 :gh:`72346` 貢獻。)" #: ../../deprecations/pending-removal-in-3.14.rst:50 -msgid "" -":mod:`importlib`: ``__package__`` and ``__cached__`` will cease to be set or " -"taken into consideration by the import system (:gh:`97879`)." -msgstr "" -":mod:`importlib`:``__package__`` 和 ``__cached__`` 將不再被設定或被 import " -"系統考慮。 (:gh:`97879`)" - -#: ../../deprecations/pending-removal-in-3.14.rst:53 msgid ":mod:`importlib.abc` deprecated classes:" msgstr ":mod:`importlib.abc` 的已棄用類別:" -#: ../../deprecations/pending-removal-in-3.14.rst:55 +#: ../../deprecations/pending-removal-in-3.14.rst:52 msgid ":class:`!importlib.abc.ResourceReader`" msgstr ":class:`!importlib.abc.ResourceReader`" -#: ../../deprecations/pending-removal-in-3.14.rst:56 +#: ../../deprecations/pending-removal-in-3.14.rst:53 msgid ":class:`!importlib.abc.Traversable`" msgstr ":class:`!importlib.abc.Traversable`" -#: ../../deprecations/pending-removal-in-3.14.rst:57 +#: ../../deprecations/pending-removal-in-3.14.rst:54 msgid ":class:`!importlib.abc.TraversableResources`" msgstr ":class:`!importlib.abc.TraversableResources`" -#: ../../deprecations/pending-removal-in-3.14.rst:59 +#: ../../deprecations/pending-removal-in-3.14.rst:56 msgid "Use :mod:`importlib.resources.abc` classes instead:" msgstr "請改用 :mod:`importlib.resources.abc` 類別:" -#: ../../deprecations/pending-removal-in-3.14.rst:61 +#: ../../deprecations/pending-removal-in-3.14.rst:58 msgid ":class:`importlib.resources.abc.Traversable`" msgstr ":class:`importlib.resources.abc.Traversable`" -#: ../../deprecations/pending-removal-in-3.14.rst:62 +#: ../../deprecations/pending-removal-in-3.14.rst:59 msgid ":class:`importlib.resources.abc.TraversableResources`" msgstr ":class:`importlib.resources.abc.TraversableResources`" -#: ../../deprecations/pending-removal-in-3.14.rst:64 +#: ../../deprecations/pending-removal-in-3.14.rst:61 msgid "(Contributed by Jason R. Coombs and Hugo van Kemenade in :gh:`93963`.)" msgstr "(由 Jason R. Coombs 和 Hugo van Kemenade 貢獻於 :gh:`93963`。)" -#: ../../deprecations/pending-removal-in-3.14.rst:66 +#: ../../deprecations/pending-removal-in-3.14.rst:63 msgid "" ":mod:`itertools` had undocumented, inefficient, historically buggy, and " "inconsistent support for copy, deepcopy, and pickle operations. This will be " @@ -176,92 +169,74 @@ msgstr "" "deepcopy 和 pickle 操作支援。將在 3.14 中移除以大幅減少程式碼量和維護負擔。 " "(由 Raymond Hettinger 於 :gh:`101588` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.14.rst:72 +#: ../../deprecations/pending-removal-in-3.14.rst:69 msgid "" ":mod:`multiprocessing`: The default start method will change to a safer one " "on Linux, BSDs, and other non-macOS POSIX platforms where ``'fork'`` is " "currently the default (:gh:`84559`). Adding a runtime warning about this was " "deemed too disruptive as the majority of code is not expected to care. Use " -"the :func:`~multiprocessing.get_context` or :func:`~multiprocessing." -"set_start_method` APIs to explicitly specify when your code *requires* " -"``'fork'``. See :ref:`multiprocessing-start-methods`." +"the :func:`~multiprocessing.get_context` " +"or :func:`~multiprocessing.set_start_method` APIs to explicitly specify when " +"your code *requires* ``'fork'``. See :ref:`multiprocessing-start-methods`." msgstr "" ":mod:`multiprocessing`:預設的啟動方法將在 Linux、BSD 和其他非 macOS POSIX 平" "台上更改為更安全的 方法,目前 ``'fork'`` 是預設值 (:gh:`84559`)。對此增加一" -"個 runtime 警告被認為太過擾人,因為 大多數程式碼不會在意。請使用 :func:" -"`~multiprocessing.get_context` 或 :func:`~multiprocessing.set_start_method` " -"API 來明確指定你的程式碼何時\\ *需要* ``'fork'``。請參閱 :ref:" -"`multiprocessing-start-methods`。" +"個 runtime 警告被認為太過擾人,因為 大多數程式碼不會在意。請使" +"用 :func:`~multiprocessing.get_context` " +"或 :func:`~multiprocessing.set_start_method` API 來明確指定你的程式碼何時\\ *" +"需要* ``'fork'``。請參閱 :ref:`multiprocessing-start-methods`。" -#: ../../deprecations/pending-removal-in-3.14.rst:80 +#: ../../deprecations/pending-removal-in-3.14.rst:77 msgid "" -":mod:`pathlib`: :meth:`~pathlib.PurePath.is_relative_to` and :meth:`~pathlib." -"PurePath.relative_to`: passing additional arguments is deprecated." +":mod:`pathlib`: :meth:`~pathlib.PurePath.is_relative_to` " +"and :meth:`~pathlib.PurePath.relative_to`: passing additional arguments is " +"deprecated." msgstr "" -":mod:`pathlib`:已棄用 :meth:`~pathlib.PurePath.is_relative_to` 和 :meth:" -"`~pathlib.PurePath.relative_to`:額外引數的傳遞已被棄用。" +":mod:`pathlib`:已棄用 :meth:`~pathlib.PurePath.is_relative_to` " +"和 :meth:`~pathlib.PurePath.relative_to`:額外引數的傳遞已被棄用。" -#: ../../deprecations/pending-removal-in-3.14.rst:84 +#: ../../deprecations/pending-removal-in-3.14.rst:81 msgid "" ":mod:`pkgutil`: :func:`~pkgutil.find_loader` and :func:`~pkgutil.get_loader` " "now raise :exc:`DeprecationWarning`; use :func:`importlib.util.find_spec` " "instead. (Contributed by Nikita Sobolev in :gh:`97850`.)" msgstr "" ":mod:`pkgutil`::func:`~pkgutil.find_loader` 和 :func:`~pkgutil.get_loader` " -"現在會引發 :exc:`DeprecationWarning`;請改用 :func:`importlib.util." -"find_spec`。 (由 Nikita Sobolev 於 :gh:`97850` 貢獻。)" +"現在會引發 :exc:`DeprecationWarning`;請改" +"用 :func:`importlib.util.find_spec`。 (由 Nikita Sobolev 於 :gh:`97850` 貢" +"獻。)" -#: ../../deprecations/pending-removal-in-3.14.rst:89 +#: ../../deprecations/pending-removal-in-3.14.rst:86 msgid ":mod:`pty`:" msgstr ":mod:`pty`:" -#: ../../deprecations/pending-removal-in-3.14.rst:91 +#: ../../deprecations/pending-removal-in-3.14.rst:88 msgid "``master_open()``: use :func:`pty.openpty`." msgstr "``master_open()``:請用 :func:`pty.openpty`。" -#: ../../deprecations/pending-removal-in-3.14.rst:92 +#: ../../deprecations/pending-removal-in-3.14.rst:89 msgid "``slave_open()``: use :func:`pty.openpty`." msgstr "``slave_open()``:請用 :func:`pty.openpty`。" -#: ../../deprecations/pending-removal-in-3.14.rst:94 +#: ../../deprecations/pending-removal-in-3.14.rst:91 msgid ":mod:`sqlite3`:" msgstr ":mod:`sqlite3`:" -#: ../../deprecations/pending-removal-in-3.14.rst:96 +#: ../../deprecations/pending-removal-in-3.14.rst:93 msgid ":data:`~sqlite3.version` and :data:`~sqlite3.version_info`." msgstr ":data:`~sqlite3.version` 和 :data:`~sqlite3.version_info`。" -#: ../../deprecations/pending-removal-in-3.14.rst:98 +#: ../../deprecations/pending-removal-in-3.14.rst:95 msgid "" -":meth:`~sqlite3.Cursor.execute` and :meth:`~sqlite3.Cursor.executemany` if :" -"ref:`named placeholders ` are used and *parameters* is " -"a sequence instead of a :class:`dict`." +":meth:`~sqlite3.Cursor.execute` and :meth:`~sqlite3.Cursor.executemany` " +"if :ref:`named placeholders ` are used and " +"*parameters* is a sequence instead of a :class:`dict`." msgstr "" ":meth:`~sqlite3.Cursor.execute` 和 :meth:`~sqlite3.Cursor.executemany`,如果" "使用 :ref:`named placeholders ` 且 *parameters* 是序列" "而不是 :class:`dict`。" -#: ../../deprecations/pending-removal-in-3.14.rst:102 -msgid "" -"date and datetime adapter, date and timestamp converter: see the :mod:" -"`sqlite3` documentation for suggested replacement recipes." -msgstr "" -"date 和 datetime 的適配器 (adapter)、date 和 timestamp 轉換器 (converter):請" -"參閱 :mod:`sqlite3` 文件以獲得建議的替代方案。" - -#: ../../deprecations/pending-removal-in-3.14.rst:105 -msgid "" -":class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was " -"deprecated in :pep:`626` since 3.10 and was planned to be removed in 3.12, " -"but it only got a proper :exc:`DeprecationWarning` in 3.12. May be removed " -"in 3.14. (Contributed by Nikita Sobolev in :gh:`101866`.)" -msgstr "" -":class:`types.CodeType`:自 3.10 起,存取 :attr:`~codeobject.co_lnotab` 已" -"在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但只在 3.12 中於適當時發出 :" -"exc:`DeprecationWarning`。可能在 3.14 中移除。(由 Nikita Sobolev 於 :gh:" -"`101866` 貢獻。)" - -#: ../../deprecations/pending-removal-in-3.14.rst:112 +#: ../../deprecations/pending-removal-in-3.14.rst:99 msgid "" ":mod:`typing`: :class:`~typing.ByteString`, deprecated since Python 3.9, now " "causes a :exc:`DeprecationWarning` to be emitted when it is used." @@ -269,11 +244,11 @@ msgstr "" ":mod:`typing`:自 Python 3.9 起已被棄用的 :class:`~typing.ByteString` 現在在" "使用時會發出 :exc:`DeprecationWarning`。" -#: ../../deprecations/pending-removal-in-3.14.rst:115 +#: ../../deprecations/pending-removal-in-3.14.rst:102 msgid "" ":mod:`urllib`: :class:`!urllib.parse.Quoter` is deprecated: it was not " -"intended to be a public API. (Contributed by Gregory P. Smith in :gh:" -"`88168`.)" +"intended to be a public API. (Contributed by Gregory P. Smith " +"in :gh:`88168`.)" msgstr "" ":mod:`urllib`::class:`!urllib.parse.Quoter` 已被棄用:它並非預期的公開 API。" "(由 Gregory P. Smith 於 :gh:`88168` 貢獻。)" diff --git a/deprecations/pending-removal-in-3.15.po b/deprecations/pending-removal-in-3.15.po index de1de43e01..345db845e3 100644 --- a/deprecations/pending-removal-in-3.15.po +++ b/deprecations/pending-removal-in-3.15.po @@ -1,16 +1,15 @@ -# SOME DESCRIPTIVE TITLE. # Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. -# FIRST AUTHOR , YEAR. # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-30 18:24+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -21,116 +20,206 @@ msgid "Pending Removal in Python 3.15" msgstr "Python 3.15 中待移除的項目" #: ../../deprecations/pending-removal-in-3.15.rst:4 +msgid "The import system:" +msgstr "引入系統 (import system):" + +#: ../../deprecations/pending-removal-in-3.15.rst:6 msgid "" -":class:`http.server.CGIHTTPRequestHandler` will be removed along with its " -"related ``--cgi`` flag to ``python -m http.server``. It was obsolete and " -"rarely used. No direct replacement exists. *Anything* is better than CGI " -"to interface a web server with a request handler." +"Setting :attr:`~module.__cached__` on a module while failing to set :attr:" +"`__spec__.cached ` is deprecated. In " +"Python 3.15, :attr:`!__cached__` will cease to be set or take into " +"consideration by the import system or standard library. (:gh:`97879`)" msgstr "" -":class:`http.server.CGIHTTPRequestHandler` 將會被移除,連同其相關的 ``--" -"cgi`` 旗標到 ``python -m http.server``。它已經過時且很少被使用。沒有直接的替" -"代方案。*任何東西*\\ 都比 CGI 更好的來介接一個帶有請求處理器的網頁伺服器。" +"在模組上設定 :attr:`~module.__cached__` 而沒有設定 :attr:`__spec__.cached " +"` 的做法已被棄用。在 Python 3.15 中," +"引入系統或標準函式庫將不再設定或考慮 :attr:`!__cached__`。(:gh:`97879`)" -#: ../../deprecations/pending-removal-in-3.15.rst:9 +#: ../../deprecations/pending-removal-in-3.15.rst:11 msgid "" -":class:`locale`: :func:`locale.getdefaultlocale` was deprecated in Python " -"3.11 and originally planned for removal in Python 3.13 (:gh:`90817`), but " -"removal has been postponed to Python 3.15. Use :func:`locale.setlocale`, :" -"func:`locale.getencoding` and :func:`locale.getlocale` instead. (Contributed " -"by Hugo van Kemenade in :gh:`111187`.)" +"Setting :attr:`~module.__package__` on a module while failing to set :attr:" +"`__spec__.parent ` is deprecated. In " +"Python 3.15, :attr:`!__package__` will cease to be set or take into " +"consideration by the import system or standard library. (:gh:`97879`)" msgstr "" -":class:`locale`::func:`locale.getdefaultlocale` 已在 Python 3.11 中被棄用," -"原本計劃在 Python 3.13 中移除 (:gh:`90817`),但被延後至 Python 3.15。請改用 :" -"func:`locale.setlocale`、:func:`locale.getencoding` 和 :func:`locale." -"getlocale`。 (由 Hugo van Kemenade 於 :gh:`111187` 貢獻。)" +"在模組上設定 :attr:`~module.__package__` 而沒有設定 :attr:`__spec__.parent " +"` 的做法已被棄用。在 Python 3.15 中," +"引入系統或標準函式庫將不再設定或考慮 :attr:`!__package__`。(:gh:`97879`)" #: ../../deprecations/pending-removal-in-3.15.rst:16 +msgid ":mod:`ctypes`:" +msgstr ":mod:`ctypes`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:18 msgid "" -":mod:`pathlib`: :meth:`pathlib.PurePath.is_reserved` is deprecated and " -"scheduled for removal in Python 3.15. From Python 3.13 onwards, use ``os." -"path.isreserved`` to detect reserved paths on Windows." +"The undocumented :func:`!ctypes.SetPointerType` function has been deprecated " +"since Python 3.13." msgstr "" -":mod:`pathlib`::meth:`pathlib.PurePath.is_reserved` 已被棄用並計劃在 Python " -"3.15 中移除。從 Python 3.13 開始,請用 ``os.path.isreserved`` 來偵測 Windows " -"上的保留路徑。" +"自 Python 3.13 起,未記錄的 :func:`!ctypes.SetPointerType` 函式已被棄用。" #: ../../deprecations/pending-removal-in-3.15.rst:21 +msgid ":mod:`http.server`:" +msgstr ":mod:`http.server`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:23 msgid "" -":mod:`platform`: :func:`~platform.java_ver` is deprecated and will be " -"removed in 3.15. It was largely untested, had a confusing API, and was only " -"useful for Jython support. (Contributed by Nikita Sobolev in :gh:`116349`.)" +"The obsolete and rarely used :class:`~http.server.CGIHTTPRequestHandler` has " +"been deprecated since Python 3.13. No direct replacement exists. *Anything* " +"is better than CGI to interface a web server with a request handler." msgstr "" -":mod:`platform`::func:`~platform.java_ver` 已被棄用並將在 3.15 中移除。它幾" -"乎沒有被測試過,API 令人困惑並且只對 Jython 支援有用。 (由 Nikita Sobolev " -"於 :gh:`116349` 貢獻。)" +"過時且很少使用的 :class:`~http.server.CGIHTTPRequestHandler` 自 Python 3.13 " +"起已被棄用。不存在直接的替代。*任何東西*\\ 都比 CGI 更好地將 Web 伺服器與請求" +"處理程序介接起來。" -#: ../../deprecations/pending-removal-in-3.15.rst:27 +#: ../../deprecations/pending-removal-in-3.15.rst:29 msgid "" -":mod:`threading`: Passing any arguments to :func:`threading.RLock` is now " -"deprecated. C version allows any numbers of args and kwargs, but they are " -"just ignored. Python version does not allow any arguments. All arguments " -"will be removed from :func:`threading.RLock` in Python 3.15. (Contributed by " -"Nikita Sobolev in :gh:`102029`.)" +"The :option:`!--cgi` flag to the :program:`python -m http.server` command-" +"line interface has been deprecated since Python 3.13." msgstr "" -":mod:`threading`:對 :func:`threading.RLock` 傳遞任何引數現在已被棄用。C 版本" -"允許任意數量的引數和關鍵字引數,但它們會被忽略。Python 版本不允許任何引數。所" -"有引數將在 Python 3.15 中從 :func:`threading.RLock` 中移除。 (由 Nikita " -"Sobolev 於 :gh:`102029` 貢獻。)" +"自 Python 3.13 起,:program:`python -m http.server` 命令列介面的 :option:`!--" +"cgi` 旗標已被棄用。" + +#: ../../deprecations/pending-removal-in-3.15.rst:32 +msgid ":mod:`importlib`:" +msgstr ":mod:`importlib`:" #: ../../deprecations/pending-removal-in-3.15.rst:34 -msgid ":class:`typing.NamedTuple`:" -msgstr ":class:`typing.NamedTuple`:" +msgid "``load_module()`` method: use ``exec_module()`` instead." +msgstr "``load_module()`` method:請改用 ``exec_module()``。" #: ../../deprecations/pending-removal-in-3.15.rst:36 +msgid ":class:`locale`:" +msgstr ":class:`locale`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:38 msgid "" -"The undocumented keyword argument syntax for creating :class:`!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." -msgstr "" -"用於建立 :class:`!NamedTuple` 類別的未以文件記錄之關鍵字引數語法 (``NT = " -"NamedTuple(\"NT\", x=int)``) 已棄用,並將在 3.15 中被禁止。請改用基於類別的語" -"法或函式語法 (functional syntax)。" - -#: ../../deprecations/pending-removal-in-3.15.rst:40 -msgid "" -"When using the functional syntax to create a :class:`!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 :class:`!NamedTuple` class with 0 " -"fields, use ``class NT(NamedTuple): pass`` or ``NT = NamedTuple(\"NT\", " -"[])``." -msgstr "" -"當使用函式語法來建立 :class:`!NamedTuple` 類別時,沒將值傳遞給 *fields* 參數" -"的方式 (``NT = NamedTuple(\"NT\")``) 已被棄用,將 ``None`` 傳遞給 *fields* 參" -"數(``NT = NamedTuple(\"NT\", None)``)也已被棄用。這兩者將在 Python 3.15 中" -"會被禁止。要建立一個沒有欄位的 :class:`!NamedTuple` 類別,請使用 ``class " -"NT(NamedTuple): pass`` 或 ``NT = NamedTuple(\"NT\", [])``。" - -#: ../../deprecations/pending-removal-in-3.15.rst:47 -msgid "" -":class:`typing.TypedDict`: When using the functional syntax to create a :" -"class:`!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 :class:`!TypedDict` class with 0 " -"fields, use ``class TD(TypedDict): pass`` or ``TD = TypedDict(\"TD\", {})``." -msgstr "" -":class:`typing.TypedDict`:當使用函式語法來建立 :class:`!TypedDict` 類別時," -"沒將值傳遞給 *fields* 參數的方式(``TD = TypedDict(\"TD\")``)已被棄用,將 " -"``None`` 傳遞給 *fields* 參數(``TD = TypedDict(\"TD\", None)``)也已被棄用。" -"這兩者將在 Python 3.15 中會被禁止。要建立一個沒有欄位的 :class:`!TypedDict` " -"類別,請使用 ``class TD(TypedDict): pass`` 或 ``TD = TypedDict(\"TD\", " -"{})``。" +"The :func:`~locale.getdefaultlocale` function has been deprecated since " +"Python 3.11. Its removal was originally planned for Python 3.13 (:gh:" +"`90817`), but has been postponed to Python 3.15. Use :func:`~locale." +"getlocale`, :func:`~locale.setlocale`, and :func:`~locale.getencoding` " +"instead. (Contributed by Hugo van Kemenade in :gh:`111187`.)" +msgstr "" +":func:`~locale.getdefaultlocale` 已在 Python 3.11 中被棄用,原本計劃在 " +"Python 3.13 中移除 (:gh:`90817`),但被延後至 Python 3.15。請改用 :func:" +"`~locale.getlocale`、:func:`~locale.setlocale` 和 :func:`~locale." +"getencoding`。 (由 Hugo van Kemenade 於 :gh:`111187` 貢獻。)" + +#: ../../deprecations/pending-removal-in-3.15.rst:46 +msgid ":mod:`pathlib`:" +msgstr ":mod:`pathlib`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:48 +msgid "" +":meth:`.PurePath.is_reserved` has been deprecated since Python 3.13. Use :" +"func:`os.path.isreserved` to detect reserved paths on Windows." +msgstr "" +":meth:`.PurePath.is_reserved` 已自 Python 3.13 被棄用。請用 :func:`os.path." +"isreserved` 來偵測 Windows 上的保留路徑。" + +#: ../../deprecations/pending-removal-in-3.15.rst:52 +msgid ":mod:`platform`:" +msgstr ":mod:`platform`:" #: ../../deprecations/pending-removal-in-3.15.rst:54 msgid "" -":mod:`wave`: Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()`` " -"methods of the :class:`wave.Wave_read` and :class:`wave.Wave_write` classes. " -"They will be removed in Python 3.15. (Contributed by Victor Stinner in :gh:" -"`105096`.)" +":func:`~platform.java_ver` has been deprecated since Python 3.13. This " +"function is only useful for Jython support, has a confusing API, and is " +"largely untested." +msgstr "" +"自 Python 3.13 起,:func:`~platform.java_ver` 已被棄用。此函式僅對 Jython 支" +"援有用,具有令人困惑的 API,基本上未經測試。" + +#: ../../deprecations/pending-removal-in-3.15.rst:58 +msgid ":mod:`sysconfig`:" +msgstr ":mod:`sysconfig`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:60 +msgid "" +"The *check_home* argument of :func:`sysconfig.is_python_build` has been " +"deprecated since Python 3.12." +msgstr "" +":func:`sysconfig.is_python_build` 的 *check_home* 引數自 Python 3.12 起已被棄" +"用。" + +#: ../../deprecations/pending-removal-in-3.15.rst:63 +msgid ":mod:`threading`:" +msgstr ":mod:`threading`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:65 +msgid "" +":func:`~threading.RLock` will take no arguments in Python 3.15. Passing any " +"arguments has been deprecated since Python 3.14, as the Python version does " +"not permit any arguments, but the C version allows any number of positional " +"or keyword arguments, ignoring every argument." +msgstr "" +":func:`~threading.RLock` 在 Python 3.15 中將不接受任何引數。自 Python 3.14 " +"起,傳遞任何引數的用法已被棄用,因為 Python 版本不允許任何引數,但 C 版本允許" +"任意數量的位置或關鍵字引數,並忽略每個引數。" + +#: ../../deprecations/pending-removal-in-3.15.rst:71 +msgid ":mod:`types`:" +msgstr ":mod:`types`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:73 +msgid "" +":class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was " +"deprecated in :pep:`626` since 3.10 and was planned to be removed in 3.12, " +"but it only got a proper :exc:`DeprecationWarning` in 3.12. May be removed " +"in 3.15. (Contributed by Nikita Sobolev in :gh:`101866`.)" +msgstr "" +":class:`types.CodeType`:自 3.10 起,存取 :attr:`~codeobject.co_lnotab` 已" +"在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但只在 3.12 中於適當時發出 :" +"exc:`DeprecationWarning`。可能在 3.15 中移除。(由 Nikita Sobolev 於 :gh:" +"`101866` 貢獻。)" + +#: ../../deprecations/pending-removal-in-3.15.rst:80 +msgid ":mod:`typing`:" +msgstr ":mod:`typing`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:82 +msgid "" +"The undocumented keyword argument syntax for creating :class:`~typing." +"NamedTuple` 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." +msgstr "" +"用於建立 :class:`~typing.NamedTuple` 類別的未以文件記錄之關鍵字引數語法 " +"(``Point = NamedTuple(\"Point\", x=int, y=int)``) 已自 Python 3.13 棄用。請改" +"用基於類別的語法或函式語法 (functional syntax)。" + +#: ../../deprecations/pending-removal-in-3.15.rst:88 +msgid "" +"When using the functional syntax of :class:`~typing.TypedDict`\\s, failing " +"to pass a value to the *fields* parameter (``TD = TypedDict(\"TD\")``) or " +"passing ``None`` (``TD = TypedDict(\"TD\", None)``) has been deprecated " +"since Python 3.13. Use ``class TD(TypedDict): pass`` or ``TD = " +"TypedDict(\"TD\", {})`` to create a TypedDict with zero field." +msgstr "" +"當使用 :class:`~typing.TypedDict` 的函式語法時,未傳遞值給 *fields* " +"參數 (``TD = TypedDict(\"TD\")``) 或傳遞 ``None`` (``TD = " +"TypedDict(\"TD\", None)``) 的做法自 Python 3.13 起已被棄用。請" +"使用 ``class TD(TypedDict): pass`` 或 ``TD = " +"TypedDict(\"TD\", {})`` 來建立具有零個欄位的 TypedDict。" + +#: ../../deprecations/pending-removal-in-3.15.rst:95 +msgid "" +"The :func:`typing.no_type_check_decorator` decorator function has been " +"deprecated since Python 3.13. After eight years in the :mod:`typing` module, " +"it has yet to be supported by any major type checker." +msgstr "" +"自 Python 3.13 起,:func:`typing.no_type_check_decorator` 裝飾器函式已被棄" +"用。在 :mod:`typing` 模組中使用了八年之後,它尚未得到任何主要型別檢查器的支" +"援。" + +#: ../../deprecations/pending-removal-in-3.15.rst:100 +msgid ":mod:`wave`:" +msgstr ":mod:`wave`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:102 +msgid "" +"The :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`, and :meth:`~wave." +"Wave_read.getmarkers` methods of the :class:`~wave.Wave_read` and :class:" +"`~wave.Wave_write` classes have been deprecated since Python 3.13." msgstr "" -":mod:`wave`:已棄用 :class:`wave.Wave_read` 和 :class:`wave.Wave_write` 類別" -"的 ``getmark()``、``setmark()`` 和 ``getmarkers()`` 方法。它們將在 Python " -"3.15 中被移除。 (由 Victor Stinner 於 :gh:`105096` 貢獻。)" +"已棄用 :class:`~wave.Wave_read` 和 :class:`~wave.Wave_write` 類別的 :meth:" +"`~wave.Wave_read.getmark`、:meth:`!setmark` 和 :meth:`~wave.Wave_read." +"getmarkers` 方法自 Python 3.13 被棄用。" diff --git a/deprecations/pending-removal-in-3.16.po b/deprecations/pending-removal-in-3.16.po index 3e33cc33de..168f04617f 100644 --- a/deprecations/pending-removal-in-3.16.po +++ b/deprecations/pending-removal-in-3.16.po @@ -1,40 +1,130 @@ # Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. -# FIRST AUTHOR , YEAR. # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-26 00:03+0000\n" +"POT-Creation-Date: 2024-11-10 17:21+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../deprecations/pending-removal-in-3.16.rst:2 -msgid "Pending Removal in Python 3.16" +msgid "Pending removal in Python 3.16" msgstr "Python 3.16 中待移除的項目" #: ../../deprecations/pending-removal-in-3.16.rst:4 +msgid "The import system:" +msgstr "引入系統 (import system):" + +#: ../../deprecations/pending-removal-in-3.16.rst:6 msgid "" -":mod:`array`: :class:`array.array` ``'u'`` type (:c:type:`wchar_t`): use the " -"``'w'`` type instead (``Py_UCS4``)." +"Setting :attr:`~module.__loader__` on a module while failing to " +"set :attr:`__spec__.loader ` is " +"deprecated. In Python 3.16, :attr:`!__loader__` will cease to be set or " +"taken into consideration by the import system or the standard library." msgstr "" -":mod:`array`::class:`array.array` ``'u'`` 型別 (:c:type:`wchar_t`):請改用 " -"``'w'`` 型別 (``Py_UCS4``)。" - -#: ../../deprecations/pending-removal-in-3.16.rst:8 -msgid ":mod:`builtins`: ``~bool``, bitwise inversion on bool." -msgstr ":mod:`builtins`:``~bool``,對 bool 進行位元反轉。" +"在模組上設定 :attr:`~module.__loader__` 而沒有設定 :attr:`__spec__.loader " +"` 的做法將於 Python 3.16 被棄用。在 " +"Python 3.16 中,引入系統或標準函式庫將不再設定或考慮 :attr:`!__loader__`。" #: ../../deprecations/pending-removal-in-3.16.rst:11 +msgid ":mod:`array`:" +msgstr ":mod:`array`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:13 +msgid "" +"The ``'u'`` format code (:c:type:`wchar_t`) has been deprecated in " +"documentation since Python 3.3 and at runtime since Python 3.13. Use the " +"``'w'`` format code (:c:type:`Py_UCS4`) for Unicode characters instead." +msgstr "" +"自 Python 3.3 起,``'u'`` 格式碼 (:c:type:`wchar_t`) 在文件中已被棄用,自 " +"Python 3.13 起在 runtime 已被棄用。請使用 ``'w'`` 格式碼 (:c:type:`Py_UCS4`) " +"來取代 Unicode 字元。" + +#: ../../deprecations/pending-removal-in-3.16.rst:19 +msgid ":mod:`asyncio`:" +msgstr ":mod:`asyncio`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:21 +msgid "" +":func:`!asyncio.iscoroutinefunction` is deprecated and will be removed in " +"Python 3.16, use :func:`inspect.iscoroutinefunction` instead. (Contributed " +"by Jiahao Li and Kumar Aditya in :gh:`122875`.)" +msgstr "" +":func:`!asyncio.iscoroutinefunction` 已被棄用並將在 Python 3.16 中移除,請改" +"用 :func:`inspect.iscoroutinefunction`。(由 Jiahao Li 和 Kumar Aditya " +"於 :gh:`122875` 貢獻。)" + +#: ../../deprecations/pending-removal-in-3.16.rst:26 +msgid ":mod:`builtins`:" +msgstr ":mod:`builtins`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:28 +msgid "" +"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)``)." +msgstr "" +"自 Python 3.12 起,布林型別的位元反轉 ``~True`` 或 ``~False`` 已被棄用,因為" +"它會產生不預期且不直觀的結果(``-2`` 和 ``-1``)。使用 ``not x`` 代替布林值的" +"邏輯否定。在極少數情況下,你需要對底層的整數進行位元反轉,請明確轉換為 " +"``~int(x)`` (``~int(x)``)。" + +#: ../../deprecations/pending-removal-in-3.16.rst:35 +msgid ":mod:`shutil`:" +msgstr ":mod:`shutil`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:37 +msgid "" +"The :class:`!ExecError` exception has been deprecated since Python 3.14. It " +"has not been used by any function in :mod:`!shutil` since Python 3.4, and is " +"now an alias of :exc:`RuntimeError`." +msgstr "" +"自 Python 3.14 起,:class:`!ExecError` 例外已被棄用。自 Python 3.4 以來,它尚" +"未被 :mod:`!shutil` 中的任何函式使用,現在是 :exc:`RuntimeError` 的別名。" + +#: ../../deprecations/pending-removal-in-3.16.rst:42 +msgid ":mod:`symtable`:" +msgstr ":mod:`symtable`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:44 +msgid "" +"The :meth:`Class.get_methods ` method has been " +"deprecated since Python 3.14." +msgstr "" +"自 Python 3.14 起,:meth:`Class.get_methods ` 方" +"法已被棄用。" + +#: ../../deprecations/pending-removal-in-3.16.rst:47 +msgid ":mod:`sys`:" +msgstr ":mod:`sys`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:49 +msgid "" +"The :func:`~sys._enablelegacywindowsfsencoding` function has been deprecated " +"since Python 3.13. Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` " +"environment variable instead." +msgstr "" +"自 Python 3.13 起,:func:`~sys._enablelegacywindowsfsencoding` 函式已被棄用。" +"請改用 :envvar:`PYTHONLEGACYWINDOWSFSENCODING` 環境變數。" + +#: ../../deprecations/pending-removal-in-3.16.rst:53 +msgid ":mod:`tarfile`:" +msgstr ":mod:`tarfile`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:55 msgid "" -":mod:`symtable`: Deprecate :meth:`symtable.Class.get_methods` due to the " -"lack of interest. (Contributed by Bénédikt Tran in :gh:`119698`.)" +"The undocumented and unused :attr:`!TarFile.tarfile` attribute has been " +"deprecated since Python 3.13." msgstr "" -":mod:`symtable`:由於並沒有太多關注,已棄用 :meth:`symtable.Class." -"get_methods`。 (由 Bénédikt Tran 於 :gh:`119698` 貢獻。)" +"自 Python 3.13 起,未以文件記錄和未被使用的 :attr:`!TarFile.tarfile` 屬性已被" +"棄用。" diff --git a/deprecations/pending-removal-in-future.po b/deprecations/pending-removal-in-future.po index fa52b56e5c..230bd84669 100644 --- a/deprecations/pending-removal-in-future.po +++ b/deprecations/pending-removal-in-future.po @@ -1,15 +1,16 @@ # Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. -# FIRST AUTHOR , YEAR. +# FIRST AUTHOR , YEAR # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-26 18:24+0000\n" +"POT-Creation-Date: 2025-04-30 00:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -32,18 +33,14 @@ msgid "" msgstr ":mod:`argparse`:已棄用巢狀引數群組和巢狀互斥群組。" #: ../../deprecations/pending-removal-in-future.rst:10 -msgid ":mod:`array`'s ``'u'`` format code (:gh:`57281`)" -msgstr ":mod:`array` 的 ``'u'`` 格式碼 (:gh:`57281`)" - -#: ../../deprecations/pending-removal-in-future.rst:12 msgid ":mod:`builtins`:" msgstr ":mod:`builtins`:" -#: ../../deprecations/pending-removal-in-future.rst:14 +#: ../../deprecations/pending-removal-in-future.rst:12 msgid "``bool(NotImplemented)``." msgstr "``bool(NotImplemented)``。" -#: ../../deprecations/pending-removal-in-future.rst:15 +#: ../../deprecations/pending-removal-in-future.rst:13 msgid "" "Generators: ``throw(type, exc, tb)`` and ``athrow(type, exc, tb)`` signature " "is deprecated: use ``throw(exc)`` and ``athrow(exc)`` instead, the single " @@ -52,7 +49,7 @@ msgstr "" "產生器:``throw(type, exc, tb)`` 和 ``athrow(type, exc, tb)`` 簽名已被棄用:" "請改用 ``throw(exc)`` 和 ``athrow(exc)``,為單引數簽名。" -#: ../../deprecations/pending-removal-in-future.rst:18 +#: ../../deprecations/pending-removal-in-future.rst:16 msgid "" "Currently Python accepts numeric literals immediately followed by keywords, " "for example ``0in x``, ``1or x``, ``0if 1else 2``. It allows confusing and " @@ -70,7 +67,7 @@ msgstr "" "`in`、:keyword:`is` 和 :keyword:`or` 之一的關鍵字,則會引發語法警告。在未來版" "本中,它將被更改為語法錯誤。(:gh:`87999`)" -#: ../../deprecations/pending-removal-in-future.rst:26 +#: ../../deprecations/pending-removal-in-future.rst:24 msgid "" "Support for ``__index__()`` and ``__int__()`` method returning non-int type: " "these methods will be required to return an instance of a strict subclass " @@ -79,7 +76,7 @@ msgstr "" "``__index__()`` 和 ``__int__()`` 方法回傳非 int 型別的支援:這些方法將需要回" "傳 :class:`int` 的嚴格子類別實例。" -#: ../../deprecations/pending-removal-in-future.rst:29 +#: ../../deprecations/pending-removal-in-future.rst:27 msgid "" "Support for ``__float__()`` method returning a strict subclass of :class:" "`float`: these methods will be required to return an instance of :class:" @@ -88,7 +85,7 @@ msgstr "" "回傳 :class:`float` 嚴格子類別 ``__float__()`` 方法的支援:這些方法將需要回" "傳 :class:`float` 的實例。" -#: ../../deprecations/pending-removal-in-future.rst:32 +#: ../../deprecations/pending-removal-in-future.rst:30 msgid "" "Support for ``__complex__()`` method returning a strict subclass of :class:" "`complex`: these methods will be required to return an instance of :class:" @@ -97,11 +94,11 @@ msgstr "" "回傳 :class:`complex` 嚴格子類別 ``__complex__()`` 方法的支援:這些方法將需要" "回傳 :class:`complex` 的實例。" -#: ../../deprecations/pending-removal-in-future.rst:35 +#: ../../deprecations/pending-removal-in-future.rst:33 msgid "Delegation of ``int()`` to ``__trunc__()`` method." msgstr "將 ``int()`` 委派給 ``__trunc__()`` 方法。" -#: ../../deprecations/pending-removal-in-future.rst:36 +#: ../../deprecations/pending-removal-in-future.rst:34 msgid "" "Passing a complex number as the *real* or *imag* argument in the :func:" "`complex` constructor is now deprecated; it should only be passed as a " @@ -111,7 +108,7 @@ msgstr "" "在 :func:`complex` 建構子中將複數作為 *real* 或 *imag* 引數傳遞現在已被棄用;" "它應該只作為單個位置引數傳遞。 (由 Serhiy Storchaka 於 :gh:`109218` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:41 +#: ../../deprecations/pending-removal-in-future.rst:39 msgid "" ":mod:`calendar`: ``calendar.January`` and ``calendar.February`` constants " "are deprecated and replaced by :data:`calendar.JANUARY` and :data:`calendar." @@ -121,18 +118,18 @@ msgstr "" "被 :data:`calendar.JANUARY` 和 :data:`calendar.FEBRUARY` 取代。 (由 Prince " "Roshan 於 :gh:`103636` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:46 +#: ../../deprecations/pending-removal-in-future.rst:44 msgid "" ":attr:`codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method " "instead." msgstr "" ":attr:`codeobject.co_lnotab`:請改用 :meth:`codeobject.co_lines` 方法。" -#: ../../deprecations/pending-removal-in-future.rst:49 +#: ../../deprecations/pending-removal-in-future.rst:47 msgid ":mod:`datetime`:" msgstr ":mod:`datetime`:" -#: ../../deprecations/pending-removal-in-future.rst:51 +#: ../../deprecations/pending-removal-in-future.rst:49 msgid "" ":meth:`~datetime.datetime.utcnow`: use ``datetime.datetime.now(tz=datetime." "UTC)``." @@ -140,7 +137,7 @@ msgstr "" ":meth:`~datetime.datetime.utcnow`:請改用 ``datetime.datetime." "now(tz=datetime.UTC)``。" -#: ../../deprecations/pending-removal-in-future.rst:53 +#: ../../deprecations/pending-removal-in-future.rst:51 msgid "" ":meth:`~datetime.datetime.utcfromtimestamp`: use ``datetime.datetime." "fromtimestamp(timestamp, tz=datetime.UTC)``." @@ -148,19 +145,15 @@ msgstr "" ":meth:`~datetime.datetime.utcfromtimestamp`:請改用 ``datetime.datetime." "fromtimestamp(timestamp, tz=datetime.UTC)``。" -#: ../../deprecations/pending-removal-in-future.rst:56 +#: ../../deprecations/pending-removal-in-future.rst:54 msgid ":mod:`gettext`: Plural value must be an integer." msgstr ":mod:`gettext`:複數值必須是整數。" -#: ../../deprecations/pending-removal-in-future.rst:58 +#: ../../deprecations/pending-removal-in-future.rst:56 msgid ":mod:`importlib`:" msgstr ":mod:`importlib`:" -#: ../../deprecations/pending-removal-in-future.rst:60 -msgid "``load_module()`` method: use ``exec_module()`` instead." -msgstr "``load_module()`` method:請改用 ``exec_module()``。" - -#: ../../deprecations/pending-removal-in-future.rst:61 +#: ../../deprecations/pending-removal-in-future.rst:58 msgid "" ":func:`~importlib.util.cache_from_source` *debug_override* parameter is " "deprecated: use the *optimization* parameter instead." @@ -168,18 +161,26 @@ msgstr "" ":func:`~importlib.util.cache_from_source` *debug_override* 參數已被棄用:請改" "用 *optimization* 參數。" -#: ../../deprecations/pending-removal-in-future.rst:64 +#: ../../deprecations/pending-removal-in-future.rst:61 msgid ":mod:`importlib.metadata`:" msgstr ":mod:`importlib.metadata`:" -#: ../../deprecations/pending-removal-in-future.rst:66 +#: ../../deprecations/pending-removal-in-future.rst:63 msgid "``EntryPoints`` tuple interface." msgstr "``EntryPoints`` 元組介面。" -#: ../../deprecations/pending-removal-in-future.rst:67 +#: ../../deprecations/pending-removal-in-future.rst:64 msgid "Implicit ``None`` on return values." msgstr "回傳值上的隱式 ``None``。" +#: ../../deprecations/pending-removal-in-future.rst:66 +msgid "" +":mod:`logging`: the ``warn()`` method has been deprecated since Python 3.3, " +"use :meth:`~logging.warning` instead." +msgstr "" +":mod:`logging`:自 Python 3.3 起,``warn()`` 方法已被棄用,請改用 :meth:" +"`~logging.warning`。" + #: ../../deprecations/pending-removal-in-future.rst:69 msgid "" ":mod:`mailbox`: Use of StringIO input and text mode is deprecated, use " @@ -282,17 +283,10 @@ msgid "``ssl.TLSVersion.TLSv1_1``" msgstr "``ssl.TLSVersion.TLSv1_1``" #: ../../deprecations/pending-removal-in-future.rst:106 -msgid "" -":func:`sysconfig.is_python_build` *check_home* parameter is deprecated and " -"ignored." -msgstr "" -":func:`sysconfig.is_python_build` 的 *check_home* 參數已被棄用並被忽略。" - -#: ../../deprecations/pending-removal-in-future.rst:109 msgid ":mod:`threading` methods:" msgstr ":mod:`threading` 方法:" -#: ../../deprecations/pending-removal-in-future.rst:111 +#: ../../deprecations/pending-removal-in-future.rst:108 msgid "" ":meth:`!threading.Condition.notifyAll`: use :meth:`~threading.Condition." "notify_all`." @@ -300,11 +294,11 @@ msgstr "" ":meth:`!threading.Condition.notifyAll`:請用 :meth:`~threading.Condition." "notify_all`。" -#: ../../deprecations/pending-removal-in-future.rst:112 +#: ../../deprecations/pending-removal-in-future.rst:109 msgid ":meth:`!threading.Event.isSet`: use :meth:`~threading.Event.is_set`." msgstr ":meth:`!threading.Event.isSet`:請用 :meth:`~threading.Event.is_set`。" -#: ../../deprecations/pending-removal-in-future.rst:113 +#: ../../deprecations/pending-removal-in-future.rst:110 msgid "" ":meth:`!threading.Thread.isDaemon`, :meth:`threading.Thread.setDaemon`: use :" "attr:`threading.Thread.daemon` attribute." @@ -312,7 +306,7 @@ msgstr "" ":meth:`!threading.Thread.isDaemon`、:meth:`threading.Thread.setDaemon`:請" "用 :attr:`threading.Thread.daemon` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:115 +#: ../../deprecations/pending-removal-in-future.rst:112 msgid "" ":meth:`!threading.Thread.getName`, :meth:`threading.Thread.setName`: use :" "attr:`threading.Thread.name` attribute." @@ -320,20 +314,20 @@ msgstr "" ":meth:`!threading.Thread.getName`、:meth:`threading.Thread.setName`:請用 :" "attr:`threading.Thread.name` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:117 +#: ../../deprecations/pending-removal-in-future.rst:114 msgid ":meth:`!threading.currentThread`: use :meth:`threading.current_thread`." msgstr "" ":meth:`!threading.currentThread`:請用 :meth:`threading.current_thread`。" -#: ../../deprecations/pending-removal-in-future.rst:118 +#: ../../deprecations/pending-removal-in-future.rst:115 msgid ":meth:`!threading.activeCount`: use :meth:`threading.active_count`." msgstr ":meth:`!threading.activeCount`:請用 :meth:`threading.active_count`。" -#: ../../deprecations/pending-removal-in-future.rst:120 +#: ../../deprecations/pending-removal-in-future.rst:117 msgid ":class:`typing.Text` (:gh:`92332`)." msgstr ":class:`typing.Text` (:gh:`92332`)。" -#: ../../deprecations/pending-removal-in-future.rst:122 +#: ../../deprecations/pending-removal-in-future.rst:119 msgid "" ":class:`unittest.IsolatedAsyncioTestCase`: it is deprecated to return a " "value that is not ``None`` from a test case." @@ -341,58 +335,58 @@ msgstr "" ":class:`unittest.IsolatedAsyncioTestCase`:從測試案例中回傳非 ``None`` 的值已" "被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:125 +#: ../../deprecations/pending-removal-in-future.rst:122 msgid "" ":mod:`urllib.parse` deprecated functions: :func:`~urllib.parse.urlparse` " "instead" msgstr "" ":mod:`urllib.parse` 已棄用函式:請改用 :func:`~urllib.parse.urlparse`。" -#: ../../deprecations/pending-removal-in-future.rst:127 +#: ../../deprecations/pending-removal-in-future.rst:124 msgid "``splitattr()``" msgstr "``splitattr()``" -#: ../../deprecations/pending-removal-in-future.rst:128 +#: ../../deprecations/pending-removal-in-future.rst:125 msgid "``splithost()``" msgstr "``splithost()``" -#: ../../deprecations/pending-removal-in-future.rst:129 +#: ../../deprecations/pending-removal-in-future.rst:126 msgid "``splitnport()``" msgstr "``splitnport()``" -#: ../../deprecations/pending-removal-in-future.rst:130 +#: ../../deprecations/pending-removal-in-future.rst:127 msgid "``splitpasswd()``" msgstr "``splitpasswd()``" -#: ../../deprecations/pending-removal-in-future.rst:131 +#: ../../deprecations/pending-removal-in-future.rst:128 msgid "``splitport()``" msgstr "``splitport()``" -#: ../../deprecations/pending-removal-in-future.rst:132 +#: ../../deprecations/pending-removal-in-future.rst:129 msgid "``splitquery()``" msgstr "``splitquery()``" -#: ../../deprecations/pending-removal-in-future.rst:133 +#: ../../deprecations/pending-removal-in-future.rst:130 msgid "``splittag()``" msgstr "``splittag()``" -#: ../../deprecations/pending-removal-in-future.rst:134 +#: ../../deprecations/pending-removal-in-future.rst:131 msgid "``splittype()``" msgstr "``splittype()``" -#: ../../deprecations/pending-removal-in-future.rst:135 +#: ../../deprecations/pending-removal-in-future.rst:132 msgid "``splituser()``" msgstr "``splituser()``" -#: ../../deprecations/pending-removal-in-future.rst:136 +#: ../../deprecations/pending-removal-in-future.rst:133 msgid "``splitvalue()``" msgstr "``splitvalue()``" -#: ../../deprecations/pending-removal-in-future.rst:137 +#: ../../deprecations/pending-removal-in-future.rst:134 msgid "``to_bytes()``" msgstr "``to_bytes()``" -#: ../../deprecations/pending-removal-in-future.rst:139 +#: ../../deprecations/pending-removal-in-future.rst:136 msgid "" ":mod:`urllib.request`: :class:`~urllib.request.URLopener` and :class:" "`~urllib.request.FancyURLopener` style of invoking requests is deprecated. " @@ -402,13 +396,13 @@ msgstr "" "class:`~urllib.request.FancyURLopener` 風格已被棄用。請改用更新的 :func:" "`~urllib.request.urlopen` 函式和方法。" -#: ../../deprecations/pending-removal-in-future.rst:143 +#: ../../deprecations/pending-removal-in-future.rst:140 msgid "" ":mod:`wsgiref`: ``SimpleHandler.stdout.write()`` should not do partial " "writes." msgstr ":mod:`wsgiref`:``SimpleHandler.stdout.write()`` 不應該進行部分寫入。" -#: ../../deprecations/pending-removal-in-future.rst:146 +#: ../../deprecations/pending-removal-in-future.rst:143 msgid "" ":mod:`xml.etree.ElementTree`: Testing the truth value of an :class:`~xml." "etree.ElementTree.Element` is deprecated. In a future release it will always " @@ -419,10 +413,13 @@ msgstr "" "Element` 的真值測試。在未來版本中,它將始終回傳 ``True``。請改用明確的 " "``len(elem)`` 或 ``elem is not None`` 測試。" -#: ../../deprecations/pending-removal-in-future.rst:151 +#: ../../deprecations/pending-removal-in-future.rst:148 msgid "" ":meth:`zipimport.zipimporter.load_module` is deprecated: use :meth:" "`~zipimport.zipimporter.exec_module` instead." msgstr "" ":meth:`zipimport.zipimporter.load_module` 已被棄用:請改用 :meth:`~zipimport." "zipimporter.exec_module`。" + +#~ msgid ":mod:`array`'s ``'u'`` format code (:gh:`57281`)" +#~ msgstr ":mod:`array` 的 ``'u'`` 格式碼 (:gh:`57281`)" diff --git a/distributing/index.po b/distributing/index.po index c21b18ddd6..6ef90c29d0 100644 --- a/distributing/index.po +++ b/distributing/index.po @@ -7,7 +7,7 @@ # Steven Hsu , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-08-18 00:03+0000\n" "PO-Revision-Date: 2021-07-04 18:06+0800\n" diff --git a/extending/building.po b/extending/building.po index 8a2a5ced44..9285c3baea 100644 --- a/extending/building.po +++ b/extending/building.po @@ -1,15 +1,16 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: +# Adrian Liaw , 2018 +# Matt Wang , 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" -"PO-Revision-Date: 2018-05-23 14:09+0000\n" -"Last-Translator: Adrian Liaw \n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"PO-Revision-Date: 2025-02-07 14:09+0000\n" +"Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -37,26 +38,35 @@ msgid "" "extension. When using setuptools, the correct filename is generated " "automatically." msgstr "" +"要能夠被引入,共用函式庫必須在 :envvar:`PYTHONPATH` 上可用,並且必須以模組名" +"稱命名,並且必須有適當的副檔名。使用 setuptools 時,正確的檔名會自動產生。" #: ../../extending/building.rst:16 msgid "The initialization function has the signature:" -msgstr "" +msgstr "初始化函式具有簽名:" #: ../../extending/building.rst:20 msgid "" "It returns either a fully initialized module, or a :c:type:`PyModuleDef` " "instance. See :ref:`initializing-modules` for details." msgstr "" +"它回傳一個完全初始化的模組,或一個 :c:type:`PyModuleDef` 實例。詳細資訊請參" +"見 :ref:`initializing-modules`。" #: ../../extending/building.rst:25 msgid "" -"For modules with ASCII-only names, the function must be named " -"``PyInit_``, with ```` replaced by the name of the " -"module. When using :ref:`multi-phase-initialization`, non-ASCII module names " -"are allowed. In this case, the initialization function name is " -"``PyInitU_``, with ```` encoded using Python's " -"*punycode* encoding with hyphens replaced by underscores. In Python::" +"For modules with ASCII-only names, the function must be named :samp:" +"`PyInit_{}`, with ```` replaced by the name of the module. When " +"using :ref:`multi-phase-initialization`, non-ASCII module names are allowed. " +"In this case, the initialization function name is :samp:`PyInitU_{}`, " +"with ```` encoded using Python's *punycode* encoding with hyphens " +"replaced by underscores. In Python::" msgstr "" +"對於僅包含 ASCII 名稱的模組,函式必須以 :samp:`PyInit_{}` 命名,其中 " +"```` 要替換為模組的名稱。當使用 :ref:`multi-phase-" +"initialization` 時,允許非 ASCII 模組名稱。在這種情況下,初始化函式名稱是 " +":samp:`PyInitU_{}`,其中 ```` 使用 Python 的 *punycode* 編" +"碼,並將連字符號替換為底線。在 Python 中: ::" #: ../../extending/building.rst:32 msgid "" @@ -82,10 +92,13 @@ msgid "" "function corresponding to the filename is found. See the *\"Multiple modules " "in one library\"* section in :pep:`489` for details." msgstr "" +"可以透過定義多個初始化函式,來從單一共用函式庫中匯出多個模組。然而要引入它們" +"需要使用符號連結或自訂引入器,因為預設只會找到對應於檔名的函式。詳細資訊請參" +"見 :pep:`489` 中的 *\"Multiple modules in one library\"* 部分。" #: ../../extending/building.rst:52 msgid "Building C and C++ Extensions with setuptools" -msgstr "" +msgstr "用 setuptools 建置 C 與 C++ 擴充套件" #: ../../extending/building.rst:54 msgid "" @@ -94,3 +107,6 @@ msgid "" "setuptools.html to learn more about how build and distribute C/C++ " "extensions with setuptools." msgstr "" +"Python 3.12 與之後的版本不再帶有 distutils。請在 https://setuptools." +"readthedocs.io/en/latest/setuptools.html 上參閱 ``setuptools`` 文件,以了解如" +"何使用 setuptools 建置和發佈 C/C++ 擴充套件。" diff --git a/extending/embedding.po b/extending/embedding.po index d49f76b779..f08b001e48 100644 --- a/extending/embedding.po +++ b/extending/embedding.po @@ -6,9 +6,9 @@ # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 14:09+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -95,43 +95,98 @@ msgid "" "int\n" "main(int argc, char *argv[])\n" "{\n" -" wchar_t *program = Py_DecodeLocale(argv[0], NULL);\n" -" if (program == NULL) {\n" -" fprintf(stderr, \"Fatal error: cannot decode argv[0]\\n\");\n" -" exit(1);\n" +" PyStatus status;\n" +" PyConfig config;\n" +" PyConfig_InitPythonConfig(&config);\n" +"\n" +" /* optional but recommended */\n" +" status = PyConfig_SetBytesString(&config, &config.program_name, " +"argv[0]);\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" " }\n" -" Py_SetProgramName(program); /* optional but recommended */\n" -" Py_Initialize();\n" +"\n" +" status = Py_InitializeFromConfig(&config);\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" +" }\n" +" PyConfig_Clear(&config);\n" +"\n" +" PyRun_SimpleString(\"from time import time,ctime\\n\"\n" +" \"print('Today is', ctime(time()))\\n\");\n" +" if (Py_FinalizeEx() < 0) {\n" +" exit(120);\n" +" }\n" +" return 0;\n" +"\n" +" exception:\n" +" PyConfig_Clear(&config);\n" +" Py_ExitStatusException(status);\n" +"}" +msgstr "" +"#define PY_SSIZE_T_CLEAN\n" +"#include \n" +"\n" +"int\n" +"main(int argc, char *argv[])\n" +"{\n" +" PyStatus status;\n" +" PyConfig config;\n" +" PyConfig_InitPythonConfig(&config);\n" +"\n" +" /* 建議但非必要 */\n" +" status = PyConfig_SetBytesString(&config, &config.program_name, " +"argv[0]);\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" +" }\n" +"\n" +" status = Py_InitializeFromConfig(&config);\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" +" }\n" +" PyConfig_Clear(&config);\n" +"\n" " PyRun_SimpleString(\"from time import time,ctime\\n\"\n" " \"print('Today is', ctime(time()))\\n\");\n" " if (Py_FinalizeEx() < 0) {\n" " exit(120);\n" " }\n" -" PyMem_RawFree(program);\n" " return 0;\n" +"\n" +" exception:\n" +" PyConfig_Clear(&config);\n" +" Py_ExitStatusException(status);\n" "}" + +#: ../../extending/embedding.rst:92 +msgid "" +"``#define PY_SSIZE_T_CLEAN`` was used to indicate that ``Py_ssize_t`` should " +"be used in some APIs instead of ``int``. It is not necessary since Python " +"3.13, but we keep it here for backward compatibility. See :ref:`arg-parsing-" +"string-and-buffers` for a description of this macro." msgstr "" -#: ../../extending/embedding.rst:78 +#: ../../extending/embedding.rst:97 msgid "" -"The :c:func:`Py_SetProgramName` function should be called before :c:func:" -"`Py_Initialize` to inform the interpreter about paths to Python run-time " -"libraries. Next, the Python interpreter is initialized with :c:func:" -"`Py_Initialize`, followed by the execution of a hard-coded Python script " -"that prints the date and time. Afterwards, the :c:func:`Py_FinalizeEx` 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 :c:func:`PyRun_SimpleFile` function, " -"which saves you the trouble of allocating memory space and loading the file " -"contents." +"Setting :c:member:`PyConfig.program_name` should be called before :c:func:" +"`Py_InitializeFromConfig` to inform the interpreter about paths to Python " +"run-time libraries. Next, the Python interpreter is initialized with :c:" +"func:`Py_Initialize`, followed by the execution of a hard-coded Python " +"script that prints the date and time. Afterwards, the :c:func:" +"`Py_FinalizeEx` 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 :c:func:" +"`PyRun_SimpleFile` function, which saves you the trouble of allocating " +"memory space and loading the file contents." msgstr "" -#: ../../extending/embedding.rst:93 +#: ../../extending/embedding.rst:112 msgid "Beyond Very High Level Embedding: An overview" msgstr "" -#: ../../extending/embedding.rst:95 +#: ../../extending/embedding.rst:114 msgid "" "The high level interface gives you the ability to execute arbitrary pieces " "of Python code from your application, but exchanging data values is quite " @@ -140,7 +195,7 @@ msgid "" "anything." msgstr "" -#: ../../extending/embedding.rst:100 +#: ../../extending/embedding.rst:119 msgid "" "It should be noted that extending Python and embedding Python is quite the " "same activity, despite the different intent. Most topics discussed in the " @@ -148,37 +203,37 @@ msgid "" "code from Python to C really does:" msgstr "" -#: ../../extending/embedding.rst:105 +#: ../../extending/embedding.rst:124 msgid "Convert data values from Python to C," msgstr "" -#: ../../extending/embedding.rst:107 +#: ../../extending/embedding.rst:126 msgid "Perform a function call to a C routine using the converted values, and" msgstr "" -#: ../../extending/embedding.rst:109 +#: ../../extending/embedding.rst:128 msgid "Convert the data values from the call from C to Python." msgstr "" -#: ../../extending/embedding.rst:111 +#: ../../extending/embedding.rst:130 msgid "When embedding Python, the interface code does:" msgstr "" -#: ../../extending/embedding.rst:113 +#: ../../extending/embedding.rst:132 msgid "Convert data values from C to Python," msgstr "" -#: ../../extending/embedding.rst:115 +#: ../../extending/embedding.rst:134 msgid "" "Perform a function call to a Python interface routine using the converted " "values, and" msgstr "" -#: ../../extending/embedding.rst:118 +#: ../../extending/embedding.rst:137 msgid "Convert the data values from the call from Python to C." msgstr "" -#: ../../extending/embedding.rst:120 +#: ../../extending/embedding.rst:139 msgid "" "As you can see, the data conversion steps are simply swapped to accommodate " "the different direction of the cross-language transfer. The only difference " @@ -186,7 +241,7 @@ msgid "" "you call a C routine, when embedding, you call a Python routine." msgstr "" -#: ../../extending/embedding.rst:125 +#: ../../extending/embedding.rst:144 msgid "" "This chapter will not discuss how to convert data from Python to C and vice " "versa. Also, proper use of references and dealing with errors is assumed to " @@ -194,11 +249,11 @@ msgid "" "interpreter, you can refer to earlier chapters for the required information." msgstr "" -#: ../../extending/embedding.rst:134 +#: ../../extending/embedding.rst:153 msgid "Pure Embedding" msgstr "" -#: ../../extending/embedding.rst:136 +#: ../../extending/embedding.rst:155 msgid "" "The first program aims to execute a function in a Python script. Like in the " "section about the very high level interface, the Python interpreter does not " @@ -206,11 +261,11 @@ msgid "" "section)." msgstr "" -#: ../../extending/embedding.rst:141 +#: ../../extending/embedding.rst:160 msgid "The code to run a function defined in a Python script is:" msgstr "" -#: ../../extending/embedding.rst:143 +#: ../../extending/embedding.rst:162 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -286,7 +341,7 @@ msgid "" "}\n" msgstr "" -#: ../../extending/embedding.rst:146 +#: ../../extending/embedding.rst:165 msgid "" "This code loads a Python script using ``argv[1]``, and calls the function " "named in ``argv[2]``. Its integer arguments are the other values of the " @@ -295,7 +350,7 @@ msgid "" "a Python script, such as:" msgstr "" -#: ../../extending/embedding.rst:152 +#: ../../extending/embedding.rst:171 msgid "" "def multiply(a,b):\n" " print(\"Will compute\", a, \"times\", b)\n" @@ -305,25 +360,25 @@ msgid "" " return c" msgstr "" -#: ../../extending/embedding.rst:161 +#: ../../extending/embedding.rst:180 msgid "then the result should be:" msgstr "" -#: ../../extending/embedding.rst:163 +#: ../../extending/embedding.rst:182 msgid "" "$ call multiply multiply 3 2\n" "Will compute 3 times 2\n" "Result of call: 6" msgstr "" -#: ../../extending/embedding.rst:169 +#: ../../extending/embedding.rst:188 msgid "" "Although the program is quite large for its functionality, most of the code " "is for data conversion between Python and C, and for error reporting. The " "interesting part with respect to embedding Python starts with ::" msgstr "" -#: ../../extending/embedding.rst:173 +#: ../../extending/embedding.rst:192 msgid "" "Py_Initialize();\n" "pName = PyUnicode_DecodeFSDefault(argv[1]);\n" @@ -331,15 +386,15 @@ msgid "" "pModule = PyImport_Import(pName);" msgstr "" -#: ../../extending/embedding.rst:178 +#: ../../extending/embedding.rst:197 msgid "" "After initializing the interpreter, the script is loaded using :c:func:" "`PyImport_Import`. This routine needs a Python string as its argument, " -"which is constructed using the :c:func:`PyUnicode_FromString` data " +"which is constructed using the :c:func:`PyUnicode_DecodeFSDefault` data " "conversion routine. ::" msgstr "" -#: ../../extending/embedding.rst:183 +#: ../../extending/embedding.rst:202 msgid "" "pFunc = PyObject_GetAttrString(pModule, argv[2]);\n" "/* pFunc is a new reference */\n" @@ -350,7 +405,7 @@ msgid "" "Py_XDECREF(pFunc);" msgstr "" -#: ../../extending/embedding.rst:191 +#: ../../extending/embedding.rst:210 msgid "" "Once the script is loaded, the name we're looking for is retrieved using :c:" "func:`PyObject_GetAttrString`. If the name exists, and the object returned " @@ -359,22 +414,22 @@ msgid "" "Python function is then made with::" msgstr "" -#: ../../extending/embedding.rst:197 +#: ../../extending/embedding.rst:216 msgid "pValue = PyObject_CallObject(pFunc, pArgs);" msgstr "pValue = PyObject_CallObject(pFunc, pArgs);" -#: ../../extending/embedding.rst:199 +#: ../../extending/embedding.rst:218 msgid "" "Upon return of the function, ``pValue`` is either ``NULL`` or it contains a " "reference to the return value of the function. Be sure to release the " "reference after examining the value." msgstr "" -#: ../../extending/embedding.rst:207 +#: ../../extending/embedding.rst:226 msgid "Extending Embedded Python" msgstr "" -#: ../../extending/embedding.rst:209 +#: ../../extending/embedding.rst:228 msgid "" "Until now, the embedded Python interpreter had no access to functionality " "from the application itself. The Python API allows this by extending the " @@ -386,7 +441,7 @@ msgid "" "like you would write a normal Python extension. For example::" msgstr "" -#: ../../extending/embedding.rst:218 +#: ../../extending/embedding.rst:237 msgid "" "static int numargs=0;\n" "\n" @@ -399,31 +454,33 @@ msgid "" " return PyLong_FromLong(numargs);\n" "}\n" "\n" -"static PyMethodDef EmbMethods[] = {\n" +"static PyMethodDef emb_module_methods[] = {\n" " {\"numargs\", emb_numargs, METH_VARARGS,\n" " \"Return the number of arguments received by the process.\"},\n" " {NULL, NULL, 0, NULL}\n" "};\n" "\n" -"static PyModuleDef EmbModule = {\n" -" PyModuleDef_HEAD_INIT, \"emb\", NULL, -1, EmbMethods,\n" -" NULL, NULL, NULL, NULL\n" +"static struct PyModuleDef emb_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"emb\",\n" +" .m_size = 0,\n" +" .m_methods = emb_module_methods,\n" "};\n" "\n" "static PyObject*\n" "PyInit_emb(void)\n" "{\n" -" return PyModule_Create(&EmbModule);\n" +" return PyModuleDef_Init(&emb_module);\n" "}" msgstr "" -#: ../../extending/embedding.rst:246 +#: ../../extending/embedding.rst:267 msgid "" "Insert the above code just above the :c:func:`main` function. Also, insert " "the following two statements before the call to :c:func:`Py_Initialize`::" msgstr "" -#: ../../extending/embedding.rst:249 +#: ../../extending/embedding.rst:270 msgid "" "numargs = argc;\n" "PyImport_AppendInittab(\"emb\", &PyInit_emb);" @@ -431,30 +488,30 @@ msgstr "" "numargs = argc;\n" "PyImport_AppendInittab(\"emb\", &PyInit_emb);" -#: ../../extending/embedding.rst:252 +#: ../../extending/embedding.rst:273 msgid "" "These two lines initialize the ``numargs`` variable, and make the :func:`!" "emb.numargs` function accessible to the embedded Python interpreter. With " "these extensions, the Python script can do things like" msgstr "" -#: ../../extending/embedding.rst:256 +#: ../../extending/embedding.rst:277 msgid "" "import emb\n" "print(\"Number of arguments\", emb.numargs())" msgstr "" -#: ../../extending/embedding.rst:261 +#: ../../extending/embedding.rst:282 msgid "" "In a real application, the methods will expose an API of the application to " "Python." msgstr "" -#: ../../extending/embedding.rst:271 +#: ../../extending/embedding.rst:292 msgid "Embedding Python in C++" msgstr "" -#: ../../extending/embedding.rst:273 +#: ../../extending/embedding.rst:294 msgid "" "It is also possible to embed Python in a C++ program; precisely how this is " "done will depend on the details of the C++ system used; in general you will " @@ -463,11 +520,11 @@ msgid "" "+." msgstr "" -#: ../../extending/embedding.rst:282 +#: ../../extending/embedding.rst:303 msgid "Compiling and Linking under Unix-like systems" msgstr "" -#: ../../extending/embedding.rst:284 +#: ../../extending/embedding.rst:305 msgid "" "It is not necessarily trivial to find the right flags to pass to your " "compiler (and linker) in order to embed the Python interpreter into your " @@ -475,7 +532,7 @@ msgid "" "implemented as C dynamic extensions (:file:`.so` files) linked against it." msgstr "" -#: ../../extending/embedding.rst:290 +#: ../../extending/embedding.rst:311 msgid "" "To find out the required compiler and linker flags, you can execute the :" "file:`python{X.Y}-config` script which is generated as part of the " @@ -484,13 +541,13 @@ msgid "" "directly useful to you:" msgstr "" -#: ../../extending/embedding.rst:296 +#: ../../extending/embedding.rst:317 msgid "" "``pythonX.Y-config --cflags`` will give you the recommended flags when " "compiling:" msgstr "" -#: ../../extending/embedding.rst:299 +#: ../../extending/embedding.rst:320 msgid "" "$ /opt/bin/python3.11-config --cflags\n" "-I/opt/include/python3.11 -I/opt/include/python3.11 -Wsign-compare -DNDEBUG " @@ -500,13 +557,13 @@ msgstr "" "-I/opt/include/python3.11 -I/opt/include/python3.11 -Wsign-compare -DNDEBUG " "-g -fwrapv -O3 -Wall" -#: ../../extending/embedding.rst:304 +#: ../../extending/embedding.rst:325 msgid "" "``pythonX.Y-config --ldflags --embed`` will give you the recommended flags " "when linking:" msgstr "" -#: ../../extending/embedding.rst:307 +#: ../../extending/embedding.rst:328 msgid "" "$ /opt/bin/python3.11-config --ldflags --embed\n" "-L/opt/lib/python3.11/config-3.11-x86_64-linux-gnu -L/opt/lib -lpython3.11 -" @@ -516,7 +573,7 @@ msgstr "" "-L/opt/lib/python3.11/config-3.11-x86_64-linux-gnu -L/opt/lib -lpython3.11 -" "lpthread -ldl -lutil -lm" -#: ../../extending/embedding.rst:313 +#: ../../extending/embedding.rst:334 msgid "" "To avoid confusion between several Python installations (and especially " "between the system Python and your own compiled Python), it is recommended " @@ -524,7 +581,7 @@ msgid "" "above example." msgstr "" -#: ../../extending/embedding.rst:318 +#: ../../extending/embedding.rst:339 msgid "" "If this procedure doesn't work for you (it is not guaranteed to work for all " "Unix-like platforms; however, we welcome :ref:`bug reports >> import sysconfig\n" ">>> sysconfig.get_config_var('LIBS')\n" diff --git a/extending/extending.po b/extending/extending.po index 24afb86878..df2ba80946 100644 --- a/extending/extending.po +++ b/extending/extending.po @@ -1,16 +1,17 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-202DESCRIPTIVE TITLE., Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 +# Adrian Liaw , 2018 +# Matt Wang , 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" -"PO-Revision-Date: 2018-05-23 14:34+0000\n" -"Last-Translator: Adrian Liaw \n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"PO-Revision-Date: 2025-02-17 14:34+0000\n" +"Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -30,6 +31,9 @@ msgid "" "done directly in Python: they can implement new built-in object types, and " "they can call C library functions and system calls." msgstr "" +"如果你會撰寫 C 程式語言,那要向 Python 新增內建模組就不困難。這種\\ :dfn:`擴" +"充模組 (extension modules)` 可以做兩件在 Python 中無法直接完成的事:它們可以" +"實作新的內建物件型別,並且可以呼叫 C 的函式庫函式和系統呼叫。" #: ../../extending/extending.rst:15 msgid "" @@ -38,12 +42,17 @@ msgid "" "aspects of the Python run-time system. The Python API is incorporated in a " "C source file by including the header ``\"Python.h\"``." msgstr "" +"為了支援擴充,Python API (Application Programmers Interface) 定義了一組函式、" +"巨集和變數,提供對 Python run-time 系統大部分面向的存取。Python API 是透過引" +"入標頭檔 ``\"Python.h\"`` 來被納入到一個 C 原始碼檔案中。" #: ../../extending/extending.rst:20 msgid "" "The compilation of an extension module depends on its intended use as well " "as on your system setup; details are given in later chapters." msgstr "" +"擴充模組的編譯取決於其預期用途以及你的系統設定;詳細資訊將在後面的章節中提" +"供。" #: ../../extending/extending.rst:25 msgid "" @@ -57,6 +66,12 @@ msgid "" "with C code and are more portable between implementations of Python than " "writing and compiling a C extension module." msgstr "" +"C 擴充介面是 CPython 所特有的,擴充模組在其他 Python 實作上無法運作。在許多情" +"況下,可以避免撰寫 C 擴充並保留對其他實作的可移植性。例如,如果你的用例是呼" +"叫 C 函式庫函式或系統呼叫,你應該考慮使用 :mod:`ctypes` 模組或 `cffi " +"`_ 函式庫,而不是編寫自定義的 C 程式碼。這些模" +"組讓你可以撰寫 Python 程式碼來與 C 程式碼介接,而且比起撰寫和編譯 C 擴充模" +"組,這些模組在 Python 實作之間更容易移植。" #: ../../extending/extending.rst:40 msgid "A Simple Example" @@ -70,6 +85,10 @@ msgid "" "terminated character string as argument and returns an integer. We want " "this function to be callable from Python as follows:" msgstr "" +"讓我們來建立一個叫做 ``spam``\\ (Monty Python 粉絲最愛的食物...)的擴充模" +"組。假設我們要建立一個 Python 介面給 C 函式庫的函式 :c:func:`system` [#]_ 使" +"用,這個函式接受一個以 null 終止的 (null-terminated) 字元字串做為引數,並回傳" +"一個整數。我們希望這個函式可以在 Python 中被呼叫,如下所示:" #: ../../extending/extending.rst:48 msgid "" @@ -86,12 +105,15 @@ msgid "" "`spammodule.c`; if the module name is very long, like ``spammify``, the " "module name can be just :file:`spammify.c`.)" msgstr "" +"首先建立一個檔案 :file:`spammodule.c`。(從過去歷史來看,如果一個模組叫做 " +"``spam``,包含其實作的 C 檔案就會叫做 :file:`spammodule.c`;如果模組名稱很" +"長,像是 ``spammify``,模組名稱也可以只是 :file:`spammify.c`)。" #: ../../extending/extending.rst:58 msgid "The first two lines of our file can be::" -msgstr "" +msgstr "我們檔案的前兩列可以為: ::" -#: ../../extending/extending.rst:60 +#: ../../extending/extending.rst:60 ../../extending/extending.rst:681 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include " @@ -104,6 +126,8 @@ msgid "" "which pulls in the Python API (you can add a comment describing the purpose " "of the module and a copyright notice if you like)." msgstr "" +"這會將 Python API 拉進來(你可以加入註解來說明模組的目的,也可以加入版權聲" +"明)。" #: ../../extending/extending.rst:68 msgid "" @@ -111,14 +135,21 @@ msgid "" "standard headers on some systems, you *must* include :file:`Python.h` before " "any standard headers are included." msgstr "" +"由於 Python 可能定義一些影響系統上某些標準標頭檔的預處理器定義,你\\ *必須" +"*\\ 在引入任何標準標頭檔之前引入 :file:`Python.h`。" #: ../../extending/extending.rst:72 msgid "" -"It is recommended to always define ``PY_SSIZE_T_CLEAN`` before including " -"``Python.h``. See :ref:`parsetuple` for a description of this macro." +"``#define PY_SSIZE_T_CLEAN`` was used to indicate that ``Py_ssize_t`` should " +"be used in some APIs instead of ``int``. It is not necessary since Python " +"3.13, but we keep it here for backward compatibility. See :ref:`arg-parsing-" +"string-and-buffers` for a description of this macro." msgstr "" +"``#define PY_SSIZE_T_CLEAN`` 被用來表示在某些 API 中應該使用 ``Py_ssize_t`` " +"而不是 ``int``。自 Python 3.13 起,它就不再是必要的了,但我們在此保留它以便向" +"後相容。關於這個巨集的描述請參閱 :ref:`arg-parsing-string-and-buffers`。" -#: ../../extending/extending.rst:75 +#: ../../extending/extending.rst:77 msgid "" "All user-visible symbols defined by :file:`Python.h` have a prefix of ``Py`` " "or ``PY``, except those defined in standard header files. For convenience, " @@ -128,15 +159,24 @@ msgid "" "on your system, it declares the functions :c:func:`malloc`, :c:func:`free` " "and :c:func:`realloc` directly." msgstr "" +"除了那些在標準標頭檔中定義的符號以外,所有由 :file:`Python.h` 定義的使用者可" +"見符號 (user-visible symbols) 的前綴都是 ``Py`` 或 ``PY``。為了方便,也因為 " +"Python 直譯器的大量使用,``\"Python.h\"`` 也引入了一些標準的標頭檔:````、````、```` 和 ````。如果 ```` 在" +"你的系統上不存在,它會直接宣告 :c:func:`malloc`、:c:func:`free` 和 :c:func:" +"`realloc` 函式。" -#: ../../extending/extending.rst:83 +#: ../../extending/extending.rst:85 msgid "" "The next thing we add to our module file is the C function that will be " "called when the Python expression ``spam.system(string)`` is evaluated " "(we'll see shortly how it ends up being called)::" msgstr "" +"接下來我們要加入到模組檔案的是 C 函式,當 Python 運算式 ``spam." +"system(string)`` 要被求值 (evaluated) 時就會被呼叫(我們很快就會看到它最後是" +"如何被呼叫的): ::" -#: ../../extending/extending.rst:87 +#: ../../extending/extending.rst:89 msgid "" "static PyObject *\n" "spam_system(PyObject *self, PyObject *args)\n" @@ -162,21 +202,25 @@ msgstr "" " return PyLong_FromLong(sts);\n" "}" -#: ../../extending/extending.rst:99 +#: ../../extending/extending.rst:101 msgid "" "There is a straightforward translation from the argument list in Python (for " "example, the single expression ``\"ls -l\"``) to the arguments passed to the " "C function. The C function always has two arguments, conventionally named " "*self* and *args*." msgstr "" +"可以很直觀地從 Python 的引數串列(例如單一的運算式 ``\"ls -l\"``)直接轉換成" +"傳給 C 函式的引數。C 函式總是有兩個引數,習慣上會命名為 *self* 和 *args*。" -#: ../../extending/extending.rst:104 +#: ../../extending/extending.rst:106 msgid "" "The *self* argument points to the module object for module-level functions; " "for a method it would point to the object instance." msgstr "" +"對於模組層級的函式,*self* 引數會指向模組物件;而對於方法來說則是指向物件的實" +"例。" -#: ../../extending/extending.rst:107 +#: ../../extending/extending.rst:109 msgid "" "The *args* argument will be a pointer to a Python tuple object containing " "the arguments. Each item of the tuple corresponds to an argument in the " @@ -187,8 +231,13 @@ msgid "" "determine the required types of the arguments as well as the types of the C " "variables into which to store the converted values. More about this later." msgstr "" +"*args* 引數會是一個指向包含引數的 Python 元組物件的指標。元組中的每一項都對應" +"於呼叫的引數串列中的一個引數。引數是 Python 物件 --- 為了在我們的 C 函式中對" +"它們做任何事情,我們必須先將它們轉換成 C 值。Python API 中的 :c:func:" +"`PyArg_ParseTuple` 函式能夠檢查引數型別並將他們轉換為 C 值。它使用模板字串來" +"決定所需的引數型別以及儲存轉換值的 C 變數型別。稍後會再詳細說明。" -#: ../../extending/extending.rst:116 +#: ../../extending/extending.rst:118 msgid "" ":c:func:`PyArg_ParseTuple` returns true (nonzero) if all arguments have the " "right type and its components have been stored in the variables whose " @@ -197,12 +246,16 @@ msgid "" "the calling function can return ``NULL`` immediately (as we saw in the " "example)." msgstr "" +"如果所有的引數都有正確的型別,且其元件已儲存在傳入位址的變數中,則 :c:func:" +"`PyArg_ParseTuple` 會回傳 true(非零)。如果傳入的是無效引數串列則回傳 false" +"(零)。在後者情況下,它也會產生適當的例外,因此呼叫函式可以立即回傳 " +"``NULL``\\ (就像我們在範例中所看到的)。" -#: ../../extending/extending.rst:126 +#: ../../extending/extending.rst:128 msgid "Intermezzo: Errors and Exceptions" -msgstr "" +msgstr "插曲:錯誤與例外" -#: ../../extending/extending.rst:128 +#: ../../extending/extending.rst:130 msgid "" "An important convention throughout the Python interpreter is the following: " "when a function fails, it should set an exception condition and return an " @@ -213,14 +266,19 @@ msgid "" "the exception type, exception instance, and a traceback object. It is " "important to know about them to understand how errors are passed around." msgstr "" +"在整個 Python 直譯器中的一個重要慣例為:當一個函式失敗時,它就應該設定一個例" +"外條件,並回傳一個錯誤值(通常是 ``-1`` 或一個 ``NULL`` 指標)。例外資訊會儲" +"存在直譯器執行緒狀態的三個成員中。如果沒有例外,它們就會是 ``NULL``。否則,它" +"們是由 :meth:`sys.exc_info` 所回傳的 Python 元組中的 C 等效元組。它們是例外型" +"別、例外實例和回溯物件。了解它們對於理解錯誤是如何傳遞是很重要的。" -#: ../../extending/extending.rst:137 +#: ../../extending/extending.rst:139 msgid "" "The Python API defines a number of functions to set various types of " "exceptions." -msgstr "" +msgstr "Python API 定義了許多能夠設定各種類型例外的函式。" -#: ../../extending/extending.rst:139 +#: ../../extending/extending.rst:141 msgid "" "The most common one is :c:func:`PyErr_SetString`. Its arguments are an " "exception object and a C string. The exception object is usually a " @@ -228,8 +286,12 @@ msgid "" "indicates the cause of the error and is converted to a Python string object " "and stored as the \"associated value\" of the exception." msgstr "" +"最常見的是 :c:func:`PyErr_SetString`。它的引數是一個例外物件和一個 C 字串。例" +"外物件通常是預先定義的物件,例如 :c:data:`PyExc_ZeroDivisionError`。C 字串則" +"指出錯誤的原因,並被轉換為 Python 字串物件且被儲存為例外的「關聯值 " +"(associated value)」。" -#: ../../extending/extending.rst:145 +#: ../../extending/extending.rst:147 msgid "" "Another useful function is :c:func:`PyErr_SetFromErrno`, which only takes an " "exception argument and constructs the associated value by inspection of the " @@ -238,8 +300,12 @@ msgid "" "associated value. You don't need to :c:func:`Py_INCREF` the objects passed " "to any of these functions." msgstr "" +"另一個有用的函式是 :c:func:`PyErr_SetFromErrno`,它只接受一個例外引數,並透過" +"檢查全域變數 :c:data:`errno` 來建立關聯值。最一般的函式是 :c:func:" +"`PyErr_SetObject`,它接受兩個物件引數,即例外和它的關聯值。你不需要對傳給任何" +"這些函式的物件呼叫 :c:func:`Py_INCREF`。" -#: ../../extending/extending.rst:152 +#: ../../extending/extending.rst:154 msgid "" "You can test non-destructively whether an exception has been set with :c:" "func:`PyErr_Occurred`. This returns the current exception object, or " @@ -247,8 +313,11 @@ msgid "" "func:`PyErr_Occurred` to see whether an error occurred in a function call, " "since you should be able to tell from the return value." msgstr "" +"你可以使用 :c:func:`PyErr_Occurred` 來不具破壞性地測試例外是否已被設定。這會" +"回傳目前的例外物件,如果沒有例外發生則回傳 ``NULL``。你通常不需要呼叫 :c:" +"func:`PyErr_Occurred` 來查看函式呼叫是否發生錯誤,因為你應可從回傳值就得知。" -#: ../../extending/extending.rst:158 +#: ../../extending/extending.rst:160 msgid "" "When a function *f* that calls another function *g* detects that the latter " "fails, *f* should itself return an error value (usually ``NULL`` or " @@ -260,8 +329,14 @@ msgid "" "interpreter's main loop, this aborts the currently executing Python code and " "tries to find an exception handler specified by the Python programmer." msgstr "" +"當函式 *f* 呼叫另一個函式 *g* 時檢測到後者失敗,*f* 本身應該回傳一個錯誤值" +"(通常是 ``NULL`` 或 ``-1``)。它\\ *不*\\ 應該呼叫 ``PyErr_*`` 函式的其中一" +"個,這會已被 *g* 呼叫過。*f* 的呼叫者然後也應該回傳一個錯誤指示給\\ *它的*\\ " +"呼叫者,同樣\\ *不會*\\ 呼叫 ``PyErr_*``,依此類推 --- 最詳細的錯誤原因已經被" +"首先檢測到它的函式回報了。一旦錯誤到達 Python 直譯器的主要迴圈,這會中止目前" +"執行的 Python 程式碼,並嘗試尋找 Python 程式設計者指定的例外處理程式。" -#: ../../extending/extending.rst:168 +#: ../../extending/extending.rst:170 msgid "" "(There are situations where a module can actually give a more detailed error " "message by calling another ``PyErr_*`` function, and in such cases it is " @@ -269,8 +344,11 @@ msgid "" "cause information about the cause of the error to be lost: most operations " "can fail for a variety of reasons.)" msgstr "" +"(在某些情況下,模組可以透過呼叫另一個 ``PyErr_*`` 函式來提供更詳細的錯誤訊" +"息,在這種情況下這樣做是沒問題的。然而這一般來說並非必要,而且可能會導致錯誤" +"原因資訊的遺失:大多數的操作都可能因為各種原因而失敗。)" -#: ../../extending/extending.rst:174 +#: ../../extending/extending.rst:176 msgid "" "To ignore an exception set by a function call that failed, the exception " "condition must be cleared explicitly by calling :c:func:`PyErr_Clear`. The " @@ -278,8 +356,12 @@ msgid "" "pass the error on to the interpreter but wants to handle it completely by " "itself (possibly by trying something else, or pretending nothing went wrong)." msgstr "" +"要忽略由函式呼叫失敗所設定的例外,必須明確地呼叫 :c:func:`PyErr_Clear` 來清除" +"例外條件。C 程式碼唯一要呼叫 :c:func:`PyErr_Clear` 的情況為當它不想將錯誤傳遞" +"給直譯器而想要完全是自己來處理它時(可能是要再嘗試其他東西,或者假裝什麼都沒" +"出錯)。" -#: ../../extending/extending.rst:180 +#: ../../extending/extending.rst:182 msgid "" "Every failing :c:func:`malloc` call must be turned into an exception --- the " "direct caller of :c:func:`malloc` (or :c:func:`realloc`) must call :c:func:" @@ -287,23 +369,33 @@ msgid "" "creating functions (for example, :c:func:`PyLong_FromLong`) already do this, " "so this note is only relevant to those who call :c:func:`malloc` directly." msgstr "" +"每個失敗的 :c:func:`malloc` 呼叫都必須被轉換成一個例外 --- :c:func:" +"`malloc`\\ (或 :c:func:`realloc`)的直接呼叫者必須呼叫 :c:func:" +"`PyErr_NoMemory` 並回傳一個失敗指示器。所有建立物件的函式(例如 :c:func:" +"`PyLong_FromLong`)都已經這麼做了,所以這個注意事項只和那些直接呼叫 :c:func:" +"`malloc` 的函式有關。" -#: ../../extending/extending.rst:186 +#: ../../extending/extending.rst:188 msgid "" "Also note that, with the important exception of :c:func:`PyArg_ParseTuple` " "and friends, functions that return an integer status usually return a " "positive value or zero for success and ``-1`` for failure, like Unix system " "calls." msgstr "" +"還要注意的是,有 :c:func:`PyArg_ParseTuple` 及同系列函式的這些重要例外,回傳" +"整數狀態的函式通常會回傳一個正值或 0 表示成功、回傳 ``-1`` 表示失敗,就像 " +"Unix 系統呼叫一樣。" -#: ../../extending/extending.rst:190 +#: ../../extending/extending.rst:192 msgid "" "Finally, be careful to clean up garbage (by making :c:func:`Py_XDECREF` or :" "c:func:`Py_DECREF` calls for objects you have already created) when you " "return an error indicator!" msgstr "" +"最後,在回傳錯誤指示器時要注意垃圾清理(透過對你已經建立的物件呼叫 :c:func:" +"`Py_XDECREF` 或 :c:func:`Py_DECREF`)!" -#: ../../extending/extending.rst:194 +#: ../../extending/extending.rst:196 msgid "" "The choice of which exception to raise is entirely yours. There are " "predeclared C objects corresponding to all built-in Python exceptions, such " @@ -315,76 +407,100 @@ msgid "" "you have an argument whose value must be in a particular range or must " "satisfy other conditions, :c:data:`PyExc_ValueError` is appropriate." msgstr "" +"你完全可以自行選擇要產生的例外。有一些預先宣告的 C 物件會對應到所有內建的 " +"Python 例外,例如 :c:data:`PyExc_ZeroDivisionError`,你可以直接使用它們。當" +"然,你應該明智地選擇例外,像是不要使用 :c:data:`PyExc_TypeError` 來表示檔案無" +"法打開(應該是 :c:data:`PyExc_OSError`)。如果引數串列有問題,:c:func:" +"`PyArg_ParseTuple` 函式通常會引發 :c:data:`PyExc_TypeError`。如果你有一個引數" +"的值必須在一個特定的範圍內或必須滿足其他條件,則可以使用 :c:data:" +"`PyExc_ValueError`。" -#: ../../extending/extending.rst:204 +#: ../../extending/extending.rst:206 msgid "" -"You can also define a new exception that is unique to your module. For this, " -"you usually declare a static object variable at the beginning of your file::" +"You can also define a new exception that is unique to your module. The " +"simplest way to do this is to declare a static global object variable at the " +"beginning of the file::" msgstr "" +"你也可以定義一個你的模組特有的新例外。最簡單的方式是在檔案的開頭宣告一個靜態全域物件變數: ::" -#: ../../extending/extending.rst:207 -msgid "static PyObject *SpamError;" -msgstr "static PyObject *SpamError;" +#: ../../extending/extending.rst:210 +msgid "static PyObject *SpamError = NULL;" +msgstr "static PyObject *SpamError = NULL;" -#: ../../extending/extending.rst:209 +#: ../../extending/extending.rst:212 msgid "" -"and initialize it in your module's initialization function (:c:func:`!" -"PyInit_spam`) with an exception object::" +"and initialize it by calling :c:func:`PyErr_NewException` in the module's :c:" +"data:`Py_mod_exec` function (:c:func:`!spam_module_exec`)::" msgstr "" -#: ../../extending/extending.rst:212 +#: ../../extending/extending.rst:215 +msgid "SpamError = PyErr_NewException(\"spam.error\", NULL, NULL);" +msgstr "" + +#: ../../extending/extending.rst:217 msgid "" -"PyMODINIT_FUNC\n" -"PyInit_spam(void)\n" -"{\n" -" PyObject *m;\n" -"\n" -" m = PyModule_Create(&spammodule);\n" -" if (m == NULL)\n" -" return NULL;\n" +"Since :c:data:`!SpamError` is a global variable, it will be overwitten every " +"time the module is reinitialized, when the :c:data:`Py_mod_exec` function is " +"called." +msgstr "" + +#: ../../extending/extending.rst:220 +msgid "" +"For now, let's avoid the issue: we will block repeated initialization by " +"raising an :py:exc:`ImportError`::" +msgstr "" + +#: ../../extending/extending.rst:223 +msgid "" +"static PyObject *SpamError = NULL;\n" "\n" +"static int\n" +"spam_module_exec(PyObject *m)\n" +"{\n" +" if (SpamError != NULL) {\n" +" PyErr_SetString(PyExc_ImportError,\n" +" \"cannot initialize spam module more than once\");\n" +" return -1;\n" +" }\n" " SpamError = PyErr_NewException(\"spam.error\", NULL, NULL);\n" -" Py_XINCREF(SpamError);\n" -" if (PyModule_AddObject(m, \"error\", SpamError) < 0) {\n" -" Py_XDECREF(SpamError);\n" -" Py_CLEAR(SpamError);\n" -" Py_DECREF(m);\n" -" return NULL;\n" +" if (PyModule_AddObjectRef(m, \"SpamError\", SpamError) < 0) {\n" +" return -1;\n" " }\n" "\n" -" return m;\n" -"}" -msgstr "" -"PyMODINIT_FUNC\n" -"PyInit_spam(void)\n" -"{\n" -" PyObject *m;\n" +" return 0;\n" +"}\n" "\n" -" m = PyModule_Create(&spammodule);\n" -" if (m == NULL)\n" -" return NULL;\n" +"static PyModuleDef_Slot spam_module_slots[] = {\n" +" {Py_mod_exec, spam_module_exec},\n" +" {0, NULL}\n" +"};\n" "\n" -" SpamError = PyErr_NewException(\"spam.error\", NULL, NULL);\n" -" Py_XINCREF(SpamError);\n" -" if (PyModule_AddObject(m, \"error\", SpamError) < 0) {\n" -" Py_XDECREF(SpamError);\n" -" Py_CLEAR(SpamError);\n" -" Py_DECREF(m);\n" -" return NULL;\n" -" }\n" +"static struct PyModuleDef spam_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"spam\",\n" +" .m_size = 0, // non-negative\n" +" .m_slots = spam_module_slots,\n" +"};\n" "\n" -" return m;\n" +"PyMODINIT_FUNC\n" +"PyInit_spam(void)\n" +"{\n" +" return PyModuleDef_Init(&spam_module);\n" "}" +msgstr "" -#: ../../extending/extending.rst:233 +#: ../../extending/extending.rst:259 msgid "" "Note that the Python name for the exception object is :exc:`!spam.error`. " "The :c:func:`PyErr_NewException` function may create a class with the base " "class being :exc:`Exception` (unless another class is passed in instead of " "``NULL``), described in :ref:`bltin-exceptions`." msgstr "" +"請注意,例外物件的 Python 名稱是 :exc:`!spam.error`。如同\\ :ref:`bltin-" +"exceptions`\\ 所述,:c:func:`PyErr_NewException` 函式可能會建立一個基底類別" +"為 :exc:`Exception` 的類別(除非傳入另一個類別來代替 ``NULL``)。" -#: ../../extending/extending.rst:238 +#: ../../extending/extending.rst:264 msgid "" "Note also that the :c:data:`!SpamError` variable retains a reference to the " "newly created exception class; this is intentional! Since the exception " @@ -394,20 +510,35 @@ msgid "" "pointer, C code which raises the exception could cause a core dump or other " "unintended side effects." msgstr "" +"請注意,:c:data:`!SpamError` 變數保留了對新建立的例外類別的參照;這是故意的!" +"因為外部程式碼可能會從模組中移除這個例外,所以需要一個對這個類別的參照來確保" +"它不會被丟棄而導致 :c:data:`!SpamError` 變成一個迷途指標 (dangling pointer)。" +"如果它變成迷途指標,那產生例外的 C 程式碼可能會導致核心轉儲 (core dump) 或其" +"他不預期的 side effect。" + +#: ../../extending/extending.rst:271 +msgid "" +"For now, the :c:func:`Py_DECREF` call to remove this reference is missing. " +"Even when the Python interpreter shuts down, the global :c:data:`!SpamError` " +"variable will not be garbage-collected. It will \"leak\". We did, however, " +"ensure that this will happen at most once per process." +msgstr "" -#: ../../extending/extending.rst:245 +#: ../../extending/extending.rst:276 msgid "" "We discuss the use of :c:macro:`PyMODINIT_FUNC` as a function return type " "later in this sample." -msgstr "" +msgstr "我們稍後會討論 :c:macro:`PyMODINIT_FUNC` 作為函式回傳型別的用法。" -#: ../../extending/extending.rst:248 +#: ../../extending/extending.rst:279 msgid "" "The :exc:`!spam.error` exception can be raised in your extension module " "using a call to :c:func:`PyErr_SetString` as shown below::" msgstr "" +"可以在你的擴充模組中呼叫 :c:func:`PyErr_SetString` 來引發 :exc:`!spam.error` " +"例外,如下所示: ::" -#: ../../extending/extending.rst:251 +#: ../../extending/extending.rst:282 msgid "" "static PyObject *\n" "spam_system(PyObject *self, PyObject *args)\n" @@ -441,17 +572,17 @@ msgstr "" " return PyLong_FromLong(sts);\n" "}" -#: ../../extending/extending.rst:271 +#: ../../extending/extending.rst:302 msgid "Back to the Example" msgstr "回到範例" -#: ../../extending/extending.rst:273 +#: ../../extending/extending.rst:304 msgid "" "Going back to our example function, you should now be able to understand " "this statement::" -msgstr "" +msgstr "回到我們的範例函式,現在你應該可以理解這個陳述式了: ::" -#: ../../extending/extending.rst:276 +#: ../../extending/extending.rst:307 msgid "" "if (!PyArg_ParseTuple(args, \"s\", &command))\n" " return NULL;" @@ -459,7 +590,7 @@ msgstr "" "if (!PyArg_ParseTuple(args, \"s\", &command))\n" " return NULL;" -#: ../../extending/extending.rst:279 +#: ../../extending/extending.rst:310 msgid "" "It returns ``NULL`` (the error indicator for functions returning object " "pointers) if an error is detected in the argument list, relying on the " @@ -469,43 +600,57 @@ msgid "" "which it points (so in Standard C, the variable :c:data:`!command` should " "properly be declared as ``const char *command``)." msgstr "" +"如果在引數串列中檢測到錯誤則會回傳 ``NULL``\\ (回傳物件指標之函式的錯誤指示" +"器),其依賴於 :c:func:`PyArg_ParseTuple` 設定的例外,否則引數的字串值會已被" +"複製到區域變數 :c:data:`!command` 中。這是一個指標賦值,你不應該修改它所指向" +"的字串(所以在標準 C 中,:c:data:`!command` 變數應該正確地被宣告為 ``const " +"char *command``)。" -#: ../../extending/extending.rst:287 +#: ../../extending/extending.rst:318 msgid "" "The next statement is a call to the Unix function :c:func:`system`, passing " "it the string we just got from :c:func:`PyArg_ParseTuple`::" msgstr "" +"接下來的陳述式會呼叫 Unix 函式 :c:func:`system`,並將剛才從 :c:func:" +"`PyArg_ParseTuple` 得到的字串傳給它:" -#: ../../extending/extending.rst:290 +#: ../../extending/extending.rst:321 msgid "sts = system(command);" msgstr "sts = system(command);" -#: ../../extending/extending.rst:292 +#: ../../extending/extending.rst:323 msgid "" "Our :func:`!spam.system` function must return the value of :c:data:`!sts` as " "a Python object. This is done using the function :c:func:" "`PyLong_FromLong`. ::" msgstr "" +"我們的 :func:`!spam.system` 函式必須以 Python 物件的形式來回傳 :c:data:`!" +"sts` 的值。這是透過 :c:func:`PyLong_FromLong` 函式來達成。 ::" -#: ../../extending/extending.rst:295 +#: ../../extending/extending.rst:326 msgid "return PyLong_FromLong(sts);" msgstr "return PyLong_FromLong(sts);" -#: ../../extending/extending.rst:297 +#: ../../extending/extending.rst:328 msgid "" "In this case, it will return an integer object. (Yes, even integers are " "objects on the heap in Python!)" msgstr "" +"在這種情況下它會回傳一個整數物件。(是的,在 Python 中連整數也是堆積 (heap) 上" +"的物件!)" -#: ../../extending/extending.rst:300 +#: ../../extending/extending.rst:331 msgid "" "If you have a C function that returns no useful argument (a function " "returning :c:expr:`void`), the corresponding Python function must return " "``None``. You need this idiom to do so (which is implemented by the :c:" "macro:`Py_RETURN_NONE` macro)::" msgstr "" +"如果你有一個不回傳任何有用引數的 C 函式(一個回傳 :c:expr:`void` 的函式),對" +"應的 Python 函式必須回傳 ``None``。你需要以下這個慣例來達成(由 :c:macro:" +"`Py_RETURN_NONE` 巨集實作): ::" -#: ../../extending/extending.rst:305 +#: ../../extending/extending.rst:336 msgid "" "Py_INCREF(Py_None);\n" "return Py_None;" @@ -513,26 +658,31 @@ msgstr "" "Py_INCREF(Py_None);\n" "return Py_None;" -#: ../../extending/extending.rst:308 +#: ../../extending/extending.rst:339 msgid "" ":c:data:`Py_None` is the C name for the special Python object ``None``. It " "is a genuine Python object rather than a ``NULL`` pointer, which means " "\"error\" in most contexts, as we have seen." msgstr "" +":c:data:`Py_None` 是特殊 Python 物件 ``None`` 的 C 名稱。它是一個真正的 " +"Python 物件而不是一個 ``NULL`` 指標,在大多數的情況下它的意思是「錯誤」,如我" +"們所見過的那樣。" -#: ../../extending/extending.rst:316 +#: ../../extending/extending.rst:347 msgid "The Module's Method Table and Initialization Function" -msgstr "" +msgstr "模組的方法表和初始化函式" -#: ../../extending/extending.rst:318 +#: ../../extending/extending.rst:349 msgid "" "I promised to show how :c:func:`!spam_system` is called from Python " "programs. First, we need to list its name and address in a \"method table\"::" msgstr "" +"我承諾過要展示 :c:func:`!spam_system` 是如何從 Python 程式中呼叫的。首先,我" +"們需要在「方法表」中列出它的名稱和位址: ::" -#: ../../extending/extending.rst:321 +#: ../../extending/extending.rst:352 msgid "" -"static PyMethodDef SpamMethods[] = {\n" +"static PyMethodDef spam_methods[] = {\n" " ...\n" " {\"system\", spam_system, METH_VARARGS,\n" " \"Execute a shell command.\"},\n" @@ -540,8 +690,15 @@ msgid "" " {NULL, NULL, 0, NULL} /* Sentinel */\n" "};" msgstr "" +"static PyMethodDef spam_methods[] = {\n" +" ...\n" +" {\"system\", spam_system, METH_VARARGS,\n" +" \"Execute a shell command.\"},\n" +" ...\n" +" {NULL, NULL, 0, NULL} /* Sentinel */\n" +"};" -#: ../../extending/extending.rst:329 +#: ../../extending/extending.rst:360 msgid "" "Note the third entry (``METH_VARARGS``). This is a flag telling the " "interpreter the calling convention to be used for the C function. It should " @@ -549,15 +706,21 @@ msgid "" "value of ``0`` means that an obsolete variant of :c:func:`PyArg_ParseTuple` " "is used." msgstr "" +"請注意第三個項目 (``METH_VARARGS``)。這是一個告訴直譯器 C 函式之呼叫方式的旗" +"標。通常應該是 ``METH_VARARGS`` 或 ``METH_VARARGS | METH_KEYWORDS``;``0`` 表" +"示是使用 :c:func:`PyArg_ParseTuple` 的一個過時變體。" -#: ../../extending/extending.rst:334 +#: ../../extending/extending.rst:365 msgid "" "When using only ``METH_VARARGS``, the function should expect the Python-" "level parameters to be passed in as a tuple acceptable for parsing via :c:" "func:`PyArg_ParseTuple`; more information on this function is provided below." msgstr "" +"當只使用 ``METH_VARARGS`` 時,函式應預期 Python 層級的參數是以元組形式傳入且" +"能夠接受以 :c:func:`PyArg_ParseTuple` 進行剖析;有關此函式的更多資訊將在下面" +"提供。" -#: ../../extending/extending.rst:338 +#: ../../extending/extending.rst:369 msgid "" "The :c:macro:`METH_KEYWORDS` bit may be set in the third field if keyword " "arguments should be passed to the function. In this case, the C function " @@ -565,85 +728,90 @@ msgid "" "keywords. Use :c:func:`PyArg_ParseTupleAndKeywords` to parse the arguments " "to such a function." msgstr "" +"如果要將關鍵字引數傳給函式,可以在第三個欄位設定 :c:macro:`METH_KEYWORDS` 位" +"元。在這種情況下,C 函式應該要能接受第三個 ``PyObject *`` 參數,這個參數將會" +"是關鍵字的字典。可使用 :c:func:`PyArg_ParseTupleAndKeywords` 來剖析這種函式的" +"引數。" -#: ../../extending/extending.rst:344 +#: ../../extending/extending.rst:375 msgid "" "The method table must be referenced in the module definition structure::" -msgstr "" +msgstr "方法表必須在模組定義結構中被參照: ::" -#: ../../extending/extending.rst:346 +#: ../../extending/extending.rst:377 msgid "" -"static struct PyModuleDef spammodule = {\n" -" PyModuleDef_HEAD_INIT,\n" -" \"spam\", /* name of module */\n" -" spam_doc, /* module documentation, may be NULL */\n" -" -1, /* size of per-interpreter state of the module,\n" -" or -1 if the module keeps state in global variables. */\n" -" SpamMethods\n" +"static struct PyModuleDef spam_module = {\n" +" ...\n" +" .m_methods = spam_methods,\n" +" ...\n" "};" msgstr "" -#: ../../extending/extending.rst:355 +#: ../../extending/extending.rst:383 msgid "" "This structure, in turn, must be passed to the interpreter in the module's " "initialization function. The initialization function must be named :c:func:" "`!PyInit_name`, where *name* is the name of the module, and should be the " "only non-\\ ``static`` item defined in the module file::" msgstr "" +"反過來說,這個結構必須在模組的初始化函式中被傳給直譯器。初始化函式必須被命名" +"為 :c:func:`!PyInit_name`,其中 *name* 是模組的名稱,且應該是模組檔案中唯一定" +"義的非「靜態 (``static``)」項目: ::" -#: ../../extending/extending.rst:360 +#: ../../extending/extending.rst:388 msgid "" "PyMODINIT_FUNC\n" "PyInit_spam(void)\n" "{\n" -" return PyModule_Create(&spammodule);\n" +" return PyModuleDef_Init(&spam_module);\n" "}" msgstr "" "PyMODINIT_FUNC\n" "PyInit_spam(void)\n" "{\n" -" return PyModule_Create(&spammodule);\n" +" return PyModuleDef_Init(&spam_module);\n" "}" -#: ../../extending/extending.rst:366 +#: ../../extending/extending.rst:394 msgid "" "Note that :c:macro:`PyMODINIT_FUNC` 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\"``." msgstr "" +"請注意,:c:macro:`PyMODINIT_FUNC` 宣告函式的回傳型別為 ``PyObject *``、宣告平" +"台所需的任何特殊連結宣告、並針對 C++ 宣告函式為 ``extern \"C\"``。" -#: ../../extending/extending.rst:370 +#: ../../extending/extending.rst:398 msgid "" -"When the Python program imports module :mod:`!spam` for the first time, :c:" -"func:`!PyInit_spam` is called. (See below for comments about embedding " -"Python.) It calls :c:func:`PyModule_Create`, which returns a module object, " -"and inserts built-in function objects into the newly created module based " -"upon the table (an array of :c:type:`PyMethodDef` structures) found in the " -"module definition. :c:func:`PyModule_Create` 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``." +":c:func:`!PyInit_spam` is called when each interpreter imports its module :" +"mod:`!spam` for the first time. (See below for comments about embedding " +"Python.) A pointer to the module definition must be returned via :c:func:" +"`PyModuleDef_Init`, so that the import machinery can create the module and " +"store it in ``sys.modules``." msgstr "" -#: ../../extending/extending.rst:381 +#: ../../extending/extending.rst:403 msgid "" "When embedding Python, the :c:func:`!PyInit_spam` function is not called " "automatically unless there's an entry in the :c:data:`PyImport_Inittab` " "table. To add the module to the initialization table, use :c:func:" "`PyImport_AppendInittab`, optionally followed by an import of the module::" msgstr "" +"嵌入 Python 時,除非在 :c:data:`PyImport_Inittab` 表中有相關條目,否則不會自" +"動呼叫 :c:func:`!PyInit_spam` 函式。要將模組加入初始化表,請使用 :c:func:" +"`PyImport_AppendInittab` 並在隨後選擇性地將該模組引入: ::" -#: ../../extending/extending.rst:386 +#: ../../extending/extending.rst:408 msgid "" +"#define PY_SSIZE_T_CLEAN\n" +"#include \n" +"\n" "int\n" "main(int argc, char *argv[])\n" "{\n" -" wchar_t *program = Py_DecodeLocale(argv[0], NULL);\n" -" if (program == NULL) {\n" -" fprintf(stderr, \"Fatal error: cannot decode argv[0]\\n\");\n" -" exit(1);\n" -" }\n" +" PyStatus status;\n" +" PyConfig config;\n" +" PyConfig_InitPythonConfig(&config);\n" "\n" " /* Add a built-in module, before Py_Initialize */\n" " if (PyImport_AppendInittab(\"spam\", PyInit_spam) == -1) {\n" @@ -653,11 +821,19 @@ msgid "" " }\n" "\n" " /* Pass argv[0] to the Python interpreter */\n" -" Py_SetProgramName(program);\n" +" status = PyConfig_SetBytesString(&config, &config.program_name, " +"argv[0]);\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" +" }\n" "\n" " /* Initialize the Python interpreter. Required.\n" " If this step fails, it will be a fatal error. */\n" -" Py_Initialize();\n" +" status = Py_InitializeFromConfig(&config);\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" +" }\n" +" PyConfig_Clear(&config);\n" "\n" " /* Optionally import the module; alternatively,\n" " import can be deferred until the embedded script\n" @@ -668,42 +844,91 @@ msgid "" " fprintf(stderr, \"Error: could not import module 'spam'\\n\");\n" " }\n" "\n" -" ...\n" +" // ... use Python C API here ...\n" "\n" -" PyMem_RawFree(program);\n" " return 0;\n" +"\n" +" exception:\n" +" PyConfig_Clear(&config);\n" +" Py_ExitStatusException(status);\n" "}" msgstr "" +"#define PY_SSIZE_T_CLEAN\n" +"#include \n" +"\n" +"int\n" +"main(int argc, char *argv[])\n" +"{\n" +" PyStatus status;\n" +" PyConfig config;\n" +" PyConfig_InitPythonConfig(&config);\n" +"\n" +" /* 在 Py_Initialize 之前加入內建模組 */\n" +" if (PyImport_AppendInittab(\"spam\", PyInit_spam) == -1) {\n" +" fprintf(stderr, \"Error: could not extend in-built modules " +"table\\n\");\n" +" exit(1);\n" +" }\n" +"\n" +" /* 將 argv[0] 傳給 Python 直譯器 */\n" +" status = PyConfig_SetBytesString(&config, &config.program_name, " +"argv[0]);\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" +" }\n" +"\n" +" /* 初始化 Python 直譯器。這會是必要的。\n" +" 如果此步驟失敗就會導致嚴重錯誤。*/\n" +" status = Py_InitializeFromConfig(&config);\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" +" }\n" +" PyConfig_Clear(&config);\n" +"\n" +" /* 可選擇引入模組;或者\n" +" 可以延遲引入,直至嵌入式腳本\n" +" 將其引入。*/\n" +" PyObject *pmodule = PyImport_ImportModule(\"spam\");\n" +" if (!pmodule) {\n" +" PyErr_Print();\n" +" fprintf(stderr, \"Error: could not import module 'spam'\\n\");\n" +" }\n" +"\n" +" // ... 在此使用 Python C API ...\n" +"\n" +" return 0;\n" +"\n" +" exception:\n" +" PyConfig_Clear(&config);\n" +" Py_ExitStatusException(status);\n" +"}" -#: ../../extending/extending.rst:425 +#: ../../extending/extending.rst:458 msgid "" -"Removing entries from ``sys.modules`` or importing compiled modules into " +"If you declare a global variable or a local static one, the module may " +"experience unintended side-effects on re-initialisation, for example when " +"removing entries from ``sys.modules`` or importing compiled modules into " "multiple interpreters within a process (or following a :c:func:`fork` " -"without an intervening :c:func:`exec`) can create problems for some " -"extension modules. Extension module authors should exercise caution when " -"initializing internal data structures." +"without an intervening :c:func:`exec`). If module state is not yet fully :" +"ref:`isolated `, authors should consider marking " +"the module as having no support for subinterpreters (via :c:macro:" +"`Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED`)." msgstr "" -#: ../../extending/extending.rst:431 +#: ../../extending/extending.rst:467 msgid "" "A more substantial example module is included in the Python source " -"distribution as :file:`Modules/xxmodule.c`. This file may be used as a " +"distribution as :file:`Modules/xxlimited.c`. This file may be used as a " "template or simply read as an example." msgstr "" +"Python 原始碼發行版本中包含了一個更實質的範例模組 :file:`Modules/xxlimited." +"c`。這個檔案可以當作模板使用,也可以簡單地當作範例來閱讀。" -#: ../../extending/extending.rst:437 -msgid "" -"Unlike our ``spam`` example, ``xxmodule`` uses *multi-phase initialization* " -"(new in Python 3.5), where a PyModuleDef structure is returned from " -"``PyInit_spam``, and creation of the module is left to the import machinery. " -"For details on multi-phase initialization, see :PEP:`489`." -msgstr "" - -#: ../../extending/extending.rst:446 +#: ../../extending/extending.rst:475 msgid "Compilation and Linkage" msgstr "" -#: ../../extending/extending.rst:448 +#: ../../extending/extending.rst:477 msgid "" "There are two more things to do before you can use your new extension: " "compiling and linking it with the Python system. If you use dynamic " @@ -713,7 +938,7 @@ msgid "" "Windows (chapter :ref:`building-on-windows`) for more information about this." msgstr "" -#: ../../extending/extending.rst:455 +#: ../../extending/extending.rst:484 msgid "" "If you can't use dynamic loading, or if you want to make your module a " "permanent part of the Python interpreter, you will have to change the " @@ -723,11 +948,11 @@ msgid "" "line to the file :file:`Modules/Setup.local` describing your file:" msgstr "" -#: ../../extending/extending.rst:462 +#: ../../extending/extending.rst:491 msgid "spam spammodule.o" msgstr "spam spammodule.o" -#: ../../extending/extending.rst:466 +#: ../../extending/extending.rst:495 msgid "" "and rebuild the interpreter by running :program:`make` in the toplevel " "directory. You can also run :program:`make` in the :file:`Modules/` " @@ -736,21 +961,21 @@ msgid "" "the :file:`Setup` file.)" msgstr "" -#: ../../extending/extending.rst:472 +#: ../../extending/extending.rst:501 msgid "" "If your module requires additional libraries to link with, these can be " "listed on the line in the configuration file as well, for instance:" msgstr "" -#: ../../extending/extending.rst:475 +#: ../../extending/extending.rst:504 msgid "spam spammodule.o -lX11" msgstr "spam spammodule.o -lX11" -#: ../../extending/extending.rst:483 +#: ../../extending/extending.rst:512 msgid "Calling Python Functions from C" msgstr "" -#: ../../extending/extending.rst:485 +#: ../../extending/extending.rst:514 msgid "" "So far we have concentrated on making C functions callable from Python. The " "reverse is also useful: calling Python functions from C. This is especially " @@ -761,7 +986,7 @@ msgid "" "uses are also imaginable." msgstr "" -#: ../../extending/extending.rst:493 +#: ../../extending/extending.rst:522 msgid "" "Fortunately, the Python interpreter is easily called recursively, and there " "is a standard interface to call a Python function. (I won't dwell on how to " @@ -770,7 +995,7 @@ msgid "" "line option in :file:`Modules/main.c` from the Python source code.)" msgstr "" -#: ../../extending/extending.rst:499 +#: ../../extending/extending.rst:528 msgid "" "Calling a Python function is easy. First, the Python program must somehow " "pass you the Python function object. You should provide a function (or some " @@ -780,7 +1005,7 @@ msgid "" "function might be part of a module definition::" msgstr "" -#: ../../extending/extending.rst:506 +#: ../../extending/extending.rst:535 msgid "" "static PyObject *my_callback = NULL;\n" "\n" @@ -807,7 +1032,7 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:529 +#: ../../extending/extending.rst:558 msgid "" "This function must be registered with the interpreter using the :c:macro:" "`METH_VARARGS` flag; this is described in section :ref:`methodtable`. The :" @@ -815,7 +1040,7 @@ msgid "" "section :ref:`parsetuple`." msgstr "" -#: ../../extending/extending.rst:534 +#: ../../extending/extending.rst:563 msgid "" "The macros :c:func:`Py_XINCREF` and :c:func:`Py_XDECREF` increment/decrement " "the reference count of an object and are safe in the presence of ``NULL`` " @@ -823,7 +1048,7 @@ msgid "" "info on them in section :ref:`refcounts`." msgstr "" -#: ../../extending/extending.rst:541 +#: ../../extending/extending.rst:570 msgid "" "Later, when it is time to call the function, you call the C function :c:func:" "`PyObject_CallObject`. This function has two arguments, both pointers to " @@ -835,7 +1060,7 @@ msgid "" "or more format codes between parentheses. For example::" msgstr "" -#: ../../extending/extending.rst:550 +#: ../../extending/extending.rst:579 msgid "" "int arg;\n" "PyObject *arglist;\n" @@ -849,7 +1074,7 @@ msgid "" "Py_DECREF(arglist);" msgstr "" -#: ../../extending/extending.rst:561 +#: ../../extending/extending.rst:590 msgid "" ":c:func:`PyObject_CallObject` returns a Python object pointer: this is the " "return value of the Python function. :c:func:`PyObject_CallObject` is " @@ -858,7 +1083,7 @@ msgid "" "`Py_DECREF`\\ -ed immediately after the :c:func:`PyObject_CallObject` call." msgstr "" -#: ../../extending/extending.rst:568 +#: ../../extending/extending.rst:597 msgid "" "The return value of :c:func:`PyObject_CallObject` is \"new\": either it is a " "brand new object, or it is an existing object whose reference count has been " @@ -867,7 +1092,7 @@ msgid "" "not interested in its value." msgstr "" -#: ../../extending/extending.rst:574 +#: ../../extending/extending.rst:603 msgid "" "Before you do this, however, it is important to check that the return value " "isn't ``NULL``. If it is, the Python function terminated by raising an " @@ -878,7 +1103,7 @@ msgid "" "should be cleared by calling :c:func:`PyErr_Clear`. For example::" msgstr "" -#: ../../extending/extending.rst:582 +#: ../../extending/extending.rst:611 msgid "" "if (result == NULL)\n" " return NULL; /* Pass error back */\n" @@ -886,7 +1111,7 @@ msgid "" "Py_DECREF(result);" msgstr "" -#: ../../extending/extending.rst:587 +#: ../../extending/extending.rst:616 msgid "" "Depending on the desired interface to the Python callback function, you may " "also have to provide an argument list to :c:func:`PyObject_CallObject`. In " @@ -898,7 +1123,7 @@ msgid "" "you want to pass an integral event code, you might use the following code::" msgstr "" -#: ../../extending/extending.rst:596 +#: ../../extending/extending.rst:625 msgid "" "PyObject *arglist;\n" "...\n" @@ -911,7 +1136,7 @@ msgid "" "Py_DECREF(result);" msgstr "" -#: ../../extending/extending.rst:606 +#: ../../extending/extending.rst:635 msgid "" "Note the placement of ``Py_DECREF(arglist)`` immediately after the call, " "before the error check! Also note that strictly speaking this code is not " @@ -919,14 +1144,14 @@ msgid "" "checked." msgstr "" -#: ../../extending/extending.rst:610 +#: ../../extending/extending.rst:639 msgid "" "You may also call a function with keyword arguments by using :c:func:" "`PyObject_Call`, which supports arguments and keyword arguments. As in the " "above example, we use :c:func:`Py_BuildValue` to construct the dictionary. ::" msgstr "" -#: ../../extending/extending.rst:614 +#: ../../extending/extending.rst:643 msgid "" "PyObject *dict;\n" "...\n" @@ -939,19 +1164,19 @@ msgid "" "Py_DECREF(result);" msgstr "" -#: ../../extending/extending.rst:628 +#: ../../extending/extending.rst:657 msgid "Extracting Parameters in Extension Functions" msgstr "" -#: ../../extending/extending.rst:632 +#: ../../extending/extending.rst:661 msgid "The :c:func:`PyArg_ParseTuple` function is declared as follows::" msgstr "" -#: ../../extending/extending.rst:634 +#: ../../extending/extending.rst:663 msgid "int PyArg_ParseTuple(PyObject *arg, const char *format, ...);" msgstr "" -#: ../../extending/extending.rst:636 +#: ../../extending/extending.rst:665 msgid "" "The *arg* argument must be a tuple object containing an argument list passed " "from Python to a C function. The *format* argument must be a format string, " @@ -960,7 +1185,7 @@ msgid "" "whose type is determined by the format string." msgstr "" -#: ../../extending/extending.rst:642 +#: ../../extending/extending.rst:671 msgid "" "Note that while :c:func:`PyArg_ParseTuple` checks that the Python arguments " "have the required types, it cannot check the validity of the addresses of C " @@ -968,23 +1193,17 @@ msgid "" "probably crash or at least overwrite random bits in memory. So be careful!" msgstr "" -#: ../../extending/extending.rst:647 +#: ../../extending/extending.rst:676 msgid "" "Note that any Python object references which are provided to the caller are " "*borrowed* references; do not decrement their reference count!" msgstr "" -#: ../../extending/extending.rst:650 +#: ../../extending/extending.rst:679 msgid "Some example calls::" msgstr "一些呼叫範例: ::" -#: ../../extending/extending.rst:652 -msgid "" -"#define PY_SSIZE_T_CLEAN /* Make \"s#\" use Py_ssize_t rather than int. */\n" -"#include " -msgstr "" - -#: ../../extending/extending.rst:657 +#: ../../extending/extending.rst:686 msgid "" "int ok;\n" "int i, j;\n" @@ -1004,27 +1223,27 @@ msgstr "" "ok = PyArg_ParseTuple(args, \"\"); /* 沒有引數 */\n" " /* Python 呼叫:f() */" -#: ../../extending/extending.rst:668 +#: ../../extending/extending.rst:697 msgid "" "ok = PyArg_ParseTuple(args, \"s\", &s); /* A string */\n" " /* Possible Python call: f('whoops!') */" msgstr "" -#: ../../extending/extending.rst:673 +#: ../../extending/extending.rst:702 msgid "" "ok = PyArg_ParseTuple(args, \"lls\", &k, &l, &s); /* Two longs and a string " "*/\n" " /* Possible Python call: f(1, 2, 'three') */" msgstr "" -#: ../../extending/extending.rst:678 +#: ../../extending/extending.rst:707 msgid "" "ok = PyArg_ParseTuple(args, \"(ii)s#\", &i, &j, &s, &size);\n" " /* A pair of ints and a string, whose size is also returned */\n" " /* Possible Python call: f((1, 2), 'three') */" msgstr "" -#: ../../extending/extending.rst:684 +#: ../../extending/extending.rst:713 msgid "" "{\n" " const char *file;\n" @@ -1039,7 +1258,7 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:698 +#: ../../extending/extending.rst:727 msgid "" "{\n" " int left, top, right, bottom, h, v;\n" @@ -1051,7 +1270,7 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:709 +#: ../../extending/extending.rst:738 msgid "" "{\n" " Py_complex c;\n" @@ -1061,24 +1280,26 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:720 +#: ../../extending/extending.rst:749 msgid "Keyword Parameters for Extension Functions" msgstr "" -#: ../../extending/extending.rst:724 +#: ../../extending/extending.rst:753 msgid "" "The :c:func:`PyArg_ParseTupleAndKeywords` function is declared as follows::" msgstr "" -#: ../../extending/extending.rst:726 +#: ../../extending/extending.rst:755 msgid "" "int PyArg_ParseTupleAndKeywords(PyObject *arg, PyObject *kwdict,\n" -" const char *format, char *kwlist[], ...);" +" const char *format, char * const " +"*kwlist, ...);" msgstr "" "int PyArg_ParseTupleAndKeywords(PyObject *arg, PyObject *kwdict,\n" -" const char *format, char *kwlist[], ...);" +" const char *format, char * const " +"*kwlist, ...);" -#: ../../extending/extending.rst:729 +#: ../../extending/extending.rst:758 msgid "" "The *arg* and *format* parameters are identical to those of the :c:func:" "`PyArg_ParseTuple` function. The *kwdict* parameter is the dictionary of " @@ -1090,22 +1311,22 @@ msgid "" "raises an appropriate exception." msgstr "" -#: ../../extending/extending.rst:739 +#: ../../extending/extending.rst:768 msgid "" "Nested tuples cannot be parsed when using keyword arguments! Keyword " "parameters passed in which are not present in the *kwlist* will cause :exc:" "`TypeError` to be raised." msgstr "" -#: ../../extending/extending.rst:745 +#: ../../extending/extending.rst:774 msgid "" "Here is an example module which uses keywords, based on an example by Geoff " "Philbrick (philbrick@hks.com)::" msgstr "" -#: ../../extending/extending.rst:748 +#: ../../extending/extending.rst:777 msgid "" -"#define PY_SSIZE_T_CLEAN /* Make \"s#\" use Py_ssize_t rather than int. */\n" +"#define PY_SSIZE_T_CLEAN\n" "#include \n" "\n" "static PyObject *\n" @@ -1142,36 +1363,35 @@ msgid "" " {NULL, NULL, 0, NULL} /* sentinel */\n" "};\n" "\n" -"static struct PyModuleDef keywdargmodule = {\n" -" PyModuleDef_HEAD_INIT,\n" -" \"keywdarg\",\n" -" NULL,\n" -" -1,\n" -" keywdarg_methods\n" +"static struct PyModuleDef keywdarg_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"keywdarg\",\n" +" .m_size = 0,\n" +" .m_methods = keywdarg_methods,\n" "};\n" "\n" "PyMODINIT_FUNC\n" "PyInit_keywdarg(void)\n" "{\n" -" return PyModule_Create(&keywdargmodule);\n" +" return PyModuleDef_Init(&keywdarg_module);\n" "}" msgstr "" -#: ../../extending/extending.rst:800 +#: ../../extending/extending.rst:828 msgid "Building Arbitrary Values" msgstr "" -#: ../../extending/extending.rst:802 +#: ../../extending/extending.rst:830 msgid "" "This function is the counterpart to :c:func:`PyArg_ParseTuple`. It is " "declared as follows::" msgstr "" -#: ../../extending/extending.rst:805 +#: ../../extending/extending.rst:833 msgid "PyObject *Py_BuildValue(const char *format, ...);" msgstr "PyObject *Py_BuildValue(const char *format, ...);" -#: ../../extending/extending.rst:807 +#: ../../extending/extending.rst:835 msgid "" "It recognizes a set of format units similar to the ones recognized by :c:" "func:`PyArg_ParseTuple`, but the arguments (which are input to the function, " @@ -1179,7 +1399,7 @@ msgid "" "object, suitable for returning from a C function called from Python." msgstr "" -#: ../../extending/extending.rst:812 +#: ../../extending/extending.rst:840 msgid "" "One difference with :c:func:`PyArg_ParseTuple`: while the latter requires " "its first argument to be a tuple (since Python argument lists are always " @@ -1191,12 +1411,12 @@ msgid "" "parenthesize the format string." msgstr "" -#: ../../extending/extending.rst:820 +#: ../../extending/extending.rst:848 msgid "" "Examples (to the left the call, to the right the resulting Python value):" msgstr "" -#: ../../extending/extending.rst:822 +#: ../../extending/extending.rst:850 msgid "" "Py_BuildValue(\"\") None\n" "Py_BuildValue(\"i\", 123) 123\n" @@ -1234,11 +1454,11 @@ msgstr "" "Py_BuildValue(\"((ii)(ii)) (ii)\",\n" " 1, 2, 3, 4, 5, 6) (((1, 2), (3, 4)), (5, 6))" -#: ../../extending/extending.rst:846 +#: ../../extending/extending.rst:874 msgid "Reference Counts" msgstr "" -#: ../../extending/extending.rst:848 +#: ../../extending/extending.rst:876 msgid "" "In languages like C or C++, the programmer is responsible for dynamic " "allocation and deallocation of memory on the heap. In C, this is done using " @@ -1247,7 +1467,7 @@ msgid "" "restrict the following discussion to the C case." msgstr "" -#: ../../extending/extending.rst:854 +#: ../../extending/extending.rst:882 msgid "" "Every block of memory allocated with :c:func:`malloc` should eventually be " "returned to the pool of available memory by exactly one call to :c:func:" @@ -1262,7 +1482,7 @@ msgid "" "crashes." msgstr "" -#: ../../extending/extending.rst:865 +#: ../../extending/extending.rst:893 msgid "" "Common causes of memory leaks are unusual paths through the code. For " "instance, a function may allocate a block of memory, do some calculation, " @@ -1279,7 +1499,7 @@ msgid "" "of errors." msgstr "" -#: ../../extending/extending.rst:878 +#: ../../extending/extending.rst:906 msgid "" "Since Python makes heavy use of :c:func:`malloc` and :c:func:`free`, it " "needs a strategy to avoid memory leaks as well as the use of freed memory. " @@ -1290,7 +1510,7 @@ msgid "" "reference to the object has been deleted and the object is freed." msgstr "" -#: ../../extending/extending.rst:886 +#: ../../extending/extending.rst:914 msgid "" "An alternative strategy is called :dfn:`automatic garbage collection`. " "(Sometimes, reference counting is also referred to as a garbage collection " @@ -1306,7 +1526,7 @@ msgid "" "with reference counts." msgstr "" -#: ../../extending/extending.rst:898 +#: ../../extending/extending.rst:926 msgid "" "While Python uses the traditional reference counting implementation, it also " "offers a cycle detector that works to detect reference cycles. This allows " @@ -1320,7 +1540,7 @@ msgid "" "though there are no further references to the cycle itself." msgstr "" -#: ../../extending/extending.rst:909 +#: ../../extending/extending.rst:937 msgid "" "The cycle detector is able to detect garbage cycles and can reclaim them. " "The :mod:`gc` module exposes a way to run the detector (the :func:`~gc." @@ -1328,11 +1548,11 @@ msgid "" "disable the detector at runtime." msgstr "" -#: ../../extending/extending.rst:918 +#: ../../extending/extending.rst:946 msgid "Reference Counting in Python" msgstr "" -#: ../../extending/extending.rst:920 +#: ../../extending/extending.rst:948 msgid "" "There are two macros, ``Py_INCREF(x)`` and ``Py_DECREF(x)``, which handle " "the incrementing and decrementing of the reference count. :c:func:" @@ -1343,7 +1563,7 @@ msgid "" "object." msgstr "" -#: ../../extending/extending.rst:927 +#: ../../extending/extending.rst:955 msgid "" "The big question now remains: when to use ``Py_INCREF(x)`` and " "``Py_DECREF(x)``? Let's first introduce some terms. Nobody \"owns\" an " @@ -1356,7 +1576,7 @@ msgid "" "reference creates a memory leak." msgstr "" -#: ../../extending/extending.rst:936 +#: ../../extending/extending.rst:964 msgid "" "It is also possible to :dfn:`borrow` [#]_ a reference to an object. The " "borrower of a reference should not call :c:func:`Py_DECREF`. The borrower " @@ -1365,7 +1585,7 @@ msgid "" "risks using freed memory and should be avoided completely [#]_." msgstr "" -#: ../../extending/extending.rst:942 +#: ../../extending/extending.rst:970 msgid "" "The advantage of borrowing over owning a reference is that you don't need to " "take care of disposing of the reference on all possible paths through the " @@ -1376,7 +1596,7 @@ msgid "" "borrowed has in fact disposed of it." msgstr "" -#: ../../extending/extending.rst:950 +#: ../../extending/extending.rst:978 msgid "" "A borrowed reference can be changed into an owned reference by calling :c:" "func:`Py_INCREF`. This does not affect the status of the owner from which " @@ -1385,18 +1605,18 @@ msgid "" "properly, as well as the previous owner)." msgstr "" -#: ../../extending/extending.rst:960 +#: ../../extending/extending.rst:988 msgid "Ownership Rules" msgstr "" -#: ../../extending/extending.rst:962 +#: ../../extending/extending.rst:990 msgid "" "Whenever an object reference is passed into or out of a function, it is part " "of the function's interface specification whether ownership is transferred " "with the reference or not." msgstr "" -#: ../../extending/extending.rst:966 +#: ../../extending/extending.rst:994 msgid "" "Most functions that return a reference to an object pass on ownership with " "the reference. In particular, all functions whose function it is to create " @@ -1407,7 +1627,7 @@ msgid "" "reference to a cached item." msgstr "" -#: ../../extending/extending.rst:974 +#: ../../extending/extending.rst:1002 msgid "" "Many functions that extract objects from other objects also transfer " "ownership with the reference, for instance :c:func:" @@ -1418,14 +1638,14 @@ msgid "" "list or dictionary." msgstr "" -#: ../../extending/extending.rst:981 +#: ../../extending/extending.rst:1009 msgid "" "The function :c:func:`PyImport_AddModule` also returns a borrowed reference, " "even though it may actually create the object it returns: this is possible " "because an owned reference to the object is stored in ``sys.modules``." msgstr "" -#: ../../extending/extending.rst:985 +#: ../../extending/extending.rst:1013 msgid "" "When you pass an object reference into another function, in general, the " "function borrows the reference from you --- if it needs to store it, it will " @@ -1436,7 +1656,7 @@ msgid "" "don't take over ownership --- they are \"normal.\")" msgstr "" -#: ../../extending/extending.rst:993 +#: ../../extending/extending.rst:1021 msgid "" "When a C function is called from Python, it borrows references to its " "arguments from the caller. The caller owns a reference to the object, so " @@ -1445,18 +1665,18 @@ msgid "" "turned into an owned reference by calling :c:func:`Py_INCREF`." msgstr "" -#: ../../extending/extending.rst:999 +#: ../../extending/extending.rst:1027 msgid "" "The object reference returned from a C function that is called from Python " "must be an owned reference --- ownership is transferred from the function to " "its caller." msgstr "" -#: ../../extending/extending.rst:1007 +#: ../../extending/extending.rst:1035 msgid "Thin Ice" msgstr "" -#: ../../extending/extending.rst:1009 +#: ../../extending/extending.rst:1037 msgid "" "There are a few situations where seemingly harmless use of a borrowed " "reference can lead to problems. These all have to do with implicit " @@ -1464,14 +1684,14 @@ msgid "" "dispose of it." msgstr "" -#: ../../extending/extending.rst:1013 +#: ../../extending/extending.rst:1041 msgid "" "The first and most important case to know about is using :c:func:`Py_DECREF` " "on an unrelated object while borrowing a reference to a list item. For " "instance::" msgstr "" -#: ../../extending/extending.rst:1016 +#: ../../extending/extending.rst:1044 msgid "" "void\n" "bug(PyObject *list)\n" @@ -1491,14 +1711,14 @@ msgstr "" " PyObject_Print(item, stdout, 0); /* BUG! */\n" "}" -#: ../../extending/extending.rst:1025 +#: ../../extending/extending.rst:1053 msgid "" "This function first borrows a reference to ``list[0]``, then replaces " "``list[1]`` with the value ``0``, and finally prints the borrowed reference. " "Looks harmless, right? But it's not!" msgstr "" -#: ../../extending/extending.rst:1029 +#: ../../extending/extending.rst:1057 msgid "" "Let's follow the control flow into :c:func:`PyList_SetItem`. The list owns " "references to all its items, so when item 1 is replaced, it has to dispose " @@ -1508,7 +1728,7 @@ msgid "" "count of 1, disposing of it will call its :meth:`!__del__` method." msgstr "" -#: ../../extending/extending.rst:1036 +#: ../../extending/extending.rst:1064 msgid "" "Since it is written in Python, the :meth:`!__del__` method can execute " "arbitrary Python code. Could it perhaps do something to invalidate the " @@ -1519,13 +1739,13 @@ msgid "" "associated with it, thereby invalidating ``item``." msgstr "" -#: ../../extending/extending.rst:1044 +#: ../../extending/extending.rst:1072 msgid "" "The solution, once you know the source of the problem, is easy: temporarily " "increment the reference count. The correct version of the function reads::" msgstr "" -#: ../../extending/extending.rst:1047 +#: ../../extending/extending.rst:1075 msgid "" "void\n" "no_bug(PyObject *list)\n" @@ -1549,27 +1769,27 @@ msgstr "" " Py_DECREF(item);\n" "}" -#: ../../extending/extending.rst:1058 +#: ../../extending/extending.rst:1086 msgid "" "This is a true story. An older version of Python contained variants of this " "bug and someone spent a considerable amount of time in a C debugger to " "figure out why his :meth:`!__del__` methods would fail..." msgstr "" -#: ../../extending/extending.rst:1062 +#: ../../extending/extending.rst:1090 msgid "" "The second case of problems with a borrowed reference is a variant involving " "threads. Normally, multiple threads in the Python interpreter can't get in " -"each other's way, because there is a global lock protecting Python's entire " -"object space. However, it is possible to temporarily release this lock " -"using the macro :c:macro:`Py_BEGIN_ALLOW_THREADS`, and to re-acquire it " -"using :c:macro:`Py_END_ALLOW_THREADS`. This is common around blocking I/O " -"calls, to let other threads use the processor while waiting for the I/O to " -"complete. Obviously, the following function has the same problem as the " -"previous one::" +"each other's way, because there is a :term:`global lock ` protecting Python's entire object space. However, it is possible to " +"temporarily release this lock using the macro :c:macro:" +"`Py_BEGIN_ALLOW_THREADS`, and to re-acquire it using :c:macro:" +"`Py_END_ALLOW_THREADS`. This is common around blocking I/O calls, to let " +"other threads use the processor while waiting for the I/O to complete. " +"Obviously, the following function has the same problem as the previous one::" msgstr "" -#: ../../extending/extending.rst:1071 +#: ../../extending/extending.rst:1100 msgid "" "void\n" "bug(PyObject *list)\n" @@ -1582,11 +1802,11 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:1085 +#: ../../extending/extending.rst:1114 msgid "NULL Pointers" msgstr "NULL 指標" -#: ../../extending/extending.rst:1087 +#: ../../extending/extending.rst:1116 msgid "" "In general, functions that take object references as arguments do not expect " "you to pass them ``NULL`` pointers, and will dump core (or cause later core " @@ -1598,21 +1818,21 @@ msgid "" "more slowly." msgstr "" -#: ../../extending/extending.rst:1095 +#: ../../extending/extending.rst:1124 msgid "" "It is better to test for ``NULL`` only at the \"source:\" when a pointer " "that may be ``NULL`` is received, for example, from :c:func:`malloc` or from " "a function that may raise an exception." msgstr "" -#: ../../extending/extending.rst:1099 +#: ../../extending/extending.rst:1128 msgid "" "The macros :c:func:`Py_INCREF` and :c:func:`Py_DECREF` do not check for " "``NULL`` pointers --- however, their variants :c:func:`Py_XINCREF` and :c:" "func:`Py_XDECREF` do." msgstr "" -#: ../../extending/extending.rst:1103 +#: ../../extending/extending.rst:1132 msgid "" "The macros for checking for a particular object type (``Pytype_Check()``) " "don't check for ``NULL`` pointers --- again, there is much code that calls " @@ -1621,24 +1841,24 @@ msgid "" "variants with ``NULL`` checking." msgstr "" -#: ../../extending/extending.rst:1109 +#: ../../extending/extending.rst:1138 msgid "" "The C function calling mechanism guarantees that the argument list passed to " "C functions (``args`` in the examples) is never ``NULL`` --- in fact it " "guarantees that it is always a tuple [#]_." msgstr "" -#: ../../extending/extending.rst:1113 +#: ../../extending/extending.rst:1142 msgid "" "It is a severe error to ever let a ``NULL`` pointer \"escape\" to the Python " "user." msgstr "" -#: ../../extending/extending.rst:1124 +#: ../../extending/extending.rst:1153 msgid "Writing Extensions in C++" msgstr "" -#: ../../extending/extending.rst:1126 +#: ../../extending/extending.rst:1155 msgid "" "It is possible to write extension modules in C++. Some restrictions apply. " "If the main program (the Python interpreter) is compiled and linked by the C " @@ -1651,11 +1871,11 @@ msgid "" "(all recent C++ compilers define this symbol)." msgstr "" -#: ../../extending/extending.rst:1140 +#: ../../extending/extending.rst:1169 msgid "Providing a C API for an Extension Module" msgstr "" -#: ../../extending/extending.rst:1145 +#: ../../extending/extending.rst:1174 msgid "" "Many extension modules just provide new functions and types to be used from " "Python, but sometimes the code in an extension module can be useful for " @@ -1666,7 +1886,7 @@ msgid "" "functions for direct manipulation from other extension modules." msgstr "" -#: ../../extending/extending.rst:1153 +#: ../../extending/extending.rst:1182 msgid "" "At first sight this seems easy: just write the functions (without declaring " "them ``static``, of course), provide an appropriate header file, and " @@ -1682,7 +1902,7 @@ msgid "" "call might not have been loaded yet!" msgstr "" -#: ../../extending/extending.rst:1165 +#: ../../extending/extending.rst:1194 msgid "" "Portability therefore requires not to make any assumptions about symbol " "visibility. This means that all symbols in extension modules should be " @@ -1692,7 +1912,7 @@ msgid "" "accessible from other extension modules must be exported in a different way." msgstr "" -#: ../../extending/extending.rst:1172 +#: ../../extending/extending.rst:1201 msgid "" "Python provides a special mechanism to pass C-level information (pointers) " "from one extension module to another one: Capsules. A Capsule is a Python " @@ -1704,7 +1924,7 @@ msgid "" "the Capsule." msgstr "" -#: ../../extending/extending.rst:1180 +#: ../../extending/extending.rst:1209 msgid "" "There are many ways in which Capsules can be used to export the C API of an " "extension module. Each function could get its own Capsule, or all C API " @@ -1714,7 +1934,7 @@ msgid "" "client modules." msgstr "" -#: ../../extending/extending.rst:1186 +#: ../../extending/extending.rst:1215 msgid "" "Whichever method you choose, it's important to name your Capsules properly. " "The function :c:func:`PyCapsule_New` takes a name parameter (:c:expr:`const " @@ -1724,17 +1944,17 @@ msgid "" "from another." msgstr "" -#: ../../extending/extending.rst:1193 +#: ../../extending/extending.rst:1222 msgid "" "In particular, Capsules used to expose C APIs should be given a name " "following this convention::" msgstr "" -#: ../../extending/extending.rst:1196 +#: ../../extending/extending.rst:1225 msgid "modulename.attributename" msgstr "modulename.attributename" -#: ../../extending/extending.rst:1198 +#: ../../extending/extending.rst:1227 msgid "" "The convenience function :c:func:`PyCapsule_Import` makes it easy to load a " "C API provided via a Capsule, but only if the Capsule's name matches this " @@ -1742,7 +1962,7 @@ msgid "" "the Capsule they load contains the correct C API." msgstr "" -#: ../../extending/extending.rst:1203 +#: ../../extending/extending.rst:1232 msgid "" "The following example demonstrates an approach that puts most of the burden " "on the writer of the exporting module, which is appropriate for commonly " @@ -1753,7 +1973,7 @@ msgid "" "modules only have to call this macro before accessing the C API." msgstr "" -#: ../../extending/extending.rst:1211 +#: ../../extending/extending.rst:1240 msgid "" "The exporting module is a modification of the :mod:`!spam` module from " "section :ref:`extending-simpleexample`. The function :func:`!spam.system` " @@ -1764,13 +1984,13 @@ msgid "" "modules." msgstr "" -#: ../../extending/extending.rst:1218 +#: ../../extending/extending.rst:1247 msgid "" "The function :c:func:`!PySpam_System` is a plain C function, declared " "``static`` like everything else::" msgstr "" -#: ../../extending/extending.rst:1221 +#: ../../extending/extending.rst:1250 msgid "" "static int\n" "PySpam_System(const char *command)\n" @@ -1784,11 +2004,11 @@ msgstr "" " return system(command);\n" "}" -#: ../../extending/extending.rst:1227 +#: ../../extending/extending.rst:1256 msgid "The function :c:func:`!spam_system` is modified in a trivial way::" msgstr "" -#: ../../extending/extending.rst:1229 +#: ../../extending/extending.rst:1258 msgid "" "static PyObject *\n" "spam_system(PyObject *self, PyObject *args)\n" @@ -1814,19 +2034,19 @@ msgstr "" " return PyLong_FromLong(sts);\n" "}" -#: ../../extending/extending.rst:1241 +#: ../../extending/extending.rst:1270 msgid "In the beginning of the module, right after the line ::" msgstr "" -#: ../../extending/extending.rst:1243 +#: ../../extending/extending.rst:1272 msgid "#include " msgstr "#include " -#: ../../extending/extending.rst:1245 +#: ../../extending/extending.rst:1274 msgid "two more lines must be added::" msgstr "" -#: ../../extending/extending.rst:1247 +#: ../../extending/extending.rst:1276 msgid "" "#define SPAM_MODULE\n" "#include \"spammodule.h\"" @@ -1834,27 +2054,22 @@ msgstr "" "#define SPAM_MODULE\n" "#include \"spammodule.h\"" -#: ../../extending/extending.rst:1250 +#: ../../extending/extending.rst:1279 msgid "" "The ``#define`` is used to tell the header file that it is being included in " -"the exporting module, not a client module. Finally, the module's " -"initialization function must take care of initializing the C API pointer " -"array::" +"the exporting module, not a client module. Finally, the module's :c:data:" +"`mod_exec ` function must take care of initializing the C API " +"pointer array::" msgstr "" -#: ../../extending/extending.rst:1254 +#: ../../extending/extending.rst:1283 msgid "" -"PyMODINIT_FUNC\n" -"PyInit_spam(void)\n" +"static int\n" +"spam_module_exec(PyObject *m)\n" "{\n" -" PyObject *m;\n" " static void *PySpam_API[PySpam_API_pointers];\n" " PyObject *c_api_object;\n" "\n" -" m = PyModule_Create(&spammodule);\n" -" if (m == NULL)\n" -" return NULL;\n" -"\n" " /* Initialize the C API pointer array */\n" " PySpam_API[PySpam_System_NUM] = (void *)PySpam_System;\n" "\n" @@ -1862,29 +2077,27 @@ msgid "" " c_api_object = PyCapsule_New((void *)PySpam_API, \"spam._C_API\", " "NULL);\n" "\n" -" if (PyModule_AddObject(m, \"_C_API\", c_api_object) < 0) {\n" -" Py_XDECREF(c_api_object);\n" -" Py_DECREF(m);\n" -" return NULL;\n" +" if (PyModule_Add(m, \"_C_API\", c_api_object) < 0) {\n" +" return -1;\n" " }\n" "\n" -" return m;\n" +" return 0;\n" "}" msgstr "" -#: ../../extending/extending.rst:1280 +#: ../../extending/extending.rst:1302 msgid "" "Note that ``PySpam_API`` is declared ``static``; otherwise the pointer array " "would disappear when :c:func:`!PyInit_spam` terminates!" msgstr "" -#: ../../extending/extending.rst:1283 +#: ../../extending/extending.rst:1305 msgid "" "The bulk of the work is in the header file :file:`spammodule.h`, which looks " "like this::" msgstr "" -#: ../../extending/extending.rst:1286 +#: ../../extending/extending.rst:1308 msgid "" "#ifndef Py_SPAMMODULE_H\n" "#define Py_SPAMMODULE_H\n" @@ -1936,38 +2149,34 @@ msgid "" "#endif /* !defined(Py_SPAMMODULE_H) */" msgstr "" -#: ../../extending/extending.rst:1334 +#: ../../extending/extending.rst:1356 msgid "" "All that a client module must do in order to have access to the function :c:" "func:`!PySpam_System` is to call the function (or rather macro) :c:func:`!" -"import_spam` in its initialization function::" +"import_spam` in its :c:data:`mod_exec ` function::" msgstr "" -#: ../../extending/extending.rst:1338 +#: ../../extending/extending.rst:1360 msgid "" -"PyMODINIT_FUNC\n" -"PyInit_client(void)\n" +"static int\n" +"client_module_exec(PyObject *m)\n" "{\n" -" PyObject *m;\n" -"\n" -" m = PyModule_Create(&clientmodule);\n" -" if (m == NULL)\n" -" return NULL;\n" -" if (import_spam() < 0)\n" -" return NULL;\n" +" if (import_spam() < 0) {\n" +" return -1;\n" +" }\n" " /* additional initialization can happen here */\n" -" return m;\n" +" return 0;\n" "}" msgstr "" -#: ../../extending/extending.rst:1352 +#: ../../extending/extending.rst:1370 msgid "" "The main disadvantage of this approach is that the file :file:`spammodule.h` " "is rather complicated. However, the basic structure is the same for each " "function that is exported, so it has to be learned only once." msgstr "" -#: ../../extending/extending.rst:1356 +#: ../../extending/extending.rst:1374 msgid "" "Finally it should be mentioned that Capsules offer additional functionality, " "which is especially useful for memory allocation and deallocation of the " @@ -1977,47 +2186,157 @@ msgid "" "in the Python source code distribution)." msgstr "" -#: ../../extending/extending.rst:1364 +#: ../../extending/extending.rst:1382 msgid "Footnotes" -msgstr "註解" +msgstr "註腳" -#: ../../extending/extending.rst:1365 +#: ../../extending/extending.rst:1383 msgid "" "An interface for this function already exists in the standard module :mod:" "`os` --- it was chosen as a simple and straightforward example." msgstr "" -#: ../../extending/extending.rst:1368 +#: ../../extending/extending.rst:1386 msgid "" "The metaphor of \"borrowing\" a reference is not completely correct: the " "owner still has a copy of the reference." msgstr "" -#: ../../extending/extending.rst:1371 +#: ../../extending/extending.rst:1389 msgid "" "Checking that the reference count is at least 1 **does not work** --- the " "reference count itself could be in freed memory and may thus be reused for " "another object!" msgstr "" -#: ../../extending/extending.rst:1375 +#: ../../extending/extending.rst:1393 msgid "" "These guarantees don't hold when you use the \"old\" style calling " "convention --- this is still found in much existing code." msgstr "" -#: ../../extending/extending.rst:539 +#: ../../extending/extending.rst:568 msgid "PyObject_CallObject (C function)" msgstr "PyObject_CallObject(C 函式)" -#: ../../extending/extending.rst:630 +#: ../../extending/extending.rst:659 msgid "PyArg_ParseTuple (C function)" msgstr "PyArg_ParseTuple(C 函式)" -#: ../../extending/extending.rst:722 +#: ../../extending/extending.rst:751 msgid "PyArg_ParseTupleAndKeywords (C function)" msgstr "PyArg_ParseTupleAndKeywords(C 函式)" -#: ../../extending/extending.rst:743 +#: ../../extending/extending.rst:772 msgid "Philbrick, Geoff" msgstr "Philbrick, Geoff" + +#~ msgid "" +#~ "and initialize it in your module's initialization function (:c:func:`!" +#~ "PyInit_spam`) with an exception object::" +#~ msgstr "" +#~ "並在你的模組初始化函式中使用一個例外物件來初始化它 (:c:func:`!" +#~ "PyInit_spam`): ::" + +#~ msgid "" +#~ "PyMODINIT_FUNC\n" +#~ "PyInit_spam(void)\n" +#~ "{\n" +#~ " PyObject *m;\n" +#~ "\n" +#~ " m = PyModule_Create(&spammodule);\n" +#~ " if (m == NULL)\n" +#~ " return NULL;\n" +#~ "\n" +#~ " SpamError = PyErr_NewException(\"spam.error\", NULL, NULL);\n" +#~ " if (PyModule_AddObjectRef(m, \"error\", SpamError) < 0) {\n" +#~ " Py_CLEAR(SpamError);\n" +#~ " Py_DECREF(m);\n" +#~ " return NULL;\n" +#~ " }\n" +#~ "\n" +#~ " return m;\n" +#~ "}" +#~ msgstr "" +#~ "PyMODINIT_FUNC\n" +#~ "PyInit_spam(void)\n" +#~ "{\n" +#~ " PyObject *m;\n" +#~ "\n" +#~ " m = PyModule_Create(&spammodule);\n" +#~ " if (m == NULL)\n" +#~ " return NULL;\n" +#~ "\n" +#~ " SpamError = PyErr_NewException(\"spam.error\", NULL, NULL);\n" +#~ " if (PyModule_AddObjectRef(m, \"error\", SpamError) < 0) {\n" +#~ " Py_CLEAR(SpamError);\n" +#~ " Py_DECREF(m);\n" +#~ " return NULL;\n" +#~ " }\n" +#~ "\n" +#~ " return m;\n" +#~ "}" + +#~ msgid "" +#~ "static struct PyModuleDef spammodule = {\n" +#~ " PyModuleDef_HEAD_INIT,\n" +#~ " \"spam\", /* name of module */\n" +#~ " spam_doc, /* module documentation, may be NULL */\n" +#~ " -1, /* size of per-interpreter state of the module,\n" +#~ " or -1 if the module keeps state in global variables. */\n" +#~ " SpamMethods\n" +#~ "};" +#~ msgstr "" +#~ "static struct PyModuleDef spammodule = {\n" +#~ " PyModuleDef_HEAD_INIT,\n" +#~ " \"spam\", /* 模組名稱 */\n" +#~ " spam_doc, /* 模組文件,可能為 NULL */\n" +#~ " -1, /* 模組的個別直譯器狀態的大小,\n" +#~ " 如果模組將狀態保存在全域變數中則為 -1 */\n" +#~ " SpamMethods\n" +#~ "};" + +#~ msgid "" +#~ "When the Python program imports module :mod:`!spam` for the first time, :" +#~ "c:func:`!PyInit_spam` is called. (See below for comments about embedding " +#~ "Python.) It calls :c:func:`PyModule_Create`, which returns a module " +#~ "object, and inserts built-in function objects into the newly created " +#~ "module based upon the table (an array of :c:type:`PyMethodDef` " +#~ "structures) found in the module definition. :c:func:`PyModule_Create` " +#~ "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``." +#~ msgstr "" +#~ "當 Python 程式第一次引入模組 :mod:`!spam` 時,:c:func:`!PyInit_spam` 會被" +#~ "呼叫。(有關嵌入 Python 的註解請參見下文。)它會呼叫回傳一個模組物件的 :c:" +#~ "func:`PyModule_Create`,並根據在模組定義中所找到的表(一個 :c:type:" +#~ "`PyMethodDef` 結構的陣列)將內建的函式物件插入到新建立的模組中。:c:func:" +#~ "`PyModule_Create` 會回傳一個指向它建立之模組物件的指標。對於某些錯誤情況," +#~ "它可能會以嚴重錯誤的形式來中止;如果模組無法令人滿意地被初始化,它也會回" +#~ "傳 ``NULL``。初始化函式必須把模組物件回傳給它的呼叫者,這樣它才會被插入到 " +#~ "``sys.modules`` 中。" + +#~ msgid "" +#~ "Removing entries from ``sys.modules`` or importing compiled modules into " +#~ "multiple interpreters within a process (or following a :c:func:`fork` " +#~ "without an intervening :c:func:`exec`) can create problems for some " +#~ "extension modules. Extension module authors should exercise caution when " +#~ "initializing internal data structures." +#~ msgstr "" +#~ "從 ``sys.modules`` 中移除項目,或在一個行程中將已編譯模組引入到多個直譯器" +#~ "中(或在沒有 :c:func:`exec` 介入的情況下使用 :c:func:`fork`)可能會對某些" +#~ "擴充模組造成問題。擴充模組作者在初始化內部資料結構時應特別小心。" + +#~ msgid "" +#~ "Unlike our ``spam`` example, ``xxmodule`` uses *multi-phase " +#~ "initialization* (new in Python 3.5), where a PyModuleDef structure is " +#~ "returned from ``PyInit_spam``, and creation of the module is left to the " +#~ "import machinery. For details on multi-phase initialization, see :PEP:" +#~ "`489`." +#~ msgstr "" +#~ "不像我們的 ``spam`` 範例,``xxmodule`` 使用了\\ *多階段初始化 (multi-" +#~ "phase initialization)*\\ (Python 3.5 新增),其中的 PyModuleDef 結構會從 " +#~ "``PyInit_spam`` 回傳,而模組的建立則交由引入機制來完成。關於多階段初始化的" +#~ "詳細資訊請參閱 :PEP:`489`。" diff --git a/extending/index.po b/extending/index.po index 51fce044dc..757994de4f 100644 --- a/extending/index.po +++ b/extending/index.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Steven Hsu , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-04-18 00:04+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2021-07-06 22:18+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -66,39 +65,19 @@ msgstr "推薦的第三方工具" #: ../../extending/index.rst:28 msgid "" "This guide only covers the basic tools for creating extensions provided as " -"part of this version of CPython. Third party tools like `Cython `_, `cffi `_, `SWIG `_ and `Numba `_ offer both simpler and " -"more sophisticated approaches to creating C and C++ extensions for Python." +"part of this version of CPython. Some :ref:`third party tools ` " +"offer both simpler and more sophisticated approaches to creating C and C++ " +"extensions for Python." msgstr "" -"這份指南僅涵蓋了此 CPython 版本所提供的、用以建立擴充的基本工具。第三方工具," -"例如 `Cython `_、`cffi `_、" -"`SWIG `_ 和 `Numba `_,提供" -"了更為簡單及更為複雜的多種方法,來為 Python 建立 C 和 C ++ 擴充。" +"這份指南僅涵蓋了此 CPython 版本所提供的、用以建立擴充的基本工具。有一些\\ " +":ref:`第三方工具 `,提供了更為簡單及更為複雜的多種方法,來為 Python 建立 " +"C 和 C++ 擴充。" -#: ../../extending/index.rst:37 -msgid "" -"`Python Packaging User Guide: Binary Extensions `_" -msgstr "" -"`Python 封裝使用者指南:二進制擴充 `_" - -#: ../../extending/index.rst:38 -msgid "" -"The Python Packaging User Guide not only covers several available tools that " -"simplify the creation of binary extensions, but also discusses the various " -"reasons why creating an extension module may be desirable in the first place." -msgstr "" -"Python 封裝使用者指南 (Python Packaging User Guide) 不僅涵蓋了數個可以用來簡" -"化二進制擴充建立過程的工具,也會討論為何建立一個擴充模組可能會是你的優先考" -"量。" - -#: ../../extending/index.rst:45 +#: ../../extending/index.rst:35 msgid "Creating extensions without third party tools" msgstr "不使用第三方工具建立擴充" -#: ../../extending/index.rst:47 +#: ../../extending/index.rst:37 msgid "" "This section of the guide covers creating C and C++ extensions without " "assistance from third party tools. It is intended primarily for creators of " @@ -108,11 +87,15 @@ msgstr "" "本指南中的這一節將說明,在沒有第三方工具的協助下,如何建立 C 和 C ++ 擴充。它" "主要是寫給使用那些工具的創作者們,而不是讓你建立自己的 C 擴充的推薦方法。" -#: ../../extending/index.rst:63 +#: ../../extending/index.rst:44 +msgid ":pep:`489` -- Multi-phase extension module initialization" +msgstr ":pep:`489` -- 多階段擴充模組初始化" + +#: ../../extending/index.rst:57 msgid "Embedding the CPython runtime in a larger application" msgstr "在更大的應用程式中嵌入 CPython 運行環境 (runtime)" -#: ../../extending/index.rst:65 +#: ../../extending/index.rst:59 msgid "" "Sometimes, rather than creating an extension that runs inside the Python " "interpreter as the main application, it is desirable to instead embed the " @@ -122,3 +105,20 @@ msgstr "" "有時候,相較於建立一個擴充,使其在 Python 直譯器中可作為主應用程式運行,還不" "如將 CPython 運行環境嵌入至一個更大的應用程式中更可取。本節將涵蓋一些要成功完" "成此任務所涉及的細節。" + +#~ msgid "" +#~ "`Python Packaging User Guide: Binary Extensions `_" +#~ msgstr "" +#~ "`Python 封裝使用者指南:二進制擴充 `_" + +#~ msgid "" +#~ "The Python Packaging User Guide not only covers several available tools " +#~ "that simplify the creation of binary extensions, but also discusses the " +#~ "various reasons why creating an extension module may be desirable in the " +#~ "first place." +#~ msgstr "" +#~ "Python 封裝使用者指南 (Python Packaging User Guide) 不僅涵蓋了數個可以用來" +#~ "簡化二進制擴充建立過程的工具,也會討論為何建立一個擴充模組可能會是你的優先" +#~ "考量。" diff --git a/extending/newtypes.po b/extending/newtypes.po index 9a479f42c9..7029e57821 100644 --- a/extending/newtypes.po +++ b/extending/newtypes.po @@ -6,9 +6,9 @@ # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-09-27 00:14+0000\n" "PO-Revision-Date: 2018-05-23 14:34+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -561,7 +561,7 @@ msgid "" "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 :attr:" -"`!__doc__` attribute." +"`~type.__doc__` attribute." msgstr "" #: ../../extending/newtypes.rst:301 @@ -775,7 +775,7 @@ msgstr "" #: ../../extending/newtypes.rst:451 msgid "" -":c:type:`!Py_hash_t` is a signed integer type with a platform-varying width. " +":c:type:`Py_hash_t` is a signed integer type with a platform-varying width. " "Returning ``-1`` from :c:member:`~PyTypeObject.tp_hash` indicates an error, " "which is why you should be careful to avoid returning it when hash " "computation is successful, as seen above." diff --git a/extending/newtypes_tutorial.po b/extending/newtypes_tutorial.po index 676dd1c7d3..525d9b3a7b 100644 --- a/extending/newtypes_tutorial.po +++ b/extending/newtypes_tutorial.po @@ -2,9 +2,9 @@ # This file is distributed under the same license as the Python package. msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-07-15 18:56+0800\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -84,32 +84,41 @@ msgid "" " .tp_new = PyType_GenericNew,\n" "};\n" "\n" -"static PyModuleDef custommodule = {\n" +"static int\n" +"custom_module_exec(PyObject *m)\n" +"{\n" +" if (PyType_Ready(&CustomType) < 0) {\n" +" return -1;\n" +" }\n" +"\n" +" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " +"{\n" +" return -1;\n" +" }\n" +"\n" +" return 0;\n" +"}\n" +"\n" +"static PyModuleDef_Slot custom_module_slots[] = {\n" +" {Py_mod_exec, custom_module_exec},\n" +" // Just use this while using static types\n" +" {Py_mod_multiple_interpreters, " +"Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},\n" +" {0, NULL}\n" +"};\n" +"\n" +"static PyModuleDef custom_module = {\n" " .m_base = PyModuleDef_HEAD_INIT,\n" " .m_name = \"custom\",\n" " .m_doc = \"Example module that creates an extension type.\",\n" -" .m_size = -1,\n" +" .m_size = 0,\n" +" .m_slots = custom_module_slots,\n" "};\n" "\n" "PyMODINIT_FUNC\n" "PyInit_custom(void)\n" "{\n" -" PyObject *m;\n" -" if (PyType_Ready(&CustomType) < 0)\n" -" return NULL;\n" -"\n" -" m = PyModule_Create(&custommodule);\n" -" if (m == NULL)\n" -" return NULL;\n" -"\n" -" Py_INCREF(&CustomType);\n" -" if (PyModule_AddObject(m, \"Custom\", (PyObject *) &CustomType) < 0) {\n" -" Py_DECREF(&CustomType);\n" -" Py_DECREF(m);\n" -" return NULL;\n" -" }\n" -"\n" -" return m;\n" +" return PyModuleDef_Init(&custom_module);\n" "}\n" msgstr "" @@ -134,15 +143,17 @@ msgstr "" #: ../../extending/newtypes_tutorial.rst:58 msgid "" -"How to initialize the :mod:`!custom` module: this is the ``PyInit_custom`` " -"function and the associated ``custommodule`` struct." +"How to define and execute the :mod:`!custom` module: this is the " +"``PyInit_custom`` function and the associated ``custom_module`` struct for " +"defining the module, and the ``custom_module_exec`` function to set up a " +"fresh module object." msgstr "" -#: ../../extending/newtypes_tutorial.rst:61 +#: ../../extending/newtypes_tutorial.rst:63 msgid "The first bit is::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:63 +#: ../../extending/newtypes_tutorial.rst:65 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -152,7 +163,7 @@ msgstr "" " PyObject_HEAD\n" "} CustomObject;" -#: ../../extending/newtypes_tutorial.rst:67 +#: ../../extending/newtypes_tutorial.rst:69 msgid "" "This is what a Custom object will contain. ``PyObject_HEAD`` is mandatory " "at the start of each object struct and defines a field called ``ob_base`` of " @@ -163,20 +174,20 @@ msgid "" "builds `." msgstr "" -#: ../../extending/newtypes_tutorial.rst:76 +#: ../../extending/newtypes_tutorial.rst:78 msgid "" "There is no semicolon above after the :c:macro:`PyObject_HEAD` macro. Be " "wary of adding one by accident: some compilers will complain." msgstr "" -#: ../../extending/newtypes_tutorial.rst:79 +#: ../../extending/newtypes_tutorial.rst:81 msgid "" "Of course, objects generally store additional data besides the standard " "``PyObject_HEAD`` boilerplate; for example, here is the definition for " "standard Python floats::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:83 +#: ../../extending/newtypes_tutorial.rst:85 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -188,11 +199,11 @@ msgstr "" " double ob_fval;\n" "} PyFloatObject;" -#: ../../extending/newtypes_tutorial.rst:88 +#: ../../extending/newtypes_tutorial.rst:90 msgid "The second bit is the definition of the type object. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:90 +#: ../../extending/newtypes_tutorial.rst:92 msgid "" "static PyTypeObject CustomType = {\n" " .ob_base = PyVarObject_HEAD_INIT(NULL, 0)\n" @@ -214,14 +225,14 @@ msgstr "" " .tp_new = PyType_GenericNew,\n" "};" -#: ../../extending/newtypes_tutorial.rst:101 +#: ../../extending/newtypes_tutorial.rst:103 msgid "" "We recommend using C99-style designated initializers as above, to avoid " "listing all the :c:type:`PyTypeObject` fields that you don't care about and " "also to avoid caring about the fields' declaration order." msgstr "" -#: ../../extending/newtypes_tutorial.rst:105 +#: ../../extending/newtypes_tutorial.rst:107 msgid "" "The actual definition of :c:type:`PyTypeObject` in :file:`object.h` has many " "more :ref:`fields ` than the definition above. The remaining " @@ -229,31 +240,31 @@ msgid "" "to not specify them explicitly unless you need them." msgstr "" -#: ../../extending/newtypes_tutorial.rst:110 +#: ../../extending/newtypes_tutorial.rst:112 msgid "We're going to pick it apart, one field at a time::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:112 +#: ../../extending/newtypes_tutorial.rst:114 msgid ".ob_base = PyVarObject_HEAD_INIT(NULL, 0)" msgstr ".ob_base = PyVarObject_HEAD_INIT(NULL, 0)" -#: ../../extending/newtypes_tutorial.rst:114 +#: ../../extending/newtypes_tutorial.rst:116 msgid "" "This line is mandatory boilerplate to initialize the ``ob_base`` field " "mentioned above. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:117 +#: ../../extending/newtypes_tutorial.rst:119 msgid ".tp_name = \"custom.Custom\"," msgstr ".tp_name = \"custom.Custom\"," -#: ../../extending/newtypes_tutorial.rst:119 +#: ../../extending/newtypes_tutorial.rst:121 msgid "" "The name of our type. This will appear in the default textual " "representation of our objects and in some error messages, for example:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:122 +#: ../../extending/newtypes_tutorial.rst:124 msgid "" ">>> \"\" + custom.Custom()\n" "Traceback (most recent call last):\n" @@ -261,7 +272,7 @@ msgid "" "TypeError: can only concatenate str (not \"custom.Custom\") to str" msgstr "" -#: ../../extending/newtypes_tutorial.rst:129 +#: ../../extending/newtypes_tutorial.rst:131 msgid "" "Note that the name is a dotted name that includes both the module name and " "the name of the type within the module. The module in this case is :mod:`!" @@ -270,7 +281,7 @@ msgid "" "your type compatible with the :mod:`pydoc` and :mod:`pickle` modules. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:135 +#: ../../extending/newtypes_tutorial.rst:137 msgid "" ".tp_basicsize = sizeof(CustomObject),\n" ".tp_itemsize = 0," @@ -278,20 +289,20 @@ msgstr "" ".tp_basicsize = sizeof(CustomObject),\n" ".tp_itemsize = 0," -#: ../../extending/newtypes_tutorial.rst:138 +#: ../../extending/newtypes_tutorial.rst:140 msgid "" "This is so that Python knows how much memory to allocate when creating new :" "class:`!Custom` instances. :c:member:`~PyTypeObject.tp_itemsize` is only " "used for variable-sized objects and should otherwise be zero." msgstr "" -#: ../../extending/newtypes_tutorial.rst:144 +#: ../../extending/newtypes_tutorial.rst:146 msgid "" "If you want your type to be subclassable from Python, and your type has the " "same :c:member:`~PyTypeObject.tp_basicsize` as its base type, you may have " "problems with multiple inheritance. A Python subclass of your type will " -"have to list your type first in its :attr:`~class.__bases__`, or else it " -"will not be able to call your type's :meth:`~object.__new__` method without " +"have to list your type first in its :attr:`~type.__bases__`, or else it will " +"not be able to call your type's :meth:`~object.__new__` method without " "getting an error. You can avoid this problem by ensuring that your type has " "a larger value for :c:member:`~PyTypeObject.tp_basicsize` than its base type " "does. Most of the time, this will be true anyway, because either your base " @@ -299,31 +310,31 @@ msgid "" "your base type, and therefore increasing its size." msgstr "" -#: ../../extending/newtypes_tutorial.rst:154 +#: ../../extending/newtypes_tutorial.rst:156 msgid "We set the class flags to :c:macro:`Py_TPFLAGS_DEFAULT`. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:156 +#: ../../extending/newtypes_tutorial.rst:158 msgid ".tp_flags = Py_TPFLAGS_DEFAULT," msgstr ".tp_flags = Py_TPFLAGS_DEFAULT," -#: ../../extending/newtypes_tutorial.rst:158 +#: ../../extending/newtypes_tutorial.rst:160 msgid "" "All types should include this constant in their flags. It enables all of " "the members defined until at least Python 3.3. If you need further members, " "you will need to OR the corresponding flags." msgstr "" -#: ../../extending/newtypes_tutorial.rst:162 +#: ../../extending/newtypes_tutorial.rst:164 msgid "" "We provide a doc string for the type in :c:member:`~PyTypeObject.tp_doc`. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:164 +#: ../../extending/newtypes_tutorial.rst:166 msgid ".tp_doc = PyDoc_STR(\"Custom objects\")," msgstr ".tp_doc = PyDoc_STR(\"Custom objects\")," -#: ../../extending/newtypes_tutorial.rst:166 +#: ../../extending/newtypes_tutorial.rst:168 msgid "" "To enable object creation, we have to provide a :c:member:`~PyTypeObject." "tp_new` handler. This is the equivalent of the Python method :meth:`~object." @@ -332,45 +343,41 @@ msgid "" "`PyType_GenericNew`. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:171 +#: ../../extending/newtypes_tutorial.rst:173 msgid ".tp_new = PyType_GenericNew," msgstr ".tp_new = PyType_GenericNew," -#: ../../extending/newtypes_tutorial.rst:173 +#: ../../extending/newtypes_tutorial.rst:175 msgid "" "Everything else in the file should be familiar, except for some code in :c:" -"func:`!PyInit_custom`::" +"func:`!custom_module_exec`::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:176 +#: ../../extending/newtypes_tutorial.rst:178 msgid "" -"if (PyType_Ready(&CustomType) < 0)\n" -" return;" +"if (PyType_Ready(&CustomType) < 0) {\n" +" return -1;\n" +"}" msgstr "" -"if (PyType_Ready(&CustomType) < 0)\n" -" return;" +"if (PyType_Ready(&CustomType) < 0) {\n" +" return -1;\n" +"}" -#: ../../extending/newtypes_tutorial.rst:179 +#: ../../extending/newtypes_tutorial.rst:182 msgid "" "This initializes the :class:`!Custom` type, filling in a number of members " "to the appropriate default values, including :c:member:`~PyObject.ob_type` " "that we initially set to ``NULL``. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:183 +#: ../../extending/newtypes_tutorial.rst:186 msgid "" -"Py_INCREF(&CustomType);\n" -"if (PyModule_AddObject(m, \"Custom\", (PyObject *) &CustomType) < 0) {\n" -" Py_DECREF(&CustomType);\n" -" Py_DECREF(m);\n" -" return NULL;\n" +"if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) {\n" +" return -1;\n" "}" msgstr "" -"Py_INCREF(&CustomType);\n" -"if (PyModule_AddObject(m, \"Custom\", (PyObject *) &CustomType) < 0) {\n" -" Py_DECREF(&CustomType);\n" -" Py_DECREF(m);\n" -" return NULL;\n" +"if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) {\n" +" return -1;\n" "}" #: ../../extending/newtypes_tutorial.rst:190 @@ -567,31 +574,40 @@ msgid "" " .tp_methods = Custom_methods,\n" "};\n" "\n" -"static PyModuleDef custommodule = {\n" -" .m_base =PyModuleDef_HEAD_INIT,\n" +"static int\n" +"custom_module_exec(PyObject *m)\n" +"{\n" +" if (PyType_Ready(&CustomType) < 0) {\n" +" return -1;\n" +" }\n" +"\n" +" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " +"{\n" +" return -1;\n" +" }\n" +"\n" +" return 0;\n" +"}\n" +"\n" +"static PyModuleDef_Slot custom_module_slots[] = {\n" +" {Py_mod_exec, custom_module_exec},\n" +" {Py_mod_multiple_interpreters, " +"Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},\n" +" {0, NULL}\n" +"};\n" +"\n" +"static PyModuleDef custom_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" " .m_name = \"custom2\",\n" " .m_doc = \"Example module that creates an extension type.\",\n" -" .m_size = -1,\n" +" .m_size = 0,\n" +" .m_slots = custom_module_slots,\n" "};\n" "\n" "PyMODINIT_FUNC\n" "PyInit_custom2(void)\n" "{\n" -" PyObject *m;\n" -" if (PyType_Ready(&CustomType) < 0)\n" -" return NULL;\n" -"\n" -" m = PyModule_Create(&custommodule);\n" -" if (m == NULL)\n" -" return NULL;\n" -"\n" -" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " -"{\n" -" Py_DECREF(m);\n" -" return NULL;\n" -" }\n" -"\n" -" return m;\n" +" return PyModuleDef_Init(&custom_module);\n" "}\n" msgstr "" @@ -1279,31 +1295,40 @@ msgid "" " .tp_getset = Custom_getsetters,\n" "};\n" "\n" -"static PyModuleDef custommodule = {\n" +"static int\n" +"custom_module_exec(PyObject *m)\n" +"{\n" +" if (PyType_Ready(&CustomType) < 0) {\n" +" return -1;\n" +" }\n" +"\n" +" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " +"{\n" +" return -1;\n" +" }\n" +"\n" +" return 0;\n" +"}\n" +"\n" +"static PyModuleDef_Slot custom_module_slots[] = {\n" +" {Py_mod_exec, custom_module_exec},\n" +" {Py_mod_multiple_interpreters, " +"Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},\n" +" {0, NULL}\n" +"};\n" +"\n" +"static PyModuleDef custom_module = {\n" " .m_base = PyModuleDef_HEAD_INIT,\n" " .m_name = \"custom3\",\n" " .m_doc = \"Example module that creates an extension type.\",\n" -" .m_size = -1,\n" +" .m_size = 0,\n" +" .m_slots = custom_module_slots,\n" "};\n" "\n" "PyMODINIT_FUNC\n" "PyInit_custom3(void)\n" "{\n" -" PyObject *m;\n" -" if (PyType_Ready(&CustomType) < 0)\n" -" return NULL;\n" -"\n" -" m = PyModule_Create(&custommodule);\n" -" if (m == NULL)\n" -" return NULL;\n" -"\n" -" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " -"{\n" -" Py_DECREF(m);\n" -" return NULL;\n" -" }\n" -"\n" -" return m;\n" +" return PyModuleDef_Init(&custom_module);\n" "}\n" msgstr "" @@ -1687,31 +1712,40 @@ msgid "" " .tp_getset = Custom_getsetters,\n" "};\n" "\n" -"static PyModuleDef custommodule = {\n" +"static int\n" +"custom_module_exec(PyObject *m)\n" +"{\n" +" if (PyType_Ready(&CustomType) < 0) {\n" +" return -1;\n" +" }\n" +"\n" +" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " +"{\n" +" return -1;\n" +" }\n" +"\n" +" return 0;\n" +"}\n" +"\n" +"static PyModuleDef_Slot custom_module_slots[] = {\n" +" {Py_mod_exec, custom_module_exec},\n" +" {Py_mod_multiple_interpreters, " +"Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},\n" +" {0, NULL}\n" +"};\n" +"\n" +"static PyModuleDef custom_module = {\n" " .m_base = PyModuleDef_HEAD_INIT,\n" " .m_name = \"custom4\",\n" " .m_doc = \"Example module that creates an extension type.\",\n" -" .m_size = -1,\n" +" .m_size = 0,\n" +" .m_slots = custom_module_slots,\n" "};\n" "\n" "PyMODINIT_FUNC\n" "PyInit_custom4(void)\n" "{\n" -" PyObject *m;\n" -" if (PyType_Ready(&CustomType) < 0)\n" -" return NULL;\n" -"\n" -" m = PyModule_Create(&custommodule);\n" -" if (m == NULL)\n" -" return NULL;\n" -"\n" -" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " -"{\n" -" Py_DECREF(m);\n" -" return NULL;\n" -" }\n" -"\n" -" return m;\n" +" return PyModuleDef_Init(&custom_module);\n" "}\n" msgstr "" @@ -1976,7 +2010,7 @@ msgid "" "}\n" "\n" "static PyTypeObject SubListType = {\n" -" PyVarObject_HEAD_INIT(NULL, 0)\n" +" .ob_base = PyVarObject_HEAD_INIT(NULL, 0)\n" " .tp_name = \"sublist.SubList\",\n" " .tp_doc = PyDoc_STR(\"SubList objects\"),\n" " .tp_basicsize = sizeof(SubListObject),\n" @@ -1986,34 +2020,41 @@ msgid "" " .tp_methods = SubList_methods,\n" "};\n" "\n" -"static PyModuleDef sublistmodule = {\n" -" PyModuleDef_HEAD_INIT,\n" +"static int\n" +"sublist_module_exec(PyObject *m)\n" +"{\n" +" SubListType.tp_base = &PyList_Type;\n" +" if (PyType_Ready(&SubListType) < 0) {\n" +" return -1;\n" +" }\n" +"\n" +" if (PyModule_AddObjectRef(m, \"SubList\", (PyObject *) &SubListType) < " +"0) {\n" +" return -1;\n" +" }\n" +"\n" +" return 0;\n" +"}\n" +"\n" +"static PyModuleDef_Slot sublist_module_slots[] = {\n" +" {Py_mod_exec, sublist_module_exec},\n" +" {Py_mod_multiple_interpreters, " +"Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},\n" +" {0, NULL}\n" +"};\n" +"\n" +"static PyModuleDef sublist_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" " .m_name = \"sublist\",\n" " .m_doc = \"Example module that creates an extension type.\",\n" -" .m_size = -1,\n" +" .m_size = 0,\n" +" .m_slots = sublist_module_slots,\n" "};\n" "\n" "PyMODINIT_FUNC\n" "PyInit_sublist(void)\n" "{\n" -" PyObject *m;\n" -" SubListType.tp_base = &PyList_Type;\n" -" if (PyType_Ready(&SubListType) < 0)\n" -" return NULL;\n" -"\n" -" m = PyModule_Create(&sublistmodule);\n" -" if (m == NULL)\n" -" return NULL;\n" -"\n" -" Py_INCREF(&SubListType);\n" -" if (PyModule_AddObject(m, \"SubList\", (PyObject *) &SubListType) < 0) " -"{\n" -" Py_DECREF(&SubListType);\n" -" Py_DECREF(m);\n" -" return NULL;\n" -" }\n" -"\n" -" return m;\n" +" return PyModuleDef_Init(&sublist_module);\n" "}\n" msgstr "" @@ -2090,59 +2131,44 @@ msgid "" "The :c:type:`PyTypeObject` struct supports a :c:member:`~PyTypeObject." "tp_base` specifying the type's concrete base class. Due to cross-platform " "compiler issues, you can't fill that field directly with a reference to :c:" -"type:`PyList_Type`; it should be done later in the module initialization " -"function::" +"type:`PyList_Type`; it should be done in the :c:data:`Py_mod_exec` function::" msgstr "" #: ../../extending/newtypes_tutorial.rst:853 msgid "" -"PyMODINIT_FUNC\n" -"PyInit_sublist(void)\n" +"static int\n" +"sublist_module_exec(PyObject *m)\n" "{\n" -" PyObject* m;\n" " SubListType.tp_base = &PyList_Type;\n" -" if (PyType_Ready(&SubListType) < 0)\n" -" return NULL;\n" -"\n" -" m = PyModule_Create(&sublistmodule);\n" -" if (m == NULL)\n" -" return NULL;\n" +" if (PyType_Ready(&SubListType) < 0) {\n" +" return -1;\n" +" }\n" "\n" -" Py_INCREF(&SubListType);\n" -" if (PyModule_AddObject(m, \"SubList\", (PyObject *) &SubListType) < 0) " -"{\n" -" Py_DECREF(&SubListType);\n" -" Py_DECREF(m);\n" -" return NULL;\n" +" if (PyModule_AddObjectRef(m, \"SubList\", (PyObject *) &SubListType) < " +"0) {\n" +" return -1;\n" " }\n" "\n" -" return m;\n" +" return 0;\n" "}" msgstr "" -"PyMODINIT_FUNC\n" -"PyInit_sublist(void)\n" +"static int\n" +"sublist_module_exec(PyObject *m)\n" "{\n" -" PyObject* m;\n" " SubListType.tp_base = &PyList_Type;\n" -" if (PyType_Ready(&SubListType) < 0)\n" -" return NULL;\n" -"\n" -" m = PyModule_Create(&sublistmodule);\n" -" if (m == NULL)\n" -" return NULL;\n" +" if (PyType_Ready(&SubListType) < 0) {\n" +" return -1;\n" +" }\n" "\n" -" Py_INCREF(&SubListType);\n" -" if (PyModule_AddObject(m, \"SubList\", (PyObject *) &SubListType) < 0) " -"{\n" -" Py_DECREF(&SubListType);\n" -" Py_DECREF(m);\n" -" return NULL;\n" +" if (PyModule_AddObjectRef(m, \"SubList\", (PyObject *) &SubListType) < " +"0) {\n" +" return -1;\n" " }\n" "\n" -" return m;\n" +" return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:875 +#: ../../extending/newtypes_tutorial.rst:868 msgid "" "Before calling :c:func:`PyType_Ready`, the type structure must have the :c:" "member:`~PyTypeObject.tp_base` slot filled in. When we are deriving an " @@ -2151,29 +2177,29 @@ msgid "" "from the base type will be inherited." msgstr "" -#: ../../extending/newtypes_tutorial.rst:881 +#: ../../extending/newtypes_tutorial.rst:874 msgid "" "After that, calling :c:func:`PyType_Ready` and adding the type object to the " "module is the same as with the basic :class:`!Custom` examples." msgstr "" -#: ../../extending/newtypes_tutorial.rst:886 +#: ../../extending/newtypes_tutorial.rst:879 msgid "Footnotes" -msgstr "註解" +msgstr "註腳" -#: ../../extending/newtypes_tutorial.rst:887 +#: ../../extending/newtypes_tutorial.rst:880 msgid "" "This is true when we know that the object is a basic type, like a string or " "a float." msgstr "" -#: ../../extending/newtypes_tutorial.rst:890 +#: ../../extending/newtypes_tutorial.rst:883 msgid "" "We relied on this in the :c:member:`~PyTypeObject.tp_dealloc` handler in " "this example, because our type doesn't support garbage collection." msgstr "" -#: ../../extending/newtypes_tutorial.rst:893 +#: ../../extending/newtypes_tutorial.rst:886 msgid "" "We now know that the first and last members are strings, so perhaps we could " "be less careful about decrementing their reference counts, however, we " @@ -2183,7 +2209,7 @@ msgid "" "objects." msgstr "" -#: ../../extending/newtypes_tutorial.rst:899 +#: ../../extending/newtypes_tutorial.rst:892 msgid "" "Also, even with our attributes restricted to strings instances, the user " "could pass arbitrary :class:`str` subclasses and therefore still create " diff --git a/extending/windows.po b/extending/windows.po index 41856183ab..a85d0b62fa 100644 --- a/extending/windows.po +++ b/extending/windows.po @@ -5,7 +5,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-01 22:24+0800\n" "PO-Revision-Date: 2015-12-09 17:51+0000\n" diff --git a/faq/design.po b/faq/design.po index 8a3f22dcfc..caed4b8892 100644 --- a/faq/design.po +++ b/faq/design.po @@ -7,9 +7,9 @@ # Steven Hsu , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-18 00:04+0000\n" +"POT-Creation-Date: 2024-09-24 07:20+0000\n" "PO-Revision-Date: 2023-08-31 11:34+0800\n" "Last-Translator: Steven Hsu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -138,17 +138,18 @@ msgstr "" #: ../../faq/design.rst:65 msgid "" -"The :class:`float` type in CPython uses a C ``double`` for storage. A :" -"class:`float` object's value is stored in binary floating-point with a fixed " -"precision (typically 53 bits) and Python uses C operations, which in turn " -"rely on the hardware implementation in the processor, to perform floating-" -"point operations. This means that as far as floating-point operations are " -"concerned, Python behaves like many popular languages including C and Java." +"The :class:`float` type in CPython uses a C ``double`` for storage. " +"A :class:`float` object's value is stored in binary floating-point with a " +"fixed precision (typically 53 bits) and Python uses C operations, which in " +"turn rely on the hardware implementation in the processor, to perform " +"floating-point operations. This means that as far as floating-point " +"operations are concerned, Python behaves like many popular languages " +"including C and Java." msgstr "" -"CPython 的 :class:`float` 型別使用了 C 的 ``double`` 型別來儲存。一個 :class:" -"`float` 物件的值會以固定的精度(通常為 53 位元)存為二進制浮點數,Python 使" -"用 C 來運算浮點數,而他的結果會依處理器中的硬體實作方式來決定。這表示就浮點數" -"運算來說,Python 和 C、Java 等很多受歡迎的語言有一樣的行為。" +"CPython 的 :class:`float` 型別使用了 C 的 ``double`` 型別來儲存。一" +"個 :class:`float` 物件的值會以固定的精度(通常為 53 位元)存為二進制浮點數," +"Python 使用 C 來運算浮點數,而他的結果會依處理器中的硬體實作方式來決定。這表" +"示就浮點數運算來說,Python 和 C、Java 等很多受歡迎的語言有一樣的行為。" #: ../../faq/design.rst:72 msgid "" @@ -249,11 +250,11 @@ msgid "" "``m_`` prefix, so this explicitness is still useful in those languages, too." msgstr "" "第一,這樣可以更明顯表現出你在用方法 (method) 或是實例 (instance) 的屬性,而" -"非一個區域變數。即使不知道類別 (class) 的定義,當看到 ``self.x`` 或 ``self." -"meth()``,就會很清楚地知道是正在使用實例的變數或是方法。在 C++ 裡,你可以藉由" -"沒有區域變數宣告來判斷這件事 ── 但在 Python 裡沒有區域變數宣告,所以你必須去" -"看類別的定義來確定。有些 C++ 和 Java 的程式碼規格要求要在實例屬性的名稱加上前" -"綴 ``m_``,所以這種明確性在那些語言也是很好用的。" +"非一個區域變數。即使不知道類別 (class) 的定義,當看到 ``self.x`` 或 " +"``self.meth()``,就會很清楚地知道是正在使用實例的變數或是方法。在 C++ 裡,你" +"可以藉由沒有區域變數宣告來判斷這件事 ── 但在 Python 裡沒有區域變數宣告,所以" +"你必須去看類別的定義來確定。有些 C++ 和 Java 的程式碼規格要求要在實例屬性的名" +"稱加上前綴 ``m_``,所以這種明確性在那些語言也是很好用的。" #: ../../faq/design.rst:127 msgid "" @@ -353,17 +354,17 @@ msgstr "" msgid "" "(b) When I read code that says len(x) I *know* that it is asking for the " "length of something. This tells me two things: the result is an integer, and " -"the argument is some kind of container. To the contrary, when I read x." -"len(), I have to already know that x is some kind of container implementing " -"an interface or inheriting from a class that has a standard len(). Witness " -"the confusion we occasionally have when a class that is not implementing a " -"mapping has a get() or keys() method, or something that isn't a file has a " -"write() method." +"the argument is some kind of container. To the contrary, when I read " +"x.len(), I have to already know that x is some kind of container " +"implementing an interface or inheriting from a class that has a standard " +"len(). Witness the confusion we occasionally have when a class that is not " +"implementing a mapping has a get() or keys() method, or something that isn't " +"a file has a write() method." msgstr "" "(二) 當我看到一段程式碼寫著 len(x),我\\ *知道*\\ 他要找某個東西的長度。這" "告訴了我兩件事:結果是一個整數、參數是某種容器。相對地,當我看到 x.len(),我" "必須先知道 x 是某種容器,並實作了一個介面或是繼承了一個有標準 len() 的類別。" -"遇到一個沒有實作映射 (mapping) 的類別卻有 get() 或 keys() 方法,或是不是檔案" +"遇到一個沒有實作對映 (mapping) 的類別卻有 get() 或 keys() 方法,或是不是檔案" "但卻有 write() 方法時,我們偶爾會覺得困惑。" #: ../../faq/design.rst:189 @@ -419,8 +420,9 @@ msgstr "" msgid "" "The second objection is typically cast as: \"I am really telling a sequence " "to join its members together with a string constant\". Sadly, you aren't. " -"For some reason there seems to be much less difficulty with having :meth:" -"`~str.split` as a string method, since in that case it is easy to see that ::" +"For some reason there seems to be much less difficulty with " +"having :meth:`~str.split` as a string method, since in that case it is easy " +"to see that ::" msgstr "" "第二個反對意見通常是:「我是在叫一個序列把它的成員用一個字串常數連接起來」。" "但很遺憾地,你並不是在這樣做。因為某種原因,把 :meth:`~str.split` 當成字串方" @@ -526,7 +528,7 @@ msgid "" "For cases where you need to choose from a very large number of " "possibilities, you can create a dictionary mapping case values to functions " "to call. For example::" -msgstr "如果可能性很多,你可以用字典去映射要呼叫的函式。舉例來說: ::" +msgstr "如果可能性很多,你可以用字典去對映要呼叫的函式。舉例來說: ::" #: ../../faq/design.rst:272 msgid "" @@ -544,8 +546,8 @@ msgstr "" #: ../../faq/design.rst:279 msgid "" -"For calling methods on objects, you can simplify yet further by using the :" -"func:`getattr` built-in to retrieve methods with a particular name::" +"For calling methods on objects, you can simplify yet further by using " +"the :func:`getattr` built-in to retrieve methods with a particular name::" msgstr "" "對於呼叫物件裡的方法,你可以利用內建用來找尋特定方法的函式 :func:`getattr` 來" "做進一步的簡化: ::" @@ -818,10 +820,10 @@ msgstr "" msgid "" "Lists, on the other hand, are more like arrays in other languages. They " "tend to hold a varying number of objects all of which have the same type and " -"which are operated on one-by-one. For example, :func:`os.listdir('.') ` returns a list of strings representing the files in the current " -"directory. Functions which operate on this output would generally not break " -"if you added another file or two to the directory." +"which are operated on one-by-one. For example, :func:`os.listdir('.') " +"` returns a list of strings representing the files in the " +"current directory. Functions which operate on this output would generally " +"not break if you added another file or two to the directory." msgstr "" "另一方面,串列更像是其他語言的陣列 (array)。他可以有不固定個同類別物件,且為" "逐項操作。舉例來說,:func:`os.listdir('.') ` 回傳當下目錄裡的檔" @@ -960,8 +962,8 @@ msgstr "" msgid "" "would raise a :exc:`KeyError` exception because the id of the ``[1, 2]`` " "used in the second line differs from that in the first line. In other " -"words, dictionary keys should be compared using ``==``, not using :keyword:" -"`is`." +"words, dictionary keys should be compared using ``==``, not " +"using :keyword:`is`." msgstr "" "這將會導致 :exc:`KeyError` 例外,因為 ``[1, 2]`` 的 id 在第一行和第二行是不同" "的。換句話說,字典的鍵應該要用 ``==`` 來做比較,而不是用 :keyword:`is`。" @@ -1011,9 +1013,7 @@ msgstr "" "如果你需要的話,這裡有個小技巧可以幫你,但請自己承擔風險:你可以把一個可變物" "件包裝進一個有 :meth:`~object.__eq__` 和 :meth:`~object.__hash__` 方法的類別" "實例。只要這種包裝物件還存在於字典(或其他類似結構)中,你就必須確定在字典" -"(或其他用雜湊為基底的結構)中他們的雜湊值會保持恆定。\n" -"\n" -"::" +"(或其他用雜湊為基底的結構)中他們的雜湊值會保持恆定。 ::" #: ../../faq/design.rst:513 msgid "" @@ -1062,16 +1062,16 @@ msgstr "" #: ../../faq/design.rst:534 msgid "" -"Furthermore it must always be the case that if ``o1 == o2`` (ie ``o1." -"__eq__(o2) is True``) then ``hash(o1) == hash(o2)`` (ie, ``o1.__hash__() == " -"o2.__hash__()``), regardless of whether the object is in a dictionary or " -"not. If you fail to meet these restrictions dictionaries and other hash " -"based structures will misbehave." +"Furthermore it must always be the case that if ``o1 == o2`` (ie " +"``o1.__eq__(o2) is True``) then ``hash(o1) == hash(o2)`` (ie, " +"``o1.__hash__() == o2.__hash__()``), regardless of whether the object is in " +"a dictionary or not. If you fail to meet these restrictions dictionaries " +"and other hash based structures will misbehave." msgstr "" "此外,不管物件是否在字典中,如果 ``o1 == o2``\\ (即 ``o1.__eq__(o2) is " -"True``),則 ``hash(o1) == hash(o2)``\\ (即 ``o1.__hash__() == o2." -"__hash__()``),這個事實必須要成立。如果無法滿足這項限制,那字典和其他用雜湊" -"為基底的結構會出現不正常的行為。" +"True``),則 ``hash(o1) == hash(o2)``\\ (即 ``o1.__hash__() == " +"o2.__hash__()``),這個事實必須要成立。如果無法滿足這項限制,那字典和其他用雜" +"湊為基底的結構會出現不正常的行為。" #: ../../faq/design.rst:539 msgid "" @@ -1136,16 +1136,17 @@ msgstr "" msgid "" "Python 2.6 adds an :mod:`abc` module that lets you define Abstract Base " "Classes (ABCs). You can then use :func:`isinstance` and :func:`issubclass` " -"to check whether an instance or a class implements a particular ABC. The :" -"mod:`collections.abc` module defines a set of useful ABCs such as :class:" -"`~collections.abc.Iterable`, :class:`~collections.abc.Container`, and :class:" -"`~collections.abc.MutableMapping`." +"to check whether an instance or a class implements a particular ABC. " +"The :mod:`collections.abc` module defines a set of useful ABCs such " +"as :class:`~collections.abc.Iterable`, :class:`~collections.abc.Container`, " +"and :class:`~collections.abc.MutableMapping`." msgstr "" "Python 2.6 加入了 :mod:`abc` 模組,讓你可以定義抽象基底類別 (Abstract Base " "Class, ABC)。你可以使用 :func:`isinstance` 和 :func:`issubclass` 來確認一個實" "例或是類別是否實作了某個抽象基底類別。而 :mod:`collections.abc` 模組定義了一" -"系列好用的抽象基底類別,像是 :class:`~collections.abc.Iterable`、:class:" -"`~collections.abc.Container` 和 :class:`~collections.abc.MutableMapping`。" +"系列好用的抽象基底類別,像" +"是 :class:`~collections.abc.Iterable`、:class:`~collections.abc.Container` " +"和 :class:`~collections.abc.MutableMapping`。" #: ../../faq/design.rst:578 msgid "" @@ -1159,12 +1160,12 @@ msgid "" "as a module interface specification and a set of examples. Many Python " "modules can be run as a script to provide a simple \"self test.\" Even " "modules which use complex external interfaces can often be tested in " -"isolation using trivial \"stub\" emulations of the external interface. The :" -"mod:`doctest` and :mod:`unittest` modules or third-party test frameworks can " -"be used to construct exhaustive test suites that exercise every line of code " -"in a module." +"isolation using trivial \"stub\" emulations of the external interface. " +"The :mod:`doctest` and :mod:`unittest` modules or third-party test " +"frameworks can be used to construct exhaustive test suites that exercise " +"every line of code in a module." msgstr "" -"一個針對模組的好測試套件提供了回歸測試 (regression testing),並作為模組介面規" +"一個針對模組的好測試套件提供了迴歸測試 (regression testing),並作為模組介面規" "範和一組範例。許多 Python 模組可以直接當成腳本執行,並提供簡單的「自我測" "試」。即便模組使用了複雜的外部介面,他依然可以用外部介面的簡單的「樁」(stub) " "模擬來獨立測試。:mod:`doctest` 和 :mod:`unittest` 模組或第三方的測試框架可以" @@ -1209,16 +1210,16 @@ msgid "" "\"spaghetti\" code that was hard to understand and revise. In a high-level " "language, it is also unneeded as long as there are ways to branch (in " "Python, with :keyword:`if` statements and :keyword:`or`, :keyword:`and`, " -"and :keyword:`if`/:keyword:`else` expressions) and loop (with :keyword:" -"`while` and :keyword:`for` statements, possibly containing :keyword:" -"`continue` and :keyword:`break`)." +"and :keyword:`if`/:keyword:`else` expressions) and loop " +"(with :keyword:`while` and :keyword:`for` statements, possibly " +"containing :keyword:`continue` and :keyword:`break`)." msgstr "" "在 1970 年代,人們了解到沒有限制的 goto 會導致混亂、難以理解和修改的「義大利" "麵」程式碼 (\"spaghetti\" code)。在高階語言裡,這也是不需要的,因為有方法可以" -"做邏輯分支(以 Python 來說,用 :keyword:`if` 陳述式和 :keyword:`or`、:" -"keyword:`and` 及 :keyword:`if`/:keyword:`else` 運算式)和迴圈(用 :keyword:" -"`while` 和 :keyword:`for` 陳述式,可能會有 :keyword:`continue` 和 :keyword:" -"`break`)。" +"做邏輯分支(以 Python 來說,用 :keyword:`if` 陳述式" +"和 :keyword:`or`、:keyword:`and` 及 :keyword:`if`/:keyword:`else` 運算式)和" +"迴圈(用 :keyword:`while` 和 :keyword:`for` 陳述式,可能會" +"有 :keyword:`continue` 和 :keyword:`break`)。" #: ../../faq/design.rst:614 msgid "" @@ -1273,9 +1274,9 @@ msgid "" "pass on the string quote character by escaping it with a backslash. These " "rules work well when r-strings are used for their intended purpose." msgstr "" -"設計出純字串是為了提供有自己反斜線轉義處理的處理器(主要是正規表示式)一個方" +"設計出純字串是為了提供有自己反斜線跳脫處理的處理器(主要是正規表示式)一個方" "便的輸入方式。這種處理器會把未配對的結尾反斜線當成錯誤,所以純字串不允許如" -"此。相對地,他讓你用一個反斜線轉義引號。這些規則在他們預想的目的上正常地運" +"此。相對地,他讓你用一個反斜線跳脫引號。這些規則在他們預想的目的上正常地運" "作。" #: ../../faq/design.rst:648 @@ -1437,14 +1438,14 @@ msgstr "為何產生器 (generator) 不支援 with 陳述式?" msgid "" "For technical reasons, a generator used directly as a context manager would " "not work correctly. When, as is most common, a generator is used as an " -"iterator run to completion, no closing is needed. When it is, wrap it as :" -"func:`contextlib.closing(generator) ` in the :keyword:" -"`with` statement." +"iterator run to completion, no closing is needed. When it is, wrap it " +"as :func:`contextlib.closing(generator) ` in " +"the :keyword:`with` statement." msgstr "" "出於技術原因,把產生器直接用作情境 (context) 管理器會無法正常運作。因為通常來" "說,產生器是被當成疊代器 (iterator),到最後完成時不需要被手動關閉。但如果你需" -"要的話,你可以在 :keyword:`with` 陳述式裡用 :func:`contextlib." -"closing(generator) ` 來包裝他。" +"要的話,你可以在 :keyword:`with` 陳述式裡" +"用 :func:`contextlib.closing(generator) ` 來包裝他。" #: ../../faq/design.rst:730 msgid "Why are colons required for the if/while/def/class statements?" diff --git a/faq/extending.po b/faq/extending.po index 8f84a4ad13..1b0e3995d4 100644 --- a/faq/extending.po +++ b/faq/extending.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2023-02-18 13:08+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -49,16 +49,15 @@ msgid "Can I create my own functions in C++?" msgstr "我可以在 C++ 中建立自己的函式嗎?" #: ../../faq/extending.rst:28 -#, fuzzy msgid "" -"Yes, using the C compatibility features found in C++. Place ``extern \"C\" " -"{ ... }`` around the Python include files and put ``extern \"C\"`` before " -"each function that is going to be called by the Python interpreter. Global " -"or static C++ objects with constructors are probably not a good idea." +"Yes, using the C compatibility features found in C++. Place ``extern " +"\"C\" { ... }`` around the Python include files and put ``extern \"C\"`` " +"before each function that is going to be called by the Python interpreter. " +"Global or static C++ objects with constructors are probably not a good idea." msgstr "" -"是的,使用 C++ 中的 C 相容性功能。將 ``extern \"C\" { ... }`` 放在 Python 包" -"含檔案周圍,並將 ``extern \"C\"`` 放在每個將由 Python 直譯器呼叫的函式之前。" -"具有構造函式的全局或靜態 C++ 物件可能不是一個好主意。" +"是的,可使用 C++ 中的 C 相容性功能。將 ``extern \"C\" { ... }`` 放在 Python 引入" +"檔案周圍,並將 ``extern \"C\"`` 放在每個將由 Python 直譯器呼叫的函式之前。" +"但具有構造函式的全域或靜態 C++ 物件可能不是一個好主意。" #: ../../faq/extending.rst:37 msgid "Writing C is hard; are there any alternatives?" @@ -67,45 +66,16 @@ msgstr "寫 C 很難;還有其他選擇嗎?" #: ../../faq/extending.rst:39 msgid "" "There are a number of alternatives to writing your own C extensions, " -"depending on what you're trying to do." -msgstr "要編寫你自己的 C 擴充有許多替代方法,取決於你要執行的具體操作為何。" - -#: ../../faq/extending.rst:44 -#, fuzzy -msgid "" -"`Cython `_ and its relative `Pyrex `_ are compilers that accept a " -"slightly modified form of Python and generate the corresponding C code. " -"Cython and Pyrex make it possible to write an extension without having to " -"learn Python's C API." +"depending on what you're trying to do. :ref:`Recommended third party tools " +"` offer both simpler and more sophisticated approaches to " +"creating C and C++ extensions for Python." msgstr "" -"`Cython `_ 及其相關的 `Pyrex `_ 是接受稍微修改 Python 形式並生成" -"相應的 C 程式碼。 Cython 和 Pyrex 使編寫擴充程式成為可能,而無需學習 Python " -"的 C API。" -#: ../../faq/extending.rst:50 -#, fuzzy -msgid "" -"If you need to interface to some C or C++ library for which no Python " -"extension currently exists, you can try wrapping the library's data types " -"and functions with a tool such as `SWIG `_. `SIP " -"`__, `CXX `_ `Boost `_, or `Weave " -"`_ are also alternatives for wrapping C++ " -"libraries." -msgstr "" -"如果你需要連接到當前不存在 Python 擴充的某些 C 或 C++ 函式庫,你可以嘗試使用 " -"`SWIG `_ 等工具包裝函式庫的資料型別和函式。`SIP " -"`__、`CXX `_ `Boost `_ 或 `Weave " -"`_ 也是包裝 C++ 函式庫的替代方法。" - -#: ../../faq/extending.rst:61 +#: ../../faq/extending.rst:46 msgid "How can I execute arbitrary Python statements from C?" msgstr "如何從 C 執行任意 Python 陳述式?" -#: ../../faq/extending.rst:63 +#: ../../faq/extending.rst:48 #, fuzzy msgid "" "The highest-level function to do this is :c:func:`PyRun_SimpleString` which " @@ -121,12 +91,12 @@ msgstr "" "`PyRun_String`;在 ``Python/pythonrun.c`` 中查看 :c:func:" "`PyRun_SimpleString` 的原始碼。" -#: ../../faq/extending.rst:72 +#: ../../faq/extending.rst:57 #, fuzzy msgid "How can I evaluate an arbitrary Python expression from C?" msgstr "如何計算來自 C 的任意 Python 運算式?" -#: ../../faq/extending.rst:74 +#: ../../faq/extending.rst:59 #, fuzzy msgid "" "Call the function :c:func:`PyRun_String` from the previous question with the " @@ -136,11 +106,11 @@ msgstr "" "呼叫上一個問題中的函式 :c:func:`PyRun_String` 開始符號 :c:data:" "`Py_eval_input`;它解析一個運算式,對其求值並回傳它的值。" -#: ../../faq/extending.rst:80 +#: ../../faq/extending.rst:65 msgid "How do I extract C values from a Python object?" msgstr "如何從 Python 物件中提取 C 值?" -#: ../../faq/extending.rst:82 +#: ../../faq/extending.rst:67 #, fuzzy msgid "" "That depends on the object's type. If it's a tuple, :c:func:`PyTuple_Size` " @@ -152,7 +122,7 @@ msgstr "" "c:func:`PyTuple_GetItem` 回傳指定索引的項目。列表具有類似的函式:c:func:" "`PyList_Size` 和 :c:func:`PyList_GetItem`。" -#: ../../faq/extending.rst:87 +#: ../../faq/extending.rst:72 #, fuzzy msgid "" "For bytes, :c:func:`PyBytes_Size` returns its length and :c:func:" @@ -164,7 +134,7 @@ msgstr "" "`PyBytes_AsStringAndSize` 提供指向它的值和長度的指標。請注意,Python 位元組物" "件可能包含空位元組,因此不應使用 C 的 :c:func:`!strlen`。" -#: ../../faq/extending.rst:92 +#: ../../faq/extending.rst:77 msgid "" "To test the type of an object, first make sure it isn't ``NULL``, and then " "use :c:func:`PyBytes_Check`, :c:func:`PyTuple_Check`, :c:func:" @@ -173,7 +143,7 @@ msgstr "" "要測試物件的型別,首先確保它不是 ``NULL``,然後再使用 :c:func:" "`PyBytes_Check`、:c:func:`PyTuple_Check`、:c:func:`PyList_Check` 等函式。" -#: ../../faq/extending.rst:95 +#: ../../faq/extending.rst:80 #, fuzzy msgid "" "There is also a high-level API to Python objects which is provided by the so-" @@ -186,21 +156,21 @@ msgstr "" "還有一個針對 Python 物件的高級 API,它由所謂的「抽象」介面提供——閱讀 " "``Include/abstract.h`` 了解更多詳細資訊。它允許使用 :c:func:" "`PySequence_Length`、:c:func:`PySequence_GetItem` 等呼叫以及許多其他有用的協" -"議(例如數字 (:c:func:`PyNumber_Index) ` 等)和 PyMapping API 中的映射。" +"議(例如數字 (:c:func:`PyNumber_Index) ` 等)和 PyMapping API 中的對映。" -#: ../../faq/extending.rst:104 +#: ../../faq/extending.rst:89 msgid "How do I use Py_BuildValue() to create a tuple of arbitrary length?" msgstr "如何使用 Py_BuildValue() 建立任意長度的元組?" -#: ../../faq/extending.rst:106 +#: ../../faq/extending.rst:91 msgid "You can't. Use :c:func:`PyTuple_Pack` instead." msgstr "這無法做到。請改用 :c:func:`PyTuple_Pack`。" -#: ../../faq/extending.rst:110 +#: ../../faq/extending.rst:95 msgid "How do I call an object's method from C?" msgstr "如何從 C 呼叫物件的方法?" -#: ../../faq/extending.rst:112 +#: ../../faq/extending.rst:97 #, fuzzy msgid "" "The :c:func:`PyObject_CallMethod` function can be used to call an arbitrary " @@ -212,7 +182,7 @@ msgstr "" "叫的方法的名稱、與 :c:func:`Py_BuildValue` 一起使用的格式字串,以及引數" "值: ::" -#: ../../faq/extending.rst:117 +#: ../../faq/extending.rst:102 msgid "" "PyObject *\n" "PyObject_CallMethod(PyObject *object, const char *method_name,\n" @@ -222,17 +192,16 @@ msgstr "" "PyObject_CallMethod(PyObject *object, const char *method_name,\n" " const char *arg_format, ...);" -#: ../../faq/extending.rst:121 -#, fuzzy +#: ../../faq/extending.rst:106 msgid "" "This works for any object that has methods -- whether built-in or user-" "defined. You are responsible for eventually :c:func:`Py_DECREF`\\ 'ing the " "return value." msgstr "" -"這適用於任何具有方法的物件——無論是內建的還是使用者定義的。你負責最終 :c:func:" -"`Py_DECREF`\\ 'ing 回傳值。" +"這適用於任何具有方法的物件 —— 無論是內建的還是使用者定義的。你負責最終為回傳值來 :c:func:" +"`Py_DECREF`。" -#: ../../faq/extending.rst:124 +#: ../../faq/extending.rst:109 msgid "" "To call, e.g., a file object's \"seek\" method with arguments 10, 0 " "(assuming the file object pointer is \"f\")::" @@ -240,7 +209,7 @@ msgstr "" "例如,使用引數 10、0 呼叫檔案物件的 \"seek\" 方法(假設檔案物件指標為 " "\"f\"): ::" -#: ../../faq/extending.rst:127 +#: ../../faq/extending.rst:112 msgid "" "res = PyObject_CallMethod(f, \"seek\", \"(ii)\", 10, 0);\n" "if (res == NULL) {\n" @@ -250,26 +219,32 @@ msgid "" " Py_DECREF(res);\n" "}" msgstr "" +"res = PyObject_CallMethod(f, \"seek\", \"(ii)\", 10, 0);\n" +"if (res == NULL) {\n" +" ... 發生一個例外 ...\n" +"}\n" +"else {\n" +" Py_DECREF(res);\n" +"}" -#: ../../faq/extending.rst:135 -#, fuzzy +#: ../../faq/extending.rst:120 msgid "" "Note that since :c:func:`PyObject_CallObject` *always* wants a tuple for the " "argument list, to call a function without arguments, pass \"()\" for the " "format, and to call a function with one argument, surround the argument in " "parentheses, e.g. \"(i)\"." msgstr "" -"請注意,由於 :c:func:`PyObject_CallObject` *總是* 需要一個元組作為引數列表," -"呼叫一個不帶引數的函式,傳遞 \"()\" 作為格式,並呼叫一個帶有一個引數的函式," -"將參數括起來在括號中,例如 \"(i)\"。" +"請注意,由於 :c:func:`PyObject_CallObject` *總是*\\ 需要一個元組作為引數列表," +"若要呼叫一個不帶引數的函式,要傳遞 \"()\" 作為格式,並呼叫一個帶有一個引數的函式," +"將引數括起來在括號中,例如 \"(i)\"。" -#: ../../faq/extending.rst:142 +#: ../../faq/extending.rst:127 msgid "" "How do I catch the output from PyErr_Print() (or anything that prints to " "stdout/stderr)?" msgstr "我如何捕捉 PyErr_Print() 的輸出(或任何印出到 stdout/stderr 的東西)?" -#: ../../faq/extending.rst:144 +#: ../../faq/extending.rst:129 #, fuzzy msgid "" "In Python code, define an object that supports the ``write()`` method. " @@ -281,11 +256,11 @@ msgstr "" "data:`sys.stdout` 和 :data:`sys.stderr`。呼叫 print_error,或者只允許標準的回" "溯機制起作用。然後,輸出將到達你的 ``write()`` 方法發送它的任何地方。" -#: ../../faq/extending.rst:149 +#: ../../faq/extending.rst:134 msgid "The easiest way to do this is to use the :class:`io.StringIO` class:" msgstr "最簡單的方法是使用 :class:`io.StringIO` 類別:" -#: ../../faq/extending.rst:151 +#: ../../faq/extending.rst:136 msgid "" ">>> import io, sys\n" ">>> sys.stdout = io.StringIO()\n" @@ -303,12 +278,11 @@ msgstr "" "foo\n" "hello world!" -#: ../../faq/extending.rst:161 -#, fuzzy +#: ../../faq/extending.rst:146 msgid "A custom object to do the same would look like this:" msgstr "執行相同操作的自定義物件如下所示:" -#: ../../faq/extending.rst:163 +#: ../../faq/extending.rst:148 msgid "" ">>> import io, sys\n" ">>> class StdoutCatcher(io.TextIOBase):\n" @@ -340,21 +314,19 @@ msgstr "" "foo\n" "hello world!" -#: ../../faq/extending.rst:182 +#: ../../faq/extending.rst:167 msgid "How do I access a module written in Python from C?" msgstr "如何從 C 存取用 Python 編寫的模組?" -#: ../../faq/extending.rst:184 -#, fuzzy +#: ../../faq/extending.rst:169 msgid "You can get a pointer to the module object as follows::" -msgstr "你可以獲得指向模組物件的指標,如下所示: ::" +msgstr "你可以取得指向模組物件的指標,如下所示: ::" -#: ../../faq/extending.rst:186 +#: ../../faq/extending.rst:171 msgid "module = PyImport_ImportModule(\"\");" msgstr "module = PyImport_ImportModule(\"\");" -#: ../../faq/extending.rst:188 -#, fuzzy +#: ../../faq/extending.rst:173 msgid "" "If the module hasn't been imported yet (i.e. it is not yet present in :data:" "`sys.modules`), this initializes the module; otherwise it simply returns the " @@ -364,33 +336,30 @@ msgid "" msgstr "" "如果模組還沒有被引入(即它還沒有出現在 :data:`sys.modules` 中),這會初始化模" "組;否則它只回傳 ``sys.modules[\"\"]`` 的值。請注意,它不會將模組" -"輸入任何命名空間——它只會確保它已被初始化並存儲在 :data:`sys.modules` 中。" +"輸入任何命名空間——它只會確保它已被初始化並儲存在 :data:`sys.modules` 中。" -#: ../../faq/extending.rst:194 -#, fuzzy +#: ../../faq/extending.rst:179 msgid "" "You can then access the module's attributes (i.e. any name defined in the " "module) as follows::" -msgstr "然後,你可以存取模組的屬性(即模組中定義的任何名稱),如下所示: ::" +msgstr "然後你可以存取模組的屬性(即模組中定義的任何名稱),如下所示: ::" -#: ../../faq/extending.rst:197 +#: ../../faq/extending.rst:182 msgid "attr = PyObject_GetAttrString(module, \"\");" msgstr "attr = PyObject_GetAttrString(module, \"\");" -#: ../../faq/extending.rst:199 +#: ../../faq/extending.rst:184 #, fuzzy msgid "" "Calling :c:func:`PyObject_SetAttrString` to assign to variables in the " "module also works." msgstr "呼叫 :c:func:`PyObject_SetAttrString` 以分配給模組中的變數也可以。" -#: ../../faq/extending.rst:204 -#, fuzzy +#: ../../faq/extending.rst:189 msgid "How do I interface to C++ objects from Python?" -msgstr "我如何從 Python 連接到 C++ 物件?" +msgstr "我如何從 Python 介接到 C++ 物件?" -#: ../../faq/extending.rst:206 -#, fuzzy +#: ../../faq/extending.rst:191 msgid "" "Depending on your requirements, there are many approaches. To do this " "manually, begin by reading :ref:`the \"Extending and Embedding\" document " @@ -399,20 +368,20 @@ msgid "" "building a new Python type around a C structure (pointer) type will also " "work for C++ objects." msgstr "" -"根據你的要求,有多種方法。要手動執行此操作,請先閱讀 :ref:`「擴充和嵌入」說明" -"檔案 `。意識到對於 Python 執行環境 (run-time) 系統,C 和 C+" -"+ 之間並沒有太多區別——因此圍繞 C 結構(指標)型別構建新 Python 型別的策略也適" +"根據你的要求不同而有多種不同方法。要手動執行此操作,請先閱讀\\ :ref:`「擴充和嵌入」說明" +"文件 `。對於 Python run-time 系統,C 和 C++ 之間並" +"沒有太多區別 —— 因此圍繞 C 結構(指標)型別來構建新 Python 型別的策略也適" "用於 C++ 物件。" -#: ../../faq/extending.rst:212 +#: ../../faq/extending.rst:197 msgid "For C++ libraries, see :ref:`c-wrapper-software`." msgstr "對於 C++ 函式庫,請參閱 :ref:`c-wrapper-software`。" -#: ../../faq/extending.rst:216 +#: ../../faq/extending.rst:201 msgid "I added a module using the Setup file and the make fails; why?" msgstr "我使用安裝檔案新增了一個模組,但 make 失敗了;為什麼?" -#: ../../faq/extending.rst:218 +#: ../../faq/extending.rst:203 #, fuzzy msgid "" "Setup must end in a newline, if there is no newline there, the build process " @@ -422,11 +391,11 @@ msgstr "" "安裝程式必須以換行符結尾,如果那裡沒有換行符,構建過程將失敗。(解決這個問題" "需要一些醜陋的 shell 腳本 hackery,而且這個錯誤很小,似乎不值得付出努力。)" -#: ../../faq/extending.rst:224 +#: ../../faq/extending.rst:209 msgid "How do I debug an extension?" msgstr "如何為擴充套件除錯?" -#: ../../faq/extending.rst:226 +#: ../../faq/extending.rst:211 #, fuzzy msgid "" "When using GDB with dynamically loaded extensions, you can't set a " @@ -434,20 +403,19 @@ msgid "" msgstr "" "將 GDB 與動態載入的擴充一起使用時,在載入擴充之前不能在擴充中設定斷點。" -#: ../../faq/extending.rst:229 -#, fuzzy +#: ../../faq/extending.rst:214 msgid "In your ``.gdbinit`` file (or interactively), add the command:" msgstr "在你的 ``.gdbinit`` 檔案中(或交互地),新增命令:" -#: ../../faq/extending.rst:231 +#: ../../faq/extending.rst:216 msgid "br _PyImport_LoadDynamicModule" msgstr "br _PyImport_LoadDynamicModule" -#: ../../faq/extending.rst:235 +#: ../../faq/extending.rst:220 msgid "Then, when you run GDB:" msgstr "然後,當你運行 GDB 時:" -#: ../../faq/extending.rst:237 +#: ../../faq/extending.rst:222 msgid "" "$ gdb /local/bin/python\n" "gdb) run myscript.py\n" @@ -457,36 +425,35 @@ msgid "" "gdb) continue" msgstr "" -#: ../../faq/extending.rst:247 +#: ../../faq/extending.rst:232 msgid "" "I want to compile a Python module on my Linux system, but some files are " "missing. Why?" msgstr "" "我想在我的 Linux 系統上編譯一個 Python 模組,但是缺少一些檔案。為什麼?" -#: ../../faq/extending.rst:249 +#: ../../faq/extending.rst:234 #, fuzzy msgid "" -"Most packaged versions of Python don't include the :file:`/usr/lib/python2." -"{x}/config/` directory, which contains various files required for compiling " +"Most packaged versions of Python omit some files required for compiling " "Python extensions." msgstr "" "大多數打包版本的 Python 不包含 :file:`/usr/lib/python2.{x}/config/` 目錄,該" "目錄包含編譯 Python 擴充所需的各種檔案。" -#: ../../faq/extending.rst:253 -msgid "For Red Hat, install the python-devel RPM to get the necessary files." -msgstr "在 Red Hat 上,請安裝 python-devel RPM 來取得必要的檔案。" +#: ../../faq/extending.rst:237 +msgid "For Red Hat, install the python3-devel RPM to get the necessary files." +msgstr "在 Red Hat 上,請安裝 python3-devel RPM 來取得必要的檔案。" -#: ../../faq/extending.rst:255 -msgid "For Debian, run ``apt-get install python-dev``." -msgstr "對於 Debian,運行 ``apt-get install python-dev``。" +#: ../../faq/extending.rst:239 +msgid "For Debian, run ``apt-get install python3-dev``." +msgstr "對於 Debian,運行 ``apt-get install python3-dev``。" -#: ../../faq/extending.rst:258 +#: ../../faq/extending.rst:242 msgid "How do I tell \"incomplete input\" from \"invalid input\"?" msgstr "如何從「無效輸入」區分出「不完整輸入」?" -#: ../../faq/extending.rst:260 +#: ../../faq/extending.rst:244 #, fuzzy msgid "" "Sometimes you want to emulate the Python interactive interpreter's behavior, " @@ -499,7 +466,7 @@ msgstr "" "(例如,你鍵入了 \"if\" 陳述句的開頭或者你沒有關閉你的括號或三重字串引號)," "但是當輸入無效時,它會立即為你提供語法錯誤消息。" -#: ../../faq/extending.rst:266 +#: ../../faq/extending.rst:250 msgid "" "In Python you can use the :mod:`codeop` module, which approximates the " "parser's behavior sufficiently. IDLE uses this, for example." @@ -507,7 +474,7 @@ msgstr "" "在 Python 中,你可以使用 :mod:`codeop` 模組,它充分模擬了剖析器 (parser) 的行" "為。像是 IDLE 就有使用它。" -#: ../../faq/extending.rst:269 +#: ../../faq/extending.rst:253 #, fuzzy msgid "" "The easiest way to do it in C is to call :c:func:`PyRun_InteractiveLoop` " @@ -521,11 +488,11 @@ msgstr "" "`PyOS_ReadlineFunctionPointer` 設定為指向你的自定義輸入函式。有關更多提示,請" "參閱``Modules/readline.c`` 和``Parser/myreadline.c``。" -#: ../../faq/extending.rst:276 +#: ../../faq/extending.rst:260 msgid "How do I find undefined g++ symbols __builtin_new or __pure_virtual?" msgstr "如何找到未定義的 g++ 符號 __builtin_new 或 __pure_virtual?" -#: ../../faq/extending.rst:278 +#: ../../faq/extending.rst:262 #, fuzzy msgid "" "To dynamically load g++ extension modules, you must recompile Python, relink " @@ -536,16 +503,15 @@ msgstr "" "Python 模組 Makefile 中的 LINKCC),並使用 g++ 鏈接你的擴充模組(例如,``g++ " "-shared -o mymodule.so mymodule.o` `)。" -#: ../../faq/extending.rst:284 -#, fuzzy +#: ../../faq/extending.rst:268 msgid "" "Can I create an object class with some methods implemented in C and others " "in Python (e.g. through inheritance)?" msgstr "" -"我可以用一些用 C 實作的方法和用 Python 實作的其他方法(例如通過繼承)建立一個" +"我可以用一些用 C 實作的方法和用 Python 實作的其他方法(例如透過繼承)建立一個" "物件類別嗎?" -#: ../../faq/extending.rst:286 +#: ../../faq/extending.rst:270 msgid "" "Yes, you can inherit from built-in classes such as :class:`int`, :class:" "`list`, :class:`dict`, etc." @@ -553,7 +519,7 @@ msgstr "" "是的,你可以繼承內建類別,例如 :class:`int`、:class:`list`、:class:`dict` " "等。" -#: ../../faq/extending.rst:289 +#: ../../faq/extending.rst:273 msgid "" "The Boost Python Library (BPL, https://www.boost.org/libs/python/doc/index." "html) provides a way of doing this from C++ (i.e. you can inherit from an " diff --git a/faq/general.po b/faq/general.po index a43f9d3e8b..ac684d513b 100644 --- a/faq/general.po +++ b/faq/general.po @@ -8,9 +8,9 @@ # Steven Hsu , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-18 00:04+0000\n" +"POT-Creation-Date: 2025-02-19 00:13+0000\n" "PO-Revision-Date: 2023-06-23 16:56+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -84,14 +84,14 @@ msgid "" msgstr "" "Python 軟體基金會 (Python Software Foundation) 是一個獨立的非營利性組織,它擁" "有 Python 2.1 版與之後各版本的版權。PSF 的使命在於推展 Python 程式設計語言相" -"關的開放原始碼技術,以及宣傳 Python 的使用。PSF 首頁的網址是 https://www." -"python.org/psf/。" +"關的開放原始碼技術,以及宣傳 Python 的使用。PSF 首頁的網址是 https://" +"www.python.org/psf/。" #: ../../faq/general.rst:42 msgid "" "Donations to the PSF are tax-exempt in the US. If you use Python and find " -"it helpful, please contribute via `the PSF donation page `_." +"it helpful, please contribute via `the PSF donation page `_." msgstr "" "在美國捐款給 PSF 是免稅的。如果你使用了 Python 且發現它很有用,請至 `PSF 捐款" "頁面 `_\\ 為它做出貢獻。" @@ -333,6 +333,11 @@ msgid "" "See also the documentation for :data:`sys.version`, :data:`sys.hexversion`, " "and :data:`sys.version_info`." msgstr "" +"請參閱\\ `開發人員指南 `__\\ 以獲得更多關於開發週期的資訊,並參閱 :pep:`387` 以瞭" +"解更多關於 Python 的向後相容性政策。另外,也請查" +"看 :data:`sys.version`、:data:`sys.hexversion` 和 :data:`sys.version_info` 的" +"說明文件。" #: ../../faq/general.rst:169 msgid "How do I obtain a copy of the Python source?" @@ -344,9 +349,9 @@ msgid "" "at https://www.python.org/downloads/. The latest development sources can be " "obtained at https://github.com/python/cpython/." msgstr "" -"最新的 Python 原始碼發行版永遠可以從 python.org 取得,在 https://www.python." -"org/downloads/。最新的開發中原始碼可以在 https://github.com/python/cpython/ " -"取得。" +"最新的 Python 原始碼發行版永遠可以從 python.org 取得,在 https://" +"www.python.org/downloads/。最新的開發中原始碼可以在 https://github.com/" +"python/cpython/ 取得。" #: ../../faq/general.rst:175 msgid "" @@ -421,9 +426,10 @@ msgid "" "There is a newsgroup, :newsgroup:`comp.lang.python`, and a mailing list, " "`python-list `_. The " "newsgroup and mailing list are gatewayed into each other -- if you can read " -"news it's unnecessary to subscribe to the mailing list. :newsgroup:`comp." -"lang.python` is high-traffic, receiving hundreds of postings every day, and " -"Usenet readers are often more able to cope with this volume." +"news it's unnecessary to subscribe to the mailing " +"list. :newsgroup:`comp.lang.python` is high-traffic, receiving hundreds of " +"postings every day, and Usenet readers are often more able to cope with this " +"volume." msgstr "" "有一個新聞群組 (newsgroup),:newsgroup:`comp.lang.python`,也有一個郵件討論" "群 (mailing list),`python-list `_." msgstr "" "新的軟體發布版本及事件的通知,可以在 comp.lang.python.announce 中找到,這是一" @@ -458,9 +464,9 @@ msgstr "如何取得 Python 的 beta 測試版本?" #: ../../faq/general.rst:229 msgid "" "Alpha and beta releases are available from https://www.python.org/" -"downloads/. All releases are announced on the comp.lang.python and comp." -"lang.python.announce newsgroups and on the Python home page at https://www." -"python.org/; an RSS feed of news is available." +"downloads/. All releases are announced on the comp.lang.python and " +"comp.lang.python.announce newsgroups and on the Python home page at https://" +"www.python.org/; an RSS feed of news is available." msgstr "" "Alpha 和 beta 發布版本可以從 https://www.python.org/downloads/ 取得。所有的發" "布版本都會在 comp.lang.python 和 comp.lang.python.announce 新聞群組上宣布,也" @@ -480,8 +486,8 @@ msgstr "如何提交 Python 的錯誤報告和修補程式?" #: ../../faq/general.rst:241 msgid "" -"To report a bug or submit a patch, use the issue tracker at https://github." -"com/python/cpython/issues." +"To report a bug or submit a patch, use the issue tracker at https://" +"github.com/python/cpython/issues." msgstr "" "要回報一個錯誤 (bug) 或提交一個修補程式 (patch),請使用於 https://github.com/" "python/cpython/issues 的問題追蹤系統。" @@ -547,8 +553,8 @@ msgstr "www.python.org 的真實位置在哪裡?" #: ../../faq/general.rst:274 msgid "" "The Python project's infrastructure is located all over the world and is " -"managed by the Python Infrastructure Team. Details `here `__." +"managed by the Python Infrastructure Team. Details `here `__." msgstr "" "Python 專案的基礎建設遍佈世界各地,由 Python 基礎建設團隊管理。詳細資訊\\ `在" "此 `__。" @@ -560,8 +566,8 @@ msgstr "為什麼要取名為 Python?" #: ../../faq/general.rst:281 msgid "" "When he began implementing Python, Guido van Rossum was also reading the " -"published scripts from `\"Monty Python's Flying Circus\" `__, a BBC comedy series from the 1970s. " +"published scripts from `\"Monty Python's Flying Circus\" `__, a BBC comedy series from the 1970s. " "Van Rossum thought he needed a name that was short, unique, and slightly " "mysterious, so he decided to call the language Python." msgstr "" @@ -613,15 +619,13 @@ msgstr "" #: ../../faq/general.rst:311 msgid "" "The latest stable releases can always be found on the `Python download page " -"`_. There are two production-ready " -"versions of Python: 2.x and 3.x. The recommended version is 3.x, which is " -"supported by most widely used libraries. Although 2.x is still widely " -"used, :pep:`it is not maintained anymore <0373>`." +"`_. Python 3.x is the recommended version " +"and supported by most widely used libraries. Python 2.x :pep:`is not " +"maintained anymore <373>`." msgstr "" "最新的穩定發布版本隨時都可以在 `Python 下載頁面 `_\\ 上找到。Python 有兩個生產就緒 (production-ready) 的版本:2.x " -"和 3.x。推薦的版本是 3.x,此版本能被那些最為廣泛使用的函式庫所支援。雖然 2.x " -"仍然被廣泛使用,但\\ :pep:`它已不再被維護 <0373>`。" +"downloads/>`_\\ 上找到。Python 3.x 是推薦的版本,並且被大多數廣泛使用的函式庫" +"所支援。Python 2.x :pep:`已不再被維護 <0373>`。" #: ../../faq/general.rst:318 msgid "How many people are using Python?" @@ -657,8 +661,8 @@ msgstr "有沒有任何重要的專案使用 Python 完成開發?" #: ../../faq/general.rst:334 msgid "" "See https://www.python.org/about/success for a list of projects that use " -"Python. Consulting the proceedings for `past Python conferences `_ will reveal contributions from many " +"Python. Consulting the proceedings for `past Python conferences `_ will reveal contributions from many " "different companies and organizations." msgstr "" "要查看使用 Python 的專案清單,請參閱 https://www.python.org/about/success。藉" @@ -668,17 +672,17 @@ msgstr "" #: ../../faq/general.rst:339 msgid "" "High-profile Python projects include `the Mailman mailing list manager " -"`_ and `the Zope application server `_. Several Linux distributions, most notably `Red Hat `_, have written part or all of their installer and system " -"administration software in Python. Companies that use Python internally " -"include Google, Yahoo, and Lucasfilm Ltd." -msgstr "" -"備受矚目的 Python 專案包括 `Mailman 郵件討論群管理員 `_\\ 和 `Zope 應用程式伺服器 `_。有一些 Linux 發行" -"版,最著名的是 `Red Hat `_,已經用 Python 編寫了部分" -"或全部的安裝程式及系統管理軟體。內部使用 Python 的公司包括 Google、Yahoo 和 " -"Lucasfilm Ltd。" +"`_ and `the Zope application server `_. Several Linux distributions, most notably `Red Hat " +"`_, have written part or all of their installer and " +"system administration software in Python. Companies that use Python " +"internally include Google, Yahoo, and Lucasfilm Ltd." +msgstr "" +"備受矚目的 Python 專案包括 `Mailman 郵件討論群管理員 `_\\ 和 `Zope 應用程式伺服器 `_。有一些 " +"Linux 發行版,最著名的是 `Red Hat `_,已經用 Python " +"編寫了部分或全部的安裝程式及系統管理軟體。內部使用 Python 的公司包括 Google、" +"Yahoo 和 Lucasfilm Ltd。" #: ../../faq/general.rst:348 msgid "What new developments are expected for Python in the future?" @@ -699,8 +703,8 @@ msgstr "" #: ../../faq/general.rst:356 msgid "" -"New development is discussed on `the python-dev mailing list `_." +"New development is discussed on `the python-dev mailing list `_." msgstr "" "新的開發會在 `python-dev 郵件討論群 `_\\ 中討論。" @@ -810,7 +814,7 @@ msgstr "" #: ../../faq/general.rst:412 msgid "" ">>> L = []\n" -">>> dir(L) \n" +">>> dir(L)\n" "['__add__', '__class__', '__contains__', '__delattr__', '__delitem__',\n" "'__dir__', '__doc__', '__eq__', '__format__', '__ge__',\n" "'__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__',\n" @@ -835,7 +839,7 @@ msgid "" "[1]" msgstr "" ">>> L = []\n" -">>> dir(L) \n" +">>> dir(L)\n" "['__add__', '__class__', '__contains__', '__delattr__', '__delitem__',\n" "'__dir__', '__doc__', '__eq__', '__format__', '__ge__',\n" "'__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__',\n" @@ -889,13 +893,3 @@ msgid "" msgstr "" "如果你想討論 Python 在教育領域中的使用,你可能會有興趣加入 `edu-sig 郵件討論" "群 `_。" - -#~ msgid "See :pep:`6` for more information about bugfix releases." -#~ msgstr "更多關於錯誤修正發布的資訊請見 :pep:`6`。" - -#~ msgid "" -#~ "See also the documentation for :data:`sys.version`, :data:`sys." -#~ "hexversion`, and :data:`sys.version_info`." -#~ msgstr "" -#~ "另請參閱 :data:`sys.version`、:data:`sys.hexversion` 和 :data:`sys." -#~ "version_info` 的說明文件。" diff --git a/faq/gui.po b/faq/gui.po index c3f53a6d87..98bd3c188e 100644 --- a/faq/gui.po +++ b/faq/gui.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,9 +6,9 @@ # Steven Hsu, 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-09-05 00:04+0000\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2022-07-02 17:41+0800\n" "Last-Translator: Steven Hsu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -93,30 +92,16 @@ msgstr "" #: ../../faq/gui.rst:49 msgid "" -"To get truly stand-alone applications, the Tcl scripts that form the library " -"have to be integrated into the application as well. One tool supporting that " -"is SAM (stand-alone modules), which is part of the Tix distribution (https://" -"tix.sourceforge.net/)." +"Various third-party freeze libraries such as py2exe and cx_Freeze have " +"handling for Tkinter applications built-in." msgstr "" -"要得到真正獨立的應用程式,必須將構成函式庫的 Tcl 腳本也整合到應用程式中。一個" -"可支援該方法的工具是 SAM(stand-alone modules,獨立模組),它是 Tix 發行版的" -"一部分 (https://tix.sourceforge.net/)。" +"各種第三方凍結函式庫,例如 py2exe 和 cx_Freeze,都有內建了對 Tkinter 應用程式的處理。" #: ../../faq/gui.rst:54 -msgid "" -"Build Tix with SAM enabled, perform the appropriate call to :c:func:`!" -"Tclsam_init`, etc. inside Python's :file:`Modules/tkappinit.c`, and link " -"with libtclsam and libtksam (you might include the Tix libraries as well)." -msgstr "" -"請在 SAM 被啟用的情況下建置 Tix,對 Python 的 :file:`Modules/tkappinit.c` 中" -"的 :c:func:`!Tclsam_init` 等函式執行適當的呼叫,並與 libtclsam 和 libtksam 連" -"結(你可能也會 include Tix 函式庫)。" - -#: ../../faq/gui.rst:61 msgid "Can I have Tk events handled while waiting for I/O?" msgstr "是否可以在等待 I/O 時處理 Tk 事件?" -#: ../../faq/gui.rst:63 +#: ../../faq/gui.rst:56 msgid "" "On platforms other than Windows, yes, and you don't even need threads! But " "you'll have to restructure your I/O code a bit. Tk has the equivalent of " @@ -130,11 +115,11 @@ msgstr "" "進行時,該函式將會從 Tk mainloop 被呼叫。請參閱\\ :ref:`tkinter-file-" "handlers`。" -#: ../../faq/gui.rst:71 +#: ../../faq/gui.rst:64 msgid "I can't get key bindings to work in Tkinter: why?" msgstr "我無法讓鍵繫結 (key binding) 在 Tkinter 中作用:為什麼?" -#: ../../faq/gui.rst:73 +#: ../../faq/gui.rst:66 msgid "" "An often-heard complaint is that event handlers :ref:`bound ` to events with the :meth:`!bind` method don't get handled even when " @@ -144,7 +129,7 @@ msgstr "" "`\\ 到帶有 :meth:`!bind` method 的事件,但在按下相應的鍵" "時,該事件也沒有被處理。" -#: ../../faq/gui.rst:77 +#: ../../faq/gui.rst:70 msgid "" "The most common cause is that the widget to which the binding applies " "doesn't have \"keyboard focus\". Check out the Tk documentation for the " diff --git a/faq/index.po b/faq/index.po index 2d73109e45..37bec95316 100644 --- a/faq/index.po +++ b/faq/index.po @@ -6,7 +6,7 @@ # Adrian Liaw , 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2017-09-22 18:26+0000\n" diff --git a/faq/installed.po b/faq/installed.po index 557def12ef..260bb53d3c 100644 --- a/faq/installed.po +++ b/faq/installed.po @@ -8,7 +8,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-09-24 00:11+0000\n" "PO-Revision-Date: 2021-12-09 21:50+0800\n" diff --git a/faq/library.po b/faq/library.po index 8a15890b33..19395ef83a 100644 --- a/faq/library.po +++ b/faq/library.po @@ -6,9 +6,9 @@ # Ching-Lung Chuang, 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2023-02-18 13:22+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -49,13 +49,13 @@ msgstr "" #: ../../faq/library.rst:21 #, fuzzy msgid "" -"For third-party packages, search the `Python Package Index `_ or try `Google `_ or another web search " +"For third-party packages, search the `Python Package Index `_ or try `Google `_ or another web search " "engine. Searching for \"Python\" plus a keyword or two for your topic of " "interest will usually find something helpful." msgstr "" -"對於第三方包,搜索`Python 包索引`_ 或嘗試`Google `_ 或其他網路搜索引擎。搜索 \"Python\" 加上你感興趣的主題的一" +"對於第三方包,搜尋`Python 包索引`_ 或嘗試`Google `_ 或其他網路搜尋引擎。搜尋 \"Python\" 加上你感興趣的主題的一" "兩個關鍵字通常會找到有用的東西。" #: ../../faq/library.rst:28 @@ -67,13 +67,13 @@ msgstr "哪裡可以找到 math.py (socket.py, regex.py, 等...) 來源檔案? msgid "" "If you can't find a source file for a module it may be a built-in or " "dynamically loaded module implemented in C, C++ or other compiled language. " -"In this case you may not have the source file or it may be something like :" -"file:`mathmodule.c`, somewhere in a C source directory (not on the Python " -"Path)." +"In this case you may not have the source file or it may be something " +"like :file:`mathmodule.c`, somewhere in a C source directory (not on the " +"Python Path)." msgstr "" "如果找不到模組的源檔案,它可能是用 C、C++ 或其他編譯語言實作的內置或動態載入" -"的模組。在這種情況下,你可能沒有源檔案,或者它可能類似於 :file:`mathmodule." -"c`,位於 C 源目錄中(不在 Python 路徑中)。" +"的模組。在這種情況下,你可能沒有源檔案,或者它可能類似" +"於 :file:`mathmodule.c`,位於 C 源目錄中(不在 Python 路徑中)。" #: ../../faq/library.rst:35 msgid "There are (at least) three kinds of modules in Python:" @@ -99,6 +99,8 @@ msgid "" "import sys\n" "print(sys.builtin_module_names)" msgstr "" +"import sys\n" +"print(sys.builtin_module_names)" #: ../../faq/library.rst:47 msgid "How do I make a Python script executable on Unix?" @@ -115,20 +117,18 @@ msgstr "" "Python 直譯器的路徑。" #: ../../faq/library.rst:53 -#, fuzzy msgid "" "The first is done by executing ``chmod +x scriptfile`` or perhaps ``chmod " "755 scriptfile``." msgstr "" -"第一個是通過執行 ``chmod +x scriptfile`` 或者 ``chmod 755 scriptfile`` 來完成" -"的。" +"第一個是透過執行 ``chmod +x scriptfile`` 或者可能是 ``chmod 755 scriptfile`` " +"來完成的。" #: ../../faq/library.rst:56 -#, fuzzy msgid "" "The second can be done in a number of ways. The most straightforward way is " "to write ::" -msgstr "第二個可以通過多種方式完成。最直接的方法是寫: ::" +msgstr "第二個則可以透過多種方式完成。最直接的方法是寫: ::" #: ../../faq/library.rst:59 msgid "#!/usr/local/bin/python" @@ -150,22 +150,21 @@ msgid "" "directory on the user's :envvar:`PATH`::" msgstr "" "如果你希望腳本獨立於 Python 直譯器所在的位置,你可以使用 :program:`env` 程" -"式。幾乎所有 Unix 變體都支援以下內容,假設 Python 直譯器位於使用者的 :envvar:" -"`PATH` 上的目錄中: ::" +"式。幾乎所有 Unix 變體都支援以下內容,假設 Python 直譯器位於使用者" +"的 :envvar:`PATH` 上的目錄中: ::" #: ../../faq/library.rst:69 msgid "#!/usr/bin/env python" msgstr "#!/usr/bin/env python" #: ../../faq/library.rst:71 -#, fuzzy msgid "" "*Don't* do this for CGI scripts. The :envvar:`PATH` variable for CGI " "scripts is often very minimal, so you need to use the actual absolute " "pathname of the interpreter." msgstr "" -"*不要*對 CGI 腳本執行此操作。 CGI 腳本的 :envvar:`PATH` 變數通常非常小,因此" -"你需要使用直譯器的實際絕對路徑名。" +"*不要*\\ 對 CGI 腳本執行此操作。CGI 腳本的 :envvar:`PATH` 變數通常非常小,因" +"此你需要使用直譯器的實際絕對路徑名稱。" #: ../../faq/library.rst:75 #, fuzzy @@ -190,17 +189,16 @@ msgstr "" "\"\"\"" #: ../../faq/library.rst:86 -#, fuzzy msgid "" "The minor disadvantage is that this defines the script's __doc__ string. " "However, you can fix that by adding ::" msgstr "" -"次要缺點是這定義了腳本的 __doc__ 字串。但是,你可以通過新增來解決這個問" -"題: ::" +"次要缺點是這定義了腳本的 __doc__ 字串。但是你可以透過新增下面這一行來解決這個" +"問題: ::" #: ../../faq/library.rst:89 msgid "__doc__ = \"\"\"...Whatever...\"\"\"" -msgstr "" +msgstr "__doc__ = \"\"\"...Whatever...\"\"\"" #: ../../faq/library.rst:94 msgid "Is there a curses/termcap package for Python?" @@ -230,7 +228,7 @@ msgid "" msgstr "" ":mod:`curses` 模組支援基本的 curses 功能以及 ncurses 和 SYSV curses 的許多附" "加功能,例如顏色、替代字元集支援、鍵盤和鼠標支援。這意味著該模組與僅具有 BSD " -"curses 的作業系統不相容,但似乎沒有任何當前維護的作業系統屬於此類型。" +"curses 的作業系統不相容,但似乎沒有任何目前維護的作業系統屬於此類型。" #: ../../faq/library.rst:111 msgid "Is there an equivalent to C's onexit() in Python?" @@ -241,19 +239,18 @@ msgstr "Python 中是否有等同於 C 的 onexit() 的函式?" msgid "" "The :mod:`atexit` module provides a register function that is similar to " "C's :c:func:`!onexit`." -msgstr "" -":mod:`atexit` 模組提供了一個類似於 C 的 :c:func:`onexit` 的寄存器函式。" +msgstr ":mod:`atexit` 模組提供了一個類似於 C :c:func:`onexit` 的註冊器函式。" #: ../../faq/library.rst:118 msgid "Why don't my signal handlers work?" -msgstr "為什麼我的信號處理程式不起作用?" +msgstr "為什麼我的訊號處理程式不起作用?" #: ../../faq/library.rst:120 #, fuzzy msgid "" "The most common problem is that the signal handler is declared with the " "wrong argument list. It is called as ::" -msgstr "最常見的問題是信號處理程式是用錯誤的引數列表聲明的。它被稱為: ::" +msgstr "最常見的問題是訊號處理程式是用錯誤的引數列表聲明的。它被稱為: ::" #: ../../faq/library.rst:123 msgid "handler(signum, frame)" @@ -286,8 +283,8 @@ msgid "" "examples in the docstrings for a module and runs them, comparing the output " "with the expected output given in the docstring." msgstr "" -"Python 帶有兩個測試框架。 :mod:`doctest` 模組在模組的文檔字串中查詢示例並運行" -"它們,將輸出與文檔字串中給出的預期輸出進行比較。" +"Python 帶有兩個測試框架。 :mod:`doctest` 模組在模組的文件字串中查詢示例並運行" +"它們,將輸出與文件字串中給出的預期輸出進行比較。" #: ../../faq/library.rst:141 #, fuzzy @@ -311,19 +308,21 @@ msgid "" msgstr "" "為了使測試更容易,你應該在程式中使用良好的模組化設計。你的程式應該將幾乎所有" "功能都封裝在函式或類別方法中——這有時會產生使程式運行得更快的令人驚訝和令人愉" -"快的效果(因為局部變數存取比全局存取更快)。此外,該程式應避免依賴於可變的全" +"快的效果(因為局部變數存取比全域存取更快)。此外,該程式應避免依賴於可變的全" "局變數,因為這會使測試變得更加困難。" #: ../../faq/library.rst:152 #, fuzzy msgid "The \"global main logic\" of your program may be as simple as ::" -msgstr "你程式的「全局主邏輯」可能像一樣簡單: ::" +msgstr "你程式的「全域主邏輯」可能像一樣簡單: ::" #: ../../faq/library.rst:154 msgid "" "if __name__ == \"__main__\":\n" " main_logic()" msgstr "" +"if __name__ == \"__main__\":\n" +" main_logic()" #: ../../faq/library.rst:157 #, fuzzy @@ -344,7 +343,7 @@ msgid "" msgstr "" "一旦你的程式被組織為函式和類別行為的易於處理的集合,你就應該編寫測試函式來執" "行這些行為。可將一系列測試自動化的測試套件與每個模組相關聯。這聽起來像是很多" -"工作,但由於 Python 如此簡潔和靈活,所以它非常容易。通過與 \"生產程式碼\" 並" +"工作,但由於 Python 如此簡潔和靈活,所以它非常容易。透過與 \"生產程式碼\" 並" "行編寫測試函式,你可以使編碼變得更加愉快和有趣,因為這使得更早地發現錯誤甚至" "設計缺陷變得容易。" @@ -360,6 +359,8 @@ msgid "" "if __name__ == \"__main__\":\n" " self_test()" msgstr "" +"if __name__ == \"__main__\":\n" +" self_test()" #: ../../faq/library.rst:173 #, fuzzy @@ -368,13 +369,12 @@ msgid "" "when the external interfaces are unavailable by using \"fake\" interfaces " "implemented in Python." msgstr "" -"即使是與復雜外部介面交互的程式也可以在外部介面不可用時通過使用 Python 中實作" +"即使是與復雜外部介面交互的程式也可以在外部介面不可用時透過使用 Python 中實作" "的 \"假\" 介面進行測試。" #: ../../faq/library.rst:179 -#, fuzzy msgid "How do I create documentation from doc strings?" -msgstr "如何從文檔字串建立文檔?" +msgstr "如何從文件字串建立文件?" #: ../../faq/library.rst:181 #, fuzzy @@ -384,9 +384,9 @@ msgid "" "docstrings is `epydoc `_. `Sphinx `_ can also include docstring content." msgstr "" -":mod:`pydoc` 模組可以從 Python 源程式碼中的文檔字串建立 HTML。純粹從文檔字串" -"建立 API 文檔的另一種方法是 `epydoc `_。 " -"`Sphinx `_ 也可以包含文檔字串內容。" +":mod:`pydoc` 模組可以從 Python 源程式碼中的文件字串建立 HTML。純粹從文件字串" +"建立 API 文件的另一種方法是 `epydoc `_。 " +"`Sphinx `_ 也可以包含文件字串內容。" #: ../../faq/library.rst:188 #, fuzzy @@ -417,8 +417,9 @@ msgid "" "module. The :mod:`threading` module builds convenient abstractions on top of " "the low-level primitives provided by the :mod:`_thread` module." msgstr "" -"請務必使用 :mod:`threading` 模組而不是 :mod:`_thread` 模組。 :mod:" -"`threading` 模組在 :mod:`_thread` 模組提供的低階原語之上構建方便的抽象。" +"請務必使用 :mod:`threading` 模組而不是 :mod:`_thread` 模" +"組。 :mod:`threading` 模組在 :mod:`_thread` 模組提供的低階原語之上構建方便的" +"抽象。" #: ../../faq/library.rst:245 msgid "None of my threads seem to run: why?" @@ -455,6 +456,17 @@ msgid "" "\n" "time.sleep(10) # <---------------------------!" msgstr "" +"import threading, time\n" +"\n" +"def thread_task(name, n):\n" +" for i in range(n):\n" +" print(name, i)\n" +"\n" +"for i in range(10):\n" +" T = threading.Thread(target=thread_task, args=(str(i), i))\n" +" T.start()\n" +"\n" +"time.sleep(10) # <---------------------------!" #: ../../faq/library.rst:265 #, fuzzy @@ -485,17 +497,27 @@ msgid "" "\n" "time.sleep(10)" msgstr "" +"def thread_task(name, n):\n" +" time.sleep(0.001) # <--------------------!\n" +" for i in range(n):\n" +" print(name, i)\n" +"\n" +"for i in range(10):\n" +" T = threading.Thread(target=thread_task, args=(str(i), i))\n" +" T.start()\n" +"\n" +"time.sleep(10)" #: ../../faq/library.rst:282 #, fuzzy msgid "" "Instead of trying to guess a good delay value for :func:`time.sleep`, it's " -"better to use some kind of semaphore mechanism. One idea is to use the :mod:" -"`queue` module to create a queue object, let each thread append a token to " -"the queue when it finishes, and let the main thread read as many tokens from " -"the queue as there are threads." +"better to use some kind of semaphore mechanism. One idea is to use " +"the :mod:`queue` module to create a queue object, let each thread append a " +"token to the queue when it finishes, and let the main thread read as many " +"tokens from the queue as there are threads." msgstr "" -"與其嘗試為 :func:`time.sleep` 猜測一個好的延遲值,不如使用某種信號量機制。一" +"與其嘗試為 :func:`time.sleep` 猜測一個好的延遲值,不如使用某種訊號量機制。一" "種想法是使用 :mod:`queue` 模組建立一個隊列物件,讓每個執行緒在完成時向隊列新" "增一個權杖,並讓主執行緒從隊列中讀取與執行緒數一樣多的權杖。" @@ -510,8 +532,8 @@ msgid "" "The easiest way is to use the :mod:`concurrent.futures` module, especially " "the :mod:`~concurrent.futures.ThreadPoolExecutor` class." msgstr "" -"最簡單的方法是使用 :mod:`concurrent.futures` 模組,尤其是 :mod:`~concurrent." -"futures.ThreadPoolExecutor` 類別。" +"最簡單的方法是使用 :mod:`concurrent.futures` 模組,尤其" +"是 :mod:`~concurrent.futures.ThreadPoolExecutor` 類別。" #: ../../faq/library.rst:295 #, fuzzy @@ -523,13 +545,12 @@ msgid "" "``.get()`` method to return them. The class will take care of the locking " "necessary to ensure that each job is handed out exactly once." msgstr "" -"或者,如果你想對調度演算法進行精細控制,你可以手動編寫自己的邏輯。使用 :mod:" -"`queue` 模組建立一個包含作業列表的隊列。 :class:`~queue.Queue` 類別維護一個物" -"件列表,並有一個 `.put(obj)`` 方法將項目新增到隊列和一個 ``.get()`` 方法回傳" -"它們。該類別將負責必要的鎖定,以確保每個作業都恰好分發一次。" +"或者,如果你想對調度演算法進行精細控制,你可以手動編寫自己的邏輯。使" +"用 :mod:`queue` 模組建立一個包含作業列表的隊列。 :class:`~queue.Queue` 類別維" +"護一個物件列表,並有一個 `.put(obj)`` 方法將項目新增到隊列和一個 ``.get()`` " +"方法回傳它們。該類別將負責必要的鎖定,以確保每個作業都恰好分發一次。" #: ../../faq/library.rst:302 -#, fuzzy msgid "Here's a trivial example::" msgstr "這是一個簡單的例子: ::" @@ -573,7 +594,6 @@ msgid "" msgstr "" #: ../../faq/library.rst:340 -#, fuzzy msgid "When run, this will produce the following output:" msgstr "運行時,這將產生以下輸出:" @@ -610,16 +630,16 @@ msgstr "" #: ../../faq/library.rst:358 #, fuzzy msgid "" -"Consult the module's documentation for more details; the :class:`~queue." -"Queue` class provides a featureful interface." +"Consult the module's documentation for more details; " +"the :class:`~queue.Queue` class provides a featureful interface." msgstr "" -"有關更多詳細資訊,請參閱模組的文檔; :class:`~queue.Queue` 類別提供了一個功能" +"有關更多詳細資訊,請參閱模組的文件; :class:`~queue.Queue` 類別提供了一個功能" "強大的介面。" #: ../../faq/library.rst:363 #, fuzzy msgid "What kinds of global value mutation are thread-safe?" -msgstr "什麼樣的全局值突變是執行緒安全的?" +msgstr "什麼樣的全域值突變是執行緒安全的?" #: ../../faq/library.rst:365 #, fuzzy @@ -631,9 +651,9 @@ msgid "" "instruction and therefore all the C implementation code reached from each " "instruction is therefore atomic from the point of view of a Python program." msgstr "" -"內部使用 :term:`全局直譯器鎖 (GIL, global interpreter lock)`\\ 來確保一次只有" +"內部使用 :term:`全域直譯器鎖 (GIL, global interpreter lock)`\\ 來確保一次只有" "一個執行緒在 Python VM 中運行。通常,Python 僅提供位元組碼指令之間的執行緒切" -"換;可以通過 :func:`sys.setswitchinterval` 設定它切換的頻率。因此,從 Python " +"換;可以透過 :func:`sys.setswitchinterval` 設定它切換的頻率。因此,從 Python " "程式的角度來看,每條位元組碼指令以及從每條指令到達的所有 C 實作程式碼都是原子" "的。" @@ -703,20 +723,20 @@ msgstr "" #: ../../faq/library.rst:399 #, fuzzy msgid "" -"Operations that replace other objects may invoke those other objects' :meth:" -"`~object.__del__` method when their reference count reaches zero, and that " -"can affect things. This is especially true for the mass updates to " -"dictionaries and lists. When in doubt, use a mutex!" +"Operations that replace other objects may invoke those other " +"objects' :meth:`~object.__del__` method when their reference count reaches " +"zero, and that can affect things. This is especially true for the mass " +"updates to dictionaries and lists. When in doubt, use a mutex!" msgstr "" -"替換其他物件的操作可能會在引用計數達到零時呼叫其他物件的 :meth:`__del__` 方" +"替換其他物件的操作可能會在引用計數達到零時叫用其他物件的 :meth:`__del__` 方" "法,這可能會影響事情。對於字典和列表的大量更新尤其如此。如有疑問,請使用互斥" "體!" #: ../../faq/library.rst:406 msgid "Can't we get rid of the Global Interpreter Lock?" -msgstr "不能擺脫全局直譯器鎖嗎?" +msgstr "不能擺脫全域直譯器鎖嗎?" -#: ../../faq/library.rst:410 +#: ../../faq/library.rst:408 #, fuzzy msgid "" "The :term:`global interpreter lock` (GIL) is often seen as a hindrance to " @@ -724,21 +744,36 @@ msgid "" "multi-threaded Python program effectively only uses one CPU, due to the " "insistence that (almost) all Python code can only run while the GIL is held." msgstr "" -":term:`global interpreter lock` (GIL) 通常被視為 Python 在高端多處理器服務器" +":term:`global interpreter lock` (GIL) 通常被視為 Python 在高端多處理器伺服器" "機器上部署的障礙,因為多執行緒 Python 程式實際上只使用一個 CPU,因為堅持(幾" "乎)所有 Python 程式碼只能在持有 GIL 的情況下運行。" -#: ../../faq/library.rst:415 +#: ../../faq/library.rst:413 +msgid "" +"With the approval of :pep:`703` 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." +msgstr "" + +#: ../../faq/library.rst:422 #, fuzzy msgid "" -"Back in the days of Python 1.5, Greg Stein actually implemented a " +"The current work to remove the GIL is based on a `fork of Python 3.9 with " +"the GIL removed `_ 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 recently did a " -"similar experiment in his `python-safethread `_ project. Unfortunately, both 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." +"GIL and replaced it with fine-grained locking. Adam Olsen did a similar " +"experiment in his `python-safethread `_ 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." msgstr "" "回到 Python 1.5 時代,Greg Stein 實際上實作了一個全面的補丁集( \"自由執行緒" "\" 補丁),刪除了 GIL 並用細粒度鎖定取而代之。 Adam Olsen 最近在他的 `python-" @@ -746,94 +781,73 @@ msgstr "" "一個類似的實驗。不幸的是,這兩個實驗都表現出單執行緒性能的急劇下降(至少慢了 " "30%),這是由於需要大量的細粒度鎖定來補償 GIL 的移除。" -#: ../../faq/library.rst:423 +#: ../../faq/library.rst:437 #, fuzzy msgid "" -"This 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 :class:" -"`~concurrent.futures.ProcessPoolExecutor` class in the new :mod:`concurrent." -"futures` module provides an easy way of doing so; the :mod:`multiprocessing` " -"module provides a lower-level API in case you want more control over " -"dispatching of tasks." +"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 :class:`~concurrent.futures.ProcessPoolExecutor` " +"class in the new :mod:`concurrent.futures` module provides an easy way of " +"doing so; the :mod:`multiprocessing` module provides a lower-level API in " +"case you want more control over dispatching of tasks." msgstr "" "這並不意味著你不能在多 CPU 機器上用好 Python!你只需要創造性地將工作分配給多" -"個*行程*而​​不是多個*執行緒*。新的 :mod:`concurrent.futures` 模組中的 :class:" -"`~concurrent.futures.ProcessPoolExecutor` 類別提供了一種簡單的方法; :mod:" -"`multiprocessing` 模組提供了一個較低階別的 API,以防你希望更好地控制任務的調" -"度。" +"個*行程*而​​不是多個*執行緒*。新的 :mod:`concurrent.futures` 模組中" +"的 :class:`~concurrent.futures.ProcessPoolExecutor` 類別提供了一種簡單的方" +"法; :mod:`multiprocessing` 模組提供了一個較低階別的 API,以防你希望更好地控" +"制任務的調度。" -#: ../../faq/library.rst:431 +#: ../../faq/library.rst:446 #, fuzzy msgid "" "Judicious use of C extensions will also help; if you use a C extension to " "perform a time-consuming task, the extension can release the GIL while the " "thread of execution is in the C code and allow other threads to get some " -"work done. Some standard library modules such as :mod:`zlib` and :mod:" -"`hashlib` already do this." +"work done. Some standard library modules such as :mod:`zlib` " +"and :mod:`hashlib` already do this." msgstr "" "明智地使用 C 擴充也會有所幫助;如果你使用 C 擴充來執行耗時任務,則該擴充可以" "在執行執行緒在 C 程式碼中時釋放 GIL,並允許其他執行緒完成一些工作。一些標準函" "式庫模組,例如 :mod:`zlib` 和 :mod:`hashlib` 已經這樣做了。" -#: ../../faq/library.rst:437 -#, fuzzy -msgid "" -"It has been suggested that the GIL should be a per-interpreter-state lock " -"rather than truly global; interpreters then wouldn't be able to share " -"objects. Unfortunately, this isn't likely to happen either. It would be a " -"tremendous amount of work, because many object implementations currently " -"have global state. For example, small integers and short strings are cached; " -"these caches would have to be moved to the interpreter state. Other object " -"types have their own free list; these free lists would have to be moved to " -"the interpreter state. And so on." -msgstr "" -"有人建議 GIL 應該是每個直譯器狀態鎖,而不是真正的全局鎖;口譯員將無法共享物" -"件。不幸的是,這也不太可能發生。這將是一項巨大的工作量,因為目前許多物件實作" -"都具有全局狀態。例如,快取小整數和短字串;這些快取必須移至直譯器狀態。其他物" -"件型別有自己的空閒列表;這些空閒列表必須移至直譯器狀態。等等。" - -#: ../../faq/library.rst:446 -#, fuzzy +#: ../../faq/library.rst:452 msgid "" -"And I doubt that it can even be done in finite time, because the same " -"problem exists for 3rd party extensions. It is likely that 3rd party " -"extensions are being written at a faster rate than you can convert them to " -"store all their global state in the interpreter state." +"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 :ref:`first " +"implemented in Python 3.12 ` 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." msgstr "" -"而且我懷疑它甚至可以在有限的時間內完成,因為第 3 方擴充存在同樣的問題。 3rd " -"方擴充的編寫速度可能比你轉換它們以將其所有全局狀態存儲在直譯器狀態中的速度更" -"快。" +"減少 GIL 影響的另一種方法是將 GIL 設置為直譯器各自狀態的鎖 (per-interpreter-" +"state lock),而不是真正的全域鎖。這在 :ref:`Python 3.12 中首次實現 " +"`,並且可於 C API 中使用。預計 Python 3.13 將會提供其 " +"Python 介面。目前主要的限制可能是第三方擴充模組,因為實作時必須考慮到多個直譯" +"器才能使用,因此許多舊的擴充模組將無法使用。" -#: ../../faq/library.rst:451 -#, fuzzy -msgid "" -"And finally, once you have multiple interpreters not sharing any state, what " -"have you gained over running each interpreter in a separate process?" -msgstr "" -"最後,如果你有多個不共享任何狀態的直譯器,那麼在單獨的行程中運行每個直譯器有" -"什麼好處呢?" - -#: ../../faq/library.rst:456 +#: ../../faq/library.rst:462 msgid "Input and Output" msgstr "輸入與輸出" -#: ../../faq/library.rst:459 +#: ../../faq/library.rst:465 msgid "How do I delete a file? (And other file questions...)" msgstr "如何刪除檔案?(以及其他檔案問題...)" -#: ../../faq/library.rst:461 +#: ../../faq/library.rst:467 #, fuzzy msgid "" "Use ``os.remove(filename)`` or ``os.unlink(filename)``; for documentation, " -"see the :mod:`os` module. The two functions are identical; :func:`~os." -"unlink` is simply the name of the Unix system call for this function." +"see the :mod:`os` module. The two functions are " +"identical; :func:`~os.unlink` is simply the name of the Unix system call for " +"this function." msgstr "" -"使用 ``os.remove(filename)`` 或 ``os.unlink(filename)``;有關文檔,請參閱 :" -"mod:`os` 模組。這兩個功能是相同的; :func:`~os.unlink` 只是這個函式的 Unix 系" -"統呼叫的名稱。" +"使用 ``os.remove(filename)`` 或 ``os.unlink(filename)``;有關文件,請參" +"閱 :mod:`os` 模組。這兩個功能是相同的; :func:`~os.unlink` 只是這個函式的 " +"Unix 系統呼叫的名稱。" -#: ../../faq/library.rst:465 +#: ../../faq/library.rst:471 #, fuzzy msgid "" "To remove a directory, use :func:`os.rmdir`; use :func:`os.mkdir` to create " @@ -842,43 +856,44 @@ msgid "" "directories as long as they're empty; if you want to delete an entire " "directory tree and its contents, use :func:`shutil.rmtree`." msgstr "" -"要刪除目錄,請使用 :func:`os.rmdir`;使用 :func:`os.mkdir` 建立一個。 ``os." -"makedirs(path)`` 將在 ``path`` 中建立任何不存在的中間目錄。 ``os." -"removedirs(path)`` 將刪除中間目錄,只要它們是空的;如果要刪除整個目錄樹及其內" -"容,請使用 :func:`shutil.rmtree`。" +"要刪除目錄,請使用 :func:`os.rmdir`;使用 :func:`os.mkdir` 建立一個。 " +"``os.makedirs(path)`` 將在 ``path`` 中建立任何不存在的中間目錄。 " +"``os.removedirs(path)`` 將刪除中間目錄,只要它們是空的;如果要刪除整個目錄樹" +"及其內容,請使用 :func:`shutil.rmtree`。" -#: ../../faq/library.rst:471 +#: ../../faq/library.rst:477 msgid "To rename a file, use ``os.rename(old_path, new_path)``." msgstr "要重新命名檔案,請使用 ``os.rename(old_path, new_path)``。" -#: ../../faq/library.rst:473 +#: ../../faq/library.rst:479 #, fuzzy msgid "" "To truncate a file, open it using ``f = open(filename, \"rb+\")``, and use " "``f.truncate(offset)``; offset defaults to the current seek position. " -"There's also ``os.ftruncate(fd, offset)`` for files opened with :func:`os." -"open`, where *fd* is the file descriptor (a small integer)." +"There's also ``os.ftruncate(fd, offset)`` for files opened " +"with :func:`os.open`, where *fd* is the file descriptor (a small integer)." msgstr "" -"要截斷一個檔案,使用``f = open(filename, \"rb+\")``打開它,然後使用``f." -"truncate(offset)``;偏移量預設為當前搜索位置。對於使用 :func:`os.open` 打開的" -"檔案,還有 ``os.ftruncate(fd, offset)``,其中 *fd* 是檔案描述器(一個小整" +"要截斷一個檔案,使用``f = open(filename, \"rb+\")``打開它,然後使用" +"``f.truncate(offset)``;偏移量預設為目前搜尋位置。對於使用 :func:`os.open` 打" +"開的檔案,還有 ``os.ftruncate(fd, offset)``,其中 *fd* 是檔案描述器(一個小整" "數)。" -#: ../../faq/library.rst:478 +#: ../../faq/library.rst:484 #, fuzzy msgid "" "The :mod:`shutil` module also contains a number of functions to work on " -"files including :func:`~shutil.copyfile`, :func:`~shutil.copytree`, and :" -"func:`~shutil.rmtree`." +"files including :func:`~shutil.copyfile`, :func:`~shutil.copytree`, " +"and :func:`~shutil.rmtree`." msgstr "" -":mod:`shutil` 模組還包含許多用於處理檔案的函式,包括:func:`~shutil." -"copyfile`、:func:`~shutil.copytree` 和:func:`~shutil.rmtree`。" +":mod:`shutil` 模組還包含許多用於處理檔案的函式,包" +"括:func:`~shutil.copyfile`、:func:`~shutil.copytree` " +"和:func:`~shutil.rmtree`。" -#: ../../faq/library.rst:484 +#: ../../faq/library.rst:490 msgid "How do I copy a file?" msgstr "如何複製檔案?" -#: ../../faq/library.rst:486 +#: ../../faq/library.rst:492 #, fuzzy msgid "" "The :mod:`shutil` module contains a :func:`~shutil.copyfile` function. Note " @@ -891,26 +906,26 @@ msgid "" msgstr "" ":mod:`shutil` 模組包含一個 :func:`~shutil.copyfile` 函式。請注意,在 Windows " "NTFS 卷上,它不會複製 `alternate data streams `_ 也不會複製 `resource forks `__ 在 macOS HFS+ 卷上,儘管現在兩者都很少" -"使用。它也不會複製檔案權限和元資料,儘管使用 :func:`shutil.copy2` 會保留其中" -"的大部分(儘管不是全部)。" +"NTFS#Alternate_data_stream_(ADS)>`_ 也不會複製 `resource forks `__ 在 macOS HFS+ 卷上,儘管現在兩者都很" +"少使用。它也不會複製檔案權限和元資料,儘管使用 :func:`shutil.copy2` 會保留其" +"中的大部分(儘管不是全部)。" -#: ../../faq/library.rst:497 +#: ../../faq/library.rst:503 msgid "How do I read (or write) binary data?" msgstr "如何讀取(或寫入)二進位制資料?" -#: ../../faq/library.rst:499 +#: ../../faq/library.rst:505 #, fuzzy msgid "" -"To read or write complex binary data formats, it's best to use the :mod:" -"`struct` module. It allows you to take a string containing binary data " -"(usually numbers) and convert it to Python objects; and vice versa." +"To read or write complex binary data formats, it's best to use " +"the :mod:`struct` module. It allows you to take a string containing binary " +"data (usually numbers) and convert it to Python objects; and vice versa." msgstr "" -"要讀取或寫入複雜的二進制資料格式,最好使用 :mod:`struct` 模組。它允許你獲取包" +"要讀取或寫入複雜的二進制資料格式,最好使用 :mod:`struct` 模組。它允許你取得包" "含二進制資料(通常是數字)的字串並將其轉換為 Python 物件;反之亦然。" -#: ../../faq/library.rst:503 +#: ../../faq/library.rst:509 #, fuzzy msgid "" "For example, the following code reads two 2-byte integers and one 4-byte " @@ -919,7 +934,7 @@ msgstr "" "例如,以下程式碼從一個檔案中以大端格式讀取兩個 2 位元組整數和一個 4 位元組整" "數: ::" -#: ../../faq/library.rst:506 +#: ../../faq/library.rst:512 msgid "" "import struct\n" "\n" @@ -933,7 +948,7 @@ msgstr "" " s = f.read(8)\n" " x, y, z = struct.unpack(\">hhl\", s)" -#: ../../faq/library.rst:512 +#: ../../faq/library.rst:518 #, fuzzy msgid "" "The '>' in the format string forces big-endian data; the letter 'h' reads " @@ -943,7 +958,7 @@ msgstr "" "格式字串中的 \">\" 強制使用大端資料;字母 'h' 讀取一個 \"短整數\" (2 位元" "組), 'l' 從字串中讀取一個 \"長整數\" (4 位元組)。" -#: ../../faq/library.rst:516 +#: ../../faq/library.rst:522 #, fuzzy msgid "" "For data that is more regular (e.g. a homogeneous list of ints or floats), " @@ -952,7 +967,7 @@ msgstr "" "對於更規則的資料(例如,整數或浮點數的同類列表),你還可以使用 :mod:`array` " "模組。" -#: ../../faq/library.rst:521 +#: ../../faq/library.rst:527 #, fuzzy msgid "" "To read and write binary data, it is mandatory to open the file in binary " @@ -960,61 +975,60 @@ msgid "" "instead (the default), the file will be open in text mode and ``f.read()`` " "will return :class:`str` objects rather than :class:`bytes` objects." msgstr "" -"要讀取和寫入二進制資料,必須以二進制模式打開檔案(這裡,將 ``\"rb\"`` 傳遞" +"要讀取和寫入二進位資料,必須以二進位模式打開檔案(這裡,將 ``\"rb\"`` 傳遞" "給 :func:`open`)。如果你改用 ``\"r\"``(預設設定),檔案將以文本模式打開,並" -"且 ``f.read()`` 將回傳 str 物件而不是 bytes ` 物件。" +"且 ``f.read()`` 將回傳 :class:`str` 物件而不是 :class:`bytes` 物件。" -#: ../../faq/library.rst:529 -#, fuzzy +#: ../../faq/library.rst:535 msgid "I can't seem to use os.read() on a pipe created with os.popen(); why?" -msgstr "我似乎無法在用 os.popen() 建立的管道上使用 os.read();為什麼?" +msgstr "我似乎無法在用 os.popen() 建立的 pipe 上使用 os.read();為什麼?" -#: ../../faq/library.rst:531 +#: ../../faq/library.rst:537 #, fuzzy msgid "" ":func:`os.read` is a low-level function which takes a file descriptor, a " "small integer representing the opened file. :func:`os.popen` creates a high-" "level file object, the same type returned by the built-in :func:`open` " -"function. Thus, to read *n* bytes from a pipe *p* created with :func:`os." -"popen`, you need to use ``p.read(n)``." +"function. Thus, to read *n* bytes from a pipe *p* created " +"with :func:`os.popen`, you need to use ``p.read(n)``." msgstr "" ":func:`os.read` 是一個低階函式,它接受一個檔案描述器,一個代表打開檔案的小整" "數。 :func:`os.popen` 建立一個高階檔案物件,與內置的 :func:`open` 函式回傳的" "型別相同。因此,要從使用 :func:`os.popen` 建立的管道 *p* 中讀取 *n* 個位元" "組,你需要使用 ``p.read(n)``。" -#: ../../faq/library.rst:617 +#: ../../faq/library.rst:623 msgid "How do I access the serial (RS232) port?" msgstr "如何存取序列 (RS232) 連接埠?" -#: ../../faq/library.rst:619 +#: ../../faq/library.rst:625 msgid "For Win32, OSX, Linux, BSD, Jython, IronPython:" msgstr "對於 Win32、OSX、Linux、BSD、Jython、IronPython:" -#: ../../faq/library.rst:621 +#: ../../faq/library.rst:627 msgid ":pypi:`pyserial`" msgstr ":pypi:`pyserial`" -#: ../../faq/library.rst:623 +#: ../../faq/library.rst:629 msgid "For Unix, see a Usenet post by Mitch Chapman:" msgstr "對於 Unix,請參閱 Mitch Chapman 的 Usenet 貼文:" -#: ../../faq/library.rst:625 +#: ../../faq/library.rst:631 msgid "https://groups.google.com/groups?selm=34A04430.CF9@ohioee.com" msgstr "https://groups.google.com/groups?selm=34A04430.CF9@ohioee.com" -#: ../../faq/library.rst:629 +#: ../../faq/library.rst:635 msgid "Why doesn't closing sys.stdout (stdin, stderr) really close it?" msgstr "為什麼關閉 sys.stdout (stdin, stderr) 並沒有真正關閉它?" -#: ../../faq/library.rst:631 +#: ../../faq/library.rst:637 msgid "" "Python :term:`file objects ` are a high-level layer of " "abstraction on low-level C file descriptors." msgstr "" "Python :term:`檔案物件 `\\ 是低階 C 檔案描述器的高階抽象層。" -#: ../../faq/library.rst:634 +#: ../../faq/library.rst:640 #, fuzzy msgid "" "For most file objects you create in Python via the built-in :func:`open` " @@ -1023,11 +1037,11 @@ msgid "" "descriptor. This also happens automatically in ``f``'s destructor, when " "``f`` becomes garbage." msgstr "" -"對於你通過內置的 :func:`open` 函式在 Python 中建立的大多數檔案物件,``f." -"close()`` 從 Python 的角度將 Python 檔案物件標記為已關閉,並安排關閉底層 C 檔" -"案描述器。當 ``f`` 變成垃圾時,這也會自動發生在 ``f`` 的析構函式中。" +"對於你透過內置的 :func:`open` 函式在 Python 中建立的大多數檔案物件," +"``f.close()`` 從 Python 的角度將 Python 檔案物件標記為已關閉,並安排關閉底層 " +"C 檔案描述器。當 ``f`` 變成垃圾時,這也會自動發生在 ``f`` 的析構函式中。" -#: ../../faq/library.rst:640 +#: ../../faq/library.rst:646 #, fuzzy msgid "" "But stdin, stdout and stderr are treated specially by Python, because of the " @@ -1039,7 +1053,7 @@ msgstr "" "態。運行 ``sys.stdout.close()`` 將 Python 級檔案物件標記為已關閉,但是 * " "not* 關閉關聯的 C 檔案描述器。" -#: ../../faq/library.rst:645 +#: ../../faq/library.rst:651 #, fuzzy msgid "" "To close the underlying C file descriptor for one of these three, you should " @@ -1049,7 +1063,7 @@ msgstr "" "要關閉這三個之一的底層 C 檔案描述器,你應該首先確定這是你真正想要做的(例如," "你可能會混淆試圖執行 I/O 的擴充模組)。如果是,使用 :func:`os.close`: ::" -#: ../../faq/library.rst:649 +#: ../../faq/library.rst:655 msgid "" "os.close(stdin.fileno())\n" "os.close(stdout.fileno())\n" @@ -1059,19 +1073,19 @@ msgstr "" "os.close(stdout.fileno())\n" "os.close(stderr.fileno())" -#: ../../faq/library.rst:653 +#: ../../faq/library.rst:659 msgid "Or you can use the numeric constants 0, 1 and 2, respectively." msgstr "或者你可以分別使用數字常數 0、1 和 2。" -#: ../../faq/library.rst:657 +#: ../../faq/library.rst:663 msgid "Network/Internet Programming" msgstr "網路 (Network)/網際網路 (Internet) 程式" -#: ../../faq/library.rst:660 +#: ../../faq/library.rst:666 msgid "What WWW tools are there for Python?" msgstr "Python 有哪些 WWW 工具?" -#: ../../faq/library.rst:662 +#: ../../faq/library.rst:668 #, fuzzy msgid "" "See the chapters titled :ref:`internet` and :ref:`netdata` in the Library " @@ -1081,7 +1095,7 @@ msgstr "" "請參閱函式庫參考手冊中標題為 :ref:`internet` 和 :ref:`netdata` 的章節。 " "Python 有許多模組可以幫助你構建伺服器端和用戶端 Web 系統。" -#: ../../faq/library.rst:668 +#: ../../faq/library.rst:674 #, fuzzy msgid "" "A summary of available frameworks is maintained by Paul Boddie at https://" @@ -1090,78 +1104,11 @@ msgstr "" "可用框架的摘要由 Paul Boddie 在 https://wiki.python.org/moin/" "WebProgramming\\ 維護。" -#: ../../faq/library.rst:671 -#, fuzzy -msgid "" -"Cameron Laird maintains a useful set of pages about Python web technologies " -"at https://web.archive.org/web/20210224183619/http://phaseit.net/claird/comp." -"lang.python/web_python." -msgstr "" -"Cameron Laird 在 https://web.archive.org/web/20210224183619/http://phaseit." -"net/claird/comp.lang.python/web_python 維護著一組有用的關於 Python 網路技術的" -"頁面。" - -#: ../../faq/library.rst:676 -msgid "How can I mimic CGI form submission (METHOD=POST)?" -msgstr "如何模擬 CGI 表單送出 (submission) (METHOD=POST)?" - -#: ../../faq/library.rst:678 -#, fuzzy -msgid "" -"I would like to retrieve web pages that are the result of POSTing a form. Is " -"there existing code that would let me do this easily?" -msgstr "" -"我想檢索作為發布表單結果的網頁。是否有現成的程式碼可以讓我輕鬆地做到這一點?" - -#: ../../faq/library.rst:681 -msgid "Yes. Here's a simple example that uses :mod:`urllib.request`::" -msgstr "是的,這是一個 :mod:`urllib.request` 的簡單範例: ::" - -#: ../../faq/library.rst:683 -msgid "" -"#!/usr/local/bin/python\n" -"\n" -"import urllib.request\n" -"\n" -"# build the query string\n" -"qs = \"First=Josephine&MI=Q&Last=Public\"\n" -"\n" -"# connect and send the server a path\n" -"req = urllib.request.urlopen('http://www.some-server.out-there'\n" -" '/cgi-bin/some-cgi-script', data=qs)\n" -"with req:\n" -" msg, hdrs = req.read(), req.info()" -msgstr "" - -#: ../../faq/library.rst:696 -#, fuzzy -msgid "" -"Note that in general for percent-encoded POST operations, query strings must " -"be quoted using :func:`urllib.parse.urlencode`. For example, to send " -"``name=Guy Steele, Jr.``::" -msgstr "" -"請注意,通常對於百分比編碼的 POST 操作,查詢字串必須使用 :func:`urllib.parse." -"urlencode` 引用。例如,發送 ``name=Guy Steele, Jr.``: ::" - -#: ../../faq/library.rst:700 -msgid "" -">>> import urllib.parse\n" -">>> urllib.parse.urlencode({'name': 'Guy Steele, Jr.'})\n" -"'name=Guy+Steele%2C+Jr.'" -msgstr "" -">>> import urllib.parse\n" -">>> urllib.parse.urlencode({'name': 'Guy Steele, Jr.'})\n" -"'name=Guy+Steele%2C+Jr.'" - -#: ../../faq/library.rst:704 -msgid ":ref:`urllib-howto` for extensive examples." -msgstr ":ref:`urllib-howto` 內有大量範例。" - -#: ../../faq/library.rst:708 +#: ../../faq/library.rst:679 msgid "What module should I use to help with generating HTML?" msgstr "我應該使用什麼模組來輔助產生 HTML?" -#: ../../faq/library.rst:712 +#: ../../faq/library.rst:683 #, fuzzy msgid "" "You can find a collection of useful links on the `Web Programming wiki page " @@ -1170,15 +1117,15 @@ msgstr "" "你可以在 \"Web 編寫程式維基頁面 \" 上找到一組有用的鏈接。" -#: ../../faq/library.rst:717 +#: ../../faq/library.rst:688 msgid "How do I send mail from a Python script?" msgstr "如何從 Python 腳本發送郵件?" -#: ../../faq/library.rst:719 +#: ../../faq/library.rst:690 msgid "Use the standard library module :mod:`smtplib`." msgstr "使用標準函式庫模組 :mod:`smtplib`。" -#: ../../faq/library.rst:721 +#: ../../faq/library.rst:692 #, fuzzy msgid "" "Here's a very simple interactive mail sender that uses it. This method will " @@ -1187,7 +1134,7 @@ msgstr "" "這是一個使用它的非常簡單的交互式郵件發件人。此方法適用於任何支援 SMTP 偵聽器" "的主機。: ::" -#: ../../faq/library.rst:724 +#: ../../faq/library.rst:695 msgid "" "import sys, smtplib\n" "\n" @@ -1206,8 +1153,24 @@ msgid "" "server.sendmail(fromaddr, toaddrs, msg)\n" "server.quit()" msgstr "" +"import sys, smtplib\n" +"\n" +"fromaddr = input(\"From: \")\n" +"toaddrs = input(\"To: \").split(',')\n" +"print(\"Enter message, end with ^D:\")\n" +"msg = ''\n" +"while True:\n" +" line = sys.stdin.readline()\n" +" if not line:\n" +" break\n" +" msg += line\n" +"\n" +"# The actual mail send\n" +"server = smtplib.SMTP('localhost')\n" +"server.sendmail(fromaddr, toaddrs, msg)\n" +"server.quit()" -#: ../../faq/library.rst:741 +#: ../../faq/library.rst:712 #, fuzzy msgid "" "A Unix-only alternative uses sendmail. The location of the sendmail program " @@ -1219,7 +1182,7 @@ msgstr "" "時是 \"/usr/lib/sendmail\" ,有時是 \"/usr/sbin/sendmail\" 。 sendmail 手冊頁" "將幫助你。這是一些示例程式碼: ::" -#: ../../faq/library.rst:746 +#: ../../faq/library.rst:717 msgid "" "import os\n" "\n" @@ -1235,18 +1198,18 @@ msgid "" " print(\"Sendmail exit status\", sts)" msgstr "" -#: ../../faq/library.rst:761 +#: ../../faq/library.rst:732 #, fuzzy msgid "How do I avoid blocking in the connect() method of a socket?" msgstr "如何避免阻塞 socket 的 connect() 方法?" -#: ../../faq/library.rst:763 +#: ../../faq/library.rst:734 msgid "" "The :mod:`select` module is commonly used to help with asynchronous I/O on " "sockets." msgstr ":mod:`select` 模組通常用於幫助處理 socket 上的非同步 I/O。" -#: ../../faq/library.rst:766 +#: ../../faq/library.rst:737 #, fuzzy msgid "" "To prevent the TCP connect from blocking, you can set the socket to non-" @@ -1257,26 +1220,26 @@ msgid "" "return different values, so you're going to have to check what's returned on " "your system." msgstr "" -"為防止 TCP 連接阻塞,可以將 socket 設定為非阻塞模式。然後當你執行 :meth:" -"`socket.connect` 時,你要麼立即連接(不太可能),要麼得到一個例外,其中包含錯" -"誤號 ``.errno``。 ``errno.EINPROGRESS`` 表示連接正在進行中,但尚未完成。不同" -"的作業系統將回傳不同的值,因此你將不得不檢查系統回傳的內容。" +"為防止 TCP 連接阻塞,可以將 socket 設定為非阻塞模式。然後當你執" +"行 :meth:`socket.connect` 時,你要麼立即連接(不太可能),要麼得到一個例外," +"其中包含錯誤號 ``.errno``。 ``errno.EINPROGRESS`` 表示連接正在進行中,但尚未" +"完成。不同的作業系統將回傳不同的值,因此你將不得不檢查系統回傳的內容。" -#: ../../faq/library.rst:774 +#: ../../faq/library.rst:745 #, fuzzy msgid "" "You can use the :meth:`~socket.socket.connect_ex` method to avoid creating " -"an exception. It will just return the errno value. To poll, you can call :" -"meth:`~socket.socket.connect_ex` again later -- ``0`` or ``errno.EISCONN`` " -"indicate that you're connected -- or you can pass this socket to :meth:" -"`select.select` to check if it's writable." +"an exception. It will just return the errno value. To poll, you can " +"call :meth:`~socket.socket.connect_ex` again later -- ``0`` or " +"``errno.EISCONN`` indicate that you're connected -- or you can pass this " +"socket to :meth:`select.select` to check if it's writable." msgstr "" "你可以使用 :meth:`socket.connect_ex` 方法來避免建立例外。它只會回傳 errno " -"值。要輪詢,你可以稍後再次呼叫 :meth:`socket.connect_ex` - ``0`` 或 ``errno." -"EISCONN`` 表示你已連接 - 或者你可以將此 socket 傳遞給 :meth:`select.select` " -"檢查它是否可寫。" +"值。要輪詢,你可以稍後再次呼叫 :meth:`socket.connect_ex` - ``0`` 或 " +"``errno.EISCONN`` 表示你已連接 - 或者你可以將此 socket 傳遞" +"給 :meth:`select.select` 檢查它是否可寫。" -#: ../../faq/library.rst:782 +#: ../../faq/library.rst:753 msgid "" "The :mod:`asyncio` module provides a general purpose single-threaded and " "concurrent asynchronous library, which can be used for writing non-blocking " @@ -1287,72 +1250,71 @@ msgstr "" "網路程式碼。第三方 `Twisted `_ 函式庫是一種流行且功能豐" "富的替代方案。" -#: ../../faq/library.rst:790 +#: ../../faq/library.rst:761 msgid "Databases" msgstr "資料庫" -#: ../../faq/library.rst:793 +#: ../../faq/library.rst:764 msgid "Are there any interfaces to database packages in Python?" msgstr "Python 中是否有任何資料庫套件的介面?" -#: ../../faq/library.rst:795 +#: ../../faq/library.rst:766 msgid "Yes." msgstr "有的。" -#: ../../faq/library.rst:797 +#: ../../faq/library.rst:768 #, fuzzy msgid "" "Interfaces to disk-based hashes such as :mod:`DBM ` and :mod:`GDBM " -"` are also included with standard Python. There is also the :mod:" -"`sqlite3` module, which provides a lightweight disk-based relational " -"database." +"` are also included with standard Python. There is also " +"the :mod:`sqlite3` module, which provides a lightweight disk-based " +"relational database." msgstr "" "基於磁盤的雜湊介面,例如 :mod:`DBM ` 和 :mod:`GDBM ` 也包" "含在標準 Python 中。還有 :mod:`sqlite3` 模組,它提供了一個輕量級的基於磁盤的" "關係資料庫。" -#: ../../faq/library.rst:802 +#: ../../faq/library.rst:773 #, fuzzy msgid "" "Support for most relational databases is available. See the " "`DatabaseProgramming wiki page `_ for details." msgstr "" -"支援大多數關係資料庫。有關詳細資訊,請參閱`DatabaseProgramming 維基頁面 " +"支援大多數關係資料庫。有關詳細資訊,請參閱 `DatabaseProgramming 維基頁面 " "`_。" -#: ../../faq/library.rst:808 -#, fuzzy +#: ../../faq/library.rst:779 msgid "How do you implement persistent objects in Python?" -msgstr "你如何在 Python 中實作持久物件?" +msgstr "你如何在 Python 中實作持久性物件?" -#: ../../faq/library.rst:810 +#: ../../faq/library.rst:781 #, fuzzy msgid "" "The :mod:`pickle` library module solves this in a very general way (though " -"you still can't store things like open files, sockets or windows), and the :" -"mod:`shelve` library module uses pickle and (g)dbm to create persistent " +"you still can't store things like open files, sockets or windows), and " +"the :mod:`shelve` library module uses pickle and (g)dbm to create persistent " "mappings containing arbitrary Python objects." msgstr "" -":mod:`pickle` 庫模組以一種非常通用的方式解決了這個問題(儘管你仍然不能存儲諸" -"如打開的檔案、socket 或窗口之類的東西),而 :mod:`shelve` 庫模組使用 pickle " -"和 (g) dbm 建立包含任意 Python 物件的持久映射。" +":mod:`pickle` 函式庫模組以一種非常通用的方式解決了這個問題(儘管你仍然不能存" +"儲諸如打開的檔案、socket 或窗口之類的東西),而 :mod:`shelve` 函式庫模組使用 " +"pickle 和 (g) dbm 建立包含任意 Python 物件的持久對映。" -#: ../../faq/library.rst:817 +#: ../../faq/library.rst:788 msgid "Mathematics and Numerics" msgstr "數學和數值" -#: ../../faq/library.rst:820 +#: ../../faq/library.rst:791 msgid "How do I generate random numbers in Python?" msgstr "如何在 Python 中生成隨機數?" -#: ../../faq/library.rst:822 +#: ../../faq/library.rst:793 msgid "" "The standard module :mod:`random` implements a random number generator. " "Usage is simple::" msgstr "標準模組 :mod:`random` 實作了一個隨機數生成器。用法很簡單: ::" -#: ../../faq/library.rst:825 +#: ../../faq/library.rst:796 msgid "" "import random\n" "random.random()" @@ -1360,41 +1322,41 @@ msgstr "" "import random\n" "random.random()" -#: ../../faq/library.rst:828 +#: ../../faq/library.rst:799 msgid "This returns a random floating-point number in the range [0, 1)." msgstr "這將回傳 [0, 1) 範圍內的隨機浮點數。" -#: ../../faq/library.rst:830 +#: ../../faq/library.rst:801 msgid "" "There are also many other specialized generators in this module, such as:" msgstr "該模組中還有許多其他專用生成器,例如:" -#: ../../faq/library.rst:832 +#: ../../faq/library.rst:803 msgid "``randrange(a, b)`` chooses an integer in the range [a, b)." msgstr "``randrange(a, b)`` 會選擇 [a, b) 範圍內的一個整數。" -#: ../../faq/library.rst:833 +#: ../../faq/library.rst:804 msgid "``uniform(a, b)`` chooses a floating-point number in the range [a, b)." msgstr "``uniform(a, b)`` 會選擇 [a, b) 範圍內的浮點數。" -#: ../../faq/library.rst:834 +#: ../../faq/library.rst:805 msgid "" "``normalvariate(mean, sdev)`` samples the normal (Gaussian) distribution." -msgstr "``normalvariate(mean, sdev)`` 對常態(高斯)分佈進行採樣 (sample)。" +msgstr "``normalvariate(mean, sdev)`` 對常態(高斯)分佈進行取樣 (sample)。" -#: ../../faq/library.rst:836 +#: ../../faq/library.rst:807 msgid "Some higher-level functions operate on sequences directly, such as:" msgstr "一些更高階的函式會直接對序列進行操作,例如:" -#: ../../faq/library.rst:838 +#: ../../faq/library.rst:809 msgid "``choice(S)`` chooses a random element from a given sequence." msgstr "``choice(S)`` 會從給定序列中選擇一個隨機元素。" -#: ../../faq/library.rst:839 +#: ../../faq/library.rst:810 msgid "``shuffle(L)`` shuffles a list in-place, i.e. permutes it randomly." msgstr "``shuffle(L)`` 會原地 (in-place) 打亂 list,即隨機排列它。" -#: ../../faq/library.rst:841 +#: ../../faq/library.rst:812 msgid "" "There's also a ``Random`` class you can instantiate to create independent " "multiple random number generators." diff --git a/faq/programming.po b/faq/programming.po index c7022e1471..33bec77f43 100644 --- a/faq/programming.po +++ b/faq/programming.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,9 +7,9 @@ # hsiao yi , 2016 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-04-06 00:16+0000\n" "PO-Revision-Date: 2024-04-25 14:17+0800\n" "Last-Translator: KNChiu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -296,7 +296,7 @@ msgstr "" msgid "" "In the example above you can access the outer scope variable by declaring it " "global:" -msgstr "在上面的示例中,你可以透過將其聲明為全域變數來存取外部範圍變數:" +msgstr "在上面的範例中,你可以透過將其聲明為全域變數來存取外部範圍變數:" #: ../../faq/programming.rst:167 #, fuzzy @@ -309,11 +309,10 @@ msgstr "" "在外部範圍內修改變數的值:" #: ../../faq/programming.rst:174 -#, fuzzy msgid "" "You can do a similar thing in a nested scope using the :keyword:`nonlocal` " "keyword:" -msgstr "你可以使用 :keyword:`nonlocal` 關鍵字在嵌套範圍內做類似的事情:" +msgstr "你可以使用 :keyword:`nonlocal` 關鍵字在巢狀作用域內做類似的事情:" #: ../../faq/programming.rst:192 msgid "What are the rules for local and global variables in Python?" @@ -347,18 +346,17 @@ msgstr "" "每個參照聲明為全域。這種混亂會破壞用於識別副作用的 ``global`` 聲明的有用性。" #: ../../faq/programming.rst:208 -#, fuzzy msgid "" "Why do lambdas defined in a loop with different values all return the same " "result?" -msgstr "為什麼在具有不同值的循環中定義的 lambda 都回傳相同的結果?" +msgstr "為什麼以不同的值在迴圈中定義的 lambda 都回傳相同的結果?" #: ../../faq/programming.rst:210 msgid "" "Assume you use a for loop to define a few different lambdas (or even plain " "functions), e.g.::" msgstr "" -"假設你使用 for 循環來定義幾個不同的 lambda(甚至是普通函式),例如: ::" +"假設你使用 for 迴圈來定義幾個不同的 lambda(甚至是普通函式),例如: ::" #: ../../faq/programming.rst:213 msgid "" @@ -371,16 +369,15 @@ msgstr "" "... squares.append(lambda: x**2)" #: ../../faq/programming.rst:217 -#, fuzzy msgid "" "This gives you a list that contains 5 lambdas that calculate ``x**2``. You " "might expect that, when called, they would return, respectively, ``0``, " "``1``, ``4``, ``9``, and ``16``. However, when you actually try you will " "see that they all return ``16``::" msgstr "" -"這為你提供了一個包含 5 個計算 ``x**2`` 的 lambda 的list。你可能期望,當被呼叫" -"時,它們會分別回傳 ``0``、``1``、``4``、``9`` 和 ``16``。然而,當你實際嘗試" -"時,你會發現它們都回傳 ``16``: ::" +"這會提供一個包含五個計算 ``x**2`` 的 lambda 串列。你可能會預期在呼叫它時,它" +"們會分別回傳 ``0``、``1``、``4``、``9`` 和 ``16``,然而當你實際嘗試你會發現它" +"們都回傳 ``16``: ::" #: ../../faq/programming.rst:222 msgid "" @@ -395,7 +392,6 @@ msgstr "" "16" #: ../../faq/programming.rst:227 -#, fuzzy msgid "" "This happens because ``x`` is not local to the lambdas, but is defined in " "the outer scope, and it is accessed when the lambda is called --- not when " @@ -403,9 +399,9 @@ msgid "" "the functions now return ``4**2``, i.e. ``16``. You can also verify this by " "changing the value of ``x`` and see how the results of the lambdas change::" msgstr "" -"發生這種情況是因為 ``x`` 不是 lambda 的局部變數,而是在外部作用域中定義的,並" -"且在呼叫 lambda 時存取它——而不是在定義時存取它。在循環結束時,``x`` 的值為 " -"``4``,因此所有函式現在都回傳 ``4**2``,即 ``16``。你還可以透過更改 ``x`` 的" +"發生這種情況是因為 ``x`` 不是 lambda 的局部變數,而是在外部作用域中定義的,且" +"是在呼叫 lambda 時才會存取它,並非於定義時就會存取。在迴圈結束時,``x`` 的值" +"為 ``4``,因此所有函式都回傳 ``4**2``,即為 ``16``。你還可以透過更改 ``x`` 的" "值來驗證這一點,並查看 lambda 運算式的結果如何變化: ::" #: ../../faq/programming.rst:233 @@ -419,7 +415,6 @@ msgstr "" "64" #: ../../faq/programming.rst:237 -#, fuzzy msgid "" "In order to avoid this, you need to save the values in variables local to " "the lambdas, so that they don't rely on the value of the global ``x``::" @@ -447,7 +442,7 @@ msgid "" "Therefore each lambda will now return the correct result::" msgstr "" "在這裡,``n=x`` 建立了一個新變數 ``n`` 局部於 lambda 並在定義 lambda 時計算," -"因此它具有與 ``x`` 在循環中的那個點相同的值。這意味著 ``n`` 的值在第一個 " +"因此它具有與 ``x`` 在迴圈中的那個點相同的值。這意味著 ``n`` 的值在第一個 " "lambda 中為 ``0`` ,在第二個中為 ``1`` ,在第三個中為 ``2`` ,依此類推。因此" "每個 lambda 現在將回傳正確的結果: ::" @@ -494,7 +489,7 @@ msgstr "config.py: ::" #: ../../faq/programming.rst:270 msgid "x = 0 # Default value of the 'x' configuration setting" -msgstr "" +msgstr "x = 0 # 'x' 配置設定的預設值" #: ../../faq/programming.rst:272 msgid "mod.py::" @@ -523,16 +518,14 @@ msgstr "" "print(config.x)" #: ../../faq/programming.rst:283 -#, fuzzy msgid "" "Note that using a module is also the basis for implementing the singleton " "design pattern, for the same reason." msgstr "請注意,出於同樣的原因,使用模組也是實作單例設計模式的基礎。" #: ../../faq/programming.rst:288 -#, fuzzy msgid "What are the \"best practices\" for using import in a module?" -msgstr "在模組中使用 import 的「最佳實踐」是什麼?" +msgstr "在模組中使用 import 的「最佳實踐」有哪些?" #: ../../faq/programming.rst:290 #, fuzzy @@ -578,7 +571,6 @@ msgstr "" "dateutil`, :mod:`!requests`, :mod:`!PIL.Image`" #: ../../faq/programming.rst:304 -#, fuzzy msgid "locally developed modules" msgstr "本地開發的模組" @@ -599,7 +591,7 @@ msgid "" "module is busy importing the 2nd." msgstr "" "在兩個模組都使用 \"import \" 引入形式的情況下,循環引入很好。當第二個" -"模組想要從第一個模組中獲取一個名稱( \"from module import name\" )並且引入位" +"模組想要從第一個模組中取得一個名稱( \"from module import name\" )並且引入位" "於頂層時,它們會失敗。那是因為 1st 中的名稱尚不可用,因為第一個模組正忙於導" "入 2nd。" @@ -649,16 +641,14 @@ msgstr "" "data:`sys.modules` 中可用。" #: ../../faq/programming.rst:338 -#, fuzzy msgid "Why are default values shared between objects?" msgstr "為什麼物件之間共享預設值?" #: ../../faq/programming.rst:340 -#, fuzzy msgid "" "This type of bug commonly bites neophyte programmers. Consider this " "function::" -msgstr "這種型別的錯誤通常會困擾新手程式員。考慮這個功能: ::" +msgstr "這種類型的錯誤通常會困擾新手程式員。像是這個函式: ::" #: ../../faq/programming.rst:342 msgid "" @@ -667,15 +657,18 @@ msgid "" " mydict[key] = value\n" " return mydict" msgstr "" +"def foo(mydict={}): # 危險:所有呼叫共享對字典的參照\n" +" ... 計算一些東西 ...\n" +" mydict[key] = value\n" +" return mydict" #: ../../faq/programming.rst:347 -#, fuzzy msgid "" "The first time you call this function, ``mydict`` contains a single item. " "The second time, ``mydict`` contains two items because when ``foo()`` begins " "executing, ``mydict`` starts out with an item already in it." msgstr "" -"第一次呼叫此函式時, ``mydict`` 包含一個項目。第二次,``mydict`` 包含兩個項" +"第一次呼叫此函式時, ``mydict`` 包含一個項目。第二次後 ``mydict`` 包含兩個項" "目,因為當 ``foo()`` 開始執行時,``mydict`` 以其中已有的項目開始。" #: ../../faq/programming.rst:351 @@ -699,19 +692,18 @@ msgid "" "dictionaries, lists, and class instances can lead to confusion." msgstr "" "根據定義,數字、字串、元組和 ``None`` 等不可變物件是安全的,不會發生變化。對" -"字典、list和類別實例等可變物件的更改可能會導致混淆。" +"字典、串列和類別實例等可變物件的更改可能會導致混淆。" #: ../../faq/programming.rst:360 -#, fuzzy msgid "" "Because of this feature, it is good programming practice to not use mutable " "objects as default values. Instead, use ``None`` as the default value and " "inside the function, check if the parameter is ``None`` and create a new " "list/dictionary/whatever if it is. For example, don't write::" msgstr "" -"由於這個特性,不使用可變物件作為預設值是一個很好的編程習慣。相反,使用 " -"``None`` 作為預設值並在函式內部檢查參數是否為 ``None`` 並建立一個新的list/字" -"典/無論是否是。例如,不要寫: ::" +"由於這個特性,不使用可變物件作為預設值是一個很好的程式設計習慣,而是應使用 " +"``None`` 作為預設值,並在函式內部檢查參數是否為 ``None``,再建立一個新的串列/" +"字典/或其他東西。例如,不要這樣寫: ::" #: ../../faq/programming.rst:365 msgid "" @@ -723,7 +715,7 @@ msgstr "" #: ../../faq/programming.rst:368 msgid "but::" -msgstr "但是: ::" +msgstr "而是寫成: ::" #: ../../faq/programming.rst:370 msgid "" @@ -731,6 +723,9 @@ msgid "" " if mydict is None:\n" " mydict = {} # create a new dict for local namespace" msgstr "" +"def foo(mydict=None):\n" +" if mydict is None:\n" +" mydict = {} # 為區域命名空間建立一個新字典" #: ../../faq/programming.rst:374 #, fuzzy @@ -758,13 +753,21 @@ msgid "" " _cache[(arg1, arg2)] = result # Store result in the cache\n" " return result" msgstr "" +"# 呼叫者只能提供兩個參數,並選擇性地透過關鍵字傳遞 _cache\n" +"def expensive(arg1, arg2, *, _cache={}):\n" +" if (arg1, arg2) in _cache:\n" +" return _cache[(arg1, arg2)]\n" +"\n" +" # Calculate the value\n" +" result = ... expensive computation ...\n" +" _cache[(arg1, arg2)] = result # 將結果儲存在快取中\n" +" return result" #: ../../faq/programming.rst:389 -#, fuzzy msgid "" "You could use a global variable containing a dictionary instead of the " "default value; it's a matter of taste." -msgstr "你可以使用包含字典的全域變數而不是預設值;這是一個品味問題。" +msgstr "你可以使用包含字典的全域變數而不是預設值;這取決於喜好。" #: ../../faq/programming.rst:394 #, fuzzy @@ -803,7 +806,6 @@ msgid "What is the difference between arguments and parameters?" msgstr "引數 (arguments) 和參數 (parameters) 有什麼區別?" #: ../../faq/programming.rst:417 -#, fuzzy msgid "" ":term:`Parameters ` are defined by the names that appear in a " "function definition, whereas :term:`arguments ` are the values " @@ -813,7 +815,7 @@ msgid "" msgstr "" ":term:`參數 `\\ 由出現在函式定義中的名稱定義,而\\ :term:`引數 " "`\\ 是呼叫函式時實際傳遞給函式的值。參數定義函式可以接受的\\ :term:" -"引數種類 `。例如,給定函式定義: ::" +"`引數種類 `。例如,給定以下函式定義: ::" #: ../../faq/programming.rst:423 msgid "" @@ -828,7 +830,7 @@ msgid "" "*foo*, *bar* and *kwargs* are parameters of ``func``. However, when calling " "``func``, for example::" msgstr "" -"*foo*、*bar* 和 *kwargs* 是 ``func`` 的參數。然而,當呼叫 ``func`` 時,例" +"*foo*、*bar* 和 *kwargs* 是 ``func`` 的參數。然而當呼叫 ``func`` 時,例" "如: ::" #: ../../faq/programming.rst:429 @@ -837,11 +839,11 @@ msgstr "func(42, bar=314, extra=somevar)" #: ../../faq/programming.rst:431 msgid "the values ``42``, ``314``, and ``somevar`` are arguments." -msgstr "``42`` 、 ``314`` 和 ``somevar`` 是引數。" +msgstr "``42``、``314`` 和 ``somevar`` 是引數。" #: ../../faq/programming.rst:435 msgid "Why did changing list 'y' also change list 'x'?" -msgstr "為什麼更改 list 'y' 也會更改 list 'x'?" +msgstr "為什麼更改串列 'y' 也會更改串列 'x'?" #: ../../faq/programming.rst:437 msgid "If you wrote code like::" @@ -892,19 +894,17 @@ msgid "" msgstr "list 是 :term:`mutable`,這意味著你可以變更它們的內容。" #: ../../faq/programming.rst:457 -#, fuzzy msgid "" "After the call to :meth:`!append`, the content of the mutable object has " "changed from ``[]`` to ``[10]``. Since both the variables refer to the same " "object, using either name accesses the modified value ``[10]``." msgstr "" "在呼叫 :meth:`!append` 之後,可變物件的內容從 ``[]`` 變成了 ``[10]``。由於這" -"兩個變數都參照同一個物件,因此使用任一名稱都可以存取修改後的值 ``[10]`` 。" +"兩個變數都參照同一個物件,因此使用任一名稱都可以存取修改後的值 ``[10]``。" #: ../../faq/programming.rst:461 -#, fuzzy msgid "If we instead assign an immutable object to ``x``::" -msgstr "如果我們改為將不可變物件分配給 ``x``: ::" +msgstr "如果我們改為賦予一個不可變物件給 ``x``: ::" #: ../../faq/programming.rst:463 msgid "" @@ -916,6 +916,13 @@ msgid "" ">>> y\n" "5" msgstr "" +">>> x = 5 # 整數為不可變的\n" +">>> y = x\n" +">>> x = x + 1 # 5 不可變,在這邊會建立一個新物件\n" +">>> x\n" +"6\n" +">>> y\n" +"5" #: ../../faq/programming.rst:471 #, fuzzy @@ -1004,12 +1011,10 @@ msgstr "" "置函式 :func:`id`。" #: ../../faq/programming.rst:510 -#, fuzzy msgid "How do I write a function with output parameters (call by reference)?" -msgstr "如何編寫帶有輸出參數的函式(透過參照呼叫)?" +msgstr "如何編寫帶有輸出參數的函式(透過傳參照呼叫 (call by reference))?" #: ../../faq/programming.rst:512 -#, fuzzy msgid "" "Remember that arguments are passed by assignment in Python. Since " "assignment just creates references to objects, there's no alias between an " @@ -1017,7 +1022,7 @@ msgid "" "You can achieve the desired effect in a number of ways." msgstr "" "請記住,在 Python 中引數是透過賦值傳遞的。由於賦值只是建立對物件的參照,因此" -"呼叫者和被呼叫者的引數名稱之間沒有別名,因此本身沒有按參照呼叫。你可以透過多" +"呼叫者和被呼叫者的引數名稱之間沒有別名,因此本身沒有傳參照呼叫。你可以透過多" "種方式實作所需的效果。" #: ../../faq/programming.rst:517 @@ -1035,22 +1040,27 @@ msgid "" ">>> func1(x, y)\n" "('new-value', 100)" msgstr "" +">>> def func1(a, b):\n" +"... a = 'new-value' # a 和 b 為區域名稱\n" +"... b = b + 1 # 賦值到新物件\n" +"... return a, b # 回傳新值\n" +"...\n" +">>> x, y = 'old-value', 99\n" +">>> func1(x, y)\n" +"('new-value', 100)" #: ../../faq/programming.rst:528 -#, fuzzy msgid "This is almost always the clearest solution." -msgstr "這幾乎總是最清晰的解決方案。" +msgstr "這幾乎都會是最清楚的方案。" #: ../../faq/programming.rst:530 -#, fuzzy msgid "" "By using global variables. This isn't thread-safe, and is not recommended." -msgstr "透過使用全域變數。這不是執行緒安全的,不推薦。" +msgstr "透過使用全域變數。這不是執行緒安全的,所以不推薦。" #: ../../faq/programming.rst:532 -#, fuzzy msgid "By passing a mutable (changeable in-place) object::" -msgstr "透過傳遞一個可變的(原地可變的)物件: ::" +msgstr "透過傳遞一個可變的(可於原地 (in-place) 改變的)物件: ::" #: ../../faq/programming.rst:534 msgid "" @@ -1063,11 +1073,18 @@ msgid "" ">>> args\n" "['new-value', 100]" msgstr "" +">>> def func2(a):\n" +"... a[0] = 'new-value' # 'a' 參照一個可變的串列\n" +"... a[1] = a[1] + 1 # 改變共享的物件\n" +"...\n" +">>> args = ['old-value', 99]\n" +">>> func2(args)\n" +">>> args\n" +"['new-value', 100]" #: ../../faq/programming.rst:543 -#, fuzzy msgid "By passing in a dictionary that gets mutated::" -msgstr "透過傳入一個發生變異的字典: ::" +msgstr "透過傳入一個發生改變的字典: ::" #: ../../faq/programming.rst:545 msgid "" @@ -1080,9 +1097,16 @@ msgid "" ">>> args\n" "{'a': 'new-value', 'b': 100}" msgstr "" +">>> def func3(args):\n" +"... args['a'] = 'new-value' # args 是可變字典\n" +"... args['b'] = args['b'] + 1 # 原地改變它\n" +"...\n" +">>> args = {'a': 'old-value', 'b': 99}\n" +">>> func3(args)\n" +">>> args\n" +"{'a': 'new-value', 'b': 100}" #: ../../faq/programming.rst:554 -#, fuzzy msgid "Or bundle up values in a class instance::" msgstr "或者在類別實例中捆綁值: ::" @@ -1102,24 +1126,33 @@ msgid "" ">>> vars(args)\n" "{'a': 'new-value', 'b': 100}" msgstr "" +">>> class Namespace:\n" +"... def __init__(self, /, **args):\n" +"... for key, value in args.items():\n" +"... setattr(self, key, value)\n" +"...\n" +">>> def func4(args):\n" +"... args.a = 'new-value' # args 是可變命名空間\n" +"... args.b = args.b + 1 # 原地改變物件\n" +"...\n" +">>> args = Namespace(a='old-value', b=99)\n" +">>> func4(args)\n" +">>> vars(args)\n" +"{'a': 'new-value', 'b': 100}" #: ../../faq/programming.rst:571 -#, fuzzy msgid "There's almost never a good reason to get this complicated." -msgstr "幾乎沒有充分的理由讓事情變得如此復雜。" +msgstr "幾乎不會有要讓事情變得如此複雜的充分理由。" #: ../../faq/programming.rst:573 -#, fuzzy msgid "Your best choice is to return a tuple containing the multiple results." msgstr "你最好的選擇是回傳一個包含多個結果的元組。" #: ../../faq/programming.rst:577 -#, fuzzy msgid "How do you make a higher order function in Python?" msgstr "你如何在 Python 中建立高階函式?" #: ../../faq/programming.rst:579 -#, fuzzy msgid "" "You have two choices: you can use nested scopes or you can use callable " "objects. For example, suppose you wanted to define ``linear(a,b)`` which " @@ -1127,7 +1160,8 @@ msgid "" "scopes::" msgstr "" "你有兩種選擇:可以使用巢狀作用域,也可以使用可呼叫物件。例如,假設你想定義 " -"linear(a,b) ,它回傳一個計算值 a*x+b 的函式 f(x) 。使用嵌套範圍: ::" +"``linear(a,b)``,它會回傳 ``a*x+b`` 計算值的函式 ``f(x)``。使用巢狀作用" +"域: ::" #: ../../faq/programming.rst:583 msgid "" @@ -1164,7 +1198,6 @@ msgstr "" " return self.a * x + self.b" #: ../../faq/programming.rst:598 -#, fuzzy msgid "In both cases, ::" msgstr "在這兩種情況下: ::" @@ -1173,9 +1206,8 @@ msgid "taxes = linear(0.3, 2)" msgstr "taxes = linear(0.3, 2)" #: ../../faq/programming.rst:602 -#, fuzzy msgid "gives a callable object where ``taxes(10e6) == 0.3 * 10e6 + 2``." -msgstr "給出一個可呼叫物件,其中 ``taxes(10e6) == 0.3 * 10e6 + 2``。" +msgstr "給定一個可呼叫物件,其中 ``taxes(10e6) == 0.3 * 10e6 + 2``。" #: ../../faq/programming.rst:604 #, fuzzy @@ -1339,7 +1371,7 @@ msgid "" "instance's name is ``a`` or ``b``, since both names are bound to the same " "value." msgstr "" -"可以說該類別有一個名稱:即使它綁定到兩個名稱並透過名稱 ``B`` 呼叫,建立的實例" +"可以說該類別有一個名稱:即使它綁定到兩個名稱並透過名稱 ``B`` 叫用,建立的實例" "仍然被報告為類別 ``A`` 的實例。但是,無法確定實例的名稱是 ``a`` 還是 ``b`` ," "因為這兩個名稱都綁定到相同的值。" @@ -1379,9 +1411,8 @@ msgid "" msgstr "....如果你發現它有很多名字,或者根本沒有名字,請不要感到驚訝!" #: ../../faq/programming.rst:701 -#, fuzzy msgid "What's up with the comma operator's precedence?" -msgstr "逗號運算子的優先級是怎麼回事?" +msgstr "逗號運算子的優先級是什麼?" #: ../../faq/programming.rst:703 #, fuzzy @@ -1482,7 +1513,7 @@ msgid "" "Bartelt::" msgstr "" "是的。通常這是透過在 :keyword:`!lambda` 中嵌套 :keyword:`lambda` 來完成的。請" -"參閱以下三個示例,稍微改編自 Ulf Bartelt: ::" +"參閱以下三個範例,稍微改編自 Ulf Bartelt: ::" #: ../../faq/programming.rst:747 msgid "" @@ -1517,9 +1548,8 @@ msgid "Don't try this at home, kids!" msgstr "孩子們,不要在家裡嘗試這個!" #: ../../faq/programming.rst:777 -#, fuzzy msgid "What does the slash(/) in the parameter list of a function mean?" -msgstr "函式參數 list 中的斜槓(/)是什麼意思?" +msgstr "函式參數串列中的斜線 (/) 是什麼意思?" #: ../../faq/programming.rst:779 #, fuzzy @@ -1531,8 +1561,8 @@ msgid "" "position. For example, :func:`divmod` is a function that accepts positional-" "only parameters. Its documentation looks like this::" msgstr "" -"函式引數list中的斜杠表示它前面的參數是位置參數。僅位置參數是沒有外部可用名稱" -"的參數。在呼叫接受僅位置參數的函式時,參數僅根據其位置映射到參數。例如,:" +"函式引數list中的斜線表示它前面的參數是位置參數。僅位置參數是沒有外部可用名稱" +"的參數。在呼叫接受僅位置參數的函式時,參數僅根據其位置對映到參數。例如,:" "func:`divmod` 是一個只接受位置參數的函式。它的文件看起來像這樣: ::" #: ../../faq/programming.rst:786 @@ -1550,13 +1580,12 @@ msgstr "" " Return the tuple (x//y, x%y). Invariant: div*y + mod == x." #: ../../faq/programming.rst:792 -#, fuzzy msgid "" "The slash at the end of the parameter list means that both parameters are " "positional-only. Thus, calling :func:`divmod` with keyword arguments would " "lead to an error::" msgstr "" -"參數list末尾的斜杠表示兩個參數都是位置參數。因此,使用關鍵字引數呼叫 :func:" +"參數串列最後的斜線表示兩個參數都是僅限位置參數。因此使用關鍵字引數呼叫 :func:" "`divmod` 會導致錯誤: ::" #: ../../faq/programming.rst:796 @@ -1671,13 +1700,12 @@ msgid "How do I get int literal attribute instead of SyntaxError?" msgstr "如何取得 int 文字屬性而不是 SyntaxError?" #: ../../faq/programming.rst:850 -#, fuzzy msgid "" "Trying to lookup an ``int`` literal attribute in the normal manner gives a :" "exc:`SyntaxError` because the period is seen as a decimal point::" msgstr "" -"嘗試以正常方式查詢 ``int`` 文字屬性會給出一個 SyntaxError ,因為句點被視為小" -"數點: ::" +"嘗試以正常方式查找 ``int`` 字面值屬性會給出一個 :exc:`SyntaxError`,因為句點" +"被視為小數點: ::" #: ../../faq/programming.rst:853 msgid "" @@ -1694,11 +1722,10 @@ msgstr "" "SyntaxError: invalid decimal literal" #: ../../faq/programming.rst:859 -#, fuzzy msgid "" "The solution is to separate the literal from the period with either a space " "or parentheses." -msgstr "解決方案是用空格或圓括號將文字與句點分開。" +msgstr "解決方式是用空格或圓括號將字面值與句點分開。" #: ../../faq/programming.rst:869 msgid "How do I convert a string to a number?" @@ -1711,7 +1738,7 @@ msgid "" "``int('144') == 144``. Similarly, :func:`float` converts to a floating-" "point number, e.g. ``float('144') == 144.0``." msgstr "" -"對於整數,使用內建的 int 型別構造函式,例如``int('144') == 144``。同樣,:" +"對於整數,使用內建的 int 型別建構函式,例如``int('144') == 144``。同樣,:" "func:`float` 轉換為浮點數,例如``浮動('144')== 144.0``。" #: ../../faq/programming.rst:875 @@ -1769,19 +1796,17 @@ msgid "" "sections, e.g. ``\"{:04d}\".format(144)`` yields ``'0144'`` and ``\"{:.3f}\"." "format(1.0/3.0)`` yields ``'0.333'``." msgstr "" -"例如,要將數字 ``144`` 轉換為字串 ``'144'``,請使用內建型別構造函式 :func:" +"例如,要將數字 ``144`` 轉換為字串 ``'144'``,請使用內建型別建構函式 :func:" "`str`。如果你想要十六進製或八進製表示,請使用內建函式 :func:`hex` 或 :func:" "`oct`。對於精美的格式,請參閱:ref:`f-strings` 和:ref:`formatstrings` 部分,例" "如``\"{:04d}\".format(144)`` 產生 ``'0144'`` 和 ``\"{:.3f}\"." "format(1.0/3.0)`` 產生 ``'0.333'`` ." #: ../../faq/programming.rst:906 -#, fuzzy msgid "How do I modify a string in place?" msgstr "如何原地修改字串?" #: ../../faq/programming.rst:908 -#, fuzzy msgid "" "You can't, because strings are immutable. In most situations, you should " "simply construct a new string from the various parts you want to assemble it " @@ -1789,8 +1814,8 @@ msgid "" "unicode data, try using an :class:`io.StringIO` object or the :mod:`array` " "module::" msgstr "" -"你不能,因為字串是不可變的。在大多數情況下,你應該簡單地從要組裝的各個部分構" -"造一個新字串。但是,如果你需要一個能夠修改原地 unicode 資料的物件,請嘗試使" +"這沒辦法做到,因為字串是不可變的。在大多數情況下,你應以要拿來組裝的各個部分" +"建構出一個新字串。但是如果你需要一個能夠原地修改 unicode 資料的物件,請嘗試使" "用 :class:`io.StringIO` 物件或 :mod:`array` 模組: ::" #: ../../faq/programming.rst:914 @@ -1808,12 +1833,12 @@ msgid "" "'Hello, there!'\n" "\n" ">>> import array\n" -">>> a = array.array('u', s)\n" +">>> a = array.array('w', s)\n" ">>> print(a)\n" -"array('u', 'Hello, world')\n" +"array('w', 'Hello, world')\n" ">>> a[0] = 'y'\n" ">>> print(a)\n" -"array('u', 'yello, world')\n" +"array('w', 'yello, world')\n" ">>> a.tounicode()\n" "'yello, world'" msgstr "" @@ -1830,24 +1855,22 @@ msgstr "" "'Hello, there!'\n" "\n" ">>> import array\n" -">>> a = array.array('u', s)\n" +">>> a = array.array('w', s)\n" ">>> print(a)\n" -"array('u', 'Hello, world')\n" +"array('w', 'Hello, world')\n" ">>> a[0] = 'y'\n" ">>> print(a)\n" -"array('u', 'yello, world')\n" +"array('w', 'yello, world')\n" ">>> a.tounicode()\n" "'yello, world'" #: ../../faq/programming.rst:938 -#, fuzzy msgid "How do I use strings to call functions/methods?" msgstr "如何使用字串呼叫函式/方法?" #: ../../faq/programming.rst:940 -#, fuzzy msgid "There are various techniques." -msgstr "有各種各樣的技術。" +msgstr "有各式各樣的技法。" #: ../../faq/programming.rst:942 #, fuzzy @@ -1857,8 +1880,8 @@ msgid "" "names of the functions. This is also the primary technique used to emulate " "a case construct::" msgstr "" -"最好的方法是使用將字串映射到函式的字典。這種技術的主要優點是字串不需要與函式" -"名稱相匹配。這也是用於模擬案例構造的主要技術: ::" +"最好的方法是使用將字串對映到函式的字典。這種技術的主要優點是字串不需要與函式" +"名稱相匹配。這也是用於模擬案例建構的主要技術: ::" #: ../../faq/programming.rst:947 msgid "" @@ -1886,16 +1909,14 @@ msgstr "" "getattr(foo, 'bar')()" #: ../../faq/programming.rst:962 -#, fuzzy msgid "" "Note that :func:`getattr` works on any object, including classes, class " "instances, modules, and so on." msgstr "請注意 :func:`getattr` 適用於任何物件,包括類別、類別實例、模組等。" #: ../../faq/programming.rst:965 -#, fuzzy msgid "This is used in several places in the standard library, like this::" -msgstr "這在標準函式庫中的幾個地方使用,如下所示: ::" +msgstr "這在標準函式庫中的幾個地方被使用,如: ::" #: ../../faq/programming.rst:967 msgid "" @@ -1944,9 +1965,10 @@ msgstr "" #: ../../faq/programming.rst:990 #, fuzzy msgid "" -"Is there an equivalent to Perl's chomp() for removing trailing newlines from " -"strings?" -msgstr "是否有與 Perl 的 chomp() 等效的方法用於從字串中刪除尾隨換行符?" +"Is there an equivalent to Perl's ``chomp()`` for removing trailing newlines " +"from strings?" +msgstr "" +"是否有與 Perl 的 chomp() 等效的方法,能用於從字串中刪除後綴的換行符號?" #: ../../faq/programming.rst:992 msgid "" @@ -1982,8 +2004,8 @@ msgstr "" #: ../../faq/programming.rst:1009 #, fuzzy -msgid "Is there a scanf() or sscanf() equivalent?" -msgstr "是否有 scanf() 或 sscanf() 等價物?" +msgid "Is there a ``scanf()`` or ``sscanf()`` equivalent?" +msgstr "是否有 scanf() 或 sscanf() 的等效方法?" #: ../../faq/programming.rst:1011 #, fuzzy @@ -2014,7 +2036,8 @@ msgstr "" "對於更複雜的輸入解析,正則運算式比 C 的 ``sscanf`` 更強大,更適合這項任務。" #: ../../faq/programming.rst:1024 -msgid "What does 'UnicodeDecodeError' or 'UnicodeEncodeError' error mean?" +#, fuzzy +msgid "What does ``UnicodeDecodeError`` or ``UnicodeEncodeError`` error mean?" msgstr "'UnicodeDecodeError' 或 'UnicodeEncodeErro' 錯誤是什麼意思?" #: ../../faq/programming.rst:1026 @@ -2024,27 +2047,27 @@ msgstr "請參閱 :ref:`unicode-howto`。" #: ../../faq/programming.rst:1032 #, fuzzy msgid "Can I end a raw string with an odd number of backslashes?" -msgstr "我可以用奇數個反斜杠結束原始字串嗎?" +msgstr "我可以用奇數個反斜線結束原始字串嗎?" #: ../../faq/programming.rst:1034 #, fuzzy msgid "" "A raw string ending with an odd number of backslashes will escape the " "string's quote::" -msgstr "以奇數個反斜杠結尾的原始字串將轉義字串的引號: ::" +msgstr "以奇數個反斜線結尾的原始字串將跳脫字串的引號: ::" #: ../../faq/programming.rst:1036 msgid "" ">>> r'C:\\this\\will\\not\\work\\'\n" " File \"\", line 1\n" " r'C:\\this\\will\\not\\work\\'\n" -" ^\n" +" ^\n" "SyntaxError: unterminated string literal (detected at line 1)" msgstr "" ">>> r'C:\\this\\will\\not\\work\\'\n" " File \"\", line 1\n" " r'C:\\this\\will\\not\\work\\'\n" -" ^\n" +" ^\n" "SyntaxError: unterminated string literal (detected at line 1)" #: ../../faq/programming.rst:1042 @@ -2052,7 +2075,7 @@ msgstr "" msgid "" "There are several workarounds for this. One is to use regular strings and " "double the backslashes::" -msgstr "有幾種解決方法。一種是使用常規字串並加倍反斜杠: ::" +msgstr "有幾種解決方法。一種是使用常規字串並加倍反斜線: ::" #: ../../faq/programming.rst:1045 msgid "" @@ -2067,7 +2090,7 @@ msgstr "" msgid "" "Another is to concatenate a regular string containing an escaped backslash " "to the raw string::" -msgstr "另一種方法是將包含轉義反斜杠的常規字串連接到原始字串: ::" +msgstr "另一種方法是將包含跳脫反斜線的常規字串連接到原始字串: ::" #: ../../faq/programming.rst:1051 msgid "" @@ -2082,7 +2105,7 @@ msgstr "" msgid "" "It is also possible to use :func:`os.path.join` to append a backslash on " "Windows::" -msgstr "也可以使用 :func:`os.path.join` 在 Windows 上附加反斜杠: ::" +msgstr "也可以使用 :func:`os.path.join` 在 Windows 上附加反斜線: ::" #: ../../faq/programming.rst:1056 msgid "" @@ -2100,8 +2123,8 @@ msgid "" "the value of the raw string. That is, the backslash remains present in the " "value of the raw string::" msgstr "" -"請注意,雖然為了確定原始字串的結束位置而使用反斜杠「跳脫」引號,但在解釋原始" -"字串的值時不會發生轉義。也就是說,反斜杠仍然存在於原始字串的值中: ::" +"請注意,雖然為了確定原始字串的結束位置而使用反斜線「跳脫」引號,但在解釋原始" +"字串的值時不會發生跳脫。也就是說,反斜線仍然存在於原始字串的值中: ::" #: ../../faq/programming.rst:1064 msgid "" @@ -2118,7 +2141,7 @@ msgstr "另請參閱 :ref:`語言參考 ` 中的規範。" #: ../../faq/programming.rst:1070 msgid "Performance" -msgstr "" +msgstr "效能" #: ../../faq/programming.rst:1073 msgid "My program is too slow. How do I speed it up?" @@ -2161,7 +2184,7 @@ msgid "" "Writing benchmark scripts will allow you to iterate quickly when searching " "for improvements (see the :mod:`timeit` module)." msgstr "" -"編寫基準測試腳本將允許你在搜索改進時快速疊代(請參閱 :mod:`timeit` 模組)。" +"編寫基準測試腳本將允許你在搜尋改進時快速疊代(請參閱 :mod:`timeit` 模組)。" #: ../../faq/programming.rst:1086 #, fuzzy @@ -2216,7 +2239,7 @@ msgstr "" "當標準函式庫提供用於執行某些操作的原語時,它很可能(儘管不能保證)比你可能想" "出的任何替代方法都更快。對於用 C 編寫的原語,例如內建函式和一些擴充型別,情況" "更是如此。例如,請務必使用 :meth:`list.sort` 內建方法或相關的 :func:`sorted` " -"函式進行排序(有關高階用法的示例,請參閱 :ref:`sortinghowto` )." +"函式進行排序(有關高階用法的範例,請參閱 :ref:`sortinghowto` )." #: ../../faq/programming.rst:1109 #, fuzzy @@ -2245,9 +2268,9 @@ msgid "" msgstr "" "如果你已經達到純 Python 所能允許的極限,可以使用一些工具讓你走得更遠。例如," "`Cython `_ 可以將稍微修改過的 Python 程式碼編譯成 C 擴" -"充,並且可以在許多不同的平台上使用。 Cython 可以利用編譯(和可選的型別註釋)" -"使你的程式碼比解釋時快得多。如果你對自己的 C 編程技能有信心,你也可以 :ref:`" -"自己編寫一個 C 擴充模組 `。" +"充,並且可以在許多不同的平台上使用。Cython 可以利用編譯(和可選的型別註釋)使" +"你的程式碼比解釋時快得多。如果你對自己的 C 程式設計技能有信心,你也可以\\ :" +"ref:`自己編寫一個 C 擴充模組 `。" #: ../../faq/programming.rst:1125 msgid "" @@ -2290,6 +2313,10 @@ msgid "" " chunks.append(s)\n" "result = ''.join(chunks)" msgstr "" +"chunks = []\n" +"for s in my_strings:\n" +" chunks.append(s)\n" +"result = ''.join(chunks)" #: ../../faq/programming.rst:1146 #, fuzzy @@ -2312,25 +2339,25 @@ msgid "" "for b in my_bytes_objects:\n" " result += b" msgstr "" +"result = bytearray()\n" +"for b in my_bytes_objects:\n" +" result += b" #: ../../faq/programming.rst:1157 -#, fuzzy msgid "Sequences (Tuples/Lists)" -msgstr "序列(元組/list)" +msgstr "序列(元組/串列)" #: ../../faq/programming.rst:1160 -#, fuzzy msgid "How do I convert between tuples and lists?" -msgstr "如何在元組和list之間進行轉換?" +msgstr "如何在元組和串列之間進行轉換?" #: ../../faq/programming.rst:1162 -#, fuzzy msgid "" "The type constructor ``tuple(seq)`` converts any sequence (actually, any " "iterable) into a tuple with the same items in the same order." msgstr "" -"型別構造器 ``tuple(seq)`` 將任何序列(實際上是任何可疊代物件)轉換為具有相同" -"順序的相同項的元組。" +"型別建構函式 ``tuple(seq)`` 將任何序列(實際上是任何可疊代物件)轉換為具有相" +"同順序的相同項的元組。" #: ../../faq/programming.rst:1165 #, fuzzy @@ -2352,15 +2379,14 @@ msgid "" "3))`` yields ``[1, 2, 3]`` and ``list('abc')`` yields ``['a', 'b', 'c']``. " "If the argument is a list, it makes a copy just like ``seq[:]`` would." msgstr "" -"型別構造函式 ``list(seq)`` 將任何序列或可疊代物件轉換為具有相同順序的相同項目" +"型別建構函式 ``list(seq)`` 將任何序列或可疊代物件轉換為具有相同順序的相同項目" "的list。例如,``list((1, 2, 3))`` 產生``[1, 2, 3]`` 和``list('abc')`` 產生" "``['a', 'b ', 'c']``。如果引數是一個list,它會像 ``seq[:]`` 那樣製作一個副" "本。" #: ../../faq/programming.rst:1177 -#, fuzzy msgid "What's a negative index?" -msgstr "什麼是負指數?" +msgstr "什麼是負索引?" #: ../../faq/programming.rst:1179 #, fuzzy @@ -2409,27 +2435,24 @@ msgid "" msgstr "這不會觸及你的原始序列,但會構建一個具有相反順序的新副本以進行疊代。" #: ../../faq/programming.rst:1202 -#, fuzzy msgid "How do you remove duplicates from a list?" -msgstr "如何從list中刪除重複項?" +msgstr "如何從串列中刪除重複項?" #: ../../faq/programming.rst:1204 -#, fuzzy msgid "See the Python Cookbook for a long discussion of many ways to do this:" -msgstr "請參閱 Python Cookbook 以獲取有關執行此操作的多種方法的詳細討論:" +msgstr "請參閱 Python Cookbook 以得到有關執行此操作的各種方法的詳細討論:" #: ../../faq/programming.rst:1206 msgid "https://code.activestate.com/recipes/52560/" msgstr "https://code.activestate.com/recipes/52560/" #: ../../faq/programming.rst:1208 -#, fuzzy msgid "" "If you don't mind reordering the list, sort it and then scan from the end of " "the list, deleting duplicates as you go::" msgstr "" -"如果你不介意重新排序list,請對其進行排序,然後從list末尾開始掃描,同時刪除重" -"複項: ::" +"如果你不介意重新排序串列,可以對其進行排序,然後從串列末尾開始掃描,同時刪除" +"重複項: ::" #: ../../faq/programming.rst:1211 msgid "" @@ -2442,31 +2465,36 @@ msgid "" " else:\n" " last = mylist[i]" msgstr "" +"if mylist:\n" +" mylist.sort()\n" +" last = mylist[-1]\n" +" for i in range(len(mylist)-2, -1, -1):\n" +" if last == mylist[i]:\n" +" del mylist[i]\n" +" else:\n" +" last = mylist[i]" #: ../../faq/programming.rst:1220 -#, fuzzy msgid "" "If all elements of the list may be used as set keys (i.e. they are all :term:" "`hashable`) this is often faster ::" msgstr "" -"如果list的所有元素都可以用作集合鍵(即它們都是 :term:`hashable`),這通常會更" -"快: ::" +"如果串列的所有元素都可以做為集合的鍵(即它們都必須是 :term:`hashable`),那這" +"通常會更快: ::" #: ../../faq/programming.rst:1223 msgid "mylist = list(set(mylist))" -msgstr "" +msgstr "mylist = list(set(mylist))" #: ../../faq/programming.rst:1225 -#, fuzzy msgid "" "This converts the list into a set, thereby removing duplicates, and then " "back into a list." -msgstr "這會將list轉換為一個集合,從而刪除重複項,然後再轉換回list。" +msgstr "這會將串列轉換為一個集合,從而刪除重複項,然後再轉換回串列。" #: ../../faq/programming.rst:1230 -#, fuzzy msgid "How do you remove multiple items from a list" -msgstr "如何從list中刪除多個項目" +msgstr "如何從串列中刪除多個項目" #: ../../faq/programming.rst:1232 #, fuzzy @@ -2550,14 +2578,12 @@ msgstr "" "樣做,因為它通常比使用 Python list慢很多。" #: ../../faq/programming.rst:1273 -#, fuzzy msgid "How do I create a multidimensional list?" -msgstr "如何建立多維 list?" +msgstr "如何建立多維度串列?" #: ../../faq/programming.rst:1275 -#, fuzzy msgid "You probably tried to make a multidimensional array like this::" -msgstr "你可能嘗試製作這樣的多維數組: ::" +msgstr "你可能會這樣建立一個多維度陣列: ::" #: ../../faq/programming.rst:1277 msgid ">>> A = [[None] * 2] * 3" @@ -2576,9 +2602,8 @@ msgstr "" "[[None, None], [None, None], [None, None]]" #: ../../faq/programming.rst:1290 -#, fuzzy msgid "But when you assign a value, it shows up in multiple places:" -msgstr "但是當你分配一個值時,它會出現在多個地方:" +msgstr "但是當你賦予一個值時,它會出現在多個地方:" #: ../../faq/programming.rst:1296 msgid "" @@ -2586,25 +2611,26 @@ msgid "" ">>> A\n" "[[5, None], [5, None], [5, None]]" msgstr "" +">>> A[0][0] = 5\n" +">>> A\n" +"[[5, None], [5, None], [5, None]]" #: ../../faq/programming.rst:1302 -#, fuzzy msgid "" "The reason is that replicating a list with ``*`` doesn't create copies, it " "only creates references to the existing objects. The ``*3`` creates a list " "containing 3 references to the same list of length two. Changes to one row " "will show in all rows, which is almost certainly not what you want." msgstr "" -"原因是複製帶有 ``*`` 的list不會建立副本,它只會建立對現有物件的參照。 ``*3`` " -"建立一個list,其中包含 3 個對長度為 2 的相同list的參照。對一行的更改將顯示在" -"所有行中,這幾乎肯定不是你想要的。" +"原因是複製帶有 ``*`` 的串列不會建立副本,它只會建立對現有物件的參照。``*3`` " +"建立一個串列,其中包含 3 個對長度為 2 的相同串列的參照。對其中一列的變更也將" +"顯示在所有其他列中,而這幾乎不會是你想要的。" #: ../../faq/programming.rst:1307 -#, fuzzy msgid "" "The suggested approach is to create a list of the desired length first and " "then fill in each element with a newly created list::" -msgstr "建議的方法是先建立所需長度的list,然後用新建立的list填充每個元素: ::" +msgstr "建議的方法是先建立所需長度的串列,然後用新建立的串列填充每個元素: ::" #: ../../faq/programming.rst:1310 msgid "" @@ -2612,34 +2638,37 @@ msgid "" "for i in range(3):\n" " A[i] = [None] * 2" msgstr "" +"A = [None] * 3\n" +"for i in range(3):\n" +" A[i] = [None] * 2" #: ../../faq/programming.rst:1314 -#, fuzzy msgid "" "This generates a list containing 3 different lists of length two. You can " "also use a list comprehension::" msgstr "" -"這會生成一個包含 3 個長度為 2 的不同list的list。你還可以使用list推導: ::" +"這會產生一個包含 3 個長度為 2 的不同串列的串列。你也可以使用串列綜合運算" +"式: ::" #: ../../faq/programming.rst:1317 msgid "" "w, h = 2, 3\n" "A = [[None] * w for i in range(h)]" msgstr "" +"w, h = 2, 3\n" +"A = [[None] * w for i in range(h)]" #: ../../faq/programming.rst:1320 -#, fuzzy msgid "" "Or, you can use an extension that provides a matrix datatype; `NumPy " "`_ is the best known." msgstr "" -"或者,你可以使用提供矩陣資料型別的擴充; `NumPy `_ 是最著" -"名的。" +"或者你也可以使用提供矩陣資料型別的擴充套件;`NumPy `_ 是" +"其中最著名的一個。" #: ../../faq/programming.rst:1325 -#, fuzzy msgid "How do I apply a method or function to a sequence of objects?" -msgstr "如何將方法或函式應用於一系列物件?" +msgstr "如何將方法或函式應用於物件序列?" #: ../../faq/programming.rst:1327 #, fuzzy @@ -2656,13 +2685,16 @@ msgid "" "\n" "result = [function(obj) for obj in mylist]" msgstr "" +"result = [obj.method() for obj in mylist]\n" +"\n" +"result = [function(obj) for obj in mylist]" #: ../../faq/programming.rst:1334 #, fuzzy msgid "" "To just run the method or function without saving the return values, a " "plain :keyword:`for` loop will suffice::" -msgstr "要只運行方法或函式而不保存回傳值,一個普通的 for 循環就足夠了: ::" +msgstr "要只運行方法或函式而不保存回傳值,一個普通的 for 迴圈就足夠了: ::" #: ../../faq/programming.rst:1337 msgid "" @@ -2672,12 +2704,16 @@ msgid "" "for obj in mylist:\n" " function(obj)" msgstr "" +"for obj in mylist:\n" +" obj.method()\n" +"\n" +"for obj in mylist:\n" +" function(obj)" #: ../../faq/programming.rst:1346 -#, fuzzy msgid "" "Why does a_tuple[i] += ['item'] raise an exception when the addition works?" -msgstr "為什麼 a_tuple[i] += ['item'] 在加法工作時引發例外?" +msgstr "為什麼 a_tuple[i] += ['item'] 做加法時會引發例外?" #: ../../faq/programming.rst:1348 #, fuzzy @@ -2697,10 +2733,9 @@ msgid "" "a ``list`` and ``+=`` as our exemplar." msgstr "" "當擴充賦值運算子應用於指向可變物件的元組元素時,此討論通常適用,但我們將使用 " -"``list`` 和 ``+=\" 作為示例。" +"``list`` 和 ``+=\" 作為範例。" #: ../../faq/programming.rst:1356 -#, fuzzy msgid "If you wrote::" msgstr "如果你寫了: ::" @@ -2712,6 +2747,11 @@ msgid "" " ...\n" "TypeError: 'tuple' object does not support item assignment" msgstr "" +">>> a_tuple = (1, 2)\n" +">>> a_tuple[0] += 1\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: 'tuple' object does not support item assignment" #: ../../faq/programming.rst:1364 #, fuzzy @@ -2727,11 +2767,10 @@ msgstr "" "會得到一個錯誤,因為我們無法更改元組的元素指向的內容。" #: ../../faq/programming.rst:1370 -#, fuzzy msgid "" "Under the covers, what this augmented assignment statement is doing is " "approximately this::" -msgstr "在幕後,這個擴充賦值陳述式所做的大致是這樣的: ::" +msgstr "這個增強賦值陳述式在背後大致是做這些事情: ::" #: ../../faq/programming.rst:1373 msgid "" @@ -2741,6 +2780,11 @@ msgid "" " ...\n" "TypeError: 'tuple' object does not support item assignment" msgstr "" +">>> result = a_tuple[0] + 1\n" +">>> a_tuple[0] = result\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: 'tuple' object does not support item assignment" #: ../../faq/programming.rst:1379 #, fuzzy @@ -2831,9 +2875,8 @@ msgstr "" "賦值仍然發生。" #: ../../faq/programming.rst:1419 -#, fuzzy msgid "Thus, in our tuple example what is happening is equivalent to::" -msgstr "因此,在我們的元組示例中,發生的事情等同於: ::" +msgstr "因此,在我們的元組範例中,發生的事情等同於: ::" #: ../../faq/programming.rst:1421 msgid "" @@ -2843,6 +2886,11 @@ msgid "" " ...\n" "TypeError: 'tuple' object does not support item assignment" msgstr "" +">>> result = a_tuple[0].__iadd__(['item'])\n" +">>> a_tuple[0] = result\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: 'tuple' object does not support item assignment" #: ../../faq/programming.rst:1427 #, fuzzy @@ -2857,7 +2905,6 @@ msgstr "" "可變的。" #: ../../faq/programming.rst:1433 -#, fuzzy msgid "" "I want to do a complicated sort: can you do a Schwartzian Transform in " "Python?" @@ -2871,8 +2918,8 @@ msgid "" "value\". In Python, use the ``key`` argument for the :meth:`list.sort` " "method::" msgstr "" -"該技術歸功於 Perl 社區的 Randal Schwartz,它透過將每個元素映射到其「排序值」" -"的度量對list的元素進行排序。在 Python 中,對 :meth:`list.sort` 方法使用 " +"該技術歸功於 Perl 社區的 Randal Schwartz,它透過將每個元素對映到其「排序值」" +"的度量對串列的元素進行排序。在 Python 中,對 :meth:`list.sort` 方法使用 " "``key`` 引數: ::" #: ../../faq/programming.rst:1439 @@ -2884,18 +2931,16 @@ msgstr "" "Isorted.sort(key=lambda s: int(s[10:15]))" #: ../../faq/programming.rst:1444 -#, fuzzy msgid "How can I sort one list by values from another list?" -msgstr "如何根據另一個list中的值對一個list進行排序?" +msgstr "如何根據另一個串列中的值對一個串列進行排序?" #: ../../faq/programming.rst:1446 -#, fuzzy msgid "" "Merge them into an iterator of tuples, sort the resulting list, and then " "pick out the element you want. ::" msgstr "" -"將它們合併到一個元組疊代器中,對結果list進行排序,然後挑選出你想要的元" -"素。: ::" +"將它們合併到一個元組疊代器中,對結果的串列進行排序,然後挑選出你想要的元" +"素。 ::" #: ../../faq/programming.rst:1449 msgid "" @@ -2980,32 +3025,29 @@ msgstr "" " return arg * 2 + self.attribute" #: ../../faq/programming.rst:1491 -#, fuzzy msgid "What is self?" -msgstr "什麼是自我?" +msgstr "什麼是 self?" #: ../../faq/programming.rst:1493 -#, fuzzy msgid "" "Self is merely a conventional name for the first argument of a method. A " "method defined as ``meth(self, a, b, c)`` should be called as ``x.meth(a, b, " "c)`` for some instance ``x`` of the class in which the definition occurs; " "the called method will think it is called as ``meth(x, a, b, c)``." msgstr "" -"Self 只是方法第一個引數的約定名稱。一個定義為 ``meth(self, a, b, c)`` 的方法" -"應該被呼叫為 ``x.meth(a, b, c)`` 對於其中類別的某個實例 ``x``定義發生;被呼叫" -"的方法會認為它被稱為 ``meth(x, a, b, c)`` 。" +"Self 只是方法第一個引數的約定名稱。對於所定義類別的某個實例 ``x``,一個定義" +"為 ``meth(self, a, b, c)`` 的方法應該以 ``x.meth(a, b, c)`` 形式來呼叫;被呼" +"叫的方法會認為它是以 ``meth(x, a, b, c)`` 來呼叫的。" #: ../../faq/programming.rst:1498 msgid "See also :ref:`why-self`." msgstr "另請參閱 :ref:`why-self`。" #: ../../faq/programming.rst:1502 -#, fuzzy msgid "" "How do I check if an object is an instance of a given class or of a subclass " "of it?" -msgstr "如何檢查一個物件是給定類別的實例還是它的子類別的實例?" +msgstr "如何檢查物件是否是給定類別的實例或其子類別的實例?" #: ../../faq/programming.rst:1504 #, fuzzy @@ -3024,16 +3066,16 @@ msgstr "" "complex))``。" #: ../../faq/programming.rst:1511 -#, fuzzy msgid "" "Note that :func:`isinstance` also checks for virtual inheritance from an :" "term:`abstract base class`. So, the test will return ``True`` for a " "registered class even if hasn't directly or indirectly inherited from it. " "To test for \"true inheritance\", scan the :term:`MRO` of the class:" msgstr "" -"請注意:func:`isinstance` 還檢查來自:term:`抽象基底類別` 的虛擬繼承。因此,測" -"試將為已註冊的類別回傳 ``True``,即使沒有直接或間接繼承自它。要測試「真正的繼" -"承」,請掃描該類別的 MRO:" +"請注意,:func:`isinstance` 還會檢查來自\\ :term:`抽象基底類別 (abstract base " +"class) ` 的虛擬繼承。因此對已註冊類別的檢驗會回傳 " +"``True``,即使沒有直接或間接繼承自它。要測試「真正繼承」,請掃描該類別的 :" +"term:`MRO`:" #: ../../faq/programming.rst:1516 msgid "" @@ -3075,6 +3117,21 @@ msgid "" ">>> Mapping in type(c).__mro__\n" "False" msgstr "" +">>> c = C()\n" +">>> isinstance(c, C) # 直接\n" +"True\n" +">>> isinstance(c, P) # 間接\n" +"True\n" +">>> isinstance(c, Mapping) # 虛擬\n" +"True\n" +"\n" +"# 實際的繼承鏈結\n" +">>> type(c).__mro__\n" +"(, , )\n" +"\n" +"# 「真正繼承」的檢驗\n" +">>> Mapping in type(c).__mro__\n" +"False" #: ../../faq/programming.rst:1546 #, fuzzy @@ -3101,17 +3158,16 @@ msgid "" msgstr "" "def search(obj):\n" " if isinstance(obj, Mailbox):\n" -" ... # code to search a mailbox\n" +" ... # 搜尋信箱的程式碼\n" " elif isinstance(obj, Document):\n" -" ... # code to search a document\n" +" ... # 搜尋文件的程式碼\n" " elif ..." #: ../../faq/programming.rst:1560 -#, fuzzy msgid "" "A better approach is to define a ``search()`` method on all the classes and " "just call it::" -msgstr "更好的方法是在所有類別上定義一個 ``search()`` 方法,然後呼叫它: ::" +msgstr "更好的方法是在所有類別上定義一個 ``search()`` 方法然後呼叫它: ::" #: ../../faq/programming.rst:1563 msgid "" @@ -3125,14 +3181,21 @@ msgid "" "\n" "obj.search()" msgstr "" +"class Mailbox:\n" +" def search(self):\n" +" ... # 搜尋信箱的程式碼\n" +"\n" +"class Document:\n" +" def search(self):\n" +" ... # 搜尋文件的程式碼\n" +"\n" +"obj.search()" #: ../../faq/programming.rst:1575 -#, fuzzy msgid "What is delegation?" -msgstr "什麼是委派?" +msgstr "什麼是委派 (delegation)?" #: ../../faq/programming.rst:1577 -#, fuzzy msgid "" "Delegation is an object oriented technique (also called a design pattern). " "Let's say you have an object ``x`` and want to change the behaviour of just " @@ -3140,19 +3203,18 @@ msgid "" "implementation of the method you're interested in changing and delegates all " "other methods to the corresponding method of ``x``." msgstr "" -"委託是一種面向物件的技術(也稱為設計模式)。假設你有一個物件 ``x`` 並且只想更" -"改其中一個方法的行為。你可以建立一個新類別,它提供你感興趣的方法的新實作,並" -"將所有其他方法委託給 ``x`` 的相應方法。" +"委派是一種物件導向的技法(也稱為設計模式)。假設你有一個物件 ``x`` 並且只想更" +"改其中一個方法的行為。你可以建立一個新類別,它提供你想改變的那個方法的新實" +"作,並將所有其他方法委派給 ``x`` 的相應方法。" #: ../../faq/programming.rst:1583 -#, fuzzy msgid "" "Python programmers can easily implement delegation. For example, the " "following class implements a class that behaves like a file but converts all " "written data to uppercase::" msgstr "" -"Python 程式員可以輕鬆實作委託。例如,下面的類別實作了一個行為類似於檔案但將所" -"有寫入資料轉換為大寫的類別: ::" +"Python 程式設計師可以輕鬆地實作委派。舉例來說,以下類別實作了一個行為類似檔案" +"的類別,但將所有寫入的資料轉換為大寫:" #: ../../faq/programming.rst:1587 msgid "" @@ -3221,27 +3283,43 @@ msgstr "" " ..." #: ../../faq/programming.rst:1616 -#, fuzzy msgid "" -"Most :meth:`!__setattr__` implementations must modify :meth:`self.__dict__ " -"` to store local state for self without causing an infinite " -"recursion." +"Many :meth:`~object.__setattr__` implementations call :meth:`!object." +"__setattr__` to set an attribute on self without causing infinite recursion::" +msgstr "" +"許多 :meth:`~object.__setattr__` 的實作會呼叫 :meth:`!object.__setattr__` 以" +"設定 self 的屬性,而不會導致無限遞迴。" + +#: ../../faq/programming.rst:1619 +msgid "" +"class X:\n" +" def __setattr__(self, name, value):\n" +" # Custom logic here...\n" +" object.__setattr__(self, name, value)" +msgstr "" +"class X:\n" +" def __setattr__(self, name, value):\n" +" # 自訂邏輯放在這裡...\n" +" object.__setattr__(self, name, value)" + +#: ../../faq/programming.rst:1624 +msgid "" +"Alternatively, it is possible to set attributes by inserting entries into :" +"attr:`self.__dict__ ` directly." msgstr "" -"大多數 :meth:`!__setattr__` 實作必須修改 :meth:`self.__dict__ ` 以存儲 self 的本地狀態,而不會導致無限遞迴。" -#: ../../faq/programming.rst:1622 +#: ../../faq/programming.rst:1629 #, fuzzy msgid "" "How do I call a method defined in a base class from a derived class that " "extends it?" msgstr "如何從擴充它的衍生類別呼叫基底類別中定義的方法?" -#: ../../faq/programming.rst:1624 +#: ../../faq/programming.rst:1631 msgid "Use the built-in :func:`super` function::" msgstr "使用內建的 :func:`super` 函式: ::" -#: ../../faq/programming.rst:1626 +#: ../../faq/programming.rst:1633 msgid "" "class Derived(Base):\n" " def meth(self):\n" @@ -3249,25 +3327,21 @@ msgid "" msgstr "" "class Derived(Base):\n" " def meth(self):\n" -" super().meth() # calls Base.meth" +" super().meth() # 呼叫 Base.meth" -#: ../../faq/programming.rst:1630 -#, fuzzy +#: ../../faq/programming.rst:1637 msgid "" "In the example, :func:`super` will automatically determine the instance from " "which it was called (the ``self`` value), look up the :term:`method " "resolution order` (MRO) with ``type(self).__mro__``, and return the next in " "line after ``Derived`` in the MRO: ``Base``." msgstr "" -"在示例中,:func:`super` 將自動確定呼叫它的實例(``self`` 值),使用 " -"``type(self ).__mro__``,並回傳 MRO 中``Derived`` 之後的下一行:``Base``。" -#: ../../faq/programming.rst:1637 -#, fuzzy +#: ../../faq/programming.rst:1644 msgid "How can I organize my code to make it easier to change the base class?" -msgstr "我如何組織我的程式碼以便更容易地更改基底類別?" +msgstr "我可以如何組織我的程式碼以使得更改基底類別變的更容易?" -#: ../../faq/programming.rst:1639 +#: ../../faq/programming.rst:1646 #, fuzzy msgid "" "You could assign the base class to an alias and derive from the alias. Then " @@ -3279,7 +3353,7 @@ msgstr "" "說一句,如果你想動態決定(例如,取決於資源的可用性)使用哪個基底類別,這個技" "巧也很方便。例子: ::" -#: ../../faq/programming.rst:1644 +#: ../../faq/programming.rst:1651 msgid "" "class Base:\n" " ...\n" @@ -3297,28 +3371,25 @@ msgstr "" "class Derived(BaseAlias):\n" " ..." -#: ../../faq/programming.rst:1654 -#, fuzzy +#: ../../faq/programming.rst:1661 msgid "How do I create static class data and static class methods?" msgstr "如何建立靜態類別資料和靜態類別方法?" -#: ../../faq/programming.rst:1656 -#, fuzzy +#: ../../faq/programming.rst:1663 msgid "" "Both static data and static methods (in the sense of C++ or Java) are " "supported in Python." msgstr "Python 支援靜態資料和靜態方法(在 C++ 或 Java 的意義上)。" -#: ../../faq/programming.rst:1659 -#, fuzzy +#: ../../faq/programming.rst:1666 msgid "" "For static data, simply define a class attribute. To assign a new value to " "the attribute, you have to explicitly use the class name in the assignment::" msgstr "" "對於靜態資料,只需定義一個類別屬性即可。要為屬性分配新值,你必須在分配中顯式" -"使用類別名: ::" +"使用類別名稱: ::" -#: ../../faq/programming.rst:1662 +#: ../../faq/programming.rst:1669 msgid "" "class C:\n" " count = 0 # number of times C.__init__ called\n" @@ -3329,19 +3400,26 @@ msgid "" " def getcount(self):\n" " return C.count # or return self.count" msgstr "" +"class C:\n" +" count = 0 # C.__init__ 被呼叫的次數\n" +"\n" +" def __init__(self):\n" +" C.count = C.count + 1\n" +"\n" +" def getcount(self):\n" +" return C.count # 或回傳 self.count" -#: ../../faq/programming.rst:1671 -#, fuzzy +#: ../../faq/programming.rst:1678 msgid "" "``c.count`` also refers to ``C.count`` for any ``c`` such that " "``isinstance(c, C)`` holds, unless overridden by ``c`` itself or by some " "class on the base-class search path from ``c.__class__`` back to ``C``." msgstr "" "``c.count`` 還指代任何 ``c`` 的 ``C.count`` 使得 ``isinstance(c, C)`` 成立," -"除非被 ``c`` 本身或某些人覆蓋從 ``c.__class__`` 回到 ``C`` 的基底類別搜索路徑" +"除非被 ``c`` 本身或某些人覆蓋從 ``c.__class__`` 回到 ``C`` 的基底類別搜尋路徑" "上的類別。" -#: ../../faq/programming.rst:1675 +#: ../../faq/programming.rst:1682 #, fuzzy msgid "" "Caution: within a method of C, an assignment like ``self.count = 42`` " @@ -3353,15 +3431,15 @@ msgstr "" "一個名為 \"count\" 的新的不相關實例。類別靜態資料名稱的重新綁定必須始終指定類" "別是否在方法內: ::" -#: ../../faq/programming.rst:1680 +#: ../../faq/programming.rst:1687 msgid "C.count = 314" msgstr "C.count = 314" -#: ../../faq/programming.rst:1682 +#: ../../faq/programming.rst:1689 msgid "Static methods are possible::" msgstr "靜態方法是可能的: ::" -#: ../../faq/programming.rst:1684 +#: ../../faq/programming.rst:1691 msgid "" "class C:\n" " @staticmethod\n" @@ -3375,7 +3453,7 @@ msgstr "" " # 沒有 'self' 參數!\n" " ..." -#: ../../faq/programming.rst:1690 +#: ../../faq/programming.rst:1697 #, fuzzy msgid "" "However, a far more straightforward way to get the effect of a static method " @@ -3383,7 +3461,7 @@ msgid "" msgstr "" "然而,獲得靜態方法效果的一種更直接的方法是透過一個簡單的模組級函式: ::" -#: ../../faq/programming.rst:1693 +#: ../../faq/programming.rst:1700 msgid "" "def getcount():\n" " return C.count" @@ -3391,7 +3469,7 @@ msgstr "" "def getcount():\n" " return C.count" -#: ../../faq/programming.rst:1696 +#: ../../faq/programming.rst:1703 #, fuzzy msgid "" "If your code is structured so as to define one class (or tightly related " @@ -3400,24 +3478,22 @@ msgstr "" "如果你的程式碼結構化以便為每個模組定義一個類別(或緊密相關的類別層次結構)," "則這提供了所需的封裝。" -#: ../../faq/programming.rst:1701 -#, fuzzy +#: ../../faq/programming.rst:1708 msgid "How can I overload constructors (or methods) in Python?" -msgstr "如何在 Python 中重載構造函式(或方法)?" +msgstr "如何在 Python 中多載 (overload) 建構函式(或方法)?" -#: ../../faq/programming.rst:1703 -#, fuzzy +#: ../../faq/programming.rst:1710 msgid "" "This answer actually applies to all methods, but the question usually comes " "up first in the context of constructors." msgstr "" -"這個答案實際上適用於所有方法,但這個問題通常首先出現在構造函式的上下文中。" +"這個答案實際上適用於所有方法,但這個問題通常會先出現在建構函式的情境中。" -#: ../../faq/programming.rst:1706 +#: ../../faq/programming.rst:1713 msgid "In C++ you'd write" msgstr "在 C++ 中你會寫成" -#: ../../faq/programming.rst:1708 +#: ../../faq/programming.rst:1715 msgid "" "class C {\n" " C() { cout << \"No arguments\\n\"; }\n" @@ -3429,15 +3505,14 @@ msgstr "" " C(int i) { cout << \"Argument is \" << i << \"\\n\"; }\n" "}" -#: ../../faq/programming.rst:1715 -#, fuzzy +#: ../../faq/programming.rst:1722 msgid "" "In Python you have to write a single constructor that catches all cases " "using default arguments. For example::" msgstr "" -"在 Python 中,你必須編寫一個構造函式來捕獲所有使用預設引數的情況。例如: ::" +"在 Python 中,你必須編寫一個建構函式來捕獲所有使用預設引數的情況。例如: ::" -#: ../../faq/programming.rst:1718 +#: ../../faq/programming.rst:1725 msgid "" "class C:\n" " def __init__(self, i=None):\n" @@ -3453,17 +3528,15 @@ msgstr "" " else:\n" " print(\"Argument is\", i)" -#: ../../faq/programming.rst:1725 -#, fuzzy +#: ../../faq/programming.rst:1732 msgid "This is not entirely equivalent, but close enough in practice." -msgstr "這並不完全等價,但在實踐中足夠接近。" +msgstr "這並不完全等價,但在實際情況中已夠接近。" -#: ../../faq/programming.rst:1727 -#, fuzzy +#: ../../faq/programming.rst:1734 msgid "You could also try a variable-length argument list, e.g. ::" -msgstr "你也可以嘗試可變長度引數 list,例如: ::" +msgstr "你也可以嘗試長度可變的引數串列,例如: ::" -#: ../../faq/programming.rst:1729 +#: ../../faq/programming.rst:1736 msgid "" "def __init__(self, *args):\n" " ..." @@ -3471,18 +3544,15 @@ msgstr "" "def __init__(self, *args):\n" " ..." -#: ../../faq/programming.rst:1732 -#, fuzzy +#: ../../faq/programming.rst:1739 msgid "The same approach works for all method definitions." -msgstr "相同的方法適用於所有方法定義。" +msgstr "相同的手段適用於所有方法的定義。" -#: ../../faq/programming.rst:1736 -#, fuzzy +#: ../../faq/programming.rst:1743 msgid "I try to use __spam and I get an error about _SomeClassName__spam." msgstr "我嘗試使用 __spam,但收到有關 _SomeClassName__spam 的錯誤。" -#: ../../faq/programming.rst:1738 -#, fuzzy +#: ../../faq/programming.rst:1745 msgid "" "Variable names with double leading underscores are \"mangled\" to provide a " "simple but effective way to define class private variables. Any identifier " @@ -3491,18 +3561,18 @@ msgid "" "``classname`` is the current class name with any leading underscores " "stripped." msgstr "" -"帶有雙前導底線的變數名被「破壞」以提供一種簡單但有效的方法來定義類別私有變" -"數。 ``__spam`` 形式的任何標識器(至少兩個前導底線,最多一個尾隨底線)在文本" -"上替換為 ``_classname__spam``,其中 ``classname`` 是當前類別名,所有前導底線" -"被去除。" +"帶有雙前導底線的變數名會被「破壞 (mangled)」以做為提供定義類別私有變數的一個" +"簡單但有效的方法。``__spam`` 形式的任何識別字(至少兩個前導底線,最多一個尾隨" +"底線)在文字上會被替換為 ``_classname__spam``,其中 ``classname`` 是目前類別" +"之所有前導底線被去除的名稱。" -#: ../../faq/programming.rst:1744 +#: ../../faq/programming.rst:1751 msgid "" "The identifier can be used unchanged within the class, but to access it " "outside the class, the mangled name must be used:" msgstr "" -#: ../../faq/programming.rst:1747 +#: ../../faq/programming.rst:1754 msgid "" "class A:\n" " def __one(self):\n" @@ -3528,7 +3598,7 @@ msgstr "" "\n" "four = 4 * A()._A__one()" -#: ../../faq/programming.rst:1761 +#: ../../faq/programming.rst:1768 #, fuzzy msgid "" "In particular, this does not guarantee privacy since an outside user can " @@ -3538,33 +3608,30 @@ msgstr "" "這並不能保證隱私:外部使用者仍然可以故意存取 \"_classname__spam\" 屬性,並且" "私有值在物件的 __dict__ 中可見。許多 Python 程式員根本懶得使用私有變數名。" -#: ../../faq/programming.rst:1767 +#: ../../faq/programming.rst:1774 msgid "" "The :ref:`private name mangling specifications ` for " "details and special cases." msgstr "" -#: ../../faq/programming.rst:1771 -#, fuzzy +#: ../../faq/programming.rst:1778 msgid "My class defines __del__ but it is not called when I delete the object." msgstr "我的類別定義了 __del__ 但是當我刪除物件時它沒有被呼叫。" -#: ../../faq/programming.rst:1773 -#, fuzzy +#: ../../faq/programming.rst:1780 msgid "There are several possible reasons for this." msgstr "這有幾個可能的原因。" -#: ../../faq/programming.rst:1775 -#, fuzzy +#: ../../faq/programming.rst:1782 msgid "" "The :keyword:`del` statement does not necessarily call :meth:`~object." "__del__` -- it simply decrements the object's reference count, and if this " "reaches zero :meth:`!__del__` is called." msgstr "" -":keyword:`del` 陳述式不一定呼叫 :meth:`~object.__del__` -- 它只是減少物件的引" -"用計數,如果達到零,則呼叫 :meth:`!__del__`。" +":keyword:`del` 陳述式不一定會呼叫 :meth:`~object.__del__` -- 它只是減少物件的" +"參照計數,如果達到零則呼叫 :meth:`!__del__`。" -#: ../../faq/programming.rst:1779 +#: ../../faq/programming.rst:1786 #, fuzzy msgid "" "If your data structures contain circular links (e.g. a tree where each child " @@ -3586,7 +3653,7 @@ msgstr "" "行順序是任意的。你可以運行 :func:`gc.collect` 來強制收集,但*存在*永遠不會收" "集物件的病態情況。" -#: ../../faq/programming.rst:1790 +#: ../../faq/programming.rst:1797 #, fuzzy msgid "" "Despite the cycle collector, it's still a good idea to define an explicit " @@ -3601,7 +3668,7 @@ msgstr "" "性。不要直接呼叫 :meth:`!__del__` -- :meth:`!__del__` 應該呼叫 ``close()`` 並" "且 ``close()`` 應該確保它可以多次呼叫同一個物件。" -#: ../../faq/programming.rst:1797 +#: ../../faq/programming.rst:1804 #, fuzzy msgid "" "Another way to avoid cyclical references is to use the :mod:`weakref` " @@ -3613,36 +3680,32 @@ msgstr "" "的情況下指向物件。例如,樹資料結構應該對其父參照和同級參照使用弱參照(如果需" "要的話!)。" -#: ../../faq/programming.rst:1810 -#, fuzzy +#: ../../faq/programming.rst:1817 msgid "" "Finally, if your :meth:`!__del__` method raises an exception, a warning " "message is printed to :data:`sys.stderr`." msgstr "" -"最後,如果你的 :meth:`!__del__` 方法引發例外,則會將一條警告消息印出到 :data:" +"最後,如果你的 :meth:`!__del__` 方法引發例外,則會將一條警告訊息印出到 :data:" "`sys.stderr`。" -#: ../../faq/programming.rst:1815 -#, fuzzy +#: ../../faq/programming.rst:1822 msgid "How do I get a list of all instances of a given class?" -msgstr "如何獲取給定類別的所有實例的 list?" +msgstr "我該如何取得給定類別的所有實例的串列?" -#: ../../faq/programming.rst:1817 -#, fuzzy +#: ../../faq/programming.rst:1824 msgid "" "Python does not keep track of all instances of a class (or of a built-in " "type). You can program the class's constructor to keep track of all " "instances by keeping a list of weak references to each instance." msgstr "" -"Python 不會跟踪類別(或內建型別)的所有實例。你可以對類別的構造函式進行編程," -"以透過保留對每個實例的弱參照list來跟踪所有實例。" +"Python 不會追蹤類別(或內建型別)的所有實例。你可以將類別的建構函式進行改寫," +"以透過保留對每個實例之弱參照串列來追蹤所有實例。" -#: ../../faq/programming.rst:1823 -#, fuzzy +#: ../../faq/programming.rst:1830 msgid "Why does the result of ``id()`` appear to be not unique?" msgstr "為什麼 ``id()`` 的結果看起來不唯一?" -#: ../../faq/programming.rst:1825 +#: ../../faq/programming.rst:1832 #, fuzzy msgid "" "The :func:`id` builtin returns an integer that is guaranteed to be unique " @@ -3655,7 +3718,7 @@ msgstr "" "CPython 中,這是物件的記憶體地址,所以經常發生在從記憶體中刪除一個物件後,下" "一個新建立的物件被分配在記憶體中的相同位置。這個例子說明了這一點:" -#: ../../faq/programming.rst:1836 +#: ../../faq/programming.rst:1843 #, fuzzy msgid "" "The two ids belong to different integer objects that are created before, and " @@ -3666,18 +3729,18 @@ msgstr "" "這兩個 id 屬於之前建立的不同整數物件,並在執行 ``id()`` 呼叫後立即刪除。要確" "保你要檢查其 id 的物件仍然存在,請建立對該物件的另一個參照:" -#: ../../faq/programming.rst:1849 +#: ../../faq/programming.rst:1856 msgid "When can I rely on identity tests with the *is* operator?" msgstr "我什麼時候可以依靠 *is* 運算子進行識別性測試?" -#: ../../faq/programming.rst:1851 +#: ../../faq/programming.rst:1858 msgid "" "The ``is`` operator tests for object identity. The test ``a is b`` is " "equivalent to ``id(a) == id(b)``." msgstr "" "``is`` 運算子測試物件識別性。測試 ``a is b`` 等同於 ``id(a) == id(b)`` 。" -#: ../../faq/programming.rst:1854 +#: ../../faq/programming.rst:1861 msgid "" "The most important property of an identity test is that an object is always " "identical to itself, ``a is a`` always returns ``True``. Identity tests are " @@ -3688,7 +3751,7 @@ msgstr "" "識別性測試通常比相等性測試更快。與相等性測試不同,識別性測試保證回傳布林值 " "``True`` 或 ``False`` 。" -#: ../../faq/programming.rst:1859 +#: ../../faq/programming.rst:1866 msgid "" "However, identity tests can *only* be substituted for equality tests when " "object identity is assured. Generally, there are three circumstances where " @@ -3697,34 +3760,36 @@ msgstr "" "然而,*只有*\\ 當物件識別性得到保證時,識別性測試才能代替相等性測試。一般來" "說,保證識別性的情況有以下三種:" -#: ../../faq/programming.rst:1863 +#: ../../faq/programming.rst:1870 +#, fuzzy msgid "" -"1) Assignments create new names but do not change object identity. After " -"the assignment ``new = old``, it is guaranteed that ``new is old``." +"Assignments create new names but do not change object identity. After the " +"assignment ``new = old``, it is guaranteed that ``new is old``." msgstr "" "1) 賦值建立新名稱但不改變物件識別性。賦值 ``new = old`` 後,保證 ``new is " "old``。" -#: ../../faq/programming.rst:1866 +#: ../../faq/programming.rst:1873 +#, fuzzy msgid "" -"2) Putting an object in a container that stores object references does not " +"Putting an object in a container that stores object references does not " "change object identity. After the list assignment ``s[0] = x``, it is " "guaranteed that ``s[0] is x``." msgstr "" -"2) 將物件放入存儲物件參照的容器中不會改變物件識別性。在 list 賦值 ``s[0] = " +"2) 將物件放入儲存物件參照的容器中不會改變物件識別性。在 list 賦值 ``s[0] = " "x`` 之後,保證 ``s[0] 是 x``。" -#: ../../faq/programming.rst:1870 +#: ../../faq/programming.rst:1877 #, fuzzy msgid "" -"3) If an object is a singleton, it means that only one instance of that " -"object can exist. After the assignments ``a = None`` and ``b = None``, it " -"is guaranteed that ``a is b`` because ``None`` is a singleton." +"If an object is a singleton, it means that only one instance of that object " +"can exist. After the assignments ``a = None`` and ``b = None``, it is " +"guaranteed that ``a is b`` because ``None`` is a singleton." msgstr "" "3)如果一個物件是單例,則意味著該物件只能存在一個實例。在賦值 ``a = None`` " "和 ``b = None`` 之後,可以保證 ``a is b`` 因為 ``None`` 是單例。" -#: ../../faq/programming.rst:1874 +#: ../../faq/programming.rst:1881 msgid "" "In most other circumstances, identity tests are inadvisable and equality " "tests are preferred. In particular, identity tests should not be used to " @@ -3734,7 +3799,7 @@ msgstr "" "在大多數其他情況下,識別性測試是不可取的,相等性測試是首選。特別是,識別性測" "試不應用於檢查常數,例如不能保證是單例的 :class:`int` 和 :class:`str`: ::" -#: ../../faq/programming.rst:1879 +#: ../../faq/programming.rst:1886 msgid "" ">>> a = 1000\n" ">>> b = 500\n" @@ -3760,12 +3825,11 @@ msgstr "" ">>> a is c\n" "False" -#: ../../faq/programming.rst:1891 -#, fuzzy +#: ../../faq/programming.rst:1898 msgid "Likewise, new instances of mutable containers are never identical::" -msgstr "同樣,可變容器的新實例永遠不會相同: ::" +msgstr "同樣地,可變容器的新實例永遠不會相同: ::" -#: ../../faq/programming.rst:1893 +#: ../../faq/programming.rst:1900 msgid "" ">>> a = []\n" ">>> b = []\n" @@ -3777,35 +3841,34 @@ msgstr "" ">>> a is b\n" "False" -#: ../../faq/programming.rst:1898 +#: ../../faq/programming.rst:1905 msgid "" "In the standard library code, you will see several common patterns for " "correctly using identity tests:" msgstr "在標準函式庫程式碼中,你將看到幾種正確使用識別性測試的常見模式:" -#: ../../faq/programming.rst:1901 +#: ../../faq/programming.rst:1908 msgid "" -"1) As recommended by :pep:`8`, an identity test is the preferred way to " -"check for ``None``. This reads like plain English in code and avoids " -"confusion with other objects that may have boolean values that evaluate to " -"false." +"As recommended by :pep:`8`, an identity test is the preferred way to check " +"for ``None``. This reads like plain English in code and avoids confusion " +"with other objects that may have boolean values that evaluate to false." msgstr "" -"1) 正如 :pep:`8` 所推薦的,識別性測試是檢查 ``None`` 的首選方法。這在程式碼中" -"讀起來像簡單的英語,並避免與其他可能具有評估為 false 的布林值的物件混淆。" +"正如 :pep:`8` 所推薦的,識別性測試是檢查 ``None`` 的首選方法。這在程式碼中讀" +"起來像簡單的英語,並避免與其他可能具有評估為 false 的布林值的物件混淆。" -#: ../../faq/programming.rst:1905 +#: ../../faq/programming.rst:1912 #, fuzzy msgid "" -"2) Detecting optional arguments can be tricky when ``None`` is a valid input " +"Detecting optional arguments can be tricky when ``None`` is a valid input " "value. In those situations, you can create a singleton sentinel object " "guaranteed to be distinct from other objects. For example, here is how to " -"implement a method that behaves like :meth:`dict.pop`::" +"implement a method that behaves like :meth:`dict.pop`:" msgstr "" -"2)當 ``None`` 是有效輸入值時,檢測可選引數可能會很棘手。在這些情況下,你可以" -"建立一個保證與其他物件不同的單例哨兵物件。例如,這裡是如何實作一個行為類似" -"於 :meth:`dict.pop` 的方法: ::" +"當 ``None`` 是有效輸入值時,檢測可選引數可能會很棘手。在這些情況下,你可以建" +"立一個保證與其他物件不同的單例哨兵物件。例如,這裡是如何實作一個行為類似於 :" +"meth:`dict.pop` 的方法:" -#: ../../faq/programming.rst:1910 +#: ../../faq/programming.rst:1917 msgid "" "_sentinel = object()\n" "\n" @@ -3829,23 +3892,23 @@ msgstr "" " raise KeyError(key)\n" " return default" -#: ../../faq/programming.rst:1921 +#: ../../faq/programming.rst:1930 msgid "" -"3) Container implementations sometimes need to augment equality tests with " +"Container implementations sometimes need to augment equality tests with " "identity tests. This prevents the code from being confused by objects such " "as ``float('NaN')`` that are not equal to themselves." msgstr "" -"3) 容器實作有時需要透過識別性測試來增強相等性測試。這可以防止程式碼被諸如 " +"容器實作有時需要透過識別性測試來增強相等性測試。這可以防止程式碼被諸如 " "float('NaN') 之類的不等於自身的物件所混淆。" -#: ../../faq/programming.rst:1925 +#: ../../faq/programming.rst:1934 msgid "" "For example, here is the implementation of :meth:`!collections.abc.Sequence." "__contains__`::" msgstr "" "例如,以下是 :meth:`!collections.abc.Sequence.__contains__` 的實作: ::" -#: ../../faq/programming.rst:1928 +#: ../../faq/programming.rst:1937 msgid "" "def __contains__(self, value):\n" " for v in self:\n" @@ -3859,12 +3922,12 @@ msgstr "" " return True\n" " return False" -#: ../../faq/programming.rst:1936 +#: ../../faq/programming.rst:1945 msgid "" "How can a subclass control what data is stored in an immutable instance?" -msgstr "子類別如何控制不可變實例中存儲的資料?" +msgstr "子類別如何控制不可變實例中儲存的資料?" -#: ../../faq/programming.rst:1938 +#: ../../faq/programming.rst:1947 #, fuzzy msgid "" "When subclassing an immutable type, override the :meth:`~object.__new__` " @@ -3876,14 +3939,13 @@ msgstr "" "`~object.__init__` 方法。後者僅在*建立實例後*運行,這為時已晚,無法更改不可變" "實例中的資料。" -#: ../../faq/programming.rst:1943 -#, fuzzy +#: ../../faq/programming.rst:1952 msgid "" "All of these immutable classes have a different signature than their parent " "class:" msgstr "所有這些不可變類別都具有與其父類別不同的簽名:" -#: ../../faq/programming.rst:1946 +#: ../../faq/programming.rst:1955 msgid "" "from datetime import date\n" "\n" @@ -3906,12 +3968,32 @@ msgid "" " s = ''.join([c for c in s if c.isalnum() or c == '-'])\n" " return super().__new__(cls, s)" msgstr "" +"from datetime import date\n" +"\n" +"class FirstOfMonthDate(date):\n" +" \"總是選擇每個月的第一天\"\n" +" def __new__(cls, year, month, day):\n" +" return super().__new__(cls, year, month, 1)\n" +"\n" +"class NamedInt(int):\n" +" \"允許一些數字的文字名稱\"\n" +" xlat = {'zero': 0, 'one': 1, 'ten': 10}\n" +" def __new__(cls, value):\n" +" value = cls.xlat.get(value, value)\n" +" return super().__new__(cls, value)\n" +"\n" +"class TitleStr(str):\n" +" \"將 str 轉換成適合作為 URL 路徑的名稱\"\n" +" def __new__(cls, s):\n" +" s = s.lower().replace(' ', '-')\n" +" s = ''.join([c for c in s if c.isalnum() or c == '-'])\n" +" return super().__new__(cls, s)" -#: ../../faq/programming.rst:1969 +#: ../../faq/programming.rst:1978 msgid "The classes can be used like this:" msgstr "這些類別可以像這樣使用:" -#: ../../faq/programming.rst:1971 +#: ../../faq/programming.rst:1980 msgid "" ">>> FirstOfMonthDate(2012, 2, 14)\n" "FirstOfMonthDate(2012, 2, 1)\n" @@ -3931,11 +4013,11 @@ msgstr "" ">>> TitleStr('Blog: Why Python Rocks')\n" "'blog-why-python-rocks'" -#: ../../faq/programming.rst:1986 +#: ../../faq/programming.rst:1995 msgid "How do I cache method calls?" msgstr "如何快取方法呼叫?" -#: ../../faq/programming.rst:1988 +#: ../../faq/programming.rst:1997 #, fuzzy msgid "" "The two principal tools for caching methods are :func:`functools." @@ -3943,19 +4025,19 @@ msgid "" "at the instance level and the latter at the class level." msgstr "" "快取方法的兩個主要工具是 func:`functools.cached_property` 和 :func:" -"`functools.lru_cache`。前者在實例級別存儲結果,後者在類別級別存儲結果。" +"`functools.lru_cache`。前者在實例級別儲存結果,後者在類別級別儲存結果。" -#: ../../faq/programming.rst:1993 +#: ../../faq/programming.rst:2002 #, fuzzy msgid "" "The *cached_property* approach only works with methods that do not take any " "arguments. It does not create a reference to the instance. The cached " "method result will be kept only as long as the instance is alive." msgstr "" -"*cached_property* 方法僅適用於不帶任何引數的方法。它不會建立對實例的參照。只" +"*cached_property* 方法僅適用於不帶任何引數的方法,它不會建立對實例的參照,只" "要實例還活著,快取的方法結果就會被保留。" -#: ../../faq/programming.rst:1997 +#: ../../faq/programming.rst:2006 #, fuzzy msgid "" "The advantage is that when an instance is no longer used, the cached method " @@ -3966,7 +4048,7 @@ msgstr "" "好處是當一個實例不再使用時,快取的方法結果會立即釋放。缺點是如果實例累積,累" "積的方法結果也會累積。他們可以不受限制地成長。" -#: ../../faq/programming.rst:2002 +#: ../../faq/programming.rst:2011 msgid "" "The *lru_cache* approach works with methods that have :term:`hashable` " "arguments. It creates a reference to the instance unless special efforts " @@ -3975,7 +4057,7 @@ msgstr "" "*lru_cache* 方法適用於具有\\ :term:`可雜湊 `\\ 引數的方法。除非特別" "努力傳遞弱參照,否則它會建立對實例的參照。" -#: ../../faq/programming.rst:2006 +#: ../../faq/programming.rst:2015 #, fuzzy msgid "" "The advantage of the least recently used algorithm is that the cache is " @@ -3985,11 +4067,11 @@ msgstr "" "最近最少使用演算法的優點是快取受指定的 *maxsize* 限制。缺點是實例會一直保持活" "動狀態,直到它們從快取中老化或快取被清除。" -#: ../../faq/programming.rst:2011 +#: ../../faq/programming.rst:2020 msgid "This example shows the various techniques::" msgstr "這個例子展示了各種技術: ::" -#: ../../faq/programming.rst:2013 +#: ../../faq/programming.rst:2022 msgid "" "class Weather:\n" " \"Lookup weather information on a government website\"\n" @@ -4014,7 +4096,7 @@ msgid "" " # Depends on the station_id, date, and units." msgstr "" -#: ../../faq/programming.rst:2035 +#: ../../faq/programming.rst:2044 #, fuzzy msgid "" "The above example assumes that the *station_id* never changes. If the " @@ -4024,7 +4106,7 @@ msgstr "" "上面的例子假設 *station_id* 永遠不會改變。如果相關的實例屬性是可變的,則 " "*cached_property* 方法無法工作,因為它無法檢測到屬性的更改。" -#: ../../faq/programming.rst:2040 +#: ../../faq/programming.rst:2049 #, fuzzy msgid "" "To make the *lru_cache* approach work when the *station_id* is mutable, the " @@ -4035,7 +4117,7 @@ msgstr "" "`~object.__eq__` 和 :meth:`~object.__hash__` 方法,以便快取可以檢測相關屬性更" "新: ::" -#: ../../faq/programming.rst:2044 +#: ../../faq/programming.rst:2053 msgid "" "class Weather:\n" " \"Example with a mutable station identifier\"\n" @@ -4058,15 +4140,15 @@ msgid "" " # Depends on the station_id, date, and units." msgstr "" -#: ../../faq/programming.rst:2066 +#: ../../faq/programming.rst:2075 msgid "Modules" msgstr "模組" -#: ../../faq/programming.rst:2069 +#: ../../faq/programming.rst:2078 msgid "How do I create a .pyc file?" msgstr "如何建立 .pyc 檔案?" -#: ../../faq/programming.rst:2071 +#: ../../faq/programming.rst:2080 #, fuzzy msgid "" "When a module is imported for the first time (or when the source file has " @@ -4077,13 +4159,13 @@ msgid "" "file, and ends with ``.pyc``, with a middle component that depends on the " "particular ``python`` binary that created it. (See :pep:`3147` for details.)" msgstr "" -"第一次引入模組時(或者源檔案自建立當前編譯檔案後發生更改時)應在 " +"第一次引入模組時(或者源檔案自建立目前編譯檔案後發生更改時)應在 " "``__pycache__`` 的子目錄中建立包含編譯程式碼的 ``.pyc`` 檔案包含 .py 檔案的目" "錄。 ``.pyc`` 檔案的檔案名以與``.py`` 檔案相同的名稱開頭,以``.pyc`` 結尾,中" "間部分依賴於特定的``python `` 建立它的二進製檔案。(有關詳細資訊,請參閱 :" "pep:`3147`。)" -#: ../../faq/programming.rst:2079 +#: ../../faq/programming.rst:2088 #, fuzzy msgid "" "One reason that a ``.pyc`` file may not be created is a permissions problem " @@ -4094,9 +4176,9 @@ msgid "" msgstr "" "無法建立 .pyc 檔案的原因之一是包含源檔案的目錄存在權限問題,這意味著無法建立 " "__pycache__ 子目錄。例如,如果你以一個使用者的身份開發但以另一個使用者的身份" -"運行,例如你正在使用 Web 服務器進行測試,就會發生這種情況。" +"運行,例如你正在使用 Web 伺服器進行測試,就會發生這種情況。" -#: ../../faq/programming.rst:2084 +#: ../../faq/programming.rst:2093 #, fuzzy msgid "" "Unless the :envvar:`PYTHONDONTWRITEBYTECODE` environment variable is set, " @@ -4105,11 +4187,11 @@ msgid "" "``__pycache__`` subdirectory and write the compiled module to that " "subdirectory." msgstr "" -"除非:envvar:`PYTHONDONTWRITEBYTECODE` 環境變數被設定,如果你正在引入一個模組" -"並且 Python 有能力(權限,空閒空間等)建立一個 .pyc 檔案是自動的建立一個" +"除非 :envvar:`PYTHONDONTWRITEBYTECODE` 環境變數有被設定,如果你正在引入一個模" +"組並且 Python 有能力(權限、空閒空間等)建立一個 .pyc 檔案是自動的建立一個" "``__pycache__ `` 子目錄並將編譯後的模組寫入該子目錄。" -#: ../../faq/programming.rst:2089 +#: ../../faq/programming.rst:2098 #, fuzzy msgid "" "Running Python on a top level script is not considered an import and no ``." @@ -4124,44 +4206,42 @@ msgstr "" "入 ``python foo.py`` 作為一個 shell 命令),將為 xyz 建立一個 .pyc 因為引入" "了 xyz,但是不會為 foo 建立 .pyc 檔案,因為 ` `foo.py`` 沒有被引入。" -#: ../../faq/programming.rst:2096 -#, fuzzy +#: ../../faq/programming.rst:2105 msgid "" "If you need to create a ``.pyc`` file for ``foo`` -- that is, to create a ``." "pyc`` file for a module that is not imported -- you can, using the :mod:" "`py_compile` and :mod:`compileall` modules." msgstr "" -"如果你需要為 ``foo`` 建立一個 ``.pyc`` 檔案——也就是說,為一個未引入的模組建立" -"一個 ``.pyc`` 檔案——你可以使用 :mod :`py_compile` 和 :mod:`compileall` 模組。" +"如果你需要為 ``foo`` 建立一個 ``.pyc`` 檔案 —— 也就是說,要為一個未引入的模組" +"建立一個 ``.pyc`` 檔案 —— 你可以使用 :mod:`py_compile` 和 :mod:`compileall` " +"模組。" -#: ../../faq/programming.rst:2100 -#, fuzzy +#: ../../faq/programming.rst:2109 msgid "" "The :mod:`py_compile` module can manually compile any module. One way is to " "use the ``compile()`` function in that module interactively::" msgstr "" -":mod:`py_compile` 模組可以手動編譯任何模組。一種方法是在該模組中以交互方式使" -"用 ``compile()`` 函式: ::" +":mod:`py_compile` 模組允許手動編譯任何模組。其中一種方法是在該模組中以交互方" +"式使用 ``compile()`` 函式: ::" -#: ../../faq/programming.rst:2103 +#: ../../faq/programming.rst:2112 msgid "" ">>> import py_compile\n" -">>> py_compile.compile('foo.py') " +">>> py_compile.compile('foo.py')" msgstr "" ">>> import py_compile\n" -">>> py_compile.compile('foo.py') " +">>> py_compile.compile('foo.py')" -#: ../../faq/programming.rst:2106 -#, fuzzy +#: ../../faq/programming.rst:2115 msgid "" "This will write the ``.pyc`` to a ``__pycache__`` subdirectory in the same " "location as ``foo.py`` (or you can override that with the optional parameter " "``cfile``)." msgstr "" -"這會將 .pyc 寫入與 foo.py 相同位置的 __pycache__ 子目錄(或者你可以使用可選參" -"數 cfile 覆蓋它)。" +"這會將 ``.pyc`` 寫入與 ``foo.py`` 相同位置的 ``__pycache__`` 子目錄(或者你可" +"以使用可選參數 ``cfile`` 覆蓋它)。" -#: ../../faq/programming.rst:2110 +#: ../../faq/programming.rst:2119 #, fuzzy msgid "" "You can also automatically compile all files in a directory or directories " @@ -4172,15 +4252,15 @@ msgstr "" "你還可以使用 :mod:`compileall` 模組自動編譯目錄中的所有檔案。你可以在 shell " "提示符下運行 ``compileall.py`` 並提供包含要編譯的 Python 檔案的目錄路徑: ::" -#: ../../faq/programming.rst:2115 +#: ../../faq/programming.rst:2124 msgid "python -m compileall ." msgstr "python -m compileall ." -#: ../../faq/programming.rst:2119 +#: ../../faq/programming.rst:2128 msgid "How do I find the current module name?" -msgstr "如何找到當前模組名稱?" +msgstr "如何找到目前模組名稱?" -#: ../../faq/programming.rst:2121 +#: ../../faq/programming.rst:2130 #, fuzzy msgid "" "A module can find out its own module name by looking at the predefined " @@ -4191,9 +4271,9 @@ msgid "" msgstr "" "模組可以透過查看預定義的全域變數 ``__name__`` 來找出自己的模組名稱。如果它的" "值為``'__main__'``,則該程式作為腳本運行。許多通常透過引入使用的模組還提供命" -"令行界面或自檢,只有在檢查 ``__name__`` 後才執行此程式碼: ::" +"令行介面或自檢,只有在檢查 ``__name__`` 後才執行此程式碼: ::" -#: ../../faq/programming.rst:2127 +#: ../../faq/programming.rst:2136 msgid "" "def main():\n" " print('Running test...')\n" @@ -4202,21 +4282,26 @@ msgid "" "if __name__ == '__main__':\n" " main()" msgstr "" +"def main():\n" +" print('Running test...')\n" +" ...\n" +"\n" +"if __name__ == '__main__':\n" +" main()" -#: ../../faq/programming.rst:2136 -#, fuzzy +#: ../../faq/programming.rst:2145 msgid "How can I have modules that mutually import each other?" -msgstr "我怎樣才能擁有相互引入的模組?" +msgstr "要怎樣才能擁有相互引入的模組?" -#: ../../faq/programming.rst:2138 +#: ../../faq/programming.rst:2147 msgid "Suppose you have the following modules:" msgstr "假設你有以下模組:" -#: ../../faq/programming.rst:2140 +#: ../../faq/programming.rst:2149 msgid ":file:`foo.py`::" msgstr ":file:`foo.py`: ::" -#: ../../faq/programming.rst:2142 +#: ../../faq/programming.rst:2151 msgid "" "from bar import bar_var\n" "foo_var = 1" @@ -4224,11 +4309,11 @@ msgstr "" "from bar import bar_var\n" "foo_var = 1" -#: ../../faq/programming.rst:2145 +#: ../../faq/programming.rst:2154 msgid ":file:`bar.py`::" msgstr ":file:`bar.py`: ::" -#: ../../faq/programming.rst:2147 +#: ../../faq/programming.rst:2156 msgid "" "from foo import foo_var\n" "bar_var = 2" @@ -4236,57 +4321,50 @@ msgstr "" "from foo import foo_var\n" "bar_var = 2" -#: ../../faq/programming.rst:2150 -#, fuzzy +#: ../../faq/programming.rst:2159 msgid "The problem is that the interpreter will perform the following steps:" msgstr "問題是直譯器將執行以下步驟:" -#: ../../faq/programming.rst:2152 -#, fuzzy +#: ../../faq/programming.rst:2161 msgid "main imports ``foo``" msgstr "主要引入 ``foo``" -#: ../../faq/programming.rst:2153 -#, fuzzy +#: ../../faq/programming.rst:2162 msgid "Empty globals for ``foo`` are created" msgstr "建立了 ``foo`` 的空全域變數" -#: ../../faq/programming.rst:2154 +#: ../../faq/programming.rst:2163 msgid "``foo`` is compiled and starts executing" msgstr "``foo`` 被編譯並開始執行" -#: ../../faq/programming.rst:2155 +#: ../../faq/programming.rst:2164 msgid "``foo`` imports ``bar``" msgstr "``foo`` 引入 ``bar``" -#: ../../faq/programming.rst:2156 -#, fuzzy +#: ../../faq/programming.rst:2165 msgid "Empty globals for ``bar`` are created" msgstr "建立了 ``bar`` 的空全域變數" -#: ../../faq/programming.rst:2157 +#: ../../faq/programming.rst:2166 msgid "``bar`` is compiled and starts executing" msgstr "``bar`` 已被編譯並開始執行" -#: ../../faq/programming.rst:2158 -#, fuzzy +#: ../../faq/programming.rst:2167 msgid "" "``bar`` imports ``foo`` (which is a no-op since there already is a module " "named ``foo``)" msgstr "" -"``bar`` 引入 ``foo``(這是一個空操作,因為已經有一個名為 ``foo`` 的模組)" +"``bar`` 引入 ``foo``\\ (這是一個空操作,因為已經有一個名為 ``foo`` 的模組)" -#: ../../faq/programming.rst:2159 -#, fuzzy +#: ../../faq/programming.rst:2168 msgid "" "The import mechanism tries to read ``foo_var`` from ``foo`` globals, to set " "``bar.foo_var = foo.foo_var``" msgstr "" -"引入機制嘗試從 ``foo`` 全域變數中讀取 ``foo_var`` ,以設定 ``bar.foo_var = " -"foo.foo_var`` " +"引入機制嘗試從 ``foo`` 全域變數中讀取 ``foo_var``,以設定 ``bar.foo_var = " +"foo.foo_var``" -#: ../../faq/programming.rst:2161 -#, fuzzy +#: ../../faq/programming.rst:2170 msgid "" "The last step fails, because Python isn't done with interpreting ``foo`` yet " "and the global symbol dictionary for ``foo`` is still empty." @@ -4294,7 +4372,7 @@ msgstr "" "最後一步失敗了,因為 Python 還沒有完成對 ``foo`` 的直譯,而 ``foo`` 的全域符" "號字典仍然是空的。" -#: ../../faq/programming.rst:2164 +#: ../../faq/programming.rst:2173 #, fuzzy msgid "" "The same thing happens when you use ``import foo``, and then try to access " @@ -4303,11 +4381,11 @@ msgstr "" "當你使用 ``import foo``,然後嘗試在全域程式碼中存取 ``foo.foo_var`` 時,也會" "發生同樣的事情。" -#: ../../faq/programming.rst:2167 +#: ../../faq/programming.rst:2176 msgid "There are (at least) three possible workarounds for this problem." msgstr "此問題有(至少)三種可能的解決方法。" -#: ../../faq/programming.rst:2169 +#: ../../faq/programming.rst:2178 #, fuzzy msgid "" "Guido van Rossum recommends avoiding all uses of ``from import ..." @@ -4320,50 +4398,51 @@ msgstr "" "函式中。全域變數和類別變數的初始化應該只使用常數或內建函式。這意味著來自引入" "模組的所有內容都被參照為 ``.``。" -#: ../../faq/programming.rst:2174 +#: ../../faq/programming.rst:2183 msgid "" "Jim Roskind suggests performing steps in the following order in each module:" msgstr "Jim Roskind 建議在每個模組中按以下順序執行各個步驟:" -#: ../../faq/programming.rst:2176 +#: ../../faq/programming.rst:2185 #, fuzzy msgid "" "exports (globals, functions, and classes that don't need imported base " "classes)" -msgstr "導出(不需要引入基底類別的全域變數、函式和類別)" +msgstr "匯出(不需要引入基底類別的全域變數、函式和類別)" -#: ../../faq/programming.rst:2178 +#: ../../faq/programming.rst:2187 msgid "``import`` statements" msgstr "``import`` 陳述式" -#: ../../faq/programming.rst:2179 +#: ../../faq/programming.rst:2188 msgid "" "active code (including globals that are initialized from imported values)." msgstr "活躍程式碼(包括從引入值初始化的全域變數)。" -#: ../../faq/programming.rst:2181 -#, fuzzy +#: ../../faq/programming.rst:2190 msgid "" "Van Rossum doesn't like this approach much because the imports appear in a " "strange place, but it does work." msgstr "" "Van Rossum 不太喜歡這種方法,因為引入出現在一個奇怪的地方,但它確實有效。" -#: ../../faq/programming.rst:2184 +#: ../../faq/programming.rst:2193 msgid "" "Matthias Urlichs recommends restructuring your code so that the recursive " "import is not necessary in the first place." -msgstr "Matthias Urlichs 建議重構你的程式碼,以便打從一開始就不需要遞迴引入。" +msgstr "" +"Matthias Urlichs 建議重組 (restructuring) 你的程式碼,以便打從一開始就不需要" +"遞迴引入。" -#: ../../faq/programming.rst:2187 +#: ../../faq/programming.rst:2196 msgid "These solutions are not mutually exclusive." msgstr "這些方案並不衝突。" -#: ../../faq/programming.rst:2191 +#: ../../faq/programming.rst:2200 msgid "__import__('x.y.z') returns ; how do I get z?" msgstr "__import__('x.y.z') 回傳 ,那我怎麼得到 z?" -#: ../../faq/programming.rst:2193 +#: ../../faq/programming.rst:2202 #, fuzzy msgid "" "Consider using the convenience function :func:`~importlib.import_module` " @@ -4372,17 +4451,17 @@ msgstr "" "考慮使用來自 :mod:`importlib` 的便利函式 :func:`~importlib.import_module` 代" "替: ::" -#: ../../faq/programming.rst:2196 +#: ../../faq/programming.rst:2205 msgid "z = importlib.import_module('x.y.z')" msgstr "z = importlib.import_module('x.y.z')" -#: ../../faq/programming.rst:2200 +#: ../../faq/programming.rst:2209 msgid "" "When I edit an imported module and reimport it, the changes don't show up. " "Why does this happen?" msgstr "當我編輯需要引入的模組並重新引入它時,更動沒有反應出來。為什麼會這樣?" -#: ../../faq/programming.rst:2202 +#: ../../faq/programming.rst:2211 #, fuzzy msgid "" "For reasons of efficiency as well as consistency, Python only reads the " @@ -4395,7 +4474,7 @@ msgstr "" "一個由許多模組組成的程式中,每個模組都引入相同的基本模組,基本模組將被解析和" "重新解析很多次。要強制重新讀取已更改的模組,請執行以下操作: ::" -#: ../../faq/programming.rst:2208 +#: ../../faq/programming.rst:2217 msgid "" "import importlib\n" "import modname\n" @@ -4405,18 +4484,17 @@ msgstr "" "import modname\n" "importlib.reload(modname)" -#: ../../faq/programming.rst:2212 -#, fuzzy +#: ../../faq/programming.rst:2221 msgid "" "Warning: this technique is not 100% fool-proof. In particular, modules " "containing statements like ::" -msgstr "警告:此技術並非 100% 萬無一失。尤其是,包含像這樣的陳述式的模組: ::" +msgstr "警告:此技術並非 100% 萬無一失。尤其是包含像這樣陳述式的模組: ::" -#: ../../faq/programming.rst:2215 +#: ../../faq/programming.rst:2224 msgid "from modname import some_objects" msgstr "from modname import some_objects" -#: ../../faq/programming.rst:2217 +#: ../../faq/programming.rst:2226 #, fuzzy msgid "" "will continue to work with the old version of the imported objects. If the " @@ -4427,7 +4505,7 @@ msgstr "" "將繼續使用舊版本的引入物件。如果模組包含類別定義,現有的類別實例將*不會*更新" "為使用新的類別定義。這可能會導致以下自相矛盾的行為: ::" -#: ../../faq/programming.rst:2222 +#: ../../faq/programming.rst:2231 msgid "" ">>> import importlib\n" ">>> import cls\n" @@ -4437,14 +4515,21 @@ msgid "" ">>> isinstance(c, cls.C) # isinstance is false?!?\n" "False" msgstr "" +">>> import importlib\n" +">>> import cls\n" +">>> c = cls.C() # 建立一個 C 的實例\n" +">>> importlib.reload(cls)\n" +"\n" +">>> isinstance(c, cls.C) # isinstance 為 false?!?\n" +"False" -#: ../../faq/programming.rst:2230 +#: ../../faq/programming.rst:2239 msgid "" "The nature of the problem is made clear if you print out the \"identity\" of " "the class objects::" msgstr "如果印出類別物件的「識別性」,問題的本質就很清楚了: ::" -#: ../../faq/programming.rst:2233 +#: ../../faq/programming.rst:2242 msgid "" ">>> hex(id(c.__class__))\n" "'0x7352a0'\n" diff --git a/faq/windows.po b/faq/windows.po index a4fa46fa95..34374de463 100644 --- a/faq/windows.po +++ b/faq/windows.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,7 +6,7 @@ # Liang-Bo Wang , 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-01 22:24+0800\n" "PO-Revision-Date: 2022-11-09 17:25+0800\n" @@ -150,10 +149,10 @@ msgstr "" #: ../../faq/windows.rst:84 msgid "" "Many people use the interactive mode as a convenient yet highly programmable " -"calculator. When you want to end your interactive Python session, call the :" -"func:`exit` function or hold the :kbd:`Ctrl` key down while you enter a :kbd:" -"`Z`, then hit the \":kbd:`Enter`\" key to get back to your Windows command " -"prompt." +"calculator. When you want to end your interactive Python session, call " +"the :func:`exit` function or hold the :kbd:`Ctrl` key down while you enter " +"a :kbd:`Z`, then hit the \":kbd:`Enter`\" key to get back to your Windows " +"command prompt." msgstr "" "許多人將互動模式作為方便但可高度程式化的計算機。如果你要結束互動式 Python 對" "話,請呼叫 :func:`exit` 函式或是按住 :kbd:`Ctrl` 鍵再輸入 :kbd:`Z`,然後按下 " @@ -161,12 +160,12 @@ msgstr "" #: ../../faq/windows.rst:90 msgid "" -"You may also find that you have a Start-menu entry such as :menuselection:" -"`Start --> Programs --> Python 3.x --> Python (command line)` that results " -"in you seeing the ``>>>`` prompt in a new window. If so, the window will " -"disappear after you call the :func:`exit` function or enter the :kbd:`Ctrl-" -"Z` character; Windows is running a single \"python\" command in the window, " -"and closes it when you terminate the interpreter." +"You may also find that you have a Start-menu entry such " +"as :menuselection:`Start --> Programs --> Python 3.x --> Python (command " +"line)` that results in you seeing the ``>>>`` prompt in a new window. If " +"so, the window will disappear after you call the :func:`exit` function or " +"enter the :kbd:`Ctrl-Z` character; Windows is running a single \"python\" " +"command in the window, and closes it when you terminate the interpreter." msgstr "" "你可能還會發現你有一個開始功能表項目,像是::menuselection:`開始 --> 所有程" "式 --> Python 3.x --> Python(命令行)`,它會讓你在一個新視窗中看到 ``>>>`` " @@ -221,11 +220,11 @@ msgid "" "typing 'foo' with no extension you need to add .py to the PATHEXT " "environment variable." msgstr "" -"在 Windows 上,標準的 Python 安裝程式已將 .py 副檔名與一種檔案類型 (Python." -"File) 進行關聯,並為該檔案類型提供一個開啟命令來運行直譯器 (``D:\\Program " -"Files\\Python\\python.exe \"%1\" %*``)。這足以使腳本能以類似 'foo.py' 的形式" -"從命令提示字元被執行。如果你希望能夠簡單地輸入 'foo' 來執行腳本,而不用加上副" -"檔名,則需要將 .py 新增至 PATHEXT 環境變數中。" +"在 Windows 上,標準的 Python 安裝程式已將 .py 副檔名與一種檔案類型 " +"(Python.File) 進行關聯,並為該檔案類型提供一個開啟命令來運行直譯器 (``D:" +"\\Program Files\\Python\\python.exe \"%1\" %*``)。這足以使腳本能以類似 " +"'foo.py' 的形式從命令提示字元被執行。如果你希望能夠簡單地輸入 'foo' 來執行腳" +"本,而不用加上副檔名,則需要將 .py 新增至 PATHEXT 環境變數中。" #: ../../faq/windows.rst:124 msgid "Why does Python sometimes take so long to start?" @@ -285,8 +284,8 @@ msgstr "" "是的,.pyd 檔類似於 dll,但也有一些區別。如果你有一個名為 ``foo.pyd`` 的 " "DLL,則它必須具有函式 ``PyInit_foo()``。接著你可以將 \"import foo\" 寫入 " "Python 腳本,Python 將會搜尋 foo.pyd(以及 foo.py、foo.pyc),如果 Python 找" -"到它,將會嘗試呼叫 ``PyInit_foo()`` 來將它初始化。你並不會將你的 .exe 與 foo." -"lib 連結 (link),因為這會導致 Windows 要求 DLL 的存在。" +"到它,將會嘗試呼叫 ``PyInit_foo()`` 來將它初始化。你並不會將你的 .exe 與 " +"foo.lib 連結 (link),因為這會導致 Windows 要求 DLL 的存在。" #: ../../faq/windows.rst:157 msgid "" @@ -318,9 +317,10 @@ msgstr "在 Windows 應用程式中嵌入 Python 直譯器的過程可以總結 msgid "" "Do **not** build Python into your .exe file directly. On Windows, Python " "must be a DLL to handle importing modules that are themselves DLL's. (This " -"is the first key undocumented fact.) Instead, link to :file:`python{NN}." -"dll`; it is typically installed in ``C:\\Windows\\System``. *NN* is the " -"Python version, a number such as \"33\" for Python 3.3." +"is the first key undocumented fact.) Instead, link " +"to :file:`python{NN}.dll`; it is typically installed in ``C:" +"\\Windows\\System``. *NN* is the Python version, a number such as \"33\" " +"for Python 3.3." msgstr "" "**不要**\\ 直接將 Python 建置到你的 .exe 檔中。在 Windows 上,Python 必須是一" "個 DLL 來處理模組的 import,而那些模組本身也是 DLL。(這是第一個未正式記載的" @@ -337,8 +337,9 @@ msgid "" msgstr "" "你可以透過兩種不同的方式連結到 Python。載入時連結 (load-time linking) 表示要" "連結到 :file:`python{NN}.lib`,而執行環境連結 (run-time linking) 表示要連結" -"到 :file:`python{NN}.dll`。(一般註解::file:`python{NN}.lib` 是 :file:" -"`python{NN}.dll` 相對應的所謂 \"import lib\"。它只會為鏈接器定義符號。)" +"到 :file:`python{NN}.dll`。(一般註解::file:`python{NN}.lib` " +"是 :file:`python{NN}.dll` 相對應的所謂 \"import lib\"。它只會為鏈接器定義符" +"號。)" #: ../../faq/windows.rst:182 msgid "" @@ -352,9 +353,9 @@ msgid "" msgstr "" "執行環境連結大大簡化了連結選項;所有事情都會發生在執行環境。你的程式碼必須使" "用 Windows ``LoadLibraryEx()`` 常式 (routine) 來載入 :file:`python{NN}.dll`。" -"該程式碼也必須用 Windows ``GetProcAddress()`` 常式所取得的指標,來使用 :file:" -"`python{NN}.dll` 中的(即為 Python C API 的)存取常式和資料。對於任何呼叫 " -"Python C API 常式的 C 程式碼,巨集可以讓使用這些指標的過程透明化。" +"該程式碼也必須用 Windows ``GetProcAddress()`` 常式所取得的指標,來使" +"用 :file:`python{NN}.dll` 中的(即為 Python C API 的)存取常式和資料。對於任" +"何呼叫 Python C API 常式的 C 程式碼,巨集可以讓使用這些指標的過程透明化。" #: ../../faq/windows.rst:191 msgid "" @@ -405,6 +406,11 @@ msgid "" "initmyAppc(); // Initialize (import) the helper class.\n" "PyRun_SimpleString(\"import myApp\"); // Import the shadow class." msgstr "" +"#include \n" +"...\n" +"Py_Initialize(); // 初始化 Python。\n" +"initmyAppc(); // 初始化(引入)幫助類別。\n" +"PyRun_SimpleString(\"import myApp\"); // 引入 shadow 類別。" #: ../../faq/windows.rst:218 msgid "" @@ -498,10 +504,10 @@ msgstr "" #: ../../faq/windows.rst:262 msgid "" "Under any editor, mixing tabs and spaces is a bad idea. MSVC is no " -"different in this respect, and is easily configured to use spaces: Take :" -"menuselection:`Tools --> Options --> Tabs`, and for file type \"Default\" " -"set \"Tab size\" and \"Indent size\" to 4, and select the \"Insert spaces\" " -"radio button." +"different in this respect, and is easily configured to use spaces: " +"Take :menuselection:`Tools --> Options --> Tabs`, and for file type " +"\"Default\" set \"Tab size\" and \"Indent size\" to 4, and select the " +"\"Insert spaces\" radio button." msgstr "" "在任何編輯器下,將 tab 和空格混合都是一個壞主意。MSVC 在這方面也是一樣,且可" "以輕鬆配置為使用空格:選擇\\ :menuselection:`工具 --> 選項 --> Tabs`,然後對" @@ -511,12 +517,12 @@ msgstr "" #: ../../faq/windows.rst:267 msgid "" "Python raises :exc:`IndentationError` or :exc:`TabError` if mixed tabs and " -"spaces are causing problems in leading whitespace. You may also run the :mod:" -"`tabnanny` module to check a directory tree in batch mode." +"spaces are causing problems in leading whitespace. You may also run " +"the :mod:`tabnanny` module to check a directory tree in batch mode." msgstr "" -"如果混合 tab 和空格造成前導空白字元出現問題,則 Python 會引發 :exc:" -"`IndentationError` 或 :exc:`TabError`。你也可以運行 :mod:`tabnanny` 模組,在" -"批次模式下檢查目錄樹。" +"如果混合 tab 和空格造成前導空白字元出現問題,則 Python 會引" +"發 :exc:`IndentationError` 或 :exc:`TabError`。你也可以運行 :mod:`tabnanny` " +"模組,在批次模式下檢查目錄樹。" #: ../../faq/windows.rst:274 msgid "How do I check for a keypress without blocking?" @@ -548,19 +554,3 @@ msgstr "" "上的版本發生這種情況。首先要確保你的作業系統仍受支援並且是最新的,如果這無法" "解決問題,請造訪 `Microsoft 支援頁面 `_\\ 以取得關於手動安裝 C Runtime 更新的指南。" - -#~ msgid "or::" -#~ msgstr "" -#~ "或是:\n" -#~ "\n" -#~ "::" - -#~ msgid "" -#~ "This series of screencasts aims to get you up and running with Python on " -#~ "Windows XP. The knowledge is distilled into 1.5 hours and will get you " -#~ "up and running with the right Python distribution, coding in your choice " -#~ "of IDE, and debugging and writing solid code with unit-tests." -#~ msgstr "" -#~ "這一組影片教學可以讓你在 Windows XP 上順利使用 Python。整組課程大約需要你" -#~ "一個半小時的時間。課程包含安裝正確的 Python 版本,在你喜歡的 IDE 中進行開" -#~ "發,除錯,以及對程式進行單元測試以生產可靠的程式。" diff --git a/focused_terminology_dictionary.csv b/focused_terminology_dictionary.csv new file mode 100644 index 0000000000..6c890ff578 --- /dev/null +++ b/focused_terminology_dictionary.csv @@ -0,0 +1,122 @@ +source_term,translated_term,frequency,files_count,priority,category,example_files +class,類別,810,152,High,Core Concepts,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +function,函式,820,154,High,Core Concepts,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +method,方法,830,156,High,Core Concepts,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +module,模組,840,158,High,Core Concepts,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +package,套件,215,55,High,Core Concepts,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +object,物件,860,162,High,Core Concepts,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +type,型別,221,57,High,Core Concepts,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +int,整數,224,58,High,Built-in Types,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +str,字串,227,59,High,Built-in Types,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +list,串列,230,60,High,Built-in Types,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +dict,字典,233,61,High,Built-in Types,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +tuple,元組,236,62,High,Built-in Types,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +set,集合,239,63,High,Built-in Types,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +float,浮點數,242,64,High,Built-in Types,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +bool,布林值,245,65,High,Built-in Types,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +complex,複數,248,66,High,Built-in Types,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +None,None,485,117,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +True,True,490,118,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +False,False,495,119,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +return,回傳,500,120,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +import,引入,505,121,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +def,def,266,72,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +async,async,269,73,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +await,await,272,74,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +if,if,548,166,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +else,else,551,167,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +elif,elif,554,168,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +for,for,557,169,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +while,while,560,170,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +try,try,563,171,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +except,except,566,172,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +finally,finally,569,173,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +with,with,572,174,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +as,as,575,175,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +pass,pass,578,176,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +break,break,581,177,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +continue,continue,584,178,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +raise,raise,587,179,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +assert,assert,590,180,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +yield,yield,593,181,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +from,from,596,182,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +global,global,599,183,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +nonlocal,nonlocal,602,184,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +del,del,605,185,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +in,in,608,186,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +is,is,611,187,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +not,not,614,188,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +and,and,617,189,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +or,or,620,190,High,Keywords/Constants,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +Exception,例外,100,45,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +ValueError,ValueError,102,46,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +TypeError,TypeError,104,47,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +AttributeError,AttributeError,106,48,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +KeyError,KeyError,108,49,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +IndexError,IndexError,110,50,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +ImportError,ImportError,112,51,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +RuntimeError,RuntimeError,114,52,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +NameError,NameError,116,53,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +FileNotFoundError,FileNotFoundError,118,54,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +PermissionError,PermissionError,120,55,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +ConnectionError,ConnectionError,122,56,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +TimeoutError,TimeoutError,124,57,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +NotImplementedError,NotImplementedError,126,58,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +MemoryError,MemoryError,136,63,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +RecursionError,RecursionError,138,64,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +ZeroDivisionError,ZeroDivisionError,140,65,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +OverflowError,OverflowError,142,66,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +UnboundLocalError,UnboundLocalError,144,67,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +AssertionError,AssertionError,146,68,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +SyntaxError,SyntaxError,148,69,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +IndentationError,IndentationError,150,70,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +TabError,TabError,152,71,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +UnicodeError,UnicodeError,154,72,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +UnicodeDecodeError,UnicodeDecodeError,156,73,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +UnicodeEncodeError,UnicodeEncodeError,158,74,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +UnicodeTranslateError,UnicodeTranslateError,160,75,Medium,Exceptions,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +__init__,__init__,635,195,Medium,Code Elements,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +__str__,__str__,638,196,Medium,Code Elements,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +__repr__,__repr__,641,197,Medium,Code Elements,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +__len__,__len__,644,198,Medium,Code Elements,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +__getitem__,__getitem__,647,199,Medium,Code Elements,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +__setitem__,__setitem__,650,200,Medium,Code Elements,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +__delitem__,__delitem__,653,201,Medium,Code Elements,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +__contains__,__contains__,656,202,Medium,Code Elements,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +__iter__,__iter__,659,203,Medium,Code Elements,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +__next__,__next__,662,204,Medium,Code Elements,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +__enter__,__enter__,665,205,Medium,Code Elements,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +__exit__,__exit__,668,206,Medium,Code Elements,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +__call__,__call__,671,207,Medium,Code Elements,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +__new__,__new__,674,208,Medium,Code Elements,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +__del__,__del__,677,209,Medium,Code Elements,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +abstract base class,抽象基底類別,368,106,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +argument,引數,371,107,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +parameter,參數,374,108,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +annotation,註釋,377,109,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +attribute,屬性,380,110,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +bytecode,位元組碼,383,111,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +callback,回呼,386,112,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +closure,閉包,389,113,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +decorator,裝飾器,392,114,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +descriptor,描述器,395,115,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +dictionary,字典,398,116,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +docstring,說明字串,401,117,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +duck-typing,鴨子型別,404,118,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +expression,運算式,407,119,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +extension module,擴充模組,410,120,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +file object,檔案物件,413,121,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +generator,產生器,425,125,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +iterator,疊代器,458,136,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +lambda,lambda,467,139,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +list comprehension,串列綜合運算,470,140,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +mapping,對映,476,142,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +metaclass,元類別,479,143,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +namespace,命名空間,491,147,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +sequence,序列,512,154,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +slice,切片,515,155,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +special method,特殊方法,518,156,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +statement,陳述式,521,157,Medium,Common Terms,glossary.po; tutorial/classes.po; reference/datamodel.po; library/functions.po; howto/descriptor.po +token,token,5,3,High,Parsing Terms,glossary.po; library/token.po; library/tokenize.po +lexical analyzer,詞法分析器,3,2,Medium,Parsing Terms,glossary.po; library/tokenize.po +tokenizer,tokenizer,4,2,Medium,Parsing Terms,glossary.po; library/tokenize.po diff --git a/glossary.po b/glossary.po index 80c6a07207..18ffbb20e3 100644 --- a/glossary.po +++ b/glossary.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # Translators: # Steven Hsu , 2021-2022 # Matt Wang , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-07 03:11+0800\n" +"POT-Creation-Date: 2025-07-13 11:32+0000\n" "PO-Revision-Date: 2023-07-02 22:47+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -30,63 +29,40 @@ msgstr "``>>>``" #: ../../glossary.rst:12 msgid "" -"The default Python prompt of the interactive shell. Often seen for code " -"examples which can be executed interactively in the interpreter." +"The default Python prompt of the :term:`interactive` shell. Often seen for " +"code examples which can be executed interactively in the interpreter." msgstr "" -"互動式 shell 的預設 Python 提示字元。常見於能在直譯器中以互動方式被執行的程式" -"碼範例。" +":term:`互動式 ` shell 的預設 Python 提示字元。常見於能在直譯器中" +"以互動方式被執行的程式碼範例。" -#: ../../glossary.rst:14 +#: ../../glossary.rst:15 msgid "``...``" msgstr "``...``" -#: ../../glossary.rst:16 +#: ../../glossary.rst:17 msgid "Can refer to:" msgstr "可以表示:" -#: ../../glossary.rst:18 +#: ../../glossary.rst:19 msgid "" -"The default Python prompt of the interactive shell when entering the code " -"for an indented code block, when within a pair of matching left and right " -"delimiters (parentheses, square brackets, curly braces or triple quotes), or " -"after specifying a decorator." +"The default Python prompt of the :term:`interactive` shell when entering the " +"code for an indented code block, when within a pair of matching left and " +"right delimiters (parentheses, square brackets, curly braces or triple " +"quotes), or after specifying a decorator." msgstr "" "在一個被縮排的程式碼區塊、在一對匹配的左右定界符(delimiter,例如括號、方括" "號、花括號或三引號)內部,或是在指定一個裝飾器 (decorator) 之後,要輸入程式碼" -"時,互動式 shell 顯示的預設 Python 提示字元。" +"時,:term:`互動式 ` shell 顯示的預設 Python 提示字元。" -#: ../../glossary.rst:23 +#: ../../glossary.rst:24 msgid "The :const:`Ellipsis` built-in constant." msgstr "內建常數 :const:`Ellipsis`。" -#: ../../glossary.rst:24 -msgid "2to3" -msgstr "2to3" - -#: ../../glossary.rst:26 -msgid "" -"A tool that tries to convert Python 2.x code to Python 3.x code by handling " -"most of the incompatibilities which can be detected by parsing the source " -"and traversing the parse tree." -msgstr "" -"一個試著將 Python 2.x 程式碼轉換為 Python 3.x 程式碼的工具,它是透過處理大部" -"分的不相容性來達成此目的,而這些不相容性能夠透過剖析原始碼和遍歷剖析樹而被檢" -"測出來。" - -#: ../../glossary.rst:30 -msgid "" -"2to3 is available in the standard library as :mod:`lib2to3`; a standalone " -"entry point is provided as :file:`Tools/scripts/2to3`. See :ref:`2to3-" -"reference`." -msgstr "" -"2to3 在可以標準函式庫中以 :mod:`lib2to3` 被使用;它提供了一個獨立的入口點," -"在 :file:`Tools/scripts/2to3`。請參閱 :ref:`2to3-reference`。" - -#: ../../glossary.rst:33 +#: ../../glossary.rst:25 msgid "abstract base class" msgstr "abstract base class(抽象基底類別)" -#: ../../glossary.rst:35 +#: ../../glossary.rst:27 msgid "" "Abstract base classes complement :term:`duck-typing` by providing a way to " "define interfaces when other techniques like :func:`hasattr` would be clumsy " @@ -109,11 +85,11 @@ msgstr "" "模組)及 import 尋檢器和載入器(在 :mod:`importlib.abc` 模組)。你可以使用 :" "mod:`abc` 模組建立自己的 ABC。" -#: ../../glossary.rst:46 +#: ../../glossary.rst:38 msgid "annotation" msgstr "annotation(註釋)" -#: ../../glossary.rst:48 +#: ../../glossary.rst:40 msgid "" "A label associated with a variable, a class attribute or a function " "parameter or return value, used by convention as a :term:`type hint`." @@ -121,7 +97,7 @@ msgstr "" "一個與變數、class 屬性、函式的參數或回傳值相關聯的標籤。照慣例,它被用來作" "為 :term:`type hint`\\ (型別提示)。" -#: ../../glossary.rst:52 +#: ../../glossary.rst:44 msgid "" "Annotations of local variables cannot be accessed at runtime, but " "annotations of global variables, class attributes, and functions are stored " @@ -132,7 +108,7 @@ msgstr "" "的註解,會分別被儲存在模組、class 和函式的 :attr:`__annotations__` 特殊屬性" "中。" -#: ../../glossary.rst:58 +#: ../../glossary.rst:50 msgid "" "See :term:`variable annotation`, :term:`function annotation`, :pep:`484` " "and :pep:`526`, which describe this functionality. Also see :ref:" @@ -142,11 +118,11 @@ msgstr "" "和 :pep:`526`,這些章節皆有此功能的說明。關於註釋的最佳實踐方法也請參閱 :ref:" "`annotations-howto`。" -#: ../../glossary.rst:62 +#: ../../glossary.rst:54 msgid "argument" msgstr "argument(引數)" -#: ../../glossary.rst:64 +#: ../../glossary.rst:56 msgid "" "A value passed to a :term:`function` (or :term:`method`) when calling the " "function. There are two kinds of argument:" @@ -154,7 +130,7 @@ msgstr "" "呼叫函式時被傳遞給 :term:`function`\\ (或 :term:`method`\\ )的值。引數有兩" "種:" -#: ../../glossary.rst:67 +#: ../../glossary.rst:59 msgid "" ":dfn:`keyword argument`: an argument preceded by an identifier (e.g. " "``name=``) in a function call or passed as a value in a dictionary preceded " @@ -166,13 +142,15 @@ msgstr "" "遞的引數。例如,``3`` 和 ``5`` 都是以下 :func:`complex` 呼叫中的關鍵字引" "數: ::" -#: ../../glossary.rst:72 +#: ../../glossary.rst:64 msgid "" "complex(real=3, imag=5)\n" "complex(**{'real': 3, 'imag': 5})" msgstr "" +"complex(real=3, imag=5)\n" +"complex(**{'real': 3, 'imag': 5})" -#: ../../glossary.rst:75 +#: ../../glossary.rst:67 msgid "" ":dfn:`positional argument`: an argument that is not a keyword argument. " "Positional arguments can appear at the beginning of an argument list and/or " @@ -183,13 +161,15 @@ msgstr "" "引數列表的起始處出現,和(或)作為 ``*`` 之後的 :term:`iterable`\\ (可疊代物" "件)中的元素被傳遞。例如,``3`` 和 ``5`` 都是以下呼叫中的位置引數: ::" -#: ../../glossary.rst:81 +#: ../../glossary.rst:73 msgid "" "complex(3, 5)\n" "complex(*(3, 5))" msgstr "" +"complex(3, 5)\n" +"complex(*(3, 5))" -#: ../../glossary.rst:84 +#: ../../glossary.rst:76 msgid "" "Arguments are assigned to the named local variables in a function body. See " "the :ref:`calls` section for the rules governing this assignment. " @@ -200,7 +180,7 @@ msgstr "" "\\ :ref:`calls`\\ 章節。在語法上,任何運算式都可以被用來表示一個引數;其評估" "值會被指定給區域變數。" -#: ../../glossary.rst:89 +#: ../../glossary.rst:81 msgid "" "See also the :term:`parameter` glossary entry, the FAQ question on :ref:`the " "difference between arguments and parameters `, " @@ -209,11 +189,11 @@ msgstr "" "另請參閱術語表的 :term:`parameter`\\ (參數)條目、常見問題中的\\ :ref:`引數" "和參數之間的差異 `,以及 :pep:`362`。" -#: ../../glossary.rst:92 +#: ../../glossary.rst:84 msgid "asynchronous context manager" msgstr "asynchronous context manager(非同步情境管理器)" -#: ../../glossary.rst:94 +#: ../../glossary.rst:86 msgid "" "An object which controls the environment seen in an :keyword:`async with` " "statement by defining :meth:`~object.__aenter__` and :meth:`~object." @@ -223,11 +203,11 @@ msgstr "" "meth:`~object.__aenter__` 和 :meth:`~object.__aexit__` method(方法)來控制" "的。由 :pep:`492` 引入。" -#: ../../glossary.rst:97 +#: ../../glossary.rst:89 msgid "asynchronous generator" msgstr "asynchronous generator(非同步產生器)" -#: ../../glossary.rst:99 +#: ../../glossary.rst:91 msgid "" "A function which returns an :term:`asynchronous generator iterator`. It " "looks like a coroutine function defined with :keyword:`async def` except " @@ -239,7 +219,7 @@ msgstr "" "function),但不同的是它包含了 :keyword:`yield` 運算式,能生成一系列可用於 :" "keyword:`async for` 迴圈的值。" -#: ../../glossary.rst:104 +#: ../../glossary.rst:96 msgid "" "Usually refers to an asynchronous generator function, but may refer to an " "*asynchronous generator iterator* in some contexts. In cases where the " @@ -249,7 +229,7 @@ msgstr "" "同步產生器疊代器 (asynchronous generator iterator)*。萬一想表達的意思不夠清" "楚,那就使用完整的術語,以避免歧義。" -#: ../../glossary.rst:108 +#: ../../glossary.rst:100 msgid "" "An asynchronous generator function may contain :keyword:`await` expressions " "as well as :keyword:`async for`, and :keyword:`async with` statements." @@ -257,16 +237,16 @@ msgstr "" "一個非同步產生器函式可能包含 :keyword:`await` 運算式,以及 :keyword:`async " "for` 和 :keyword:`async with` 陳述式。" -#: ../../glossary.rst:111 +#: ../../glossary.rst:103 msgid "asynchronous generator iterator" msgstr "asynchronous generator iterator(非同步產生器疊代器)" -#: ../../glossary.rst:113 +#: ../../glossary.rst:105 msgid "An object created by a :term:`asynchronous generator` function." msgstr "" "一個由 :term:`asynchronous generator`\\ (非同步產生器)函式所建立的物件。" -#: ../../glossary.rst:115 +#: ../../glossary.rst:107 msgid "" "This is an :term:`asynchronous iterator` which when called using the :meth:" "`~object.__anext__` method returns an awaitable object which will execute " @@ -278,24 +258,24 @@ msgstr "" "object),該物件將執行非同步產生器的函式主體,直到遇到下一個 :keyword:`yield` " "運算式。" -#: ../../glossary.rst:120 +#: ../../glossary.rst:112 msgid "" "Each :keyword:`yield` temporarily suspends processing, remembering the " -"location execution state (including local variables and pending try-" -"statements). When the *asynchronous generator iterator* effectively resumes " -"with another awaitable returned by :meth:`~object.__anext__`, it picks up " -"where it left off. See :pep:`492` and :pep:`525`." +"execution state (including local variables and pending try-statements). " +"When the *asynchronous generator iterator* effectively resumes with another " +"awaitable returned by :meth:`~object.__anext__`, it picks up where it left " +"off. See :pep:`492` and :pep:`525`." msgstr "" -"每個 :keyword:`yield` 會暫停處理程序,並記住位置執行狀態(包括區域變數及擱置" -"中的 try 陳述式)。當\\ *非同步產生器疊代器*\\ 以另一個被 :meth:`~object." +"每個 :keyword:`yield` 會暫停處理程序,並記住執行狀態(包括區域變數及擱置中的 " +"try 陳述式)。當\\ *非同步產生器疊代器*\\ 以另一個被 :meth:`~object." "__anext__` 回傳的可等待物件有效地回復時,它會從停止的地方繼續執行。請參閱 :" "pep:`492` 和 :pep:`525`。" -#: ../../glossary.rst:125 +#: ../../glossary.rst:117 msgid "asynchronous iterable" msgstr "asynchronous iterable(非同步可疊代物件)" -#: ../../glossary.rst:127 +#: ../../glossary.rst:119 msgid "" "An object, that can be used in an :keyword:`async for` statement. Must " "return an :term:`asynchronous iterator` from its :meth:`~object.__aiter__` " @@ -305,11 +285,11 @@ msgstr "" "`~object.__aiter__` method 回傳一個 :term:`asynchronous iterator`\\ (非同步" "疊代器)。由 :pep:`492` 引入。" -#: ../../glossary.rst:130 +#: ../../glossary.rst:122 msgid "asynchronous iterator" msgstr "asynchronous iterator(非同步疊代器)" -#: ../../glossary.rst:132 +#: ../../glossary.rst:124 msgid "" "An object that implements the :meth:`~object.__aiter__` and :meth:`~object." "__anext__` methods. :meth:`~object.__anext__` must return an :term:" @@ -323,11 +303,11 @@ msgstr "" "method 所回傳的可等待物件,直到它引發 :exc:`StopAsyncIteration` 例外。由 :" "pep:`492` 引入。" -#: ../../glossary.rst:137 +#: ../../glossary.rst:129 msgid "attribute" msgstr "attribute(屬性)" -#: ../../glossary.rst:139 +#: ../../glossary.rst:131 msgid "" "A value associated with an object which is usually referenced by name using " "dotted expressions. For example, if an object *o* has an attribute *a* it " @@ -336,7 +316,7 @@ msgstr "" "一個與某物件相關聯的值,該值大多能透過使用點分隔運算式 (dotted expression) 的" "名稱被參照。例如,如果物件 *o* 有一個屬性 *a*,則該屬性能以 *o.a* 被參照。" -#: ../../glossary.rst:144 +#: ../../glossary.rst:136 msgid "" "It is possible to give an object an attribute whose name is not an " "identifier as defined by :ref:`identifiers`, for example using :func:" @@ -348,11 +328,11 @@ msgstr "" "別符 (identifier) 的屬性是有可能的,例如使用 :func:`setattr`。像這樣的屬性將" "無法使用點分隔運算式來存取,而是需要使用 :func:`getattr` 來取得它。" -#: ../../glossary.rst:149 +#: ../../glossary.rst:141 msgid "awaitable" msgstr "awaitable(可等待物件)" -#: ../../glossary.rst:151 +#: ../../glossary.rst:143 msgid "" "An object that can be used in an :keyword:`await` expression. Can be a :" "term:`coroutine` or an object with an :meth:`~object.__await__` method. See " @@ -362,11 +342,11 @@ msgstr "" "`coroutine`\\ (協程),或是一個有 :meth:`~object.__await__` method 的物件。" "另請參閱 :pep:`492`。" -#: ../../glossary.rst:154 +#: ../../glossary.rst:146 msgid "BDFL" msgstr "BDFL" -#: ../../glossary.rst:156 +#: ../../glossary.rst:148 msgid "" "Benevolent Dictator For Life, a.k.a. `Guido van Rossum `_, Python's creator." @@ -374,11 +354,11 @@ msgstr "" "Benevolent Dictator For Life(終身仁慈獨裁者),又名 `Guido van Rossum " "`_,Python 的創造者。" -#: ../../glossary.rst:158 +#: ../../glossary.rst:150 msgid "binary file" msgstr "binary file(二進位檔案)" -#: ../../glossary.rst:160 +#: ../../glossary.rst:152 msgid "" "A :term:`file object` able to read and write :term:`bytes-like objects " "`. Examples of binary files are files opened in binary " @@ -392,7 +372,7 @@ msgstr "" "`、:data:`sys.stdout.buffer `,以及 :class:`io." "BytesIO` 和 :class:`gzip.GzipFile` 實例。" -#: ../../glossary.rst:167 +#: ../../glossary.rst:159 msgid "" "See also :term:`text file` for a file object able to read and write :class:" "`str` objects." @@ -400,11 +380,11 @@ msgstr "" "另請參閱 :term:`text file`\\ (文字檔案),它是一個能夠讀取和寫入 :class:" "`str` 物件的檔案物件。" -#: ../../glossary.rst:169 +#: ../../glossary.rst:161 msgid "borrowed reference" msgstr "borrowed reference(借用參照)" -#: ../../glossary.rst:171 +#: ../../glossary.rst:163 msgid "" "In Python's C API, a borrowed reference is a reference to an object, where " "the code using the object does not own the reference. It becomes a dangling " @@ -416,7 +396,7 @@ msgstr "" "如,一次垃圾回收 (garbage collection) 可以移除對物件的最後一個 :term:`strong " "reference`\\ (強參照),而將該物件銷毀。" -#: ../../glossary.rst:177 +#: ../../glossary.rst:169 msgid "" "Calling :c:func:`Py_INCREF` on the :term:`borrowed reference` is recommended " "to convert it to a :term:`strong reference` in-place, except when the object " @@ -429,11 +409,11 @@ msgstr "" "借用參照之前被銷毀。:c:func:`Py_NewRef` 函式可用於建立一個新的 :term:`strong " "reference`。" -#: ../../glossary.rst:182 +#: ../../glossary.rst:174 msgid "bytes-like object" msgstr "bytes-like object(類位元組串物件)" -#: ../../glossary.rst:184 +#: ../../glossary.rst:176 msgid "" "An object that supports the :ref:`bufferobjects` and can export a C-:term:" "`contiguous` buffer. This includes all :class:`bytes`, :class:`bytearray`, " @@ -447,7 +427,7 @@ msgstr "" "物件,以及許多常見的 :class:`memoryview` 物件。類位元組串物件可用於處理二進位" "資料的各種運算;這些運算包括壓縮、儲存至二進位檔案和透過 socket(插座)發送。" -#: ../../glossary.rst:191 +#: ../../glossary.rst:183 msgid "" "Some operations need the binary data to be mutable. The documentation often " "refers to these as \"read-write bytes-like objects\". Example mutable " @@ -462,11 +442,11 @@ msgstr "" "的類位元組串物件」)中;這些物件包括 :class:`bytes`,以及 :class:`bytes` 物件" "的 :class:`memoryview`。" -#: ../../glossary.rst:199 +#: ../../glossary.rst:191 msgid "bytecode" msgstr "bytecode(位元組碼)" -#: ../../glossary.rst:201 +#: ../../glossary.rst:193 msgid "" "Python source code is compiled into bytecode, the internal representation of " "a Python program in the CPython interpreter. The bytecode is also cached in " @@ -485,18 +465,18 @@ msgstr "" "上是無法在不同的 Python 虛擬機器之間運作的,也不能在不同版本的 Python 之間保" "持穩定。" -#: ../../glossary.rst:211 +#: ../../glossary.rst:203 msgid "" "A list of bytecode instructions can be found in the documentation for :ref:" "`the dis module `." msgstr "" "位元組碼的指令列表可以在 :ref:`dis 模組 `\\ 的說明文件中找到。" -#: ../../glossary.rst:213 +#: ../../glossary.rst:205 msgid "callable" msgstr "callable(可呼叫物件)" -#: ../../glossary.rst:215 +#: ../../glossary.rst:207 msgid "" "A callable is an object that can be called, possibly with a set of arguments " "(see :term:`argument`), with the following syntax::" @@ -504,11 +484,11 @@ msgstr "" "一個 callable 是可以被呼叫的物件,呼叫時可能以下列形式帶有一組引數(請見 :" "term:`argument`): ::" -#: ../../glossary.rst:218 +#: ../../glossary.rst:210 msgid "callable(argument1, argument2, argumentN)" -msgstr "" +msgstr "callable(argument1, argument2, argumentN)" -#: ../../glossary.rst:220 +#: ../../glossary.rst:212 msgid "" "A :term:`function`, and by extension a :term:`method`, is a callable. An " "instance of a class that implements the :meth:`~object.__call__` method is " @@ -517,22 +497,22 @@ msgstr "" "一個 :term:`function` 與其延伸的 :term:`method` 都是 callable。一個有實作 :" "meth:`~object.__call__` 方法的 class 之實例也是個 callable。" -#: ../../glossary.rst:223 +#: ../../glossary.rst:215 msgid "callback" msgstr "callback(回呼)" -#: ../../glossary.rst:225 +#: ../../glossary.rst:217 msgid "" "A subroutine function which is passed as an argument to be executed at some " "point in the future." msgstr "" "作為引數被傳遞的一個副程式 (subroutine) 函式,會在未來的某個時間點被執行。" -#: ../../glossary.rst:227 +#: ../../glossary.rst:219 msgid "class" msgstr "class(類別)" -#: ../../glossary.rst:229 +#: ../../glossary.rst:221 msgid "" "A template for creating user-defined objects. Class definitions normally " "contain method definitions which operate on instances of the class." @@ -540,11 +520,11 @@ msgstr "" "一個用於建立使用者定義物件的模板。Class 的定義通常會包含 method 的定義,這些 " "method 可以在 class 的實例上進行操作。" -#: ../../glossary.rst:232 +#: ../../glossary.rst:224 msgid "class variable" msgstr "class variable(類別變數)" -#: ../../glossary.rst:234 +#: ../../glossary.rst:226 msgid "" "A variable defined in a class and intended to be modified only at class " "level (i.e., not in an instance of the class)." @@ -552,11 +532,67 @@ msgstr "" "一個在 class 中被定義,且應該只能在 class 層次(意即不是在 class 的實例中)被" "修改的變數。" -#: ../../glossary.rst:236 +#: ../../glossary.rst:228 +msgid "closure variable" +msgstr "closure variable(閉包變數)" + +#: ../../glossary.rst:230 +msgid "" +"A :term:`free variable` referenced from a :term:`nested scope` that is " +"defined in an outer scope rather than being resolved at runtime from the " +"globals or builtin namespaces. May be explicitly defined with the :keyword:" +"`nonlocal` keyword to allow write access, or implicitly defined if the " +"variable is only being read." +msgstr "" +"從外部作用域中定義且從\\ :term:`巢狀作用域 `\\ 參照的\\ :term:`" +"自由變數 `,不是於 runtime 從全域或內建命名空間解析。可以使" +"用 :keyword:`nonlocal` 關鍵字明確定義以允許寫入存取,或者如果僅需讀取變數則隱" +"式定義即可。" + +#: ../../glossary.rst:235 +msgid "" +"For example, in the ``inner`` function in the following code, both ``x`` and " +"``print`` are :term:`free variables `, but only ``x`` is a " +"*closure variable*::" +msgstr "" +"例如在下面程式碼中的 ``inner`` 函式中,``x`` 和 ``print`` 都是\\ :term:`自由" +"變數 `,但只有 ``x`` 是\\ *閉包變數*: ::" + +#: ../../glossary.rst:238 +msgid "" +"def outer():\n" +" x = 0\n" +" def inner():\n" +" nonlocal x\n" +" x += 1\n" +" print(x)\n" +" return inner" +msgstr "" +"def outer():\n" +" x = 0\n" +" def inner():\n" +" nonlocal x\n" +" x += 1\n" +" print(x)\n" +" return inner" + +#: ../../glossary.rst:246 +msgid "" +"Due to the :attr:`codeobject.co_freevars` attribute (which, despite its " +"name, only includes the names of closure variables rather than listing all " +"referenced free variables), the more general :term:`free variable` term is " +"sometimes used even when the intended meaning is to refer specifically to " +"closure variables." +msgstr "" +"由於 :attr:`codeobject.co_freevars` 屬性(儘管名稱如此,但它僅包含閉包變數的" +"名稱,而不是列出所有參照的自由變數),當預期含義是特指閉包變數時,有時候甚至" +"也會使用更通用的\\ :term:`自由變數 `\\ 一詞。" + +#: ../../glossary.rst:250 msgid "complex number" msgstr "complex number(複數)" -#: ../../glossary.rst:238 +#: ../../glossary.rst:252 msgid "" "An extension of the familiar real number system in which all numbers are " "expressed as a sum of a real part and an imaginary part. Imaginary numbers " @@ -576,44 +612,75 @@ msgstr "" "相當進階的數學功能。如果你沒有察覺到對它們的需求,那麼幾乎能確定你可以安全地" "忽略它們。" -#: ../../glossary.rst:248 +#: ../../glossary.rst:262 +msgid "context" +msgstr "context(情境)" + +#: ../../glossary.rst:264 +msgid "" +"This term has different meanings depending on where and how it is used. Some " +"common meanings:" +msgstr "" + +#: ../../glossary.rst:267 +msgid "" +"The temporary state or environment established by a :term:`context manager` " +"via a :keyword:`with` statement." +msgstr "" + +#: ../../glossary.rst:269 +msgid "" +"The collection of key­value bindings associated with a particular :class:" +"`contextvars.Context` object and accessed via :class:`~contextvars." +"ContextVar` objects. Also see :term:`context variable`." +msgstr "" + +#: ../../glossary.rst:273 +msgid "" +"A :class:`contextvars.Context` object. Also see :term:`current context`." +msgstr "" +"一個 :class:`contextvars.Context` 物件。另請參閱 :term:`current context`。" + +#: ../../glossary.rst:275 +msgid "context management protocol" +msgstr "context management protocol(情境管理協定)" + +#: ../../glossary.rst:277 +msgid "" +"The :meth:`~object.__enter__` and :meth:`~object.__exit__` methods called by " +"the :keyword:`with` statement. See :pep:`343`." +msgstr "" +"由 :keyword:`with` 陳述式所呼叫的 :meth:`~object.__enter__` 和 :meth:" +"`~object.__exit__` 方法。另請參閱 :pep:`343`。" + +#: ../../glossary.rst:279 msgid "context manager" msgstr "context manager(情境管理器)" -#: ../../glossary.rst:250 +#: ../../glossary.rst:281 msgid "" -"An object which controls the environment seen in a :keyword:`with` statement " -"by defining :meth:`~object.__enter__` and :meth:`~object.__exit__` methods. " -"See :pep:`343`." +"An object which implements the :term:`context management protocol` and " +"controls the environment seen in a :keyword:`with` statement. See :pep:" +"`343`." msgstr "" -"一個可以控制 :keyword:`with` 陳述式中所見環境的物件,而它是透過定義 :meth:" -"`~object.__enter__` 和 :meth:`~object.__exit__` method 來控制的。請參閱 :pep:" -"`343`。" -#: ../../glossary.rst:253 +#: ../../glossary.rst:284 msgid "context variable" msgstr "context variable(情境變數)" -#: ../../glossary.rst:255 +#: ../../glossary.rst:286 msgid "" -"A variable which can have different values depending on its context. This is " -"similar to Thread-Local Storage in which each execution thread may have a " -"different value for a variable. However, with context variables, there may " -"be several contexts in one execution thread and the main usage for context " -"variables is to keep track of variables in concurrent asynchronous tasks. " -"See :mod:`contextvars`." +"A variable whose value depends on which context is the :term:`current " +"context`. Values are accessed via :class:`contextvars.ContextVar` objects. " +"Context variables are primarily used to isolate state between concurrent " +"asynchronous tasks." msgstr "" -"一個變數,其值可以根據上下文的情境而有所不同。這類似執行緒區域儲存區 (Thread-" -"Local Storage),在其中,一個變數在每個執行緒可能具有不同的值。然而,關於情境" -"變數,在一個執行緒中可能會有多個情境,而情境變數的主要用途,是在並行的非同步" -"任務 (concurrent asynchronous task) 中,對於變數狀態的追蹤。請參閱 :mod:" -"`contextvars`。" -#: ../../glossary.rst:262 +#: ../../glossary.rst:290 msgid "contiguous" msgstr "contiguous(連續的)" -#: ../../glossary.rst:266 +#: ../../glossary.rst:294 msgid "" "A buffer is considered contiguous exactly if it is either *C-contiguous* or " "*Fortran contiguous*. Zero-dimensional buffers are C and Fortran " @@ -627,14 +694,14 @@ msgstr "" "是連續的。零維 (zero-dimensional) 的緩衝區都是 C 及 Fortran contiguous。在一" "維 (one-dimensional) 陣列中,各項目必須在記憶體中彼此相鄰地排列,而其索引順序" "是從零開始遞增。在多維的 (multidimensional) C-contiguous 陣列中,按記憶體位址" -"的順序訪問各個項目時,最後一個索引的變化最快。然而,在 Fortran contiguous 陣" +"的順序瀏覽各個項目時,最後一個索引的變化最快。然而,在 Fortran contiguous 陣" "列中,第一個索引的變化最快。" -#: ../../glossary.rst:274 +#: ../../glossary.rst:302 msgid "coroutine" msgstr "coroutine(協程)" -#: ../../glossary.rst:276 +#: ../../glossary.rst:304 msgid "" "Coroutines are a more generalized form of subroutines. Subroutines are " "entered at one point and exited at another point. Coroutines can be " @@ -645,11 +712,11 @@ msgstr "" "在另一個時間點被退出。協程可以在許多不同的時間點被進入、退出和回復。它們能夠" "以 :keyword:`async def` 陳述式被實作。另請參閱 :pep:`492`。" -#: ../../glossary.rst:281 +#: ../../glossary.rst:309 msgid "coroutine function" msgstr "coroutine function(協程函式)" -#: ../../glossary.rst:283 +#: ../../glossary.rst:311 msgid "" "A function which returns a :term:`coroutine` object. A coroutine function " "may be defined with the :keyword:`async def` statement, and may contain :" @@ -660,11 +727,11 @@ msgstr "" "`async def` 陳述式被定義,並可能會包含 :keyword:`await`、:keyword:`async " "for` 和 :keyword:`async with` 關鍵字。這些關鍵字由 :pep:`492` 引入。" -#: ../../glossary.rst:288 +#: ../../glossary.rst:316 msgid "CPython" msgstr "CPython" -#: ../../glossary.rst:290 +#: ../../glossary.rst:318 msgid "" "The canonical implementation of the Python programming language, as " "distributed on `python.org `_. The term \"CPython\" " @@ -675,11 +742,25 @@ msgstr "" "`_ 上。「CPython」這個術語在必要時被使用,以區分此實" "作與其它語言的實作,例如 Jython 或 IronPython。" -#: ../../glossary.rst:294 +#: ../../glossary.rst:322 +msgid "current context" +msgstr "" + +#: ../../glossary.rst:324 +msgid "" +"The :term:`context` (:class:`contextvars.Context` object) that is currently " +"used by :class:`~contextvars.ContextVar` objects to access (get or set) the " +"values of :term:`context variables `. Each thread has its " +"own current context. Frameworks for executing asynchronous tasks (see :mod:" +"`asyncio`) associate each task with a context which becomes the current " +"context whenever the task starts or resumes execution." +msgstr "" + +#: ../../glossary.rst:330 msgid "decorator" msgstr "decorator(裝飾器)" -#: ../../glossary.rst:296 +#: ../../glossary.rst:332 msgid "" "A function returning another function, usually applied as a function " "transformation using the ``@wrapper`` syntax. Common examples for " @@ -689,13 +770,13 @@ msgstr "" "式的變換 (function transformation)。裝飾器的常見範例是 :func:`classmethod` " "和 :func:`staticmethod`。" -#: ../../glossary.rst:300 +#: ../../glossary.rst:336 msgid "" "The decorator syntax is merely syntactic sugar, the following two function " "definitions are semantically equivalent::" msgstr "裝飾器語法只是語法糖。以下兩個函式定義在語義上是等效的: ::" -#: ../../glossary.rst:303 +#: ../../glossary.rst:339 msgid "" "def f(arg):\n" " ...\n" @@ -713,7 +794,7 @@ msgstr "" "def f(arg):\n" " ..." -#: ../../glossary.rst:311 +#: ../../glossary.rst:347 msgid "" "The same concept exists for classes, but is less commonly used there. See " "the documentation for :ref:`function definitions ` and :ref:`class " @@ -722,11 +803,11 @@ msgstr "" "Class 也存在相同的概念,但在那裡比較不常用。關於裝飾器的更多內容,請參閱\\ :" "ref:`函式定義 `\\ 和 :ref:`class 定義 `\\ 的說明文件。" -#: ../../glossary.rst:314 +#: ../../glossary.rst:350 msgid "descriptor" msgstr "descriptor(描述器)" -#: ../../glossary.rst:316 +#: ../../glossary.rst:352 msgid "" "Any object which defines the methods :meth:`~object.__get__`, :meth:`~object." "__set__`, or :meth:`~object.__delete__`. When a class attribute is a " @@ -746,7 +827,7 @@ msgstr "" "們是許多功能的基礎,這些功能包括函式、method、屬性 (property)、class method、" "靜態 method,以及對 super class(父類別)的參照。" -#: ../../glossary.rst:327 +#: ../../glossary.rst:363 msgid "" "For more information about descriptors' methods, see :ref:`descriptors` or " "the :ref:`Descriptor How To Guide `." @@ -754,25 +835,25 @@ msgstr "" "關於描述器 method 的更多資訊,請參閱\\ :ref:`descriptors`\\ 或\\ :ref:`描述器" "使用指南 `。" -#: ../../glossary.rst:329 +#: ../../glossary.rst:365 msgid "dictionary" msgstr "dictionary(字典)" -#: ../../glossary.rst:331 +#: ../../glossary.rst:367 msgid "" "An associative array, where arbitrary keys are mapped to values. The keys " "can be any object with :meth:`~object.__hash__` and :meth:`~object.__eq__` " "methods. Called a hash in Perl." msgstr "" -"一個關聯陣列 (associative array),其中任意的鍵會被映射到值。鍵可以是任何帶" +"一個關聯陣列 (associative array),其中任意的鍵會被對映到值。鍵可以是任何帶" "有 :meth:`~object.__hash__` 和 :meth:`~object.__eq__` method 的物件。在 Perl " "中被稱為雜湊 (hash)。" -#: ../../glossary.rst:335 +#: ../../glossary.rst:371 msgid "dictionary comprehension" msgstr "dictionary comprehension(字典綜合運算)" -#: ../../glossary.rst:337 +#: ../../glossary.rst:373 msgid "" "A compact way to process all or part of the elements in an iterable and " "return a dictionary with the results. ``results = {n: n ** 2 for n in " @@ -781,13 +862,13 @@ msgid "" msgstr "" "一種緊密的方法,用來處理一個可疊代物件中的全部或部分元素,並將處理結果以一個" "字典回傳。``results = {n: n ** 2 for n in range(10)}`` 會產生一個字典,它包含" -"了鍵 ``n`` 映射到值 ``n ** 2``。請參閱\\ :ref:`comprehensions`。" +"了鍵 ``n`` 對映到值 ``n ** 2``。請參閱\\ :ref:`comprehensions`。" -#: ../../glossary.rst:341 +#: ../../glossary.rst:377 msgid "dictionary view" msgstr "dictionary view(字典檢視)" -#: ../../glossary.rst:343 +#: ../../glossary.rst:379 msgid "" "The objects returned from :meth:`dict.keys`, :meth:`dict.values`, and :meth:" "`dict.items` are called dictionary views. They provide a dynamic view on the " @@ -800,28 +881,28 @@ msgstr "" "反映這些變動。若要強制將字典檢視轉為完整的 list(串列),須使用 " "``list(dictview)``。請參閱\\ :ref:`dict-views`。" -#: ../../glossary.rst:349 +#: ../../glossary.rst:385 msgid "docstring" msgstr "docstring(說明字串)" -#: ../../glossary.rst:351 +#: ../../glossary.rst:387 msgid "" "A string literal which appears as the first expression in a class, function " "or module. While ignored when the suite is executed, it is recognized by " -"the compiler and put into the :attr:`!__doc__` attribute of the enclosing " -"class, function or module. Since it is available via introspection, it is " -"the canonical place for documentation of the object." +"the compiler and put into the :attr:`~definition.__doc__` attribute of the " +"enclosing class, function or module. Since it is available via " +"introspection, it is the canonical place for documentation of the object." msgstr "" "一個在 class、函式或模組中,作為第一個運算式出現的字串文本。雖然它在套件執行" -"時會被忽略,但它會被編譯器辨識,並被放入所屬 class、函式或模組的 :attr:`!" -"__doc__` 屬性中。由於說明字串可以透過內省 (introspection) 來瀏覽,因此它是物" -"件的說明文件存放的標準位置。" +"時會被忽略,但它會被編譯器辨識,並被放入所屬 class、函式或模組的 :attr:" +"`~definition.__doc__` 屬性中。由於說明字串可以透過內省 (introspection) 來瀏" +"覽,因此它是物件的說明文件存放的標準位置。" -#: ../../glossary.rst:357 +#: ../../glossary.rst:393 msgid "duck-typing" msgstr "duck-typing(鴨子型別)" -#: ../../glossary.rst:359 +#: ../../glossary.rst:395 msgid "" "A programming style which does not look at an object's type to determine if " "it has the right interface; instead, the method or attribute is simply " @@ -842,11 +923,11 @@ msgstr "" "來補充。)然而,它通常會採用 :func:`hasattr` 測試,或是 :term:`EAFP` 程式設計" "風格。" -#: ../../glossary.rst:368 +#: ../../glossary.rst:404 msgid "EAFP" msgstr "EAFP" -#: ../../glossary.rst:370 +#: ../../glossary.rst:406 msgid "" "Easier to ask for forgiveness than permission. This common Python coding " "style assumes the existence of valid keys or attributes and catches " @@ -861,11 +942,11 @@ msgstr "" "keyword:`except` 陳述式。該技術與許多其他語言(例如 C)常見的 :term:`LBYL` 風" "格形成了對比。" -#: ../../glossary.rst:376 +#: ../../glossary.rst:412 msgid "expression" msgstr "expression(運算式)" -#: ../../glossary.rst:378 +#: ../../glossary.rst:414 msgid "" "A piece of syntax which can be evaluated to some value. In other words, an " "expression is an accumulation of expression elements like literals, names, " @@ -881,11 +962,11 @@ msgstr "" "(陳述式)不能被用作運算式,例如 :keyword:`while`。賦值 (assignment) 也是陳述" "式,而不是運算式。" -#: ../../glossary.rst:385 +#: ../../glossary.rst:421 msgid "extension module" msgstr "extension module(擴充模組)" -#: ../../glossary.rst:387 +#: ../../glossary.rst:423 msgid "" "A module written in C or C++, using Python's C API to interact with the core " "and with user code." @@ -893,11 +974,11 @@ msgstr "" "一個以 C 或 C++ 編寫的模組,它使用 Python 的 C API 來與核心及使用者程式碼進行" "互動。" -#: ../../glossary.rst:389 +#: ../../glossary.rst:425 msgid "f-string" msgstr "f-string(f 字串)" -#: ../../glossary.rst:391 +#: ../../glossary.rst:427 msgid "" "String literals prefixed with ``'f'`` or ``'F'`` are commonly called \"f-" "strings\" which is short for :ref:`formatted string literals `. " @@ -906,11 +987,11 @@ msgstr "" "以 ``'f'`` 或 ``'F'`` 為前綴的字串文本通常被稱為「f 字串」,它是\\ :ref:`格式" "化的字串文本 `\\ 的縮寫。另請參閱 :pep:`498`。" -#: ../../glossary.rst:394 +#: ../../glossary.rst:430 msgid "file object" msgstr "file object(檔案物件)" -#: ../../glossary.rst:396 +#: ../../glossary.rst:432 msgid "" "An object exposing a file-oriented API (with methods such as :meth:`!read` " "or :meth:`!write`) to an underlying resource. Depending on the way it was " @@ -925,7 +1006,7 @@ msgstr "" "衝區、socket(插座)、管線 (pipe) 等)的存取。檔案物件也被稱為\\ :dfn:`類檔案" "物件 (file-like object)` 或\\ :dfn:`串流 (stream)`。" -#: ../../glossary.rst:404 +#: ../../glossary.rst:440 msgid "" "There are actually three categories of file objects: raw :term:`binary files " "`, buffered :term:`binary files ` and :term:`text " @@ -937,19 +1018,19 @@ msgstr "" "term:`二進位檔案 `\\ 和\\ :term:`文字檔案 `。它們的介" "面在 :mod:`io` 模組中被定義。建立檔案物件的標準方法是使用 :func:`open` 函式。" -#: ../../glossary.rst:409 +#: ../../glossary.rst:445 msgid "file-like object" msgstr "file-like object(類檔案物件)" -#: ../../glossary.rst:411 +#: ../../glossary.rst:447 msgid "A synonym for :term:`file object`." msgstr ":term:`file object`\\ (檔案物件)的同義字。" -#: ../../glossary.rst:412 +#: ../../glossary.rst:448 msgid "filesystem encoding and error handler" msgstr "filesystem encoding and error handler(檔案系統編碼和錯誤處理函式)" -#: ../../glossary.rst:414 +#: ../../glossary.rst:450 msgid "" "Encoding and error handler used by Python to decode bytes from the operating " "system and encode Unicode to the operating system." @@ -957,7 +1038,7 @@ msgstr "" "Python 所使用的一種編碼和錯誤處理函式,用來解碼來自作業系統的位元組,以及將 " "Unicode 編碼到作業系統。" -#: ../../glossary.rst:417 +#: ../../glossary.rst:453 msgid "" "The filesystem encoding must guarantee to successfully decode all bytes " "below 128. If the file system encoding fails to provide this guarantee, API " @@ -966,7 +1047,7 @@ msgstr "" "檔案系統編碼必須保證能成功解碼所有小於 128 的位元組。如果檔案系統編碼無法提供" "此保證,則 API 函式會引發 :exc:`UnicodeError`。" -#: ../../glossary.rst:421 +#: ../../glossary.rst:457 msgid "" "The :func:`sys.getfilesystemencoding` and :func:`sys." "getfilesystemencodeerrors` functions can be used to get the filesystem " @@ -975,7 +1056,7 @@ msgstr "" ":func:`sys.getfilesystemencoding` 和 :func:`sys.getfilesystemencodeerrors` 函" "式可用於取得檔案系統編碼和錯誤處理函式。" -#: ../../glossary.rst:425 +#: ../../glossary.rst:461 msgid "" "The :term:`filesystem encoding and error handler` are configured at Python " "startup by the :c:func:`PyConfig_Read` function: see :c:member:`~PyConfig." @@ -987,22 +1068,22 @@ msgstr "" "member:`~PyConfig.filesystem_encoding`,以及 :c:type:`PyConfig` 的成員 :c:" "member:`~PyConfig.filesystem_errors`。" -#: ../../glossary.rst:430 +#: ../../glossary.rst:466 msgid "See also the :term:`locale encoding`." msgstr "另請參閱 :term:`locale encoding`\\ (區域編碼)。" -#: ../../glossary.rst:431 +#: ../../glossary.rst:467 msgid "finder" msgstr "finder(尋檢器)" -#: ../../glossary.rst:433 +#: ../../glossary.rst:469 msgid "" "An object that tries to find the :term:`loader` for a module that is being " "imported." msgstr "" "一個物件,它會嘗試為正在被 import 的模組尋找 :term:`loader`\\ (載入器)。" -#: ../../glossary.rst:436 +#: ../../glossary.rst:472 msgid "" "There are two types of finder: :term:`meta path finders ` " "for use with :data:`sys.meta_path`, and :term:`path entry finders ` 會使用 :data:`sys.meta_path`,而\\ :term:`路徑項目尋檢器 (path " "entry finder) ` 會使用 :data:`sys.path_hooks`。" -#: ../../glossary.rst:440 -msgid "See :ref:`importsystem` and :mod:`importlib` for much more detail." -msgstr "請參閱 :ref:`importsystem` 和 :mod:`importlib` 以了解更多細節。" +#: ../../glossary.rst:476 +msgid "" +"See :ref:`finders-and-loaders` and :mod:`importlib` for much more detail." +msgstr "請參閱 :ref:`finders-and-loaders` 和 :mod:`importlib` 以了解更多細節。" -#: ../../glossary.rst:441 +#: ../../glossary.rst:477 msgid "floor division" msgstr "floor division(向下取整除法)" -#: ../../glossary.rst:443 +#: ../../glossary.rst:479 msgid "" "Mathematical division that rounds down to nearest integer. The floor " "division operator is ``//``. For example, the expression ``11 // 4`` " @@ -1033,11 +1115,40 @@ msgstr "" "``2.75`` 不同。請注意,``(-11) // 4`` 的結果是 ``-3``,因為是 ``-2.75`` 被\\ " "*向下*\\ 無條件捨去。請參閱 :pep:`238`。" -#: ../../glossary.rst:448 +#: ../../glossary.rst:484 +msgid "free threading" +msgstr "free threading(自由執行緒)" + +#: ../../glossary.rst:486 +msgid "" +"A threading model where multiple threads can run Python bytecode " +"simultaneously within the same interpreter. This is in contrast to the :" +"term:`global interpreter lock` which allows only one thread to execute " +"Python bytecode at a time. See :pep:`703`." +msgstr "" +"為一種執行緒模型,多個執行緒可以在同一直譯器中同時運行 Python 位元組碼。這與" +"\\ :term:`全域直譯器鎖 `\\ 形成對比,後者一次只允許" +"一個執行緒執行 Python 位元組碼。請參閱 :pep:`703`。" + +#: ../../glossary.rst:490 +msgid "free variable" +msgstr "free variable(自由變數)" + +#: ../../glossary.rst:492 +msgid "" +"Formally, as defined in the :ref:`language execution model `, a " +"free variable is any variable used in a namespace which is not a local " +"variable in that namespace. See :term:`closure variable` for an example. " +"Pragmatically, due to the name of the :attr:`codeobject.co_freevars` " +"attribute, the term is also sometimes used as a synonym for :term:`closure " +"variable`." +msgstr "" + +#: ../../glossary.rst:497 msgid "function" msgstr "function(函式)" -#: ../../glossary.rst:450 +#: ../../glossary.rst:499 msgid "" "A series of statements which returns some value to a caller. It can also be " "passed zero or more :term:`arguments ` which may be used in the " @@ -1049,15 +1160,15 @@ msgstr "" "`parameter`\\ (參數)、:term:`method`\\ (方法),以及\\ :ref:`function`\\ " "章節。" -#: ../../glossary.rst:454 +#: ../../glossary.rst:503 msgid "function annotation" msgstr "function annotation(函式註釋)" -#: ../../glossary.rst:456 +#: ../../glossary.rst:505 msgid "An :term:`annotation` of a function parameter or return value." msgstr "函式參數或回傳值的一個 :term:`annotation`\\ (註釋)。" -#: ../../glossary.rst:458 +#: ../../glossary.rst:507 msgid "" "Function annotations are usually used for :term:`type hints `: " "for example, this function is expected to take two :class:`int` arguments " @@ -1066,7 +1177,7 @@ msgstr "" "函式註釋通常被使用於\\ :term:`型別提示 `:例如,這個函式預期會得到" "兩個 :class:`int` 引數,並會有一個 :class:`int` 回傳值: ::" -#: ../../glossary.rst:463 +#: ../../glossary.rst:512 msgid "" "def sum_two_numbers(a: int, b: int) -> int:\n" " return a + b" @@ -1074,11 +1185,11 @@ msgstr "" "def sum_two_numbers(a: int, b: int) -> int:\n" " return a + b" -#: ../../glossary.rst:466 +#: ../../glossary.rst:515 msgid "Function annotation syntax is explained in section :ref:`function`." msgstr "函式註釋的語法在\\ :ref:`function`\\ 章節有詳細解釋。" -#: ../../glossary.rst:468 +#: ../../glossary.rst:517 msgid "" "See :term:`variable annotation` and :pep:`484`, which describe this " "functionality. Also see :ref:`annotations-howto` for best practices on " @@ -1087,11 +1198,11 @@ msgstr "" "請參閱 :term:`variable annotation` 和 :pep:`484`,皆有此功能的描述。關於註釋" "的最佳實踐方法,另請參閱 :ref:`annotations-howto`。" -#: ../../glossary.rst:472 +#: ../../glossary.rst:521 msgid "__future__" msgstr "__future__" -#: ../../glossary.rst:474 +#: ../../glossary.rst:523 msgid "" "A :ref:`future statement `, ``from __future__ import ``, " "directs the compiler to compile the current module using syntax or semantics " @@ -1102,12 +1213,12 @@ msgid "" "default::" msgstr "" ":ref:`future 陳述式 `:``from __future__ import ``,會指示編" -"譯器使用那些在 Python 未來的發布版本中將成為標準的語法或語義,來編譯當前的模" +"譯器使用那些在 Python 未來的發布版本中將成為標準的語法或語義,來編譯目前的模" "組。而 :mod:`__future__` 模組則記錄了 *feature(功能)*\\ 可能的值。透過 " "import 此模組並對其變數求值,你可以看見一個新的功能是何時首次被新增到此語言" "中,以及它何時將會(或已經)成為預設的功能: ::" -#: ../../glossary.rst:482 +#: ../../glossary.rst:531 msgid "" ">>> import __future__\n" ">>> __future__.division\n" @@ -1117,11 +1228,11 @@ msgstr "" ">>> __future__.division\n" "_Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192)" -#: ../../glossary.rst:485 +#: ../../glossary.rst:534 msgid "garbage collection" msgstr "garbage collection(垃圾回收)" -#: ../../glossary.rst:487 +#: ../../glossary.rst:536 msgid "" "The process of freeing memory when it is not used anymore. Python performs " "garbage collection via reference counting and a cyclic garbage collector " @@ -1133,11 +1244,11 @@ msgstr "" "垃圾回收器 (cyclic garbage collector) 來完成。垃圾回收器可以使用 :mod:`gc` 模" "組對其進行控制。" -#: ../../glossary.rst:492 ../../glossary.rst:493 +#: ../../glossary.rst:541 ../../glossary.rst:542 msgid "generator" msgstr "generator(產生器)" -#: ../../glossary.rst:495 +#: ../../glossary.rst:544 msgid "" "A function which returns a :term:`generator iterator`. It looks like a " "normal function except that it contains :keyword:`yield` expressions for " @@ -1148,7 +1259,7 @@ msgstr "" "個正常的函式,但不同的是它包含了 :keyword:`yield` 運算式,能產生一系列的值," "這些值可用於 for 迴圈,或是以 :func:`next` 函式,每次檢索其中的一個值。" -#: ../../glossary.rst:500 +#: ../../glossary.rst:549 msgid "" "Usually refers to a generator function, but may refer to a *generator " "iterator* in some contexts. In cases where the intended meaning isn't " @@ -1157,51 +1268,54 @@ msgstr "" "這個術語通常用來表示一個產生器函式,但在某些情境中,也可能是表示\\ *產生器疊" "代器*。萬一想表達的意思不夠清楚,那就使用完整的術語,以避免歧義。" -#: ../../glossary.rst:503 +#: ../../glossary.rst:552 msgid "generator iterator" msgstr "generator iterator(產生器疊代器)" -#: ../../glossary.rst:505 +#: ../../glossary.rst:554 msgid "An object created by a :term:`generator` function." msgstr "一個由 :term:`generator`\\ (產生器)函式所建立的物件。" -#: ../../glossary.rst:507 +#: ../../glossary.rst:556 msgid "" "Each :keyword:`yield` temporarily suspends processing, remembering the " -"location execution state (including local variables and pending try-" -"statements). When the *generator iterator* resumes, it picks up where it " -"left off (in contrast to functions which start fresh on every invocation)." +"execution state (including local variables and pending try-statements). " +"When the *generator iterator* resumes, it picks up where it left off (in " +"contrast to functions which start fresh on every invocation)." msgstr "" -"每個 :keyword:`yield` 會暫停處理程序,並記住位置執行狀態(包括區域變數及擱置" -"中的 try 陳述式)。當\\ *產生器疊代器*\\ 回復時,它會從停止的地方繼續執行(與" -"那些每次調用時都要重新開始的函式有所不同)。" +"每個 :keyword:`yield` 會暫停處理程序,並記住執行狀態(包括區域變數及擱置中的 " +"try 陳述式)。當\\ *產生器疊代器*\\ 回復時,它會從停止的地方繼續執行(與那些" +"每次呼叫時都要重新開始的函式有所不同)。" -#: ../../glossary.rst:513 ../../glossary.rst:514 +#: ../../glossary.rst:562 ../../glossary.rst:563 msgid "generator expression" msgstr "generator expression(產生器運算式)" -#: ../../glossary.rst:516 +#: ../../glossary.rst:565 msgid "" -"An expression that returns an iterator. It looks like a normal expression " -"followed by a :keyword:`!for` clause defining a loop variable, range, and an " -"optional :keyword:`!if` clause. The combined expression generates values " -"for an enclosing function::" +"An :term:`expression` that returns an :term:`iterator`. It looks like a " +"normal expression followed by a :keyword:`!for` clause defining a loop " +"variable, range, and an optional :keyword:`!if` clause. The combined " +"expression generates values for an enclosing function::" msgstr "" -"一個會回傳疊代器的運算式。它看起來像一個正常的運算式,後面接著一個 :keyword:" -"`!for` 子句,該子句定義了迴圈變數、範圍以及一個選擇性的 :keyword:`!if` 子句。" -"該組合運算式會為外層函式產生多個值: ::" +"一個會回傳\\ :term:`疊代器 `\\ 的\\ :term:`運算式 `。它" +"看起來像一個正常的運算式,後面接著一個 :keyword:`!for` 子句,該子句定義了迴圈" +"變數、範圍以及一個選擇性的 :keyword:`!if` 子句。該組合運算式會為外層函式產生" +"多個值: ::" -#: ../../glossary.rst:521 +#: ../../glossary.rst:570 msgid "" ">>> sum(i*i for i in range(10)) # sum of squares 0, 1, 4, ... 81\n" "285" msgstr "" +">>> sum(i*i for i in range(10)) # 平方之和 0, 1, 4, ... 81\n" +"285" -#: ../../glossary.rst:523 +#: ../../glossary.rst:572 msgid "generic function" msgstr "generic function(泛型函式)" -#: ../../glossary.rst:525 +#: ../../glossary.rst:574 msgid "" "A function composed of multiple functions implementing the same operation " "for different types. Which implementation should be used during a call is " @@ -1210,7 +1324,7 @@ msgstr "" "一個由多個函式組成的函式,該函式會對不同的型別實作相同的運算。呼叫期間應該使" "用哪種實作,是由調度演算法 (dispatch algorithm) 來決定。" -#: ../../glossary.rst:529 +#: ../../glossary.rst:578 msgid "" "See also the :term:`single dispatch` glossary entry, the :func:`functools." "singledispatch` decorator, and :pep:`443`." @@ -1218,11 +1332,11 @@ msgstr "" "另請參閱 :term:`single dispatch`\\ (單一調度)術語表條目、:func:`functools." "singledispatch` 裝飾器和 :pep:`443`。" -#: ../../glossary.rst:531 +#: ../../glossary.rst:580 msgid "generic type" msgstr "generic type(泛型型別)" -#: ../../glossary.rst:533 +#: ../../glossary.rst:582 msgid "" "A :term:`type` that can be parameterized; typically a :ref:`container " "class` such as :class:`list` or :class:`dict`. Used for :" @@ -1232,7 +1346,7 @@ msgstr "" "`容器型別 `,像是 :class:`list` 和 :class:`dict`。它被用於" "\\ :term:`型別提示 `\\ 和\\ :term:`註釋 `。" -#: ../../glossary.rst:538 +#: ../../glossary.rst:587 msgid "" "For more details, see :ref:`generic alias types`, :pep:" "`483`, :pep:`484`, :pep:`585`, and the :mod:`typing` module." @@ -1240,19 +1354,19 @@ msgstr "" "詳情請參閱\\ :ref:`泛型別名型別 `、:pep:`483`、:pep:" "`484`、:pep:`585` 和 :mod:`typing` 模組。" -#: ../../glossary.rst:540 +#: ../../glossary.rst:589 msgid "GIL" msgstr "GIL" -#: ../../glossary.rst:542 +#: ../../glossary.rst:591 msgid "See :term:`global interpreter lock`." msgstr "請參閱 :term:`global interpreter lock`\\ (全域直譯器鎖)。" -#: ../../glossary.rst:543 +#: ../../glossary.rst:592 msgid "global interpreter lock" msgstr "global interpreter lock(全域直譯器鎖)" -#: ../../glossary.rst:545 +#: ../../glossary.rst:594 msgid "" "The mechanism used by the :term:`CPython` interpreter to assure that only " "one thread executes Python :term:`bytecode` at a time. This simplifies the " @@ -1269,7 +1383,7 @@ msgstr "" "(multi-threaded),但代價是會犧牲掉多處理器的機器能夠提供的一大部分平行性 " "(parallelism)。" -#: ../../glossary.rst:554 +#: ../../glossary.rst:603 msgid "" "However, some extension modules, either standard or third-party, are " "designed so as to release the GIL when doing computationally intensive tasks " @@ -1280,23 +1394,26 @@ msgstr "" "計算密集 (computationally intensive) 的任務時,可以解除 GIL。另外,在執行 I/" "O 時,GIL 總是會被解除。" -#: ../../glossary.rst:559 +#: ../../glossary.rst:608 msgid "" -"Past efforts to create a \"free-threaded\" interpreter (one which locks " -"shared data at a much finer granularity) have not been successful because " -"performance suffered in the common single-processor case. It is believed " -"that overcoming this performance issue would make the implementation much " -"more complicated and therefore costlier to maintain." +"As of Python 3.13, the GIL can be disabled using the :option:`--disable-gil` " +"build configuration. After building Python with this option, code must be " +"run with :option:`-X gil=0 <-X>` or after setting the :envvar:`PYTHON_GIL=0 " +"` 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`." msgstr "" -"過去對於建立「無限制執行緒」直譯器(以更高的精細度鎖定共享資料的直譯器)的努" -"力並未成功,因為在一般的單一處理器情況下,效能會有所損失。一般認為,若要克服" -"這個效能問題,會使實作變得複雜許多,進而付出更高的維護成本。" +"從 Python 3.13 開始可以使用 :option:`--disable-gil` 建置設定來停用 GIL。使用" +"此選項建立 Python 後,必須使用 :option:`-X gil=0 <-X>` 來執行程式碼,或者設" +"定 :envvar:`PYTHON_GIL=0 ` 環境變數後再執行程式碼。此功能可以提高" +"多執行緒應用程式的效能,並使多核心 CPU 的高效使用變得更加容易。有關更多詳細資" +"訊,請參閱 :pep:`703`。" -#: ../../glossary.rst:565 +#: ../../glossary.rst:614 msgid "hash-based pyc" msgstr "hash-based pyc(雜湊架構的 pyc)" -#: ../../glossary.rst:567 +#: ../../glossary.rst:616 msgid "" "A bytecode cache file that uses the hash rather than the last-modified time " "of the corresponding source file to determine its validity. See :ref:`pyc-" @@ -1305,11 +1422,11 @@ msgstr "" "一個位元組碼 (bytecode) 暫存檔,它使用雜湊值而不是對應原始檔案的最後修改時" "間,來確定其有效性。請參閱\\ :ref:`pyc-invalidation`。" -#: ../../glossary.rst:570 +#: ../../glossary.rst:619 msgid "hashable" msgstr "hashable(可雜湊的)" -#: ../../glossary.rst:572 +#: ../../glossary.rst:621 msgid "" "An object is *hashable* if it has a hash value which never changes during " "its lifetime (it needs a :meth:`~object.__hash__` method), and can be " @@ -1321,7 +1438,7 @@ msgstr "" "`~object.__eq__` method),那麼它就是一個\\ *可雜湊*\\ 物件。比較結果為相等的" "多個可雜湊物件,它們必須擁有相同的雜湊值。" -#: ../../glossary.rst:578 +#: ../../glossary.rst:627 msgid "" "Hashability makes an object usable as a dictionary key and a set member, " "because these data structures use the hash value internally." @@ -1329,7 +1446,7 @@ msgstr "" "可雜湊性 (hashability) 使一個物件可用作 dictionary(字典)的鍵和 set(集合)" "的成員,因為這些資料結構都在其內部使用了雜湊值。" -#: ../../glossary.rst:581 +#: ../../glossary.rst:630 msgid "" "Most of Python's immutable built-in objects are hashable; mutable containers " "(such as lists or dictionaries) are not; immutable containers (such as " @@ -1344,11 +1461,11 @@ msgstr "" "則這些物件會被預設為可雜湊的。它們在互相比較時都是不相等的(除非它們與自己比" "較),而它們的雜湊值則是衍生自它們的 :func:`id`。" -#: ../../glossary.rst:588 +#: ../../glossary.rst:637 msgid "IDLE" msgstr "IDLE" -#: ../../glossary.rst:590 +#: ../../glossary.rst:639 msgid "" "An Integrated Development and Learning Environment for Python. :ref:`idle` " "is a basic editor and interpreter environment which ships with the standard " @@ -1358,28 +1475,31 @@ msgstr "" "境)。:ref:`idle` 是一個基本的編輯器和直譯器環境,它和 Python 的標準發行版本" "一起被提供。" -#: ../../glossary.rst:593 +#: ../../glossary.rst:642 msgid "immortal" -msgstr "" +msgstr "immortal(不滅)" -#: ../../glossary.rst:595 +#: ../../glossary.rst:644 msgid "" "*Immortal objects* are a CPython implementation detail introduced in :pep:" "`683`." -msgstr "" +msgstr "*不滅物件 (Immortal objects)* 是 :pep:`683` 引入的 CPython 實作細節。" -#: ../../glossary.rst:598 +#: ../../glossary.rst:647 msgid "" "If an object is immortal, its :term:`reference count` is never modified, and " "therefore it is never deallocated while the interpreter is running. For " "example, :const:`True` and :const:`None` are immortal in CPython." msgstr "" +"如果一個物件是不滅的,它的\\ :term:`參照計數 `\\ 永遠不會被" +"修改,因此在直譯器運行時它永遠不會被釋放。例如,:const:`True` 和 :const:" +"`None` 在 CPython 中是不滅的。" -#: ../../glossary.rst:601 +#: ../../glossary.rst:650 msgid "immutable" msgstr "immutable(不可變物件)" -#: ../../glossary.rst:603 +#: ../../glossary.rst:652 msgid "" "An object with a fixed value. Immutable objects include numbers, strings " "and tuples. Such an object cannot be altered. A new object has to be " @@ -1391,11 +1511,11 @@ msgstr "" "能被改變的。如果一個不同的值必須被儲存,則必須建立一個新的物件。它們在需要恆" "定雜湊值的地方,扮演重要的角色,例如 dictionary(字典)中的一個鍵。" -#: ../../glossary.rst:608 +#: ../../glossary.rst:657 msgid "import path" msgstr "import path(引入路徑)" -#: ../../glossary.rst:610 +#: ../../glossary.rst:659 msgid "" "A list of locations (or :term:`path entries `) that are searched " "by the :term:`path based finder` for modules to import. During import, this " @@ -1407,11 +1527,11 @@ msgstr "" "的位置。在 import 期間,此位置列表通常是來自 :data:`sys.path`,但對於子套件 " "(subpackage) 而言,它也可能是來自父套件的 ``__path__`` 屬性。" -#: ../../glossary.rst:615 +#: ../../glossary.rst:664 msgid "importing" msgstr "importing(引入)" -#: ../../glossary.rst:617 +#: ../../glossary.rst:666 msgid "" "The process by which Python code in one module is made available to Python " "code in another module." @@ -1419,11 +1539,11 @@ msgstr "" "一個過程。一個模組中的 Python 程式碼可以透過此過程,被另一個模組中的 Python " "程式碼使用。" -#: ../../glossary.rst:619 +#: ../../glossary.rst:668 msgid "importer" msgstr "importer(引入器)" -#: ../../glossary.rst:621 +#: ../../glossary.rst:670 msgid "" "An object that both finds and loads a module; both a :term:`finder` and :" "term:`loader` object." @@ -1431,28 +1551,29 @@ msgstr "" "一個能夠尋找及載入模組的物件;它既是 :term:`finder`\\ (尋檢器)也是 :term:" "`loader`\\ (載入器)物件。" -#: ../../glossary.rst:623 +#: ../../glossary.rst:672 msgid "interactive" msgstr "interactive(互動的)" -#: ../../glossary.rst:625 +#: ../../glossary.rst:674 msgid "" "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)``)." +"test out new ideas or inspect modules and packages (remember ``help(x)``). " +"For more on interactive mode, see :ref:`tut-interac`." msgstr "" "Python 有一個互動式直譯器,這表示你可以在直譯器的提示字元輸入陳述式和運算式," "立即執行它們並且看到它們的結果。只要啟動 ``python``,不需要任何引數(可能藉由" -"從你的電腦的主選單選擇它)。這是測試新想法或檢查模塊和包的非常強大的方法(請" -"記住help(x))。" +"從你的電腦的主選單選擇它)。這是測試新想法或檢查模組和包的非常強大的方法(請" +"記住help(x))。更多互動式模式相關資訊請見 :ref:`tut-interac`。" -#: ../../glossary.rst:631 +#: ../../glossary.rst:681 msgid "interpreted" msgstr "interpreted(直譯的)" -#: ../../glossary.rst:633 +#: ../../glossary.rst:683 msgid "" "Python is an interpreted language, as opposed to a compiled one, though the " "distinction can be blurry because of the presence of the bytecode compiler. " @@ -1466,11 +1587,11 @@ msgstr "" "一個執行檔,然後再執行它。直譯語言通常比編譯語言有更短的開發/除錯週期,不過" "它們的程式通常也運行得較慢。另請參閱 :term:`interactive`\\ (互動的)。" -#: ../../glossary.rst:640 +#: ../../glossary.rst:690 msgid "interpreter shutdown" msgstr "interpreter shutdown(直譯器關閉)" -#: ../../glossary.rst:642 +#: ../../glossary.rst:692 msgid "" "When asked to shut down, the Python interpreter enters a special phase where " "it gradually releases all allocated resources, such as modules and various " @@ -1488,34 +1609,33 @@ msgstr "" "段被執行的程式碼會遇到各種例外,因為它所依賴的資源可能不再有作用了(常見的例" "子是函式庫模組或是警告機制)。" -#: ../../glossary.rst:651 +#: ../../glossary.rst:701 msgid "" "The main reason for interpreter shutdown is that the ``__main__`` module or " "the script being run has finished executing." msgstr "" "直譯器關閉的主要原因,是 ``__main__`` 模組或正被運行的腳本已經執行完成。" -#: ../../glossary.rst:653 +#: ../../glossary.rst:703 msgid "iterable" msgstr "iterable(可疊代物件)" -#: ../../glossary.rst:655 +#: ../../glossary.rst:705 msgid "" "An object capable of returning its members one at a time. Examples of " "iterables include all sequence types (such as :class:`list`, :class:`str`, " "and :class:`tuple`) and some non-sequence types like :class:`dict`, :term:" "`file objects `, and objects of any classes you define with an :" -"meth:`~iterator.__iter__` method or with a :meth:`~object.__getitem__` " -"method that implements :term:`sequence` semantics." +"meth:`~object.__iter__` method or with a :meth:`~object.__getitem__` method " +"that implements :term:`sequence` semantics." msgstr "" "一種能夠一次回傳一個其中成員的物件。可疊代物件的例子包括所有的序列型別(像" "是 :class:`list`、:class:`str` 和 :class:`tuple`\\ )和某些非序列型別,像是 :" "class:`dict`、:term:`檔案物件 `,以及你所定義的任何 class 物件," -"只要那些 class 有 :meth:`~iterator.__iter__` method 或是實作 :term:" -"`sequence`\\ (序列)語意的 :meth:`~object.__getitem__` method,該物件就是可" -"疊代物件。" +"只要那些 class 有實作 :term:`sequence`\\ (序列)語意的 :meth:`~object." +"__iter__` 或是 :meth:`~object.__getitem__` method,該物件就是可疊代物件。" -#: ../../glossary.rst:663 +#: ../../glossary.rst:713 msgid "" "Iterables can be used in a :keyword:`for` loop and in many other places " "where a sequence is needed (:func:`zip`, :func:`map`, ...). When an " @@ -1535,11 +1655,11 @@ msgstr "" "數,用於在迴圈期間保有該疊代器。另請參閱 :term:`iterator`\\ (疊代器)、:" "term:`sequence`\\ (序列)和 :term:`generator`\\ (產生器)。" -#: ../../glossary.rst:673 +#: ../../glossary.rst:723 msgid "iterator" msgstr "iterator(疊代器)" -#: ../../glossary.rst:675 +#: ../../glossary.rst:725 msgid "" "An object representing a stream of data. Repeated calls to the iterator's :" "meth:`~iterator.__next__` method (or passing it to the built-in function :" @@ -1568,23 +1688,25 @@ msgstr "" "此事(多遍疊代)時,只會回傳在前一遍疊代中被用過的、同一個已被用盡的疊代器物" "件,使其看起來就像一個空的容器。" -#: ../../glossary.rst:690 +#: ../../glossary.rst:740 msgid "More information can be found in :ref:`typeiter`." msgstr "在\\ :ref:`typeiter`\\ 文中可以找到更多資訊。" -#: ../../glossary.rst:694 +#: ../../glossary.rst:744 msgid "" "CPython does not consistently apply the requirement that an iterator define :" -"meth:`~iterator.__iter__`." +"meth:`~iterator.__iter__`. And also please note that the free-threading " +"CPython does not guarantee the thread-safety of iterator operations." msgstr "" "CPython 並不是始終如一地都會檢查「疊代器有定義 :meth:`~iterator." -"__iter__`\\ 」這個規定。" +"__iter__`\\ 」這個規定。另請注意,free-threading(自由執行緒)CPython 不保證" +"疊代器操作的執行緒安全。" -#: ../../glossary.rst:696 +#: ../../glossary.rst:749 msgid "key function" msgstr "key function(鍵函式)" -#: ../../glossary.rst:698 +#: ../../glossary.rst:751 msgid "" "A key function or collation function is a callable that returns a value used " "for sorting or ordering. For example, :func:`locale.strxfrm` is used to " @@ -1594,7 +1716,7 @@ msgstr "" "一個用於排序 (sorting) 或定序 (ordering) 的值。例如,:func:`locale.strxfrm` " "被用來產生一個了解區域特定排序慣例的排序鍵。" -#: ../../glossary.rst:703 +#: ../../glossary.rst:756 msgid "" "A number of tools in Python accept key functions to control how elements are " "ordered or grouped. They include :func:`min`, :func:`max`, :func:`sorted`, :" @@ -1606,7 +1728,7 @@ msgstr "" "merge`、:func:`heapq.nsmallest`、:func:`heapq.nlargest` 和 :func:`itertools." "groupby`。" -#: ../../glossary.rst:709 +#: ../../glossary.rst:762 msgid "" "There are several ways to create a key function. For example. the :meth:" "`str.lower` method can serve as a key function for case insensitive sorts. " @@ -1623,19 +1745,19 @@ msgstr "" "式 (constructor)。關於如何建立和使用鍵函式的範例,請參閱\\ :ref:`如何排序 " "`。" -#: ../../glossary.rst:716 +#: ../../glossary.rst:769 msgid "keyword argument" msgstr "keyword argument(關鍵字引數)" -#: ../../glossary.rst:718 ../../glossary.rst:1008 +#: ../../glossary.rst:771 ../../glossary.rst:1086 msgid "See :term:`argument`." msgstr "請參閱 :term:`argument`\\ (引數)。" -#: ../../glossary.rst:719 +#: ../../glossary.rst:772 msgid "lambda" msgstr "lambda" -#: ../../glossary.rst:721 +#: ../../glossary.rst:774 msgid "" "An anonymous inline function consisting of a single :term:`expression` which " "is evaluated when the function is called. The syntax to create a lambda " @@ -1645,11 +1767,11 @@ msgstr "" "function),於該函式被呼叫時求值。建立 lambda 函式的語法是 ``lambda " "[parameters]: expression``" -#: ../../glossary.rst:724 +#: ../../glossary.rst:777 msgid "LBYL" msgstr "LBYL" -#: ../../glossary.rst:726 +#: ../../glossary.rst:779 msgid "" "Look before you leap. This coding style explicitly tests for pre-conditions " "before making calls or lookups. This style contrasts with the :term:`EAFP` " @@ -1660,7 +1782,7 @@ msgstr "" "地測試先決條件。這種風格與 :term:`EAFP` 方式形成對比,且它的特色是會有許多 :" "keyword:`if` 陳述式的存在。" -#: ../../glossary.rst:731 +#: ../../glossary.rst:784 msgid "" "In a multi-threaded environment, the LBYL approach can risk introducing a " "race condition between \"the looking\" and \"the leaping\". For example, " @@ -1674,11 +1796,19 @@ msgstr "" "了 *key*,則該程式碼就會失效。這個問題可以用鎖 (lock) 或使用 EAFP 編碼方式來" "解決。" -#: ../../glossary.rst:736 +#: ../../glossary.rst:789 +msgid "lexical analyzer" +msgstr "lexical analyzer(詞法分析器)" + +#: ../../glossary.rst:792 +msgid "Formal name for the *tokenizer*; see :term:`token`." +msgstr "tokenizer 的正式名稱;請參閱 :term:`token`。" + +#: ../../glossary.rst:793 msgid "list" msgstr "list(串列)" -#: ../../glossary.rst:738 +#: ../../glossary.rst:795 msgid "" "A built-in Python :term:`sequence`. Despite its name it is more akin to an " "array in other languages than to a linked list since access to elements is " @@ -1688,11 +1818,11 @@ msgstr "" "似其他語言中的一個陣列 (array) 而較不像一個鏈結串列 (linked list),因為存取元" "素的時間複雜度是 *O*\\ (1)。" -#: ../../glossary.rst:741 +#: ../../glossary.rst:798 msgid "list comprehension" msgstr "list comprehension(串列綜合運算)" -#: ../../glossary.rst:743 +#: ../../glossary.rst:800 msgid "" "A compact way to process all or part of the elements in a sequence and " "return a list with the results. ``result = ['{:#04x}'.format(x) for x in " @@ -1706,27 +1836,38 @@ msgstr "" "keyword:`if` 子句是選擇性的。如果省略它,則 ``range(256)`` 中的所有元素都會被" "處理。" -#: ../../glossary.rst:749 +#: ../../glossary.rst:806 msgid "loader" msgstr "loader(載入器)" -#: ../../glossary.rst:751 +#: ../../glossary.rst:808 msgid "" -"An object that loads a module. It must define a method named :meth:" -"`load_module`. A loader is typically returned by a :term:`finder`. See :pep:" -"`302` for details and :class:`importlib.abc.Loader` for an :term:`abstract " -"base class`." +"An object that loads a module. It must define the :meth:`!exec_module` and :" +"meth:`!create_module` methods to implement the :class:`~importlib.abc." +"Loader` interface. A loader is typically returned by a :term:`finder`. See " +"also:" msgstr "" -"一個能夠載入模組的物件。它必須定義一個名為 :meth:`load_module` 的 method(方" -"法)。載入器通常是被 :term:`finder`\\ (尋檢器)回傳。更多細節請參閱 :pep:" -"`302`,關於 :term:`abstract base class`\\ (抽象基底類別),請參閱 :class:" -"`importlib.abc.Loader`。" +"一個能夠載入模組的物件。它必須定義 :meth:`!exec_module` 和 :meth:`!" +"create_module` 方法以實作 :class:`~importlib.abc.Loader` 介面。載入器通常是" +"被 :term:`finder`\\ (尋檢器)回傳。更多細節請參閱:" + +#: ../../glossary.rst:814 +msgid ":ref:`finders-and-loaders`" +msgstr ":ref:`finders-and-loaders`" + +#: ../../glossary.rst:815 +msgid ":class:`importlib.abc.Loader`" +msgstr ":class:`importlib.abc.Loader`" + +#: ../../glossary.rst:816 +msgid ":pep:`302`" +msgstr ":pep:`302`" -#: ../../glossary.rst:755 +#: ../../glossary.rst:817 msgid "locale encoding" msgstr "locale encoding(區域編碼)" -#: ../../glossary.rst:757 +#: ../../glossary.rst:819 msgid "" "On Unix, it is the encoding of the LC_CTYPE locale. It can be set with :func:" "`locale.setlocale(locale.LC_CTYPE, new_locale) `." @@ -1734,36 +1875,36 @@ msgstr "" "在 Unix 上,它是 LC_CTYPE 區域設定的編碼。它可以用 :func:`locale." "setlocale(locale.LC_CTYPE, new_locale) ` 來設定。" -#: ../../glossary.rst:760 +#: ../../glossary.rst:822 msgid "On Windows, it is the ANSI code page (ex: ``\"cp1252\"``)." -msgstr "在 Windows 上,它是 ANSI 代碼頁(code page,例如 ``\"cp1252\"``\\ )。" +msgstr "在 Windows 上,它是 ANSI 碼頁(code page,例如 ``\"cp1252\"``\\ )。" -#: ../../glossary.rst:762 +#: ../../glossary.rst:824 msgid "" "On Android and VxWorks, Python uses ``\"utf-8\"`` as the locale encoding." msgstr "在 Android 和 VxWorks 上,Python 使用 ``\"utf-8\"`` 作為區域編碼。" -#: ../../glossary.rst:764 +#: ../../glossary.rst:826 msgid ":func:`locale.getencoding` can be used to get the locale encoding." msgstr ":func:`locale.getencoding` 可以用來取得區域編碼。" -#: ../../glossary.rst:766 +#: ../../glossary.rst:828 msgid "See also the :term:`filesystem encoding and error handler`." msgstr "也請參考 :term:`filesystem encoding and error handler`。" -#: ../../glossary.rst:767 +#: ../../glossary.rst:829 msgid "magic method" msgstr "magic method(魔術方法)" -#: ../../glossary.rst:771 +#: ../../glossary.rst:833 msgid "An informal synonym for :term:`special method`." msgstr ":term:`special method`\\ (特殊方法)的一個非正式同義詞。" -#: ../../glossary.rst:772 +#: ../../glossary.rst:834 msgid "mapping" msgstr "mapping(對映)" -#: ../../glossary.rst:774 +#: ../../glossary.rst:836 msgid "" "A container object that supports arbitrary key lookups and implements the " "methods specified in the :class:`collections.abc.Mapping` or :class:" @@ -1778,11 +1919,11 @@ msgstr "" "包括 :class:`dict`、:class:`collections.defaultdict`、:class:`collections." "OrderedDict` 和 :class:`collections.Counter`。" -#: ../../glossary.rst:780 +#: ../../glossary.rst:842 msgid "meta path finder" msgstr "meta path finder(元路徑尋檢器)" -#: ../../glossary.rst:782 +#: ../../glossary.rst:844 msgid "" "A :term:`finder` returned by a search of :data:`sys.meta_path`. Meta path " "finders are related to, but different from :term:`path entry finders ` " "相關但是不同。" -#: ../../glossary.rst:786 +#: ../../glossary.rst:848 msgid "" "See :class:`importlib.abc.MetaPathFinder` for the methods that meta path " "finders implement." msgstr "" "關於元路徑尋檢器實作的 method,請參閱 :class:`importlib.abc.MetaPathFinder`。" -#: ../../glossary.rst:788 +#: ../../glossary.rst:850 msgid "metaclass" msgstr "metaclass(元類別)" -#: ../../glossary.rst:790 +#: ../../glossary.rst:852 msgid "" "The class of a class. Class definitions create a class name, a class " "dictionary, and a list of base classes. The metaclass is responsible for " @@ -1823,15 +1964,15 @@ msgstr "" "性存取、增加執行緒安全性、追蹤物件建立、實作單例模式 (singleton),以及許多其" "他的任務。" -#: ../../glossary.rst:800 +#: ../../glossary.rst:862 msgid "More information can be found in :ref:`metaclasses`." msgstr "更多資訊可以在\\ :ref:`metaclasses`\\ 章節中找到。" -#: ../../glossary.rst:769 ../../glossary.rst:801 ../../glossary.rst:1138 +#: ../../glossary.rst:831 ../../glossary.rst:863 ../../glossary.rst:1236 msgid "method" msgstr "method(方法)" -#: ../../glossary.rst:803 +#: ../../glossary.rst:865 msgid "" "A function which is defined inside a class body. If called as an attribute " "of an instance of that class, the method will get the instance object as its " @@ -1843,11 +1984,11 @@ msgstr "" "通常被稱為 ``self``)。請參閱 :term:`function`\\ (函式)和 :term:`nested " "scope`\\ (巢狀作用域)。" -#: ../../glossary.rst:807 +#: ../../glossary.rst:869 msgid "method resolution order" msgstr "method resolution order(方法解析順序)" -#: ../../glossary.rst:809 +#: ../../glossary.rst:871 msgid "" "Method Resolution Order is the order in which base classes are searched for " "a member during lookup. See :ref:`python_2.3_mro` for details of the " @@ -1856,11 +1997,11 @@ msgstr "" "方法解析順序是在查找某個成員的過程中,base class(基底類別)被搜尋的順序。關" "於 Python 自 2.3 版直譯器所使用的演算法細節,請參閱 :ref:`python_2.3_mro`。" -#: ../../glossary.rst:812 +#: ../../glossary.rst:874 msgid "module" msgstr "module(模組)" -#: ../../glossary.rst:814 +#: ../../glossary.rst:876 msgid "" "An object that serves as an organizational unit of Python code. Modules " "have a namespace containing arbitrary Python objects. Modules are loaded " @@ -1870,15 +2011,15 @@ msgstr "" "空間,它包含任意的 Python 物件。模組是藉由 :term:`importing` 的過程,被載入" "至 Python。" -#: ../../glossary.rst:818 +#: ../../glossary.rst:880 msgid "See also :term:`package`." msgstr "另請參閱 :term:`package`\\ (套件)。" -#: ../../glossary.rst:819 +#: ../../glossary.rst:881 msgid "module spec" msgstr "module spec(模組規格)" -#: ../../glossary.rst:821 +#: ../../glossary.rst:883 msgid "" "A namespace containing the import-related information used to load a module. " "An instance of :class:`importlib.machinery.ModuleSpec`." @@ -1886,19 +2027,23 @@ msgstr "" "一個命名空間,它包含用於載入模組的 import 相關資訊。它是 :class:`importlib." "machinery.ModuleSpec` 的一個實例。" -#: ../../glossary.rst:823 +#: ../../glossary.rst:886 +msgid "See also :ref:`module-specs`." +msgstr "另請參閱 :ref:`module-specs`。" + +#: ../../glossary.rst:887 msgid "MRO" msgstr "MRO" -#: ../../glossary.rst:825 +#: ../../glossary.rst:889 msgid "See :term:`method resolution order`." msgstr "請參閱 :term:`method resolution order`\\ (方法解析順序)。" -#: ../../glossary.rst:826 +#: ../../glossary.rst:890 msgid "mutable" msgstr "mutable(可變物件)" -#: ../../glossary.rst:828 +#: ../../glossary.rst:892 msgid "" "Mutable objects can change their value but keep their :func:`id`. See also :" "term:`immutable`." @@ -1906,11 +2051,11 @@ msgstr "" "可變物件可以改變它們的值,但維持它們的 :func:`id`。另請參閱 :term:" "`immutable`\\ (不可變物件)。" -#: ../../glossary.rst:830 +#: ../../glossary.rst:894 msgid "named tuple" msgstr "named tuple(附名元組)" -#: ../../glossary.rst:832 +#: ../../glossary.rst:896 msgid "" "The term \"named tuple\" applies to any type or class that inherits from " "tuple and whose indexable elements are also accessible using named " @@ -1920,7 +2065,7 @@ msgstr "" "索引 (indexable) 元素也可以用附名屬性來存取。這些型別或 class 也可以具有其他" "的特性。" -#: ../../glossary.rst:836 +#: ../../glossary.rst:900 msgid "" "Several built-in types are named tuples, including the values returned by :" "func:`time.localtime` and :func:`os.stat`. Another example is :data:`sys." @@ -1929,7 +2074,7 @@ msgstr "" "有些內建型別是 named tuple,包括由 :func:`time.localtime` 和 :func:`os.stat` " "回傳的值。另一個例子是 :data:`sys.float_info`: ::" -#: ../../glossary.rst:840 +#: ../../glossary.rst:904 msgid "" ">>> sys.float_info[1] # indexed access\n" "1024\n" @@ -1938,8 +2083,14 @@ msgid "" ">>> isinstance(sys.float_info, tuple) # kind of tuple\n" "True" msgstr "" +">>> sys.float_info[1] # 以索引存取\n" +"1024\n" +">>> sys.float_info.max_exp # 以欄位名稱存取\n" +"1024\n" +">>> isinstance(sys.float_info, tuple) # 屬於 tuple 型別\n" +"True" -#: ../../glossary.rst:847 +#: ../../glossary.rst:911 msgid "" "Some named tuples are built-in types (such as the above examples). " "Alternatively, a named tuple can be created from a regular class definition " @@ -1956,11 +2107,11 @@ msgstr "" "namedtuple` 來建立。後者技術也增加了一些額外的 method,這些 method 可能是在手" "寫或內建的 named tuple 中,無法找到的。" -#: ../../glossary.rst:855 +#: ../../glossary.rst:919 msgid "namespace" msgstr "namespace(命名空間)" -#: ../../glossary.rst:857 +#: ../../glossary.rst:921 msgid "" "The place where a variable is stored. Namespaces are implemented as " "dictionaries. There are the local, global and built-in namespaces as well " @@ -1980,30 +2131,43 @@ msgstr "" "func:`itertools.islice` 明確地表示,這些函式分別是由 :mod:`random` 和 :mod:" "`itertools` 模組在實作。" -#: ../../glossary.rst:867 +#: ../../glossary.rst:931 msgid "namespace package" msgstr "namespace package(命名空間套件)" -#: ../../glossary.rst:869 +#: ../../glossary.rst:933 msgid "" -"A :pep:`420` :term:`package` which serves only as a container for " -"subpackages. Namespace packages may have no physical representation, and " -"specifically are not like a :term:`regular package` because they have no " -"``__init__.py`` file." +"A :term:`package` which serves only as a container for subpackages. " +"Namespace packages may have no physical representation, and specifically are " +"not like a :term:`regular package` because they have no ``__init__.py`` file." msgstr "" -"一個 :pep:`420` :term:`package`\\ (套件),它只能作為子套件 (subpackage) 的" -"一個容器。命名空間套件可能沒有實體的表示法,而且具體來說它們不像是一個 :term:" -"`regular package`\\ (正規套件),因為它們並沒有 ``__init__.py`` 這個檔案。" +"一個 :term:`package`\\ (套件),它只能作為子套件 (subpackage) 的一個容器。命" +"名空間套件可能沒有實體的表示法,而且具體來說它們不像是一個 :term:`regular " +"package`\\ (正規套件),因為它們並沒有 ``__init__.py`` 這個檔案。" -#: ../../glossary.rst:874 +#: ../../glossary.rst:938 +msgid "" +"Namespace packages allow several individually installable packages to have a " +"common parent package. Otherwise, it is recommended to use a :term:`regular " +"package`." +msgstr "" +"命名空間套件允許數個可獨立安裝的套件擁有一個共同的父套件。除此之外,建議使" +"用 :term:`regular package`。" + +#: ../../glossary.rst:941 +msgid "" +"For more information, see :pep:`420` and :ref:`reference-namespace-package`." +msgstr "更多資訊,請參閱 :pep:`420` 和 :ref:`reference-namespace-package`。" + +#: ../../glossary.rst:943 msgid "See also :term:`module`." msgstr "另請參閱 :term:`module`\\ (模組)。" -#: ../../glossary.rst:875 +#: ../../glossary.rst:944 msgid "nested scope" msgstr "nested scope(巢狀作用域)" -#: ../../glossary.rst:877 +#: ../../glossary.rst:946 msgid "" "The ability to refer to a variable in an enclosing definition. For " "instance, a function defined inside another function can refer to variables " @@ -2018,11 +2182,11 @@ msgstr "" "寫入。同樣地,全域變數是在全域命名空間中讀取及寫入。:keyword:`nonlocal` 容許" "對外層作用域進行寫入。" -#: ../../glossary.rst:884 +#: ../../glossary.rst:953 msgid "new-style class" msgstr "new-style class(新式類別)" -#: ../../glossary.rst:886 +#: ../../glossary.rst:955 msgid "" "Old name for the flavor of classes now used for all class objects. In " "earlier Python versions, only new-style classes could use Python's newer, " @@ -2034,11 +2198,11 @@ msgstr "" "__slots__`、描述器 (descriptor)、屬性 (property)、:meth:`~object." "__getattribute__`、class method(類別方法)和 static method(靜態方法)。" -#: ../../glossary.rst:891 +#: ../../glossary.rst:960 msgid "object" msgstr "object(物件)" -#: ../../glossary.rst:893 +#: ../../glossary.rst:962 msgid "" "Any data with state (attributes or value) and defined behavior (methods). " "Also the ultimate base class of any :term:`new-style class`." @@ -2046,11 +2210,26 @@ msgstr "" "具有狀態(屬性或值)及被定義的行為(method)的任何資料。它也是任何 :term:" "`new-style class`\\ (新式類別)的最終 base class(基底類別)。" -#: ../../glossary.rst:896 +#: ../../glossary.rst:965 +msgid "optimized scope" +msgstr "optimized scope(最佳化作用域)" + +#: ../../glossary.rst:967 +msgid "" +"A scope where target local variable names are reliably known to the compiler " +"when the code is compiled, allowing optimization of read and write access to " +"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." +msgstr "" + +#: ../../glossary.rst:974 msgid "package" msgstr "package(套件)" -#: ../../glossary.rst:898 +#: ../../glossary.rst:976 msgid "" "A Python :term:`module` which can contain submodules or recursively, " "subpackages. Technically, a package is a Python module with a ``__path__`` " @@ -2060,17 +2239,17 @@ msgstr "" "迴的子套件 (subpackage)。技術上而言,套件就是具有 ``__path__`` 屬性的一個 " "Python 模組。" -#: ../../glossary.rst:902 +#: ../../glossary.rst:980 msgid "See also :term:`regular package` and :term:`namespace package`." msgstr "" "另請參閱 :term:`regular package`\\ (正規套件)和 :term:`namespace " "package`\\ (命名空間套件)。" -#: ../../glossary.rst:903 +#: ../../glossary.rst:981 msgid "parameter" msgstr "parameter(參數)" -#: ../../glossary.rst:905 +#: ../../glossary.rst:983 msgid "" "A named entity in a :term:`function` (or method) definition that specifies " "an :term:`argument` (or in some cases, arguments) that the function can " @@ -2080,7 +2259,7 @@ msgstr "" "它指明該函式能夠接受的一個 :term:`argument`\\ (引數),或在某些情況下指示多" "個引數。共有有五種不同的參數類型:" -#: ../../glossary.rst:909 +#: ../../glossary.rst:987 msgid "" ":dfn:`positional-or-keyword`: specifies an argument that can be passed " "either :term:`positionally ` or as a :term:`keyword argument " @@ -2091,11 +2270,11 @@ msgstr "" "置 `\\ 或是作為\\ :term:`關鍵字引數 `\\ 被傳遞的引數。這" "是參數的預設類型,例如以下的 *foo* 和 *bar*: ::" -#: ../../glossary.rst:914 +#: ../../glossary.rst:992 msgid "def func(foo, bar=None): ..." msgstr "def func(foo, bar=None): ..." -#: ../../glossary.rst:918 +#: ../../glossary.rst:996 msgid "" ":dfn:`positional-only`: specifies an argument that can be supplied only by " "position. Positional-only parameters can be defined by including a ``/`` " @@ -2106,11 +2285,11 @@ msgstr "" "式定義的參數列表中包含一個 ``/`` 字元,就可以在該字元前面定義僅限位置參數,例" "如以下的 *posonly1* 和 *posonly2*: ::" -#: ../../glossary.rst:923 +#: ../../glossary.rst:1001 msgid "def func(posonly1, posonly2, /, positional_or_keyword): ..." msgstr "def func(posonly1, posonly2, /, positional_or_keyword): ..." -#: ../../glossary.rst:927 +#: ../../glossary.rst:1005 msgid "" ":dfn:`keyword-only`: specifies an argument that can be supplied only by " "keyword. Keyword-only parameters can be defined by including a single var-" @@ -2123,11 +2302,11 @@ msgstr "" "單純的 ``*`` 字元,就可以在其後方定義僅限關鍵字參數,例如以下的 *kw_only1* " "和 *kw_only2*: ::" -#: ../../glossary.rst:933 +#: ../../glossary.rst:1011 msgid "def func(arg, *, kw_only1, kw_only2): ..." msgstr "def func(arg, *, kw_only1, kw_only2): ..." -#: ../../glossary.rst:935 +#: ../../glossary.rst:1013 msgid "" ":dfn:`var-positional`: specifies that an arbitrary sequence of positional " "arguments can be provided (in addition to any positional arguments already " @@ -2139,11 +2318,11 @@ msgstr "" "數(在已被其他參數接受的任何位置引數之外)。這類參數是透過在其參數名稱字首加" "上 ``*`` 來定義的,例如以下的 *args*: ::" -#: ../../glossary.rst:941 +#: ../../glossary.rst:1019 msgid "def func(*args, **kwargs): ..." msgstr "def func(*args, **kwargs): ..." -#: ../../glossary.rst:943 +#: ../../glossary.rst:1021 msgid "" ":dfn:`var-keyword`: specifies that arbitrarily many keyword arguments can be " "provided (in addition to any keyword arguments already accepted by other " @@ -2154,14 +2333,14 @@ msgstr "" "已被其他參數接受的任何關鍵字引數之外)。這類參數是透過在其參數名稱字首加上 " "``**`` 來定義的,例如上面範例中的 *kwargs*。" -#: ../../glossary.rst:949 +#: ../../glossary.rst:1027 msgid "" "Parameters can specify both optional and required arguments, as well as " "default values for some optional arguments." msgstr "" "參數可以指明引數是選擇性的或必需的,也可以為一些選擇性的引數指定預設值。" -#: ../../glossary.rst:952 +#: ../../glossary.rst:1030 msgid "" "See also the :term:`argument` glossary entry, the FAQ question on :ref:`the " "difference between arguments and parameters `, " @@ -2172,11 +2351,11 @@ msgstr "" "參數之間的差異 `、:class:`inspect.Parameter` " "class、:ref:`function`\\ 章節,以及 :pep:`362`。" -#: ../../glossary.rst:956 +#: ../../glossary.rst:1034 msgid "path entry" msgstr "path entry(路徑項目)" -#: ../../glossary.rst:958 +#: ../../glossary.rst:1036 msgid "" "A single location on the :term:`import path` which the :term:`path based " "finder` consults to find modules for importing." @@ -2184,11 +2363,11 @@ msgstr "" "在 :term:`import path`\\ (引入路徑)中的一個位置,而 :term:`path based " "finder` (基於路徑的尋檢器)會參考該位置來尋找要 import 的模組。" -#: ../../glossary.rst:960 +#: ../../glossary.rst:1038 msgid "path entry finder" msgstr "path entry finder(路徑項目尋檢器)" -#: ../../glossary.rst:962 +#: ../../glossary.rst:1040 msgid "" "A :term:`finder` returned by a callable on :data:`sys.path_hooks` (i.e. a :" "term:`path entry hook`) which knows how to locate modules given a :term:" @@ -2198,7 +2377,7 @@ msgstr "" "`path entry hook`\\ )所回傳的一種 :term:`finder`,它知道如何以一個 :term:" "`path entry`\\ 定位模組。" -#: ../../glossary.rst:966 +#: ../../glossary.rst:1044 msgid "" "See :class:`importlib.abc.PathEntryFinder` for the methods that path entry " "finders implement." @@ -2206,11 +2385,11 @@ msgstr "" "關於路徑項目尋檢器實作的 method,請參閱 :class:`importlib.abc." "PathEntryFinder`。" -#: ../../glossary.rst:968 +#: ../../glossary.rst:1046 msgid "path entry hook" msgstr "path entry hook(路徑項目鉤)" -#: ../../glossary.rst:970 +#: ../../glossary.rst:1048 msgid "" "A callable on the :data:`sys.path_hooks` list which returns a :term:`path " "entry finder` if it knows how to find modules on a specific :term:`path " @@ -2220,11 +2399,11 @@ msgstr "" "個特定的 :term:`path entry` 中尋找模組,則會回傳一個 :term:`path entry " "finder`\\ (路徑項目尋檢器)。" -#: ../../glossary.rst:973 +#: ../../glossary.rst:1051 msgid "path based finder" msgstr "path based finder(基於路徑的尋檢器)" -#: ../../glossary.rst:975 +#: ../../glossary.rst:1053 msgid "" "One of the default :term:`meta path finders ` which " "searches an :term:`import path` for modules." @@ -2232,11 +2411,11 @@ msgstr "" "預設的\\ :term:`元路徑尋檢器 (meta path finder) ` 之一,它" "會在一個 :term:`import path` 中搜尋模組。" -#: ../../glossary.rst:977 +#: ../../glossary.rst:1055 msgid "path-like object" msgstr "path-like object(類路徑物件)" -#: ../../glossary.rst:979 +#: ../../glossary.rst:1057 msgid "" "An object representing a file system path. A path-like object is either a :" "class:`str` or :class:`bytes` object representing a path, or an object " @@ -2254,11 +2433,11 @@ msgstr "" "`os.fsencode` 則分別可用於確保 :class:`str` 及 :class:`bytes` 的結果。由 :" "pep:`519` 引入。" -#: ../../glossary.rst:987 +#: ../../glossary.rst:1065 msgid "PEP" msgstr "PEP" -#: ../../glossary.rst:989 +#: ../../glossary.rst:1067 msgid "" "Python Enhancement Proposal. A PEP is a design document providing " "information to the Python community, or describing a new feature for Python " @@ -2269,7 +2448,7 @@ msgstr "" "為 Python 社群提供資訊,或是描述 Python 的一個新功能或該功能的程序和環境。" "PEP 應該要提供簡潔的技術規範以及被提案功能的運作原理。" -#: ../../glossary.rst:995 +#: ../../glossary.rst:1073 msgid "" "PEPs are intended to be the primary mechanisms for proposing major new " "features, for collecting community input on an issue, and for documenting " @@ -2281,15 +2460,15 @@ msgstr "" "已納入 Python 的設計決策的記錄,這些過程的主要機制。PEP 的作者要負責在社群內" "建立共識並記錄反對意見。" -#: ../../glossary.rst:1001 +#: ../../glossary.rst:1079 msgid "See :pep:`1`." msgstr "請參閱 :pep:`1`。" -#: ../../glossary.rst:1002 +#: ../../glossary.rst:1080 msgid "portion" msgstr "portion(部分)" -#: ../../glossary.rst:1004 +#: ../../glossary.rst:1082 msgid "" "A set of files in a single directory (possibly stored in a zip file) that " "contribute to a namespace package, as defined in :pep:`420`." @@ -2297,15 +2476,15 @@ msgstr "" "在單一目錄中的一組檔案(也可能儲存在一個 zip 檔中),這些檔案能對一個命名空間" "套件 (namespace package) 有所貢獻,如同 :pep:`420` 中的定義。" -#: ../../glossary.rst:1006 +#: ../../glossary.rst:1084 msgid "positional argument" msgstr "positional argument(位置引數)" -#: ../../glossary.rst:1009 +#: ../../glossary.rst:1087 msgid "provisional API" msgstr "provisional API(暫行 API)" -#: ../../glossary.rst:1011 +#: ../../glossary.rst:1089 msgid "" "A provisional API is one which has been deliberately excluded from the " "standard library's backwards compatibility guarantees. While major changes " @@ -2321,7 +2500,7 @@ msgstr "" "該介面)。這種變更並不會無端地產生——只有 API 被納入之前未察覺的嚴重基本缺陷被" "揭露時,它們才會發生。" -#: ../../glossary.rst:1020 +#: ../../glossary.rst:1098 msgid "" "Even for provisional APIs, backwards incompatible changes are seen as a " "\"solution of last resort\" - every attempt will still be made to find a " @@ -2330,7 +2509,7 @@ msgstr "" "即使對於暫行 API,向後不相容的變更也會被視為「最後的解決方案」——對於任何被發" "現的問題,仍然會盡可能找出一個向後相容的解決方案。" -#: ../../glossary.rst:1024 +#: ../../glossary.rst:1102 msgid "" "This process allows the standard library to continue to evolve over time, " "without locking in problematic design errors for extended periods of time. " @@ -2339,19 +2518,19 @@ msgstr "" "這個過程使得標準函式庫能隨著時間不斷進化,而避免耗費過長的時間去鎖定有問題的" "設計錯誤。請參閱 :pep:`411` 了解更多細節。" -#: ../../glossary.rst:1027 +#: ../../glossary.rst:1105 msgid "provisional package" msgstr "provisional package(暫行套件)" -#: ../../glossary.rst:1029 +#: ../../glossary.rst:1107 msgid "See :term:`provisional API`." msgstr "請參閱 :term:`provisional API`\\ (暫行 API)。" -#: ../../glossary.rst:1030 +#: ../../glossary.rst:1108 msgid "Python 3000" msgstr "Python 3000" -#: ../../glossary.rst:1032 +#: ../../glossary.rst:1110 msgid "" "Nickname for the Python 3.x release line (coined long ago when the release " "of version 3 was something in the distant future.) This is also abbreviated " @@ -2360,11 +2539,11 @@ msgstr "" "Python 3.x 系列版本的暱稱(很久以前創造的,當時第 3 版的發布是在遙遠的未" "來。)也可以縮寫為「Py3k」。" -#: ../../glossary.rst:1035 +#: ../../glossary.rst:1113 msgid "Pythonic" msgstr "Pythonic(Python 風格的)" -#: ../../glossary.rst:1037 +#: ../../glossary.rst:1115 msgid "" "An idea or piece of code which closely follows the most common idioms of the " "Python language, rather than implementing code using concepts common to " @@ -2378,7 +2557,7 @@ msgstr "" "keyword:`for` 陳述式,對一個可疊代物件的所有元素進行迴圈。許多其他語言並沒有" "這種類型的架構,所以不熟悉 Python 的人有時會使用一個數值計數器來代替: ::" -#: ../../glossary.rst:1044 +#: ../../glossary.rst:1122 msgid "" "for i in range(len(food)):\n" " print(food[i])" @@ -2386,11 +2565,11 @@ msgstr "" "for i in range(len(food)):\n" " print(food[i])" -#: ../../glossary.rst:1047 +#: ../../glossary.rst:1125 msgid "As opposed to the cleaner, Pythonic method::" msgstr "相較之下,以下方法更簡潔、更具有 Python 風格: ::" -#: ../../glossary.rst:1049 +#: ../../glossary.rst:1127 msgid "" "for piece in food:\n" " print(piece)" @@ -2398,11 +2577,11 @@ msgstr "" "for piece in food:\n" " print(piece)" -#: ../../glossary.rst:1051 +#: ../../glossary.rst:1129 msgid "qualified name" msgstr "qualified name(限定名稱)" -#: ../../glossary.rst:1053 +#: ../../glossary.rst:1131 msgid "" "A dotted name showing the \"path\" from a module's global scope to a class, " "function or method defined in that module, as defined in :pep:`3155`. For " @@ -2413,7 +2592,7 @@ msgstr "" "或 method 的「路徑」,如 :pep:`3155` 中的定義。對於頂層的函式和 class 而言," "限定名稱與其物件名稱相同: ::" -#: ../../glossary.rst:1058 +#: ../../glossary.rst:1136 msgid "" ">>> class C:\n" "... class D:\n" @@ -2439,7 +2618,7 @@ msgstr "" ">>> C.D.meth.__qualname__\n" "'C.D.meth'" -#: ../../glossary.rst:1070 +#: ../../glossary.rst:1148 msgid "" "When used to refer to modules, the *fully qualified name* means the entire " "dotted path to the module, including any parent packages, e.g. ``email.mime." @@ -2448,7 +2627,7 @@ msgstr "" "當用於引用模組時,*完全限定名稱 (fully qualified name)* 是表示該模組的完整點" "分隔路徑,包括任何的父套件,例如 ``email.mime.text``: ::" -#: ../../glossary.rst:1074 +#: ../../glossary.rst:1152 msgid "" ">>> import email.mime.text\n" ">>> email.mime.text.__name__\n" @@ -2458,31 +2637,40 @@ msgstr "" ">>> email.mime.text.__name__\n" "'email.mime.text'" -#: ../../glossary.rst:1077 +#: ../../glossary.rst:1155 msgid "reference count" msgstr "reference count(參照計數)" -#: ../../glossary.rst:1079 +#: ../../glossary.rst:1157 msgid "" "The number of references to an object. When the reference count of an " -"object drops to zero, it is deallocated. Some objects are \"immortal\" and " -"have reference counts that are never modified, and therefore the objects are " -"never deallocated. Reference counting is generally not visible to Python " -"code, but it is a key element of the :term:`CPython` implementation. " +"object drops to zero, it is deallocated. Some objects are :term:`immortal` " +"and have reference counts that are never modified, and therefore the objects " +"are never deallocated. Reference counting is generally not visible to " +"Python code, but it is a key element of the :term:`CPython` implementation. " "Programmers can call the :func:`sys.getrefcount` function to return the " "reference count for a particular object." msgstr "" "對於一個物件的參照次數。當一個物件的參照計數下降到零時,它會被解除配置 " -"(deallocated)。有些物件是「不滅的 (immortal)」並擁有不會被改變的參照計數,也" -"因此永遠不會被解除配置。參照計數通常在 Python 程式碼中看不到,但它卻是 :term:" -"`CPython` 實作的一個關鍵元素。程式設計師可以呼叫 :func:`~sys.getrefcount` 函" -"式來回傳一個特定物件的參照計數。" +"(deallocated)。有些物件是「\\ :term:`不滅的 ` (immortal)」並擁有不" +"會被改變的參照計數,也因此永遠不會被解除配置。參照計數通常在 Python 程式碼中" +"看不到,但它卻是 :term:`CPython` 實作的一個關鍵元素。程式設計師可以呼叫 :" +"func:`~sys.getrefcount` 函式來回傳一個特定物件的參照計數。" -#: ../../glossary.rst:1087 +#: ../../glossary.rst:1166 +msgid "" +"In :term:`CPython`, reference counts are not considered to be stable or well-" +"defined values; the number of references to an object, and how that number " +"is affected by Python code, may be different between versions." +msgstr "" +"在 :term:`CPython` 中,參照計數不被視為穩定或明確定義的值;對物件的參照數量," +"以及該數量如何受到 Python 程式碼的影響,在不同版本之間可能會有所不同。" + +#: ../../glossary.rst:1170 msgid "regular package" msgstr "regular package(正規套件)" -#: ../../glossary.rst:1089 +#: ../../glossary.rst:1172 msgid "" "A traditional :term:`package`, such as a directory containing an ``__init__." "py`` file." @@ -2490,15 +2678,27 @@ msgstr "" "一個傳統的 :term:`package`\\ (套件),例如一個包含 ``__init__.py`` 檔案的目" "錄。" -#: ../../glossary.rst:1092 +#: ../../glossary.rst:1175 msgid "See also :term:`namespace package`." msgstr "另請參閱 :term:`namespace package`\\ (命名空間套件)。" -#: ../../glossary.rst:1093 +#: ../../glossary.rst:1176 +msgid "REPL" +msgstr "REPL" + +#: ../../glossary.rst:1178 +msgid "" +"An acronym for the \"read–eval–print loop\", another name for the :term:" +"`interactive` interpreter shell." +msgstr "" +"「read-eval-print 迴圈 (read–eval–print loop)」的縮寫,是\\ :term:`互動式 " +"`\\ 直譯器 shell 的另一個名稱。" + +#: ../../glossary.rst:1180 msgid "__slots__" msgstr "__slots__" -#: ../../glossary.rst:1095 +#: ../../glossary.rst:1182 msgid "" "A declaration inside a class that saves memory by pre-declaring space for " "instance attributes and eliminating instance dictionaries. Though popular, " @@ -2511,11 +2711,11 @@ msgstr "" "最好保留給那種在一個記憶體關鍵 (memory-critical) 的應用程式中存在大量實例的罕" "見情況。" -#: ../../glossary.rst:1100 +#: ../../glossary.rst:1187 msgid "sequence" msgstr "sequence(序列)" -#: ../../glossary.rst:1102 +#: ../../glossary.rst:1189 msgid "" "An :term:`iterable` which supports efficient element access using integer " "indices via the :meth:`~object.__getitem__` special method and defines a :" @@ -2523,18 +2723,18 @@ msgid "" "built-in sequence types are :class:`list`, :class:`str`, :class:`tuple`, " "and :class:`bytes`. Note that :class:`dict` also supports :meth:`~object." "__getitem__` and :meth:`!__len__`, but is considered a mapping rather than a " -"sequence because the lookups use arbitrary :term:`immutable` keys rather " -"than integers." +"sequence because the lookups use arbitrary :term:`hashable` keys rather than " +"integers." msgstr "" "一個 :term:`iterable`\\ (可疊代物件),它透過 :meth:`~object.__getitem__` " "special method(特殊方法),使用整數索引來支援高效率的元素存取,並定義了一" "個 :meth:`~object.__len__` method 來回傳該序列的長度。一些內建序列型別包括 :" "class:`list`、:class:`str`、:class:`tuple` 和 :class:`bytes`。請注意,雖然 :" "class:`dict` 也支援 :meth:`~object.__getitem__` 和 :meth:`!__len__`,但它被視" -"為對映 (mapping) 而不是序列,因為其查找方式是使用任意的 :term:`immutable` " -"鍵,而不是整數。" +"為對映 (mapping) 而不是序列,因為其查找方式是使用任意的 :term:`hashable` 鍵," +"而不是整數。" -#: ../../glossary.rst:1111 +#: ../../glossary.rst:1198 msgid "" "The :class:`collections.abc.Sequence` abstract base class defines a much " "richer interface that goes beyond just :meth:`~object.__getitem__` and :meth:" @@ -2551,11 +2751,11 @@ msgstr "" "用 :func:`~abc.ABCMeta.register` 被明確地註冊。更多關於序列方法的文件,請見" "\\ :ref:`常見序列操作 `。" -#: ../../glossary.rst:1120 +#: ../../glossary.rst:1207 msgid "set comprehension" msgstr "set comprehension(集合綜合運算)" -#: ../../glossary.rst:1122 +#: ../../glossary.rst:1209 msgid "" "A compact way to process all or part of the elements in an iterable and " "return a set with the results. ``results = {c for c in 'abracadabra' if c " @@ -2566,11 +2766,11 @@ msgstr "" "set 回傳。``results = {c for c in 'abracadabra' if c not in 'abc'}`` 會產生一" "個字串 set:``{'r', 'd'}``。請參閱\\ :ref:`comprehensions`。" -#: ../../glossary.rst:1126 +#: ../../glossary.rst:1213 msgid "single dispatch" msgstr "single dispatch(單一調度)" -#: ../../glossary.rst:1128 +#: ../../glossary.rst:1215 msgid "" "A form of :term:`generic function` dispatch where the implementation is " "chosen based on the type of a single argument." @@ -2578,11 +2778,11 @@ msgstr "" ":term:`generic function`\\ (泛型函式)調度的一種形式,在此,實作的選擇是基於" "單一引數的型別。" -#: ../../glossary.rst:1130 +#: ../../glossary.rst:1217 msgid "slice" msgstr "slice(切片)" -#: ../../glossary.rst:1132 +#: ../../glossary.rst:1219 msgid "" "An object usually containing a portion of a :term:`sequence`. A slice is " "created using the subscript notation, ``[]`` with colons between numbers " @@ -2594,11 +2794,38 @@ msgstr "" "之間使用冒號,例如 ``variable_name[1:3:5]``。在括號(下標)符號的內部,會使" "用 :class:`slice` 物件。" -#: ../../glossary.rst:1136 +#: ../../glossary.rst:1223 +msgid "soft deprecated" +msgstr "soft deprecated(軟性棄用)" + +#: ../../glossary.rst:1225 +msgid "" +"A soft deprecated API should not be used in new code, but it is safe for " +"already existing code to use it. The API remains documented and tested, but " +"will not be enhanced further." +msgstr "" +"被軟性棄用的 API 代表不應再用於新程式碼中,但在現有程式碼中繼續使用它仍會是安" +"全的。API 仍會以文件記錄並會被測試,但不會被繼續改進。" + +#: ../../glossary.rst:1229 +msgid "" +"Soft deprecation, unlike normal deprecation, does not plan on removing the " +"API and will not emit warnings." +msgstr "與正常棄用不同,軟性棄用沒有刪除 API 的規劃,也不會發出警告。" + +#: ../../glossary.rst:1232 +msgid "" +"See `PEP 387: Soft Deprecation `_." +msgstr "" +"請參閱 `PEP 387:軟性棄用 `_。" + +#: ../../glossary.rst:1234 msgid "special method" msgstr "special method(特殊方法)" -#: ../../glossary.rst:1140 +#: ../../glossary.rst:1238 msgid "" "A method that is called implicitly by Python to execute a certain operation " "on a type, such as addition. Such methods have names starting and ending " @@ -2609,11 +2836,36 @@ msgstr "" "種 method 的名稱會在開頭和結尾有兩個下底線。Special method 在\\ :ref:" "`specialnames`\\ 中有詳細說明。" -#: ../../glossary.rst:1144 +#: ../../glossary.rst:1242 +msgid "standard library" +msgstr "標準函式庫" + +#: ../../glossary.rst:1244 +msgid "" +"The collection of :term:`packages `, :term:`modules ` and :" +"term:`extension modules ` distributed as a part of the " +"official Python interpreter package. The exact membership of the collection " +"may vary based on platform, available system libraries, or other criteria. " +"Documentation can be found at :ref:`library-index`." +msgstr "" +"包含\\ :term:`套件 `、:term:`模組 `\\ 和\\ :term:`擴充模組 " +"`\\ 的集合,它們是作為官方 Python 直譯器套件的一部分來發" +"行。該集合的成員可能會因平台、可用的系統函式庫或其他條件而有所不同。相關文件" +"可以在 :ref:`library-index` 中找到。" + +#: ../../glossary.rst:1250 +msgid "" +"See also :data:`sys.stdlib_module_names` for a list of all possible standard " +"library module names." +msgstr "" +"請參閱 :data:`sys.stdlib_module_names` 以取得所有可能的標準函式庫模組名稱的列" +"表。" + +#: ../../glossary.rst:1252 msgid "statement" msgstr "statement(陳述式)" -#: ../../glossary.rst:1146 +#: ../../glossary.rst:1254 msgid "" "A statement is part of a suite (a \"block\" of code). A statement is either " "an :term:`expression` or one of several constructs with a keyword, such as :" @@ -2623,11 +2875,11 @@ msgstr "" "term:`expression`\\ (運算式),或是含有關鍵字(例如 :keyword:`if`、:keyword:" "`while` 或 :keyword:`for`\\ )的多種結構之一。" -#: ../../glossary.rst:1149 +#: ../../glossary.rst:1257 msgid "static type checker" msgstr "static type checker(靜態型別檢查器)" -#: ../../glossary.rst:1151 +#: ../../glossary.rst:1259 msgid "" "An external tool that reads Python code and analyzes it, looking for issues " "such as incorrect types. See also :term:`type hints ` and the :" @@ -2637,11 +2889,19 @@ msgstr "" "另請參閱\\ :term:`型別提示 (type hints) ` 以及 :mod:`typing` 模" "組。" -#: ../../glossary.rst:1154 +#: ../../glossary.rst:1262 +msgid "stdlib" +msgstr "stdlib(標準函式庫)" + +#: ../../glossary.rst:1264 +msgid "An abbreviation of :term:`standard library`." +msgstr ":term:`standard library` 的縮寫。" + +#: ../../glossary.rst:1265 msgid "strong reference" msgstr "strong reference(強參照)" -#: ../../glossary.rst:1156 +#: ../../glossary.rst:1267 msgid "" "In Python's C API, a strong reference is a reference to an object which is " "owned by the code holding the reference. The strong reference is taken by " @@ -2652,7 +2912,7 @@ msgstr "" "有。建立參照時透過呼叫 :c:func:`Py_INCREF` 來獲得強參照、刪除參照時透過 :c:" "func:`Py_DECREF` 釋放強參照。" -#: ../../glossary.rst:1162 +#: ../../glossary.rst:1273 msgid "" "The :c:func:`Py_NewRef` function can be used to create a strong reference to " "an object. Usually, the :c:func:`Py_DECREF` function must be called on the " @@ -2662,15 +2922,15 @@ msgstr "" ":c:func:`Py_NewRef` 函式可用於建立一個對物件的強參照。通常,在退出強參照的作" "用域之前,必須在該強參照上呼叫 :c:func:`Py_DECREF` 函式,以避免洩漏一個參照。" -#: ../../glossary.rst:1167 +#: ../../glossary.rst:1278 msgid "See also :term:`borrowed reference`." msgstr "另請參閱 :term:`borrowed reference`\\ (借用參照)。" -#: ../../glossary.rst:1168 +#: ../../glossary.rst:1279 msgid "text encoding" msgstr "text encoding(文字編碼)" -#: ../../glossary.rst:1170 +#: ../../glossary.rst:1281 msgid "" "A string in Python is a sequence of Unicode code points (in range " "``U+0000``--``U+10FFFF``). To store or transfer a string, it needs to be " @@ -2679,7 +2939,7 @@ msgstr "" "Python 中的字串是一個 Unicode 碼點 (code point) 的序列(範圍在 ``U+0000`` -- " "``U+10FFFF`` 之間)。若要儲存或傳送一個字串,它必須被序列化為一個位元組序列。" -#: ../../glossary.rst:1174 +#: ../../glossary.rst:1285 msgid "" "Serializing a string into a sequence of bytes is known as \"encoding\", and " "recreating the string from the sequence of bytes is known as \"decoding\"." @@ -2687,7 +2947,7 @@ msgstr "" "將一個字串序列化為位元組序列,稱為「編碼」,而從位元組序列重新建立該字串則稱" "為「解碼 (decoding)」。" -#: ../../glossary.rst:1177 +#: ../../glossary.rst:1288 msgid "" "There are a variety of different text serialization :ref:`codecs `, which are collectively referred to as \"text encodings\"." @@ -2695,11 +2955,11 @@ msgstr "" "有多種不同的文字序列化編解碼器 (:ref:`codecs `),它們被統" "稱為「文字編碼」。" -#: ../../glossary.rst:1180 +#: ../../glossary.rst:1291 msgid "text file" msgstr "text file(文字檔案)" -#: ../../glossary.rst:1182 +#: ../../glossary.rst:1293 msgid "" "A :term:`file object` able to read and write :class:`str` objects. Often, a " "text file actually accesses a byte-oriented datastream and handles the :term:" @@ -2713,7 +2973,7 @@ msgstr "" "有:以文字模式(``'r'`` 或 ``'w'``)開啟的檔案、:data:`sys.stdin`、:data:" "`sys.stdout` 以及 :class:`io.StringIO` 的實例。" -#: ../../glossary.rst:1189 +#: ../../glossary.rst:1300 msgid "" "See also :term:`binary file` for a file object able to read and write :term:" "`bytes-like objects `." @@ -2721,11 +2981,32 @@ msgstr "" "另請參閱 :term:`binary file`\\ (二進位檔案),它是一個能夠讀取和寫入\\ :" "term:`類位元組串物件 (bytes-like object) ` 的檔案物件。" -#: ../../glossary.rst:1191 +#: ../../glossary.rst:1302 +msgid "token" +msgstr "token" + +#: ../../glossary.rst:1305 +msgid "" +"A small unit of source code, generated by the :ref:`lexical analyzer " +"` (also called the *tokenizer*). Names, numbers, strings, " +"operators, newlines and similar are represented by tokens." +msgstr "" +"原始碼的小單位,由 :ref:`詞法分析器 ` (也稱為 *tokenizer*)產生。名" +"稱、數字、字串、運算子、換行符號等都以 token 表示。" + +#: ../../glossary.rst:1310 +msgid "" +"The :mod:`tokenize` module exposes Python's lexical analyzer. The :mod:" +"`token` module contains information on the various types of tokens." +msgstr "" +":mod:`tokenize` 模組公開了 Python 的詞法分析器。:mod:`token` 模組包含各種 token " +"類型的資訊。" + +#: ../../glossary.rst:1313 msgid "triple-quoted string" msgstr "triple-quoted string(三引號內字串)" -#: ../../glossary.rst:1193 +#: ../../glossary.rst:1315 msgid "" "A string which is bound by three instances of either a quotation mark (\") " "or an apostrophe ('). While they don't provide any functionality not " @@ -2740,36 +3021,36 @@ msgstr "" "中包含未跳脫 (unescaped) 的單引號和雙引號,而且它們不需使用連續字元 " "(continuation character) 就可以跨越多行,這使得它們在編寫說明字串時特別有用。" -#: ../../glossary.rst:1200 +#: ../../glossary.rst:1322 msgid "type" msgstr "type(型別)" -#: ../../glossary.rst:1202 +#: ../../glossary.rst:1324 msgid "" "The type of a Python object determines what kind of object it is; every " -"object has a type. An object's type is accessible as its :attr:`~instance." +"object has a type. An object's type is accessible as its :attr:`~object." "__class__` attribute or can be retrieved with ``type(obj)``." msgstr "" "一個 Python 物件的型別決定了它是什麼類型的物件;每個物件都有一個型別。一個物" -"件的型別可以用它的 :attr:`~instance.__class__` 屬性來存取,或以 " -"``type(obj)`` 來檢索。" +"件的型別可以用它的 :attr:`~object.__class__` 屬性來存取,或以 ``type(obj)`` " +"來檢索。" -#: ../../glossary.rst:1206 +#: ../../glossary.rst:1328 msgid "type alias" msgstr "type alias(型別別名)" -#: ../../glossary.rst:1208 +#: ../../glossary.rst:1330 msgid "A synonym for a type, created by assigning the type to an identifier." msgstr "一個型別的同義詞,透過將型別指定給一個識別符 (identifier) 來建立。" -#: ../../glossary.rst:1210 +#: ../../glossary.rst:1332 msgid "" "Type aliases are useful for simplifying :term:`type hints `. For " "example::" msgstr "" "型別別名對於簡化\\ :term:`型別提示 (type hint) ` 很有用。例如: ::" -#: ../../glossary.rst:1213 +#: ../../glossary.rst:1335 msgid "" "def remove_gray_shades(\n" " colors: list[tuple[int, int, int]]) -> list[tuple[int, int, int]]:\n" @@ -2779,11 +3060,11 @@ msgstr "" " colors: list[tuple[int, int, int]]) -> list[tuple[int, int, int]]:\n" " pass" -#: ../../glossary.rst:1217 +#: ../../glossary.rst:1339 msgid "could be made more readable like this::" msgstr "可以寫成這樣,更具有可讀性: ::" -#: ../../glossary.rst:1219 +#: ../../glossary.rst:1341 msgid "" "Color = tuple[int, int, int]\n" "\n" @@ -2795,15 +3076,15 @@ msgstr "" "def remove_gray_shades(colors: list[Color]) -> list[Color]:\n" " pass" -#: ../../glossary.rst:1224 ../../glossary.rst:1238 +#: ../../glossary.rst:1346 ../../glossary.rst:1360 msgid "See :mod:`typing` and :pep:`484`, which describe this functionality." msgstr "請參閱 :mod:`typing` 和 :pep:`484`,有此功能的描述。" -#: ../../glossary.rst:1225 +#: ../../glossary.rst:1347 msgid "type hint" msgstr "type hint(型別提示)" -#: ../../glossary.rst:1227 +#: ../../glossary.rst:1349 msgid "" "An :term:`annotation` that specifies the expected type for a variable, a " "class attribute, or a function parameter or return value." @@ -2811,7 +3092,7 @@ msgstr "" "一種 :term:`annotation`\\ (註釋),它指定一個變數、一個 class 屬性或一個函式" "的參數或回傳值的預期型別。" -#: ../../glossary.rst:1230 +#: ../../glossary.rst:1352 msgid "" "Type hints are optional and are not enforced by Python but they are useful " "to :term:`static type checkers `. They can also aid " @@ -2821,7 +3102,7 @@ msgstr "" "(static type checkers) `\\ 很有用,並能協助 IDE 完成程式" "碼的補全 (completion) 和重構 (refactoring)。" -#: ../../glossary.rst:1234 +#: ../../glossary.rst:1356 msgid "" "Type hints of global variables, class attributes, and functions, but not " "local variables, can be accessed using :func:`typing.get_type_hints`." @@ -2829,11 +3110,11 @@ msgstr "" "全域變數、class 屬性和函式(不含區域變數)的型別提示,都可以使用 :func:" "`typing.get_type_hints` 來存取。" -#: ../../glossary.rst:1239 +#: ../../glossary.rst:1361 msgid "universal newlines" msgstr "universal newlines(通用換行字元)" -#: ../../glossary.rst:1241 +#: ../../glossary.rst:1363 msgid "" "A manner of interpreting text streams in which all of the following are " "recognized as ending a line: the Unix end-of-line convention ``'\\n'``, the " @@ -2846,20 +3127,20 @@ msgstr "" "``'\\r'``。請參閱 :pep:`278` 和 :pep:`3116`,以及用於 :func:`bytes." "splitlines` 的附加用途。" -#: ../../glossary.rst:1246 +#: ../../glossary.rst:1368 msgid "variable annotation" msgstr "variable annotation(變數註釋)" -#: ../../glossary.rst:1248 +#: ../../glossary.rst:1370 msgid "An :term:`annotation` of a variable or a class attribute." msgstr "一個變數或 class 屬性的 :term:`annotation`\\ (註釋)。" -#: ../../glossary.rst:1250 +#: ../../glossary.rst:1372 msgid "" "When annotating a variable or a class attribute, assignment is optional::" msgstr "註釋變數或 class 屬性時,賦值是選擇性的: ::" -#: ../../glossary.rst:1252 +#: ../../glossary.rst:1374 msgid "" "class C:\n" " field: 'annotation'" @@ -2867,7 +3148,7 @@ msgstr "" "class C:\n" " field: 'annotation'" -#: ../../glossary.rst:1255 +#: ../../glossary.rst:1377 msgid "" "Variable annotations are usually used for :term:`type hints `: " "for example this variable is expected to take :class:`int` values::" @@ -2875,15 +3156,15 @@ msgstr "" "變數註釋通常用於\\ :term:`型別提示 (type hint) `:例如,這個變數預" "期會取得 :class:`int`\\ (整數)值: ::" -#: ../../glossary.rst:1259 +#: ../../glossary.rst:1381 msgid "count: int = 0" msgstr "count: int = 0" -#: ../../glossary.rst:1261 +#: ../../glossary.rst:1383 msgid "Variable annotation syntax is explained in section :ref:`annassign`." msgstr "變數註釋的語法在\\ :ref:`annassign`\\ 章節有詳細的解釋。" -#: ../../glossary.rst:1263 +#: ../../glossary.rst:1385 msgid "" "See :term:`function annotation`, :pep:`484` and :pep:`526`, which describe " "this functionality. Also see :ref:`annotations-howto` for best practices on " @@ -2892,11 +3173,11 @@ msgstr "" "請參閱 :term:`function annotation`\\ (函式註釋)、:pep:`484` 和 :pep:`526`," "皆有此功能的描述。關於註釋的最佳實踐方法,另請參閱 :ref:`annotations-howto`。" -#: ../../glossary.rst:1267 +#: ../../glossary.rst:1389 msgid "virtual environment" msgstr "virtual environment(虛擬環境)" -#: ../../glossary.rst:1269 +#: ../../glossary.rst:1391 msgid "" "A cooperatively isolated runtime environment that allows Python users and " "applications to install and upgrade Python distribution packages without " @@ -2907,15 +3188,15 @@ msgstr "" "程式得以安裝和升級 Python 發佈套件,而不會對同一個系統上運行的其他 Python 應" "用程式的行為產生干擾。" -#: ../../glossary.rst:1274 +#: ../../glossary.rst:1396 msgid "See also :mod:`venv`." msgstr "另請參閱 :mod:`venv`。" -#: ../../glossary.rst:1275 +#: ../../glossary.rst:1397 msgid "virtual machine" msgstr "virtual machine(虛擬機器)" -#: ../../glossary.rst:1277 +#: ../../glossary.rst:1399 msgid "" "A computer defined entirely in software. Python's virtual machine executes " "the :term:`bytecode` emitted by the bytecode compiler." @@ -2923,11 +3204,11 @@ msgstr "" "一部完全由軟體所定義的電腦 (computer)。Python 的虛擬機器會執行由 :term:" "`bytecode`\\ (位元組碼)編譯器所發出的位元組碼。" -#: ../../glossary.rst:1279 +#: ../../glossary.rst:1401 msgid "Zen of Python" msgstr "Zen of Python(Python 之禪)" -#: ../../glossary.rst:1281 +#: ../../glossary.rst:1403 msgid "" "Listing of Python design principles and philosophies that are helpful in " "understanding and using the language. The listing can be found by typing " @@ -2936,18 +3217,84 @@ msgstr "" "Python 設計原則與哲學的列表,其內容有助於理解和使用此語言。此列表可以透過在互" "動式提式字元後輸入「``import this``」來找到它。" -#: ../../glossary.rst:264 +#: ../../glossary.rst:292 msgid "C-contiguous" msgstr "C-contiguous(C 連續的)" -#: ../../glossary.rst:264 +#: ../../glossary.rst:292 msgid "Fortran contiguous" msgstr "Fortran contiguous(Fortran 連續的)" -#: ../../glossary.rst:769 +#: ../../glossary.rst:831 msgid "magic" msgstr "magic" -#: ../../glossary.rst:1138 +#: ../../glossary.rst:1236 msgid "special" msgstr "special" + +#~ msgid "" +#~ "An object which controls the environment seen in a :keyword:`with` " +#~ "statement by defining :meth:`~object.__enter__` and :meth:`~object." +#~ "__exit__` methods. See :pep:`343`." +#~ msgstr "" +#~ "一個可以控制 :keyword:`with` 陳述式中所見環境的物件,而它是透過定義 :meth:" +#~ "`~object.__enter__` 和 :meth:`~object.__exit__` method 來控制的。請參閱 :" +#~ "pep:`343`。" + +#~ msgid "" +#~ "A variable which can have different values depending on its context. This " +#~ "is similar to Thread-Local Storage in which each execution thread may " +#~ "have a different value for a variable. However, with context variables, " +#~ "there may be several contexts in one execution thread and the main usage " +#~ "for context variables is to keep track of variables in concurrent " +#~ "asynchronous tasks. See :mod:`contextvars`." +#~ msgstr "" +#~ "一個變數,其值可以根據上下文的情境而有所不同。這類似執行緒區域儲存區 " +#~ "(Thread-Local Storage),在其中,一個變數在每個執行緒可能具有不同的值。然" +#~ "而,關於情境變數,在一個執行緒中可能會有多個情境,而情境變數的主要用途,是" +#~ "在並行的非同步任務 (concurrent asynchronous task) 中,對於變數狀態的追蹤。" +#~ "請參閱 :mod:`contextvars`。" + +#~ msgid "" +#~ "The main difference between a \"soft\" and a (regular) \"hard\" " +#~ "deprecation is that the soft deprecation does not imply scheduling the " +#~ "removal of the deprecated API." +#~ msgstr "" +#~ "「軟性」棄用和(常規的)「硬性」棄用之間的主要區別在於,軟性棄用並不代表已" +#~ "經確定要什麼時候刪除已棄用的 API。" + +#~ msgid "" +#~ "Another difference is that a soft deprecation does not issue a warning." +#~ msgstr "另一個區別是軟性棄用不會發出警告。" + +#~ msgid "2to3" +#~ msgstr "2to3" + +#~ msgid "" +#~ "A tool that tries to convert Python 2.x code to Python 3.x code by " +#~ "handling most of the incompatibilities which can be detected by parsing " +#~ "the source and traversing the parse tree." +#~ msgstr "" +#~ "一個試著將 Python 2.x 程式碼轉換為 Python 3.x 程式碼的工具,它是透過處理大" +#~ "部分的不相容性來達成此目的,而這些不相容性能夠透過剖析原始碼和遍歷剖析樹而" +#~ "被檢測出來。" + +#~ msgid "" +#~ "2to3 is available in the standard library as :mod:`lib2to3`; a standalone " +#~ "entry point is provided as :file:`Tools/scripts/2to3`. See :ref:`2to3-" +#~ "reference`." +#~ msgstr "" +#~ "2to3 在可以標準函式庫中以 :mod:`lib2to3` 被使用;它提供了一個獨立的入口" +#~ "點,在 :file:`Tools/scripts/2to3`。請參閱 :ref:`2to3-reference`。" + +#~ msgid "" +#~ "Past efforts to create a \"free-threaded\" interpreter (one which locks " +#~ "shared data at a much finer granularity) have not been successful because " +#~ "performance suffered in the common single-processor case. It is believed " +#~ "that overcoming this performance issue would make the implementation much " +#~ "more complicated and therefore costlier to maintain." +#~ msgstr "" +#~ "過去對於建立「無限制執行緒」直譯器(以更高的精細度鎖定共享資料的直譯器)的" +#~ "努力並未成功,因為在一般的單一處理器情況下,效能會有所損失。一般認為,若要" +#~ "克服這個效能問題,會使實作變得複雜許多,進而付出更高的維護成本。" diff --git a/howto/annotations.po b/howto/annotations.po index 0135a78029..67acc522c3 100644 --- a/howto/annotations.po +++ b/howto/annotations.po @@ -5,9 +5,9 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2024-09-27 00:14+0000\n" "PO-Revision-Date: 2023-11-08 23:11+0800\n" "Last-Translator: rockleon \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -192,15 +192,15 @@ msgid "" "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 ``__dict__`` " +"annotations defined, they are stored in the class's :attr:`~type.__dict__` " "dictionary. Since the class may or may not have annotations defined, best " -"practice is to call the ``get`` method on the class dict." +"practice is to call the :meth:`~dict.get` method on the class dict." msgstr "" "如果你正在檢查的物件是一個類別 (``isinstance(o, type)``),你的程式碼將必須有" "一個單獨的程式碼路徑。在這種情況下,最佳實踐依賴 Python 3.9 及之前版本的實作" -"細節 (implementation detail):如果一個類別定義了註釋,它們將儲存在該類別的 " -"``__dict__`` 字典中。由於類別可能定義了註釋,也可能沒有定義,因此最佳實踐是在" -"類別字典上呼叫 ``get`` 方法。" +"細節 (implementation detail):如果一個類別定義了註釋,它們將儲存在該類別的 :" +"attr:`~type.__dict__` 字典中。由於類別可能定義了註釋,也可能沒有定義,因此最" +"佳實踐是在類別字典上呼叫 :meth:`~dict.get` 方法。" #: ../../howto/annotations.rst:109 msgid "" @@ -234,13 +234,13 @@ msgstr "" #: ../../howto/annotations.rst:123 msgid "" -"Note that some exotic or malformed type objects may not have a ``__dict__`` " -"attribute, so for extra safety you may also wish to use :func:`getattr` to " -"access ``__dict__``." +"Note that some exotic or malformed type objects may not have a :attr:`~type." +"__dict__` attribute, so for extra safety you may also wish to use :func:" +"`getattr` to access :attr:`!__dict__`." msgstr "" -"請注意,某些外來 (exotic) 或格式錯誤 (malform) 的型別物件可能沒有 " -"``__dict__`` 屬性,因此為了額外的安全,你可能還希望使用 :func:`getattr` 來存" -"取 ``__dict__`` 。" +"請注意,某些外來 (exotic) 或格式錯誤 (malform) 的型別物件可能沒有 :attr:" +"`~type.__dict__` 屬性,因此為了額外的安全,你可能還希望使用 :func:`getattr` " +"來存取 :attr:`!__dict__`。" #: ../../howto/annotations.rst:129 msgid "Manually Un-Stringizing Stringized Annotations" diff --git a/howto/argparse-optparse.po b/howto/argparse-optparse.po new file mode 100644 index 0000000000..62fdf4ecdd --- /dev/null +++ b/howto/argparse-optparse.po @@ -0,0 +1,166 @@ +# Copyright (C) 2001-2024, Python Software Foundation +# This file is distributed under the same license as the Python package. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.13\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-12-29 11:18+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" +"Language: zh_TW\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../../howto/argparse-optparse.rst:8 +msgid "Migrating ``optparse`` code to ``argparse``" +msgstr "將 ``optparse`` 程式碼遷移到 ``argparse``" + +#: ../../howto/argparse-optparse.rst:10 +msgid "" +"The :mod:`argparse` module offers several higher level features not natively " +"provided by the :mod:`optparse` module, including:" +msgstr "" +":mod:`argparse` 模組提供了一些高階功能,這些功能在 :mod:`optparse` 模組中並未" +"原生提供,包括:" + +#: ../../howto/argparse-optparse.rst:13 +msgid "Handling positional arguments." +msgstr "處理位置引數。" + +#: ../../howto/argparse-optparse.rst:14 +msgid "Supporting subcommands." +msgstr "支援子命令。" + +#: ../../howto/argparse-optparse.rst:15 +msgid "Allowing alternative option prefixes like ``+`` and ``/``." +msgstr "允許替代選項前綴,如 ``+`` 和 ``/``。" + +#: ../../howto/argparse-optparse.rst:16 +msgid "Handling zero-or-more and one-or-more style arguments." +msgstr "" +"處理零或多個 (zero-or-more) 和一個或多個 (and one-or-more) 樣式的引數。" + +#: ../../howto/argparse-optparse.rst:17 +msgid "Producing more informative usage messages." +msgstr "產生更多資訊的使用訊息。" + +#: ../../howto/argparse-optparse.rst:18 +msgid "Providing a much simpler interface for custom ``type`` and ``action``." +msgstr "為自訂 ``type`` 和 ``action`` 提供了一個更簡單的介面。" + +#: ../../howto/argparse-optparse.rst:20 +msgid "" +"Originally, the :mod:`argparse` module attempted to maintain compatibility " +"with :mod:`optparse`. However, the fundamental design differences between " +"supporting declarative command line option processing (while leaving " +"positional argument processing to application code), and supporting both " +"named options and positional arguments in the declarative interface mean " +"that the API has diverged from that of ``optparse`` over time." +msgstr "" +"最初 :mod:`argparse` 模組試圖保持與 :mod:`optparse` 的相容性,但在基礎設計上" +"的存在差異 -- 支援宣告式 (declarative) 命令列選項處理 (同時將位置引數處理留給" +"應用程式的程式碼) 和在宣告式介面中支援命名選項 (named options) 和位置引數 -- " +"代表 API 隨著時間的推移已經與 ``optparse`` API 分歧。" + +#: ../../howto/argparse-optparse.rst:27 +msgid "" +"As described in :ref:`choosing-an-argument-parser`, applications that are " +"currently using :mod:`optparse` and are happy with the way it works can just " +"continue to use ``optparse``." +msgstr "" +"如 :ref:`choosing-an-argument-parser` 中所述,目前使用 :mod:`optparse` 並對其" +"運作方式滿意的應用程式可以繼續使用 ``optparse``。" + +#: ../../howto/argparse-optparse.rst:31 +msgid "" +"Application developers that are considering migrating should also review the " +"list of intrinsic behavioural differences described in that section before " +"deciding whether or not migration is desirable." +msgstr "" +"在決定是否遷移之前,應用程式開發人員應該先檢閱該段落中描述的內在行為差異清" +"單,來決定是否值得遷移。" + +#: ../../howto/argparse-optparse.rst:35 +msgid "" +"For applications that do choose to migrate from :mod:`optparse` to :mod:" +"`argparse`, the following suggestions should be helpful:" +msgstr "" +"對於選擇從 :mod:`optparse` 遷移到 :mod:`argparse` 的應用程式,以下建議應會有" +"所幫助:" + +#: ../../howto/argparse-optparse.rst:38 +msgid "" +"Replace all :meth:`optparse.OptionParser.add_option` calls with :meth:" +"`ArgumentParser.add_argument` calls." +msgstr "" +"將所有 :meth:`optparse.OptionParser.add_option` 呼叫替換為 :meth:" +"`ArgumentParser.add_argument` 呼叫。" + +#: ../../howto/argparse-optparse.rst:41 +msgid "" +"Replace ``(options, args) = parser.parse_args()`` with ``args = parser." +"parse_args()`` and add additional :meth:`ArgumentParser.add_argument` calls " +"for the positional arguments. Keep in mind that what was previously called " +"``options``, now in the :mod:`argparse` context is called ``args``." +msgstr "" +"將 ``(options, args) = parser.parse_args()`` 替換為 ``args = parser." +"parse_args()``,並為位置引數新增額外的 :meth:`ArgumentParser.add_argument` 呼" +"叫。請記住,以前稱為 ``options`` 的東西,在 :mod:`argparse` 情境中現在稱為 " +"``args``。" + +#: ../../howto/argparse-optparse.rst:46 +msgid "" +"Replace :meth:`optparse.OptionParser.disable_interspersed_args` by using :" +"meth:`~ArgumentParser.parse_intermixed_args` instead of :meth:" +"`~ArgumentParser.parse_args`." +msgstr "" +"使用 :meth:`~ArgumentParser.parse_intermixed_args` 來替換掉 :meth:`optparse." +"OptionParser.disable_interspersed_args`,而不是使用 :meth:`~ArgumentParser." +"parse_args`。" + +#: ../../howto/argparse-optparse.rst:50 +msgid "" +"Replace callback actions and the ``callback_*`` keyword arguments with " +"``type`` or ``action`` arguments." +msgstr "" +"將回呼動作和 ``callback_*`` 關鍵字引數替換為 ``type`` 或 ``action`` 引數。" + +#: ../../howto/argparse-optparse.rst:53 +msgid "" +"Replace string names for ``type`` keyword arguments with the corresponding " +"type objects (e.g. int, float, complex, etc)." +msgstr "" +"將 ``type`` 關鍵字引數的字串名稱替換為相應的類型物件 (例如 int、float、" +"complex 等)。" + +#: ../../howto/argparse-optparse.rst:56 +msgid "" +"Replace :class:`optparse.Values` with :class:`Namespace` and :exc:`optparse." +"OptionError` and :exc:`optparse.OptionValueError` with :exc:`ArgumentError`." +msgstr "" +"將 :class:`optparse.Values` 替換為 :class:`Namespace`,並將 :exc:`optparse." +"OptionError` 和 :exc:`optparse.OptionValueError` 替換為 :exc:" +"`ArgumentError`。" + +#: ../../howto/argparse-optparse.rst:60 +msgid "" +"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``." +msgstr "" +"將隱式引數的字串,如 ``%default`` 或 ``%prog`` 替換為使用字典來格式化字串的標" +"準 Python 語法,即 ``%(default)s`` 和 ``%(prog)s``。" + +#: ../../howto/argparse-optparse.rst:64 +msgid "" +"Replace the OptionParser constructor ``version`` argument with a call to " +"``parser.add_argument('--version', action='version', version='')``." +msgstr "" +"將 OptionParser 建構函式的 ``version`` 引數替換為呼叫 ``parser." +"add_argument('--version', action='version', version='')``。" diff --git a/howto/argparse.po b/howto/argparse.po index 21c4f4cd19..5f4710c87f 100644 --- a/howto/argparse.po +++ b/howto/argparse.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -10,9 +10,9 @@ # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-12-29 11:18+0000\n" "PO-Revision-Date: 2023-12-11 17:33+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -46,27 +46,36 @@ msgstr "" #: ../../howto/argparse.rst:16 msgid "" -"There are two other modules that fulfill the same task, namely :mod:`getopt` " -"(an equivalent for ``getopt()`` from the C language) and the deprecated :mod:" -"`optparse`. Note also that :mod:`argparse` is based on :mod:`optparse`, and " -"therefore very similar in terms of usage." -msgstr "" -"另外還有兩個模組可以完成相同的任務,即 :mod:`getopt`\\ (相當於 C 語言中的 " -"``getopt()``)和已棄用的 :mod:`optparse`。另請注意,:mod:`argparse` 是基於 :" -"mod:`optparse` 的,因此在用法上非常相似。" +"The standard library includes two other libraries directly related to " +"command-line parameter processing: the lower level :mod:`optparse` module " +"(which may require more code to configure for a given application, but also " +"allows an application to request behaviors that ``argparse`` doesn't " +"support), and the very low level :mod:`getopt` (which specifically serves as " +"an equivalent to the :c:func:`!getopt` family of functions available to C " +"programmers). While neither of those modules is covered directly in this " +"guide, many of the core concepts in ``argparse`` first originated in " +"``optparse``, so some aspects of this tutorial will also be relevant to " +"``optparse`` users." +msgstr "" +"標準函式庫包含另外兩個與命令列參數處理直接相關的函式庫:較低階的 :mod:" +"`optparse` 模組(可能需要更多程式碼來為給定應用程式設定,但也允許應用程式要" +"求 ``argparse`` 不支援的行為),以及非常低階的 :mod:`getopt`\\ (專門用作 C " +"程式設計師可用的 :c:func:`!getopt` 函式系列的等價)。雖然這個指南並未直接涵蓋" +"這些模組,但 ``argparse`` 的許多核心概念最初來自於 ``optparse``,因此本教學的" +"某些部分也適用於 ``optparse`` 使用者。" -#: ../../howto/argparse.rst:24 +#: ../../howto/argparse.rst:29 msgid "Concepts" msgstr "概念" -#: ../../howto/argparse.rst:26 +#: ../../howto/argparse.rst:31 msgid "" "Let's show the sort of functionality that we are going to explore in this " "introductory tutorial by making use of the :command:`ls` command:" msgstr "" "讓我們透過使用 :command:`ls` 指令來展示我們將在本介紹教學中探索的功能類型:" -#: ../../howto/argparse.rst:29 +#: ../../howto/argparse.rst:34 msgid "" "$ ls\n" "cpython devguide prog.py pypy rm-unused-function.patch\n" @@ -102,11 +111,11 @@ msgstr "" "Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.\n" "..." -#: ../../howto/argparse.rst:48 +#: ../../howto/argparse.rst:53 msgid "A few concepts we can learn from the four commands:" msgstr "我們可以從這四個命令中學到一些概念:" -#: ../../howto/argparse.rst:50 +#: ../../howto/argparse.rst:55 msgid "" "The :command:`ls` command is useful when run without any options at all. It " "defaults to displaying the contents of the current directory." @@ -114,7 +123,7 @@ msgstr "" ":command:`ls` 命令即便在沒有任何選項的情況下執行仍非常有用。它預設顯示目前目" "錄的內容。" -#: ../../howto/argparse.rst:53 +#: ../../howto/argparse.rst:58 msgid "" "If we want beyond what it provides by default, we tell it a bit more. In " "this case, we want it to display a different directory, ``pypy``. What we " @@ -131,7 +140,7 @@ msgstr "" "command:`cp` 這樣的指令更相關,其最基本的用法是 ``cp SRC DEST``。第一個是\\ *" "你想要複製的位置*,第二個是\\ *你想要複製過去的位置*。" -#: ../../howto/argparse.rst:62 +#: ../../howto/argparse.rst:67 msgid "" "Now, say we want to change behaviour of the program. In our example, we " "display more info for each file instead of just showing the file names. The " @@ -140,7 +149,7 @@ msgstr "" "現在假設我們想要改變程式的行為。在我們的範例中,我們顯示每個檔案的更多資訊," "而不僅是顯示檔案名稱。在這種情況下,``-l`` 被稱為可選引數。" -#: ../../howto/argparse.rst:66 +#: ../../howto/argparse.rst:71 msgid "" "That's a snippet of the help text. It's very useful in that you can come " "across a program you have never used before, and can figure out how it works " @@ -149,15 +158,15 @@ msgstr "" "這是幫助文字的片段。它非常有用,因為當你遇到以前從未使用過的程式時,只需閱讀" "其幫助文字即可了解它的工作原理。" -#: ../../howto/argparse.rst:72 +#: ../../howto/argparse.rst:77 msgid "The basics" msgstr "基本用法" -#: ../../howto/argparse.rst:74 +#: ../../howto/argparse.rst:79 msgid "Let us start with a very simple example which does (almost) nothing::" msgstr "讓我們從一個非常簡單的例子開始,它(幾乎)什麼都不做: ::" -#: ../../howto/argparse.rst:76 +#: ../../howto/argparse.rst:81 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -167,12 +176,12 @@ msgstr "" "parser = argparse.ArgumentParser()\n" "parser.parse_args()" -#: ../../howto/argparse.rst:80 ../../howto/argparse.rst:188 -#: ../../howto/argparse.rst:209 +#: ../../howto/argparse.rst:85 ../../howto/argparse.rst:193 +#: ../../howto/argparse.rst:214 msgid "Following is a result of running the code:" msgstr "程式碼執行結果如下:" -#: ../../howto/argparse.rst:82 +#: ../../howto/argparse.rst:87 msgid "" "$ python prog.py\n" "$ python prog.py --help\n" @@ -200,18 +209,18 @@ msgstr "" "usage: prog.py [-h]\n" "prog.py: error: unrecognized arguments: foo" -#: ../../howto/argparse.rst:97 ../../howto/argparse.rst:254 -#: ../../howto/argparse.rst:298 +#: ../../howto/argparse.rst:102 ../../howto/argparse.rst:259 +#: ../../howto/argparse.rst:303 msgid "Here is what is happening:" msgstr "這是發生的事情:" -#: ../../howto/argparse.rst:99 +#: ../../howto/argparse.rst:104 msgid "" "Running the script without any options results in nothing displayed to " "stdout. Not so useful." msgstr "執行不帶任何選項的腳本不會在標準輸出中顯示任何內容。不太有用。" -#: ../../howto/argparse.rst:102 +#: ../../howto/argparse.rst:107 msgid "" "The second one starts to display the usefulness of the :mod:`argparse` " "module. We have done almost nothing, but already we get a nice help message." @@ -219,7 +228,7 @@ msgstr "" "第二個開始能夠顯現 :mod:`argparse` 模組的有用之處。我們幾乎什麼也沒做,但我們" "已經收到了一個很好的幫助訊息。" -#: ../../howto/argparse.rst:105 +#: ../../howto/argparse.rst:110 msgid "" "The ``--help`` option, which can also be shortened to ``-h``, is the only " "option we get for free (i.e. no need to specify it). Specifying anything " @@ -230,15 +239,15 @@ msgstr "" "它)。指定任何其他內容都會導致錯誤。但即便如此,我們也還是輕鬆地獲得了有用的" "使用資訊。" -#: ../../howto/argparse.rst:112 +#: ../../howto/argparse.rst:117 msgid "Introducing Positional arguments" msgstr "位置引數的介紹" -#: ../../howto/argparse.rst:114 +#: ../../howto/argparse.rst:119 msgid "An example::" msgstr "例如: ::" -#: ../../howto/argparse.rst:116 +#: ../../howto/argparse.rst:121 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -252,11 +261,11 @@ msgstr "" "args = parser.parse_args()\n" "print(args.echo)" -#: ../../howto/argparse.rst:122 +#: ../../howto/argparse.rst:127 msgid "And running the code:" msgstr "執行這段程式碼:" -#: ../../howto/argparse.rst:124 +#: ../../howto/argparse.rst:129 msgid "" "$ python prog.py\n" "usage: prog.py [-h] echo\n" @@ -286,11 +295,11 @@ msgstr "" "$ python prog.py foo\n" "foo" -#: ../../howto/argparse.rst:140 +#: ../../howto/argparse.rst:145 msgid "Here is what's happening:" msgstr "這是會發生的事情:" -#: ../../howto/argparse.rst:142 +#: ../../howto/argparse.rst:147 msgid "" "We've added the :meth:`~ArgumentParser.add_argument` method, which is what " "we use to specify which command-line options the program is willing to " @@ -300,11 +309,11 @@ msgstr "" "我們新增了 :meth:`~ArgumentParser.add_argument` 方法,我們用它來指定程式願意" "接受哪些命令列選項。在本例中,我將其命名為 ``echo``,以便與其功能一致。" -#: ../../howto/argparse.rst:146 +#: ../../howto/argparse.rst:151 msgid "Calling our program now requires us to specify an option." msgstr "現在呼叫我們的程式時需要指定一個選項。" -#: ../../howto/argparse.rst:148 +#: ../../howto/argparse.rst:153 msgid "" "The :meth:`~ArgumentParser.parse_args` method actually returns some data " "from the options specified, in this case, ``echo``." @@ -312,7 +321,7 @@ msgstr "" ":meth:`~ArgumentParser.parse_args` 方法實際上從指定的選項中回傳一些資料,在本" "例中為 ``echo``。" -#: ../../howto/argparse.rst:151 +#: ../../howto/argparse.rst:156 msgid "" "The variable is some form of 'magic' that :mod:`argparse` performs for free " "(i.e. no need to specify which variable that value is stored in). You will " @@ -322,7 +331,7 @@ msgstr "" "該變數是某種形式的「魔法」,:mod:`argparse` 可以自由執行(即無需指定該值儲存" "在哪個變數中)。你還會注意到,它的名稱與提供給方法 ``echo`` 的字串引數相符。" -#: ../../howto/argparse.rst:156 +#: ../../howto/argparse.rst:161 msgid "" "Note however that, although the help display looks nice and all, it " "currently is not as helpful as it can be. For example we see that we got " @@ -334,7 +343,7 @@ msgstr "" "看到 ``echo`` 作為位置引數,但除了猜測或閱讀原始程式碼之外,我們不知道它的作" "用。那麼,我們來讓它變得更有用一點: ::" -#: ../../howto/argparse.rst:161 +#: ../../howto/argparse.rst:166 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -348,11 +357,11 @@ msgstr "" "args = parser.parse_args()\n" "print(args.echo)" -#: ../../howto/argparse.rst:167 +#: ../../howto/argparse.rst:172 msgid "And we get:" msgstr "然後我們得到:" -#: ../../howto/argparse.rst:169 +#: ../../howto/argparse.rst:174 msgid "" "$ python prog.py -h\n" "usage: prog.py [-h] echo\n" @@ -372,11 +381,11 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../howto/argparse.rst:180 +#: ../../howto/argparse.rst:185 msgid "Now, how about doing something even more useful::" msgstr "現在來做一些更有用處的事情: ::" -#: ../../howto/argparse.rst:182 +#: ../../howto/argparse.rst:187 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -392,7 +401,7 @@ msgstr "" "args = parser.parse_args()\n" "print(args.square**2)" -#: ../../howto/argparse.rst:190 +#: ../../howto/argparse.rst:195 msgid "" "$ python prog.py 4\n" "Traceback (most recent call last):\n" @@ -406,7 +415,7 @@ msgstr "" " print(args.square**2)\n" "TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'" -#: ../../howto/argparse.rst:198 +#: ../../howto/argparse.rst:203 msgid "" "That didn't go so well. That's because :mod:`argparse` treats the options we " "give it as strings, unless we tell it otherwise. So, let's tell :mod:" @@ -415,7 +424,7 @@ msgstr "" "進展不太順利。這是因為,除非我們另有說明,:mod:`argparse` 會將我們給它的選項" "視為字串。因此,讓我們告訴 :mod:`argparse` 將該輸入視為整數: ::" -#: ../../howto/argparse.rst:202 +#: ../../howto/argparse.rst:207 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -433,7 +442,7 @@ msgstr "" "args = parser.parse_args()\n" "print(args.square**2)" -#: ../../howto/argparse.rst:211 +#: ../../howto/argparse.rst:216 msgid "" "$ python prog.py 4\n" "16\n" @@ -447,23 +456,23 @@ msgstr "" "usage: prog.py [-h] square\n" "prog.py: error: argument square: invalid int value: 'four'" -#: ../../howto/argparse.rst:219 +#: ../../howto/argparse.rst:224 msgid "" "That went well. The program now even helpfully quits on bad illegal input " "before proceeding." msgstr "順利進展。現在該程式甚至可以在繼續操作之前因錯誤的非法輸入而退出。" -#: ../../howto/argparse.rst:224 +#: ../../howto/argparse.rst:229 msgid "Introducing Optional arguments" msgstr "可選引數的介紹" -#: ../../howto/argparse.rst:226 +#: ../../howto/argparse.rst:231 msgid "" "So far we have been playing with positional arguments. Let us have a look on " "how to add optional ones::" msgstr "到目前為止,我們一直在討論位置引數。我們來看看如何新增可選引數: ::" -#: ../../howto/argparse.rst:229 +#: ../../howto/argparse.rst:234 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -479,12 +488,12 @@ msgstr "" "if args.verbosity:\n" " print(\"verbosity turned on\")" -#: ../../howto/argparse.rst:236 ../../howto/argparse.rst:282 -#: ../../howto/argparse.rst:398 ../../howto/argparse.rst:432 +#: ../../howto/argparse.rst:241 ../../howto/argparse.rst:287 +#: ../../howto/argparse.rst:403 ../../howto/argparse.rst:437 msgid "And the output:" msgstr "接者是結果:" -#: ../../howto/argparse.rst:238 +#: ../../howto/argparse.rst:243 msgid "" "$ python prog.py --verbosity 1\n" "verbosity turned on\n" @@ -514,7 +523,7 @@ msgstr "" "usage: prog.py [-h] [--verbosity VERBOSITY]\n" "prog.py: error: argument --verbosity: expected one argument" -#: ../../howto/argparse.rst:256 +#: ../../howto/argparse.rst:261 msgid "" "The program is written so as to display something when ``--verbosity`` is " "specified and display nothing when not." @@ -522,7 +531,7 @@ msgstr "" "程式被編寫為在指定 ``--verbosity`` 時顯示一些內容,並在未指定時不顯示任何內" "容。" -#: ../../howto/argparse.rst:259 +#: ../../howto/argparse.rst:264 msgid "" "To show that the option is actually optional, there is no error when running " "the program without it. Note that by default, if an optional argument isn't " @@ -534,17 +543,17 @@ msgstr "" "情況下,如果未使用可選引數,則相關變數(在本例中為 ``args.verbosity``)將被賦" "予 ``None`` 作為值,這就是它未能通過 :keyword:`if` 陳述式真值測試的原因。" -#: ../../howto/argparse.rst:265 +#: ../../howto/argparse.rst:270 msgid "The help message is a bit different." msgstr "幫助訊息有點不同。" -#: ../../howto/argparse.rst:267 +#: ../../howto/argparse.rst:272 msgid "" "When using the ``--verbosity`` option, one must also specify some value, any " "value." msgstr "當使用 ``--verbosity`` 選項時必須要指定一些值,任何值都可以。" -#: ../../howto/argparse.rst:270 +#: ../../howto/argparse.rst:275 msgid "" "The above example accepts arbitrary integer values for ``--verbosity``, but " "for our simple program, only two values are actually useful, ``True`` or " @@ -553,7 +562,7 @@ msgstr "" "在上面的例子中,``--verbosity`` 接受任意的整數,但對我們的程式來說只接受兩個" "輸入值, ``True`` 或 ``False``。所以我們來修改一下程式碼使其符合: ::" -#: ../../howto/argparse.rst:274 +#: ../../howto/argparse.rst:279 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -571,7 +580,7 @@ msgstr "" "if args.verbose:\n" " print(\"verbosity turned on\")" -#: ../../howto/argparse.rst:284 +#: ../../howto/argparse.rst:289 msgid "" "$ python prog.py --verbose\n" "verbosity turned on\n" @@ -597,7 +606,7 @@ msgstr "" " -h, --help show this help message and exit\n" " --verbose increase output verbosity" -#: ../../howto/argparse.rst:300 +#: ../../howto/argparse.rst:305 msgid "" "The option is now more of a flag than something that requires a value. We " "even changed the name of the option to match that idea. Note that we now " @@ -610,21 +619,21 @@ msgstr "" "``\"store_true\"``。這意味著,如果指定了該選項,則將值 ``True`` 指派給 " "``args.verbose``。不指定它代表為 ``False``。" -#: ../../howto/argparse.rst:307 +#: ../../howto/argparse.rst:312 msgid "" "It complains when you specify a value, in true spirit of what flags actually " "are." msgstr "當你指定一個值時,它會本著旗標的實際精神來抱怨。" -#: ../../howto/argparse.rst:310 +#: ../../howto/argparse.rst:315 msgid "Notice the different help text." msgstr "請注意不同的幫助文字。" -#: ../../howto/argparse.rst:314 +#: ../../howto/argparse.rst:319 msgid "Short options" msgstr "短選項" -#: ../../howto/argparse.rst:316 +#: ../../howto/argparse.rst:321 msgid "" "If you are familiar with command line usage, you will notice that I haven't " "yet touched on the topic of short versions of the options. It's quite " @@ -632,7 +641,7 @@ msgid "" msgstr "" "如果你熟悉命令列用法,你會注意到我尚未提及選項的簡短版本。這很簡單: ::" -#: ../../howto/argparse.rst:320 +#: ../../howto/argparse.rst:325 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -652,11 +661,11 @@ msgstr "" "if args.verbose:\n" " print(\"verbosity turned on\")" -#: ../../howto/argparse.rst:328 +#: ../../howto/argparse.rst:333 msgid "And here goes:" msgstr "而這為:" -#: ../../howto/argparse.rst:330 +#: ../../howto/argparse.rst:335 msgid "" "$ python prog.py -v\n" "verbosity turned on\n" @@ -676,19 +685,19 @@ msgstr "" " -h, --help show this help message and exit\n" " -v, --verbose increase output verbosity" -#: ../../howto/argparse.rst:341 +#: ../../howto/argparse.rst:346 msgid "Note that the new ability is also reflected in the help text." msgstr "請注意,新功能也反映在幫助文字中。" -#: ../../howto/argparse.rst:345 +#: ../../howto/argparse.rst:350 msgid "Combining Positional and Optional arguments" msgstr "組合位置引數和可選引數" -#: ../../howto/argparse.rst:347 +#: ../../howto/argparse.rst:352 msgid "Our program keeps growing in complexity::" msgstr "我們的程式的複雜性不斷增加: ::" -#: ../../howto/argparse.rst:349 +#: ../../howto/argparse.rst:354 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -716,11 +725,11 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:362 +#: ../../howto/argparse.rst:367 msgid "And now the output:" msgstr "然後現在的輸出結果:" -#: ../../howto/argparse.rst:364 +#: ../../howto/argparse.rst:369 msgid "" "$ python prog.py\n" "usage: prog.py [-h] [-v] square\n" @@ -742,15 +751,15 @@ msgstr "" "$ python prog.py --verbose 4\n" "the square of 4 equals 16" -#: ../../howto/argparse.rst:376 +#: ../../howto/argparse.rst:381 msgid "We've brought back a positional argument, hence the complaint." msgstr "我們帶回了位置引數,因而被抱怨。" -#: ../../howto/argparse.rst:378 +#: ../../howto/argparse.rst:383 msgid "Note that the order does not matter." msgstr "請注意,順序並不重要。" -#: ../../howto/argparse.rst:380 +#: ../../howto/argparse.rst:385 msgid "" "How about we give this program of ours back the ability to have multiple " "verbosity values, and actually get to use them::" @@ -758,7 +767,7 @@ msgstr "" "我們讓這個程式擁有多個訊息詳細級別 (verbosity) 之值的能力,並實際使用它" "們: ::" -#: ../../howto/argparse.rst:383 +#: ../../howto/argparse.rst:388 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -790,7 +799,7 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:400 +#: ../../howto/argparse.rst:405 msgid "" "$ python prog.py 4\n" "16\n" @@ -816,7 +825,7 @@ msgstr "" "$ python prog.py 4 -v 3\n" "16" -#: ../../howto/argparse.rst:414 +#: ../../howto/argparse.rst:419 msgid "" "These all look good except the last one, which exposes a bug in our program. " "Let's fix it by restricting the values the ``--verbosity`` option can " @@ -825,7 +834,7 @@ msgstr "" "除了最後一個外都看起來正常,它透露了我們程式中的一個錯誤。我們可透過限制 ``--" "verbosity`` 選項可以接受的值來修復它: ::" -#: ../../howto/argparse.rst:417 +#: ../../howto/argparse.rst:422 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -857,7 +866,7 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:434 +#: ../../howto/argparse.rst:439 msgid "" "$ python prog.py 4 -v 3\n" "usage: prog.py [-h] [-v {0,1,2}] square\n" @@ -871,7 +880,7 @@ msgid "" "\n" "options:\n" " -h, --help show this help message and exit\n" -" -v {0,1,2}, --verbosity {0,1,2}\n" +" -v, --verbosity {0,1,2}\n" " increase output verbosity" msgstr "" "$ python prog.py 4 -v 3\n" @@ -886,16 +895,16 @@ msgstr "" "\n" "options:\n" " -h, --help show this help message and exit\n" -" -v {0,1,2}, --verbosity {0,1,2}\n" +" -v, --verbosity {0,1,2}\n" " increase output verbosity" -#: ../../howto/argparse.rst:450 +#: ../../howto/argparse.rst:455 msgid "" "Note that the change also reflects both in the error message as well as the " "help string." msgstr "請注意,更改也會反映在錯誤訊息和幫助字串中。" -#: ../../howto/argparse.rst:453 +#: ../../howto/argparse.rst:458 msgid "" "Now, let's use a different approach of playing with verbosity, which is " "pretty common. It also matches the way the CPython executable handles its " @@ -904,7 +913,7 @@ msgstr "" "現在,讓我們使用另一種常見方法來玩玩訊息詳細級別。它也與 CPython 執行檔處理其" "自身訊息詳細級別引數的方式相符(請見 ``python --help`` 的輸出): ::" -#: ../../howto/argparse.rst:457 +#: ../../howto/argparse.rst:462 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -936,13 +945,13 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:472 +#: ../../howto/argparse.rst:477 msgid "" "We have introduced another action, \"count\", to count the number of " "occurrences of specific options." msgstr "我們已經介紹過另一個操作 \"count\" 用來計算指定的選項出現的次數。" -#: ../../howto/argparse.rst:476 +#: ../../howto/argparse.rst:481 msgid "" "$ python prog.py 4\n" "16\n" @@ -990,7 +999,7 @@ msgstr "" "$ python prog.py 4 -vvv\n" "16" -#: ../../howto/argparse.rst:501 +#: ../../howto/argparse.rst:506 msgid "" "Yes, it's now more of a flag (similar to ``action=\"store_true\"``) in the " "previous version of our script. That should explain the complaint." @@ -998,29 +1007,29 @@ msgstr "" "是的,現在它更像是我們上一版腳本中的旗標(類似於 " "``action=\"store_true\"``),這應該可以解釋抱怨的原因。" -#: ../../howto/argparse.rst:504 +#: ../../howto/argparse.rst:509 msgid "It also behaves similar to \"store_true\" action." msgstr "它的行為也類似 \"store_true\" 操作。" -#: ../../howto/argparse.rst:506 +#: ../../howto/argparse.rst:511 msgid "" "Now here's a demonstration of what the \"count\" action gives. You've " "probably seen this sort of usage before." msgstr "現在這裡示範了 \"count\" 動作的作用。你可能以前見過這種用法。" -#: ../../howto/argparse.rst:509 +#: ../../howto/argparse.rst:514 msgid "" "And if you don't specify the ``-v`` flag, that flag is considered to have " "``None`` value." msgstr "如果你不指定 ``-v`` 旗標,則該旗標被視為具有 ``None`` 值。" -#: ../../howto/argparse.rst:512 +#: ../../howto/argparse.rst:517 msgid "" "As should be expected, specifying the long form of the flag, we should get " "the same output." msgstr "正如預期的那樣,指定長形式旗標,我們應該得到相同的輸出。" -#: ../../howto/argparse.rst:515 +#: ../../howto/argparse.rst:520 msgid "" "Sadly, our help output isn't very informative on the new ability our script " "has acquired, but that can always be fixed by improving the documentation " @@ -1029,15 +1038,15 @@ msgstr "" "遺憾的是,我們的幫助輸出對於我們腳本獲得的新功能並沒有提供太多資訊,但我們都" "可以透過改進腳本的文件來解決這個問題(例如:透過 ``help`` 關鍵字引數)。" -#: ../../howto/argparse.rst:519 +#: ../../howto/argparse.rst:524 msgid "That last output exposes a bug in our program." msgstr "最後的輸出透露了我們程式中的一個錯誤。" -#: ../../howto/argparse.rst:522 +#: ../../howto/argparse.rst:527 msgid "Let's fix::" msgstr "讓我們來解決問題: ::" -#: ../../howto/argparse.rst:524 +#: ../../howto/argparse.rst:529 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -1073,11 +1082,11 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:541 +#: ../../howto/argparse.rst:546 msgid "And this is what it gives:" msgstr "這就是它給出的:" -#: ../../howto/argparse.rst:543 +#: ../../howto/argparse.rst:548 msgid "" "$ python prog.py 4 -vvv\n" "the square of 4 equals 16\n" @@ -1099,7 +1108,7 @@ msgstr "" " if args.verbosity >= 2:\n" "TypeError: '>=' not supported between instances of 'NoneType' and 'int'" -#: ../../howto/argparse.rst:556 +#: ../../howto/argparse.rst:561 msgid "" "First output went well, and fixes the bug we had before. That is, we want " "any value >= 2 to be as verbose as possible." @@ -1107,15 +1116,15 @@ msgstr "" "第一次輸出順利進行,並修復了我們之前遇到的錯誤。也就是說,我們希望任何 >= 2 " "的值都盡可能詳細。" -#: ../../howto/argparse.rst:559 +#: ../../howto/argparse.rst:564 msgid "Third output not so good." msgstr "第三個輸出不太好。" -#: ../../howto/argparse.rst:561 +#: ../../howto/argparse.rst:566 msgid "Let's fix that bug::" msgstr "我們來修復這個錯誤: ::" -#: ../../howto/argparse.rst:563 +#: ../../howto/argparse.rst:568 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -1147,7 +1156,7 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:578 +#: ../../howto/argparse.rst:583 msgid "" "We've just introduced yet another keyword, ``default``. We've set it to " "``0`` in order to make it comparable to the other int values. Remember that " @@ -1159,11 +1168,11 @@ msgstr "" "int 值進行比較。請記住,預設情況下,如果未指定可選引數,它將獲得 ``None`` " "值,並且不能與 int 值進行比較(因此會出現 :exc:`TypeError` 例外)。" -#: ../../howto/argparse.rst:585 +#: ../../howto/argparse.rst:590 msgid "And:" msgstr "而且:" -#: ../../howto/argparse.rst:587 +#: ../../howto/argparse.rst:592 msgid "" "$ python prog.py 4\n" "16" @@ -1171,7 +1180,7 @@ msgstr "" "$ python prog.py 4\n" "16" -#: ../../howto/argparse.rst:592 +#: ../../howto/argparse.rst:597 msgid "" "You can go quite far just with what we've learned so far, and we have only " "scratched the surface. The :mod:`argparse` module is very powerful, and " @@ -1181,17 +1190,17 @@ msgstr "" "毛而已。:mod:`argparse` 模組非常強大,在結束本教學之前我們會對它進行更多探" "索。" -#: ../../howto/argparse.rst:599 +#: ../../howto/argparse.rst:604 msgid "Getting a little more advanced" msgstr "更進階一點" -#: ../../howto/argparse.rst:601 +#: ../../howto/argparse.rst:606 msgid "" "What if we wanted to expand our tiny program to perform other powers, not " "just squares::" msgstr "如果我們想擴充我們的小程式來執行其他次方的運算,而不僅是平方: ::" -#: ../../howto/argparse.rst:604 +#: ../../howto/argparse.rst:609 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -1221,11 +1230,12 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:618 ../../howto/argparse.rst:656 +#: ../../howto/argparse.rst:623 ../../howto/argparse.rst:661 +#: ../../howto/argparse.rst:877 msgid "Output:" msgstr "結果:" -#: ../../howto/argparse.rst:620 +#: ../../howto/argparse.rst:625 msgid "" "$ python prog.py\n" "usage: prog.py [-h] [-v] x y\n" @@ -1259,7 +1269,7 @@ msgstr "" "$ python prog.py 4 2 -v\n" "4^2 == 16" -#: ../../howto/argparse.rst:639 +#: ../../howto/argparse.rst:644 msgid "" "Notice that so far we've been using verbosity level to *change* the text " "that gets displayed. The following example instead uses verbosity level to " @@ -1268,7 +1278,7 @@ msgstr "" "請注意,到目前為止,我們一直在使用詳細級別來\\ *更改*\\ 顯示的文字。以下範例" "使用詳細級別來顯示\\ *更多*\\ 文字: ::" -#: ../../howto/argparse.rst:643 +#: ../../howto/argparse.rst:648 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -1296,7 +1306,7 @@ msgstr "" " print(f\"{args.x}^{args.y} == \", end=\"\")\n" "print(answer)" -#: ../../howto/argparse.rst:658 +#: ../../howto/argparse.rst:663 msgid "" "$ python prog.py 4 2\n" "16\n" @@ -1314,11 +1324,11 @@ msgstr "" "Running 'prog.py'\n" "4^2 == 16" -#: ../../howto/argparse.rst:672 +#: ../../howto/argparse.rst:677 msgid "Specifying ambiguous arguments" msgstr "指定不明確的引數" -#: ../../howto/argparse.rst:674 +#: ../../howto/argparse.rst:679 msgid "" "When there is ambiguity in deciding whether an argument is positional or for " "an argument, ``--`` can be used to tell :meth:`~ArgumentParser.parse_args` " @@ -1327,7 +1337,7 @@ msgstr "" "當決定一個引數是位置引數還是引數會有歧義,可以使用 ``--`` 來告訴 :meth:" "`~ArgumentParser.parse_args` 之後的所有內容都是位置引數: ::" -#: ../../howto/argparse.rst:678 +#: ../../howto/argparse.rst:683 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-n', nargs='+')\n" @@ -1367,11 +1377,11 @@ msgstr "" ">>> parser.parse_args(['-n', '1', '--', '2', '3'])\n" "Namespace(args=['2', '3'], n=['1'])" -#: ../../howto/argparse.rst:699 +#: ../../howto/argparse.rst:704 msgid "Conflicting options" msgstr "相互衝突的選項" -#: ../../howto/argparse.rst:701 +#: ../../howto/argparse.rst:706 msgid "" "So far, we have been working with two methods of an :class:`argparse." "ArgumentParser` instance. Let's introduce a third one, :meth:" @@ -1385,7 +1395,7 @@ msgstr "" "許我們指定彼此衝突的選項。我們還可以更改程式的其餘部分,以使得新功能更有意" "義:我們將引入 ``--quiet`` 選項,該選項與 ``--verbose`` 選項相反: ::" -#: ../../howto/argparse.rst:709 +#: ../../howto/argparse.rst:714 msgid "" "import argparse\n" "\n" @@ -1423,7 +1433,7 @@ msgstr "" "else:\n" " print(f\"{args.x}^{args.y} == {answer}\")" -#: ../../howto/argparse.rst:727 +#: ../../howto/argparse.rst:732 msgid "" "Our program is now simpler, and we've lost some functionality for the sake " "of demonstration. Anyways, here's the output:" @@ -1431,7 +1441,7 @@ msgstr "" "我們的程式現在更簡單了,我們因為功能展示失去了一些功能,但無論如何,以下這是" "輸出:" -#: ../../howto/argparse.rst:730 +#: ../../howto/argparse.rst:735 msgid "" "$ python prog.py 4 2\n" "4^2 == 16\n" @@ -1459,7 +1469,7 @@ msgstr "" "usage: prog.py [-h] [-v | -q] x y\n" "prog.py: error: argument -q/--quiet: not allowed with argument -v/--verbose" -#: ../../howto/argparse.rst:745 +#: ../../howto/argparse.rst:750 msgid "" "That should be easy to follow. I've added that last output so you can see " "the sort of flexibility you get, i.e. mixing long form options with short " @@ -1468,14 +1478,14 @@ msgstr "" "這應該很容易理解。我新增了最後一個輸出,以便看到所獲得的靈活性,即可以混合長" "形式與短形式選項。" -#: ../../howto/argparse.rst:749 +#: ../../howto/argparse.rst:754 msgid "" "Before we conclude, you probably want to tell your users the main purpose of " "your program, just in case they don't know::" msgstr "" "在我們結束之前,你可能想告訴使用者你的程式的主要目的,以防他們不知道: ::" -#: ../../howto/argparse.rst:752 +#: ../../howto/argparse.rst:757 msgid "" "import argparse\n" "\n" @@ -1515,7 +1525,7 @@ msgstr "" "else:\n" " print(f\"{args.x}^{args.y} == {answer}\")" -#: ../../howto/argparse.rst:770 +#: ../../howto/argparse.rst:775 msgid "" "Note that slight difference in the usage text. Note the ``[-v | -q]``, which " "tells us that we can either use ``-v`` or ``-q``, but not both at the same " @@ -1524,7 +1534,7 @@ msgstr "" "請注意用法文字中的細微差別。注意 ``[-v | -q]``,它告訴我們可以使用 ``-v`` 或 " "``-q``,但不能同時使用:" -#: ../../howto/argparse.rst:774 ../../howto/argparse.rst:801 +#: ../../howto/argparse.rst:779 ../../howto/argparse.rst:806 msgid "" "$ python prog.py --help\n" "usage: prog.py [-h] [-v | -q] x y\n" @@ -1554,11 +1564,11 @@ msgstr "" " -v, --verbose\n" " -q, --quiet" -#: ../../howto/argparse.rst:792 +#: ../../howto/argparse.rst:797 msgid "How to translate the argparse output" msgstr "如何翻譯 argparse 輸出" -#: ../../howto/argparse.rst:794 +#: ../../howto/argparse.rst:799 msgid "" "The output of the :mod:`argparse` module such as its help text and error " "messages are all made translatable using the :mod:`gettext` module. This " @@ -1569,11 +1579,11 @@ msgstr "" "`gettext` 模組進行翻譯。這允許應用程式能輕鬆本地化 :mod:`argparse` 生成的訊" "息。另請參閱 :ref:`i18n-howto`。" -#: ../../howto/argparse.rst:799 +#: ../../howto/argparse.rst:804 msgid "For instance, in this :mod:`argparse` output:" msgstr "例如,在此 :mod:`argparse` 輸出中:" -#: ../../howto/argparse.rst:817 +#: ../../howto/argparse.rst:822 msgid "" "The strings ``usage:``, ``positional arguments:``, ``options:`` and ``show " "this help message and exit`` are all translatable." @@ -1581,7 +1591,7 @@ msgstr "" "字串 ``usage:``、``positional arguments:``、``options:`` 和 ``show this help " "message and exit`` 都是可被翻譯的。" -#: ../../howto/argparse.rst:820 +#: ../../howto/argparse.rst:825 msgid "" "In order to translate these strings, they must first be extracted into a ``." "po`` file. For example, using `Babel `__, run this " @@ -1590,11 +1600,11 @@ msgstr "" "為了翻譯這些字串,必須先將它們提取到 ``.po`` 檔案中。例如,使用 `Babel " "`__ 並執行下列命令:" -#: ../../howto/argparse.rst:824 +#: ../../howto/argparse.rst:829 msgid "$ pybabel extract -o messages.po /usr/lib/python3.12/argparse.py" msgstr "$ pybabel extract -o messages.po /usr/lib/python3.12/argparse.py" -#: ../../howto/argparse.rst:828 +#: ../../howto/argparse.rst:833 msgid "" "This command will extract all translatable strings from the :mod:`argparse` " "module and output them into a file named ``messages.po``. This command " @@ -1603,13 +1613,13 @@ msgstr "" "此命令將從 :mod:`argparse` 模組中提取出所有可翻譯的字串,並將它們輸出到名為 " "``messages.po`` 的檔案中。這個指令假設你的 Python 是安裝在 ``/usr/lib`` 中。" -#: ../../howto/argparse.rst:832 +#: ../../howto/argparse.rst:837 msgid "" "You can find out the location of the :mod:`argparse` module on your system " "using this script::" msgstr "你可以使用以下腳本找到 :mod:`argparse` 模組在系統上的位置: ::" -#: ../../howto/argparse.rst:835 +#: ../../howto/argparse.rst:840 msgid "" "import argparse\n" "print(argparse.__file__)" @@ -1617,7 +1627,7 @@ msgstr "" "import argparse\n" "print(argparse.__file__)" -#: ../../howto/argparse.rst:838 +#: ../../howto/argparse.rst:843 msgid "" "Once the messages in the ``.po`` file are translated and the translations " "are installed using :mod:`gettext`, :mod:`argparse` will be able to display " @@ -1626,17 +1636,102 @@ msgstr "" "一旦翻譯了 ``.po`` 檔案中的訊息並使用 :mod:`gettext` 安裝了翻譯,:mod:" "`argparse` 將能夠顯示翻譯後的訊息。" -#: ../../howto/argparse.rst:842 +#: ../../howto/argparse.rst:847 msgid "" "To translate your own strings in the :mod:`argparse` output, use :mod:" "`gettext`." msgstr "若要在 :mod:`argparse` 輸出中翻譯你自己的字串,請使用 :mod:`gettext`。" -#: ../../howto/argparse.rst:845 +#: ../../howto/argparse.rst:850 +msgid "Custom type converters" +msgstr "自定義型別轉換器" + +#: ../../howto/argparse.rst:852 +msgid "" +"The :mod:`argparse` module allows you to specify custom type converters for " +"your command-line arguments. This allows you to modify user input before " +"it's stored in the :class:`argparse.Namespace`. This can be useful when you " +"need to pre-process the input before it is used in your program." +msgstr "" + +#: ../../howto/argparse.rst:857 +msgid "" +"When using a custom type converter, you can use any callable that takes a " +"single string argument (the argument value) and returns the converted value. " +"However, if you need to handle more complex scenarios, you can use a custom " +"action class with the **action** parameter instead." +msgstr "" + +#: ../../howto/argparse.rst:862 +msgid "" +"For example, let's say you want to handle arguments with different prefixes " +"and process them accordingly::" +msgstr "" + +#: ../../howto/argparse.rst:865 +msgid "" +"import argparse\n" +"\n" +"parser = argparse.ArgumentParser(prefix_chars='-+')\n" +"\n" +"parser.add_argument('-a', metavar='', action='append',\n" +" type=lambda x: ('-', x))\n" +"parser.add_argument('+a', metavar='', action='append',\n" +" type=lambda x: ('+', x))\n" +"\n" +"args = parser.parse_args()\n" +"print(args)" +msgstr "" +"import argparse\n" +"\n" +"parser = argparse.ArgumentParser(prefix_chars='-+')\n" +"\n" +"parser.add_argument('-a', metavar='', action='append',\n" +" type=lambda x: ('-', x))\n" +"parser.add_argument('+a', metavar='', action='append',\n" +" type=lambda x: ('+', x))\n" +"\n" +"args = parser.parse_args()\n" +"print(args)" + +#: ../../howto/argparse.rst:879 +msgid "" +"$ python prog.py -a value1 +a value2\n" +"Namespace(a=[('-', 'value1'), ('+', 'value2')])" +msgstr "" +"$ python prog.py -a value1 +a value2\n" +"Namespace(a=[('-', 'value1'), ('+', 'value2')])" + +#: ../../howto/argparse.rst:884 +msgid "In this example, we:" +msgstr "在這個範例當中,我們:" + +#: ../../howto/argparse.rst:886 +msgid "" +"Created a parser with custom prefix characters using the ``prefix_chars`` " +"parameter." +msgstr "" + +#: ../../howto/argparse.rst:889 +msgid "" +"Defined two arguments, ``-a`` and ``+a``, which used the ``type`` parameter " +"to create custom type converters to store the value in a tuple with the " +"prefix." +msgstr "" + +#: ../../howto/argparse.rst:892 +msgid "" +"Without the custom type converters, the arguments would have treated the ``-" +"a`` and ``+a`` as the same argument, which would have been undesirable. By " +"using custom type converters, we were able to differentiate between the two " +"arguments." +msgstr "" + +#: ../../howto/argparse.rst:897 msgid "Conclusion" msgstr "結論" -#: ../../howto/argparse.rst:847 +#: ../../howto/argparse.rst:899 msgid "" "The :mod:`argparse` module offers a lot more than shown here. Its docs are " "quite detailed and thorough, and full of examples. Having gone through this " diff --git a/howto/clinic.po b/howto/clinic.po index c039a32a4c..4deac0b429 100644 --- a/howto/clinic.po +++ b/howto/clinic.po @@ -5,7 +5,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-10-13 00:03+0000\n" "PO-Revision-Date: 2018-05-23 14:36+0000\n" diff --git a/howto/cporting.po b/howto/cporting.po index 2735f9fcc3..06a67dd24b 100644 --- a/howto/cporting.po +++ b/howto/cporting.po @@ -6,9 +6,9 @@ # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-20 18:08+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 14:36+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -44,8 +44,8 @@ msgstr "" #: ../../howto/cporting.rst:17 msgid "" -"The `Cython`_ and `CFFI`_ libraries offer abstractions over Python's C API. " -"Extensions generally need to be re-written to use one of them, but the " -"library then handles differences between various Python versions and " -"implementations." +":ref:`Recommended third party tools ` offer abstractions over " +"the Python's C API. Extensions generally need to be re-written to use one of " +"them, but the library then handles differences between various Python " +"versions and implementations." msgstr "" diff --git a/howto/curses.po b/howto/curses.po index 8679624e6d..5c22aaf379 100644 --- a/howto/curses.po +++ b/howto/curses.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-04-11 00:15+0000\n" "PO-Revision-Date: 2018-05-23 14:36+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -240,8 +240,8 @@ msgid "" " v = i-10\n" " stdscr.addstr(i, 0, '10 divided by {} is {}'.format(v, 10/v))\n" "\n" -" stdscr.refresh()\n" -" stdscr.getkey()\n" +" stdscr.refresh()\n" +" stdscr.getkey()\n" "\n" "wrapper(main)" msgstr "" diff --git a/howto/descriptor.po b/howto/descriptor.po index b15d02417c..8a489fafc2 100644 --- a/howto/descriptor.po +++ b/howto/descriptor.po @@ -5,9 +5,9 @@ # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-11-27 00:14+0000\n" "PO-Revision-Date: 2018-05-23 14:36+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -75,8 +75,9 @@ msgstr "" msgid "" "The last section has pure Python equivalents for built-in descriptors that " "are written in C. Read this if you're curious about how functions turn into " -"bound methods or about the implementation of common tools like :func:" -"`classmethod`, :func:`staticmethod`, :func:`property`, and :term:`__slots__`." +"bound methods or about the implementation of common tools " +"like :func:`classmethod`, :func:`staticmethod`, :func:`property`, " +"and :term:`__slots__`." msgstr "" #: ../../howto/descriptor.rst:36 @@ -95,8 +96,8 @@ msgstr "" #: ../../howto/descriptor.rst:45 msgid "" -"The :class:`Ten` class is a descriptor whose :meth:`__get__` method always " -"returns the constant ``10``:" +"The :class:`!Ten` class is a descriptor whose :meth:`~object.__get__` method " +"always returns the constant ``10``:" msgstr "" #: ../../howto/descriptor.rst:48 @@ -214,11 +215,11 @@ msgstr "" #: ../../howto/descriptor.rst:122 msgid "" "Besides showing how descriptors can run computations, this example also " -"reveals the purpose of the parameters to :meth:`__get__`. The *self* " -"parameter is *size*, an instance of *DirectorySize*. The *obj* parameter is " -"either *g* or *s*, an instance of *Directory*. It is the *obj* parameter " -"that lets the :meth:`__get__` method learn the target directory. The " -"*objtype* parameter is the class *Directory*." +"reveals the purpose of the parameters to :meth:`~object.__get__`. The " +"*self* parameter is *size*, an instance of *DirectorySize*. The *obj* " +"parameter is either *g* or *s*, an instance of *Directory*. It is the *obj* " +"parameter that lets the :meth:`~object.__get__` method learn the target " +"directory. The *objtype* parameter is the class *Directory*." msgstr "" #: ../../howto/descriptor.rst:131 @@ -230,8 +231,9 @@ msgid "" "A popular use for descriptors is managing access to instance data. The " "descriptor is assigned to a public attribute in the class dictionary while " "the actual data is stored as a private attribute in the instance " -"dictionary. The descriptor's :meth:`__get__` and :meth:`__set__` methods " -"are triggered when the public attribute is accessed." +"dictionary. The descriptor's :meth:`~object.__get__` " +"and :meth:`~object.__set__` methods are triggered when the public attribute " +"is accessed." msgstr "" #: ../../howto/descriptor.rst:139 @@ -326,10 +328,10 @@ msgstr "" #: ../../howto/descriptor.rst:218 msgid "" -"In this example, the :class:`Person` class has two descriptor instances, " -"*name* and *age*. When the :class:`Person` class is defined, it makes a " -"callback to :meth:`__set_name__` in *LoggedAccess* so that the field names " -"can be recorded, giving each descriptor its own *public_name* and " +"In this example, the :class:`!Person` class has two descriptor instances, " +"*name* and *age*. When the :class:`!Person` class is defined, it makes a " +"callback to :meth:`~object.__set_name__` in *LoggedAccess* so that the field " +"names can be recorded, giving each descriptor its own *public_name* and " "*private_name*:" msgstr "" @@ -369,9 +371,10 @@ msgstr "" #: ../../howto/descriptor.rst:256 msgid "" -"An interactive session shows that the :class:`Person` class has called :meth:" -"`__set_name__` so that the field names would be recorded. Here we call :" -"func:`vars` to look up the descriptor without triggering it:" +"An interactive session shows that the :class:`!Person` class has " +"called :meth:`~object.__set_name__` so that the field names would be " +"recorded. Here we call :func:`vars` to look up the descriptor without " +"triggering it:" msgstr "" #: ../../howto/descriptor.rst:260 @@ -428,16 +431,17 @@ msgstr "" #: ../../howto/descriptor.rst:297 msgid "" -"A :term:`descriptor` is what we call any object that defines :meth:" -"`__get__`, :meth:`__set__`, or :meth:`__delete__`." +"A :term:`descriptor` is what we call any object that " +"defines :meth:`~object.__get__`, :meth:`~object.__set__`, " +"or :meth:`~object.__delete__`." msgstr "" #: ../../howto/descriptor.rst:300 msgid "" -"Optionally, descriptors can have a :meth:`__set_name__` method. This is " -"only used in cases where a descriptor needs to know either the class where " -"it was created or the name of class variable it was assigned to. (This " -"method, if present, is called even if the class is not a descriptor.)" +"Optionally, descriptors can have a :meth:`~object.__set_name__` method. " +"This is only used in cases where a descriptor needs to know either the class " +"where it was created or the name of class variable it was assigned to. " +"(This method, if present, is called even if the class is not a descriptor.)" msgstr "" #: ../../howto/descriptor.rst:305 @@ -469,9 +473,9 @@ msgstr "" #: ../../howto/descriptor.rst:319 msgid "" "Descriptors are used throughout the language. It is how functions turn into " -"bound methods. Common tools like :func:`classmethod`, :func:" -"`staticmethod`, :func:`property`, and :func:`functools.cached_property` are " -"all implemented as descriptors." +"bound methods. Common tools " +"like :func:`classmethod`, :func:`staticmethod`, :func:`property`, " +"and :func:`functools.cached_property` are all implemented as descriptors." msgstr "" #: ../../howto/descriptor.rst:326 @@ -498,7 +502,7 @@ msgstr "" #: ../../howto/descriptor.rst:340 msgid "" -"This :class:`Validator` class is both an :term:`abstract base class` and a " +"This :class:`!Validator` class is both an :term:`abstract base class` and a " "managed attribute descriptor:" msgstr "" @@ -542,8 +546,8 @@ msgstr "" #: ../../howto/descriptor.rst:363 msgid "" -"Custom validators need to inherit from :class:`Validator` and must supply a :" -"meth:`validate` method to test various restrictions as needed." +"Custom validators need to inherit from :class:`!Validator` and must supply " +"a :meth:`!validate` method to test various restrictions as needed." msgstr "" #: ../../howto/descriptor.rst:368 @@ -556,19 +560,19 @@ msgstr "" #: ../../howto/descriptor.rst:372 msgid "" -":class:`OneOf` verifies that a value is one of a restricted set of options." +":class:`!OneOf` verifies that a value is one of a restricted set of options." msgstr "" #: ../../howto/descriptor.rst:374 msgid "" -":class:`Number` verifies that a value is either an :class:`int` or :class:" -"`float`. Optionally, it verifies that a value is between a given minimum or " -"maximum." +":class:`!Number` verifies that a value is either an :class:`int` " +"or :class:`float`. Optionally, it verifies that a value is between a given " +"minimum or maximum." msgstr "" #: ../../howto/descriptor.rst:378 msgid "" -":class:`String` verifies that a value is a :class:`str`. Optionally, it " +":class:`!String` verifies that a value is a :class:`str`. Optionally, it " "validates a given minimum or maximum length. It can validate a user-defined " "`predicate `_ " "as well." @@ -583,8 +587,9 @@ msgid "" "\n" " def validate(self, value):\n" " if value not in self.options:\n" -" raise ValueError(f'Expected {value!r} to be one of {self.options!" -"r}')\n" +" raise ValueError(\n" +" f'Expected {value!r} to be one of {self.options!r}'\n" +" )\n" "\n" "class Number(Validator):\n" "\n" @@ -629,15 +634,15 @@ msgid "" " )" msgstr "" -#: ../../howto/descriptor.rst:437 +#: ../../howto/descriptor.rst:439 msgid "Practical application" msgstr "" -#: ../../howto/descriptor.rst:439 +#: ../../howto/descriptor.rst:441 msgid "Here's how the data validators can be used in a real class:" msgstr "" -#: ../../howto/descriptor.rst:441 +#: ../../howto/descriptor.rst:443 msgid "" "class Component:\n" "\n" @@ -651,11 +656,11 @@ msgid "" " self.quantity = quantity" msgstr "" -#: ../../howto/descriptor.rst:454 +#: ../../howto/descriptor.rst:456 msgid "The descriptors prevent invalid instances from being created:" msgstr "" -#: ../../howto/descriptor.rst:456 +#: ../../howto/descriptor.rst:458 msgid "" ">>> Component('Widget', 'metal', 5) # Blocked: 'Widget' is not all " "uppercase\n" @@ -673,6 +678,7 @@ msgid "" "Traceback (most recent call last):\n" " ...\n" "ValueError: Expected -5 to be at least 0\n" +"\n" ">>> Component('WIDGET', 'metal', 'V') # Blocked: 'V' isn't a number\n" "Traceback (most recent call last):\n" " ...\n" @@ -681,45 +687,46 @@ msgid "" ">>> c = Component('WIDGET', 'metal', 5) # Allowed: The inputs are valid" msgstr "" -#: ../../howto/descriptor.rst:481 +#: ../../howto/descriptor.rst:484 msgid "Technical Tutorial" msgstr "" -#: ../../howto/descriptor.rst:483 +#: ../../howto/descriptor.rst:486 msgid "" "What follows is a more technical tutorial for the mechanics and details of " "how descriptors work." msgstr "" -#: ../../howto/descriptor.rst:488 +#: ../../howto/descriptor.rst:491 msgid "Abstract" msgstr "摘要" -#: ../../howto/descriptor.rst:490 +#: ../../howto/descriptor.rst:493 msgid "" "Defines descriptors, summarizes the protocol, and shows how descriptors are " "called. Provides an example showing how object relational mappings work." msgstr "" -#: ../../howto/descriptor.rst:493 +#: ../../howto/descriptor.rst:496 msgid "" "Learning about descriptors not only provides access to a larger toolset, it " "creates a deeper understanding of how Python works." msgstr "" -#: ../../howto/descriptor.rst:498 +#: ../../howto/descriptor.rst:501 msgid "Definition and introduction" msgstr "" -#: ../../howto/descriptor.rst:500 +#: ../../howto/descriptor.rst:503 msgid "" "In general, a descriptor is an attribute value that has one of the methods " -"in the descriptor protocol. Those methods are :meth:`__get__`, :meth:" -"`__set__`, and :meth:`__delete__`. If any of those methods are defined for " -"an attribute, it is said to be a :term:`descriptor`." +"in the descriptor protocol. Those methods " +"are :meth:`~object.__get__`, :meth:`~object.__set__`, " +"and :meth:`~object.__delete__`. If any of those methods are defined for an " +"attribute, it is said to be a :term:`descriptor`." msgstr "" -#: ../../howto/descriptor.rst:505 +#: ../../howto/descriptor.rst:508 msgid "" "The default behavior for attribute access is to get, set, or delete the " "attribute from an object's dictionary. For instance, ``a.x`` has a lookup " @@ -731,47 +738,47 @@ msgid "" "methods were defined." msgstr "" -#: ../../howto/descriptor.rst:514 +#: ../../howto/descriptor.rst:517 msgid "" "Descriptors are a powerful, general purpose protocol. They are the " -"mechanism behind properties, methods, static methods, class methods, and :" -"func:`super`. They are used throughout Python itself. Descriptors simplify " -"the underlying C code and offer a flexible set of new tools for everyday " -"Python programs." +"mechanism behind properties, methods, static methods, class methods, " +"and :func:`super`. They are used throughout Python itself. Descriptors " +"simplify the underlying C code and offer a flexible set of new tools for " +"everyday Python programs." msgstr "" -#: ../../howto/descriptor.rst:522 +#: ../../howto/descriptor.rst:525 msgid "Descriptor protocol" msgstr "描述器協定" -#: ../../howto/descriptor.rst:524 +#: ../../howto/descriptor.rst:527 msgid "``descr.__get__(self, obj, type=None)``" msgstr "``descr.__get__(self, obj, type=None)``" -#: ../../howto/descriptor.rst:526 +#: ../../howto/descriptor.rst:529 msgid "``descr.__set__(self, obj, value)``" msgstr "``descr.__set__(self, obj, value)``" -#: ../../howto/descriptor.rst:528 +#: ../../howto/descriptor.rst:531 msgid "``descr.__delete__(self, obj)``" msgstr "``descr.__delete__(self, obj)``" -#: ../../howto/descriptor.rst:530 +#: ../../howto/descriptor.rst:533 msgid "" "That is all there is to it. Define any of these methods and an object is " "considered a descriptor and can override default behavior upon being looked " "up as an attribute." msgstr "" -#: ../../howto/descriptor.rst:534 +#: ../../howto/descriptor.rst:537 msgid "" -"If an object defines :meth:`__set__` or :meth:`__delete__`, it is considered " -"a data descriptor. Descriptors that only define :meth:`__get__` are called " -"non-data descriptors (they are often used for methods but other uses are " -"possible)." +"If an object defines :meth:`~object.__set__` or :meth:`~object.__delete__`, " +"it is considered a data descriptor. Descriptors that only " +"define :meth:`~object.__get__` are called non-data descriptors (they are " +"often used for methods but other uses are possible)." msgstr "" -#: ../../howto/descriptor.rst:539 +#: ../../howto/descriptor.rst:542 msgid "" "Data and non-data descriptors differ in how overrides are calculated with " "respect to entries in an instance's dictionary. If an instance's dictionary " @@ -780,69 +787,70 @@ msgid "" "name as a non-data descriptor, the dictionary entry takes precedence." msgstr "" -#: ../../howto/descriptor.rst:545 +#: ../../howto/descriptor.rst:548 msgid "" -"To make a read-only data descriptor, define both :meth:`__get__` and :meth:" -"`__set__` with the :meth:`__set__` raising an :exc:`AttributeError` when " -"called. Defining the :meth:`__set__` method with an exception raising " -"placeholder is enough to make it a data descriptor." +"To make a read-only data descriptor, define both :meth:`~object.__get__` " +"and :meth:`~object.__set__` with the :meth:`~object.__set__` raising " +"an :exc:`AttributeError` when called. Defining the :meth:`~object.__set__` " +"method with an exception raising placeholder is enough to make it a data " +"descriptor." msgstr "" -#: ../../howto/descriptor.rst:552 +#: ../../howto/descriptor.rst:555 msgid "Overview of descriptor invocation" msgstr "" -#: ../../howto/descriptor.rst:554 +#: ../../howto/descriptor.rst:557 msgid "" -"A descriptor can be called directly with ``desc.__get__(obj)`` or ``desc." -"__get__(None, cls)``." +"A descriptor can be called directly with ``desc.__get__(obj)`` or " +"``desc.__get__(None, cls)``." msgstr "" -#: ../../howto/descriptor.rst:557 +#: ../../howto/descriptor.rst:560 msgid "" "But it is more common for a descriptor to be invoked automatically from " "attribute access." msgstr "" -#: ../../howto/descriptor.rst:560 +#: ../../howto/descriptor.rst:563 msgid "" "The expression ``obj.x`` looks up the attribute ``x`` in the chain of " "namespaces for ``obj``. If the search finds a descriptor outside of the " -"instance ``__dict__``, its :meth:`__get__` method is invoked according to " -"the precedence rules listed below." +"instance :attr:`~object.__dict__`, its :meth:`~object.__get__` method is " +"invoked according to the precedence rules listed below." msgstr "" -#: ../../howto/descriptor.rst:565 +#: ../../howto/descriptor.rst:568 msgid "" "The details of invocation depend on whether ``obj`` is an object, class, or " "instance of super." msgstr "" -#: ../../howto/descriptor.rst:570 +#: ../../howto/descriptor.rst:573 msgid "Invocation from an instance" msgstr "" -#: ../../howto/descriptor.rst:572 +#: ../../howto/descriptor.rst:575 msgid "" "Instance lookup scans through a chain of namespaces giving data descriptors " "the highest priority, followed by instance variables, then non-data " -"descriptors, then class variables, and lastly :meth:`__getattr__` if it is " -"provided." +"descriptors, then class variables, and lastly :meth:`~object.__getattr__` if " +"it is provided." msgstr "" -#: ../../howto/descriptor.rst:577 +#: ../../howto/descriptor.rst:580 msgid "" -"If a descriptor is found for ``a.x``, then it is invoked with: ``desc." -"__get__(a, type(a))``." +"If a descriptor is found for ``a.x``, then it is invoked with: " +"``desc.__get__(a, type(a))``." msgstr "" -#: ../../howto/descriptor.rst:580 +#: ../../howto/descriptor.rst:583 msgid "" "The logic for a dotted lookup is in :meth:`object.__getattribute__`. Here " "is a pure Python equivalent:" msgstr "" -#: ../../howto/descriptor.rst:583 +#: ../../howto/descriptor.rst:586 msgid "" "def find_name_in_mro(cls, name, default):\n" " \"Emulate _PyType_Lookup() in Objects/typeobject.c\"\n" @@ -871,22 +879,24 @@ msgid "" " raise AttributeError(name)" msgstr "" -#: ../../howto/descriptor.rst:719 +#: ../../howto/descriptor.rst:722 msgid "" -"Note, there is no :meth:`__getattr__` hook in the :meth:`__getattribute__` " -"code. That is why calling :meth:`__getattribute__` directly or with " -"``super().__getattribute__`` will bypass :meth:`__getattr__` entirely." +"Note, there is no :meth:`~object.__getattr__` hook in " +"the :meth:`~object.__getattribute__` code. That is why " +"calling :meth:`~object.__getattribute__` directly or with " +"``super().__getattribute__`` will bypass :meth:`~object.__getattr__` " +"entirely." msgstr "" -#: ../../howto/descriptor.rst:723 +#: ../../howto/descriptor.rst:726 msgid "" "Instead, it is the dot operator and the :func:`getattr` function that are " -"responsible for invoking :meth:`__getattr__` whenever :meth:" -"`__getattribute__` raises an :exc:`AttributeError`. Their logic is " -"encapsulated in a helper function:" +"responsible for invoking :meth:`~object.__getattr__` " +"whenever :meth:`~object.__getattribute__` raises an :exc:`AttributeError`. " +"Their logic is encapsulated in a helper function:" msgstr "" -#: ../../howto/descriptor.rst:728 +#: ../../howto/descriptor.rst:731 msgid "" "def getattr_hook(obj, name):\n" " \"Emulate slot_tp_getattr_hook() in Objects/typeobject.c\"\n" @@ -906,146 +916,148 @@ msgstr "" " raise\n" " return type(obj).__getattr__(obj, name) # __getattr__" -#: ../../howto/descriptor.rst:773 +#: ../../howto/descriptor.rst:776 msgid "Invocation from a class" msgstr "" -#: ../../howto/descriptor.rst:775 +#: ../../howto/descriptor.rst:778 msgid "" -"The logic for a dotted lookup such as ``A.x`` is in :meth:`type." -"__getattribute__`. The steps are similar to those for :meth:`object." -"__getattribute__` but the instance dictionary lookup is replaced by a search " -"through the class's :term:`method resolution order`." +"The logic for a dotted lookup such as ``A.x`` is in :meth:`!" +"type.__getattribute__`. The steps are similar to those for :meth:`!" +"object.__getattribute__` but the instance dictionary lookup is replaced by a " +"search through the class's :term:`method resolution order`." msgstr "" -#: ../../howto/descriptor.rst:780 +#: ../../howto/descriptor.rst:783 msgid "If a descriptor is found, it is invoked with ``desc.__get__(None, A)``." msgstr "" -#: ../../howto/descriptor.rst:782 +#: ../../howto/descriptor.rst:785 msgid "" -"The full C implementation can be found in :c:func:`!type_getattro` and :c:" -"func:`!_PyType_Lookup` in :source:`Objects/typeobject.c`." +"The full C implementation can be found in :c:func:`!type_getattro` " +"and :c:func:`!_PyType_Lookup` in :source:`Objects/typeobject.c`." msgstr "" -#: ../../howto/descriptor.rst:787 +#: ../../howto/descriptor.rst:790 msgid "Invocation from super" msgstr "" -#: ../../howto/descriptor.rst:789 +#: ../../howto/descriptor.rst:792 msgid "" -"The logic for super's dotted lookup is in the :meth:`__getattribute__` " -"method for object returned by :func:`super`." +"The logic for super's dotted lookup is in " +"the :meth:`~object.__getattribute__` method for object returned " +"by :func:`super`." msgstr "" -#: ../../howto/descriptor.rst:792 +#: ../../howto/descriptor.rst:795 msgid "" -"A dotted lookup such as ``super(A, obj).m`` searches ``obj.__class__." -"__mro__`` for the base class ``B`` immediately following ``A`` and then " -"returns ``B.__dict__['m'].__get__(obj, A)``. If not a descriptor, ``m`` is " -"returned unchanged." +"A dotted lookup such as ``super(A, obj).m`` searches " +"``obj.__class__.__mro__`` for the base class ``B`` immediately following " +"``A`` and then returns ``B.__dict__['m'].__get__(obj, A)``. If not a " +"descriptor, ``m`` is returned unchanged." msgstr "" -#: ../../howto/descriptor.rst:797 +#: ../../howto/descriptor.rst:800 msgid "" -"The full C implementation can be found in :c:func:`!super_getattro` in :" -"source:`Objects/typeobject.c`. A pure Python equivalent can be found in " +"The full C implementation can be found in :c:func:`!super_getattro` " +"in :source:`Objects/typeobject.c`. A pure Python equivalent can be found in " "`Guido's Tutorial `_." msgstr "" -#: ../../howto/descriptor.rst:804 +#: ../../howto/descriptor.rst:807 msgid "Summary of invocation logic" msgstr "" -#: ../../howto/descriptor.rst:806 +#: ../../howto/descriptor.rst:809 msgid "" -"The mechanism for descriptors is embedded in the :meth:`__getattribute__` " -"methods for :class:`object`, :class:`type`, and :func:`super`." +"The mechanism for descriptors is embedded in " +"the :meth:`~object.__getattribute__` methods " +"for :class:`object`, :class:`type`, and :func:`super`." msgstr "" -#: ../../howto/descriptor.rst:809 +#: ../../howto/descriptor.rst:812 msgid "The important points to remember are:" msgstr "要記住的重點是:" -#: ../../howto/descriptor.rst:811 -msgid "Descriptors are invoked by the :meth:`__getattribute__` method." +#: ../../howto/descriptor.rst:814 +msgid "Descriptors are invoked by the :meth:`~object.__getattribute__` method." msgstr "" -#: ../../howto/descriptor.rst:813 +#: ../../howto/descriptor.rst:816 msgid "" -"Classes inherit this machinery from :class:`object`, :class:`type`, or :func:" -"`super`." +"Classes inherit this machinery from :class:`object`, :class:`type`, " +"or :func:`super`." msgstr "" -#: ../../howto/descriptor.rst:816 +#: ../../howto/descriptor.rst:819 msgid "" -"Overriding :meth:`__getattribute__` prevents automatic descriptor calls " -"because all the descriptor logic is in that method." +"Overriding :meth:`~object.__getattribute__` prevents automatic descriptor " +"calls because all the descriptor logic is in that method." msgstr "" -#: ../../howto/descriptor.rst:819 +#: ../../howto/descriptor.rst:822 msgid "" -":meth:`object.__getattribute__` and :meth:`type.__getattribute__` make " -"different calls to :meth:`__get__`. The first includes the instance and may " -"include the class. The second puts in ``None`` for the instance and always " -"includes the class." +":meth:`!object.__getattribute__` and :meth:`!type.__getattribute__` make " +"different calls to :meth:`~object.__get__`. The first includes the instance " +"and may include the class. The second puts in ``None`` for the instance and " +"always includes the class." msgstr "" -#: ../../howto/descriptor.rst:824 +#: ../../howto/descriptor.rst:827 msgid "Data descriptors always override instance dictionaries." msgstr "" -#: ../../howto/descriptor.rst:826 +#: ../../howto/descriptor.rst:829 msgid "Non-data descriptors may be overridden by instance dictionaries." msgstr "" -#: ../../howto/descriptor.rst:830 +#: ../../howto/descriptor.rst:833 msgid "Automatic name notification" msgstr "" -#: ../../howto/descriptor.rst:832 +#: ../../howto/descriptor.rst:835 msgid "" "Sometimes it is desirable for a descriptor to know what class variable name " "it was assigned to. When a new class is created, the :class:`type` " "metaclass scans the dictionary of the new class. If any of the entries are " -"descriptors and if they define :meth:`__set_name__`, that method is called " -"with two arguments. The *owner* is the class where the descriptor is used, " -"and the *name* is the class variable the descriptor was assigned to." +"descriptors and if they define :meth:`~object.__set_name__`, that method is " +"called with two arguments. The *owner* is the class where the descriptor is " +"used, and the *name* is the class variable the descriptor was assigned to." msgstr "" -#: ../../howto/descriptor.rst:839 +#: ../../howto/descriptor.rst:842 msgid "" "The implementation details are in :c:func:`!type_new` and :c:func:`!" "set_names` in :source:`Objects/typeobject.c`." msgstr "" -#: ../../howto/descriptor.rst:842 +#: ../../howto/descriptor.rst:845 msgid "" -"Since the update logic is in :meth:`type.__new__`, notifications only take " +"Since the update logic is in :meth:`!type.__new__`, notifications only take " "place at the time of class creation. If descriptors are added to the class " -"afterwards, :meth:`__set_name__` will need to be called manually." +"afterwards, :meth:`~object.__set_name__` will need to be called manually." msgstr "" -#: ../../howto/descriptor.rst:848 +#: ../../howto/descriptor.rst:851 msgid "ORM example" msgstr "ORM 範例" -#: ../../howto/descriptor.rst:850 +#: ../../howto/descriptor.rst:853 msgid "" "The following code is a simplified skeleton showing how data descriptors " -"could be used to implement an `object relational mapping `_." +"could be used to implement an `object relational mapping `_." msgstr "" -#: ../../howto/descriptor.rst:854 +#: ../../howto/descriptor.rst:857 msgid "" "The essential idea is that the data is stored in an external database. The " "Python instances only hold keys to the database's tables. Descriptors take " "care of lookups or updates:" msgstr "" -#: ../../howto/descriptor.rst:858 +#: ../../howto/descriptor.rst:861 msgid "" "class Field:\n" "\n" @@ -1077,14 +1089,14 @@ msgstr "" " conn.execute(self.store, [value, obj.key])\n" " conn.commit()" -#: ../../howto/descriptor.rst:873 +#: ../../howto/descriptor.rst:876 msgid "" -"We can use the :class:`Field` class to define `models `_ that describe the schema for each table in a " -"database:" +"We can use the :class:`!Field` class to define `models `_ that describe the schema for each " +"table in a database:" msgstr "" -#: ../../howto/descriptor.rst:877 +#: ../../howto/descriptor.rst:880 msgid "" "class Movie:\n" " table = 'Movies' # Table name\n" @@ -1106,11 +1118,11 @@ msgid "" " self.key = key" msgstr "" -#: ../../howto/descriptor.rst:898 +#: ../../howto/descriptor.rst:901 msgid "To use the models, first connect to the database::" msgstr "" -#: ../../howto/descriptor.rst:900 +#: ../../howto/descriptor.rst:903 msgid "" ">>> import sqlite3\n" ">>> conn = sqlite3.connect('entertainment.db')" @@ -1118,13 +1130,13 @@ msgstr "" ">>> import sqlite3\n" ">>> conn = sqlite3.connect('entertainment.db')" -#: ../../howto/descriptor.rst:903 +#: ../../howto/descriptor.rst:906 msgid "" "An interactive session shows how data is retrieved from the database and how " "it can be updated:" msgstr "" -#: ../../howto/descriptor.rst:931 +#: ../../howto/descriptor.rst:934 msgid "" ">>> Movie('Star Wars').director\n" "'George Lucas'\n" @@ -1152,11 +1164,11 @@ msgstr "" ">>> Movie('Star Wars').director\n" "'J.J. Abrams'" -#: ../../howto/descriptor.rst:952 +#: ../../howto/descriptor.rst:955 msgid "Pure Python Equivalents" msgstr "" -#: ../../howto/descriptor.rst:954 +#: ../../howto/descriptor.rst:957 msgid "" "The descriptor protocol is simple and offers exciting possibilities. " "Several use cases are so common that they have been prepackaged into built-" @@ -1164,27 +1176,27 @@ msgid "" "\\_\\_slots\\_\\_ are all based on the descriptor protocol." msgstr "" -#: ../../howto/descriptor.rst:961 +#: ../../howto/descriptor.rst:964 msgid "Properties" msgstr "" -#: ../../howto/descriptor.rst:963 +#: ../../howto/descriptor.rst:966 msgid "" "Calling :func:`property` is a succinct way of building a data descriptor " "that triggers a function call upon access to an attribute. Its signature " "is::" msgstr "" -#: ../../howto/descriptor.rst:966 +#: ../../howto/descriptor.rst:969 msgid "property(fget=None, fset=None, fdel=None, doc=None) -> property" msgstr "property(fget=None, fset=None, fdel=None, doc=None) -> property" -#: ../../howto/descriptor.rst:968 +#: ../../howto/descriptor.rst:971 msgid "" "The documentation shows a typical use to define a managed attribute ``x``:" msgstr "" -#: ../../howto/descriptor.rst:970 +#: ../../howto/descriptor.rst:973 msgid "" "class C:\n" " def getx(self): return self.__x\n" @@ -1198,13 +1210,14 @@ msgstr "" " def delx(self): del self.__x\n" " x = property(getx, setx, delx, \"I'm the 'x' property.\")" -#: ../../howto/descriptor.rst:992 +#: ../../howto/descriptor.rst:995 msgid "" "To see how :func:`property` is implemented in terms of the descriptor " -"protocol, here is a pure Python equivalent:" +"protocol, here is a pure Python equivalent that implements most of the core " +"functionality:" msgstr "" -#: ../../howto/descriptor.rst:995 +#: ../../howto/descriptor.rst:998 msgid "" "class Property:\n" " \"Emulate PyProperty_Type() in Objects/descrobject.c\"\n" @@ -1216,61 +1229,45 @@ msgid "" " if doc is None and fget is not None:\n" " doc = fget.__doc__\n" " self.__doc__ = doc\n" -" self._name = ''\n" "\n" " def __set_name__(self, owner, name):\n" -" self._name = name\n" +" self.__name__ = name\n" "\n" " def __get__(self, obj, objtype=None):\n" " if obj is None:\n" " return self\n" " if self.fget is None:\n" -" raise AttributeError(\n" -" f'property {self._name!r} of {type(obj).__name__!r} object " -"has no getter'\n" -" )\n" +" raise AttributeError\n" " return self.fget(obj)\n" "\n" " def __set__(self, obj, value):\n" " if self.fset is None:\n" -" raise AttributeError(\n" -" f'property {self._name!r} of {type(obj).__name__!r} object " -"has no setter'\n" -" )\n" +" raise AttributeError\n" " self.fset(obj, value)\n" "\n" " def __delete__(self, obj):\n" " if self.fdel is None:\n" -" raise AttributeError(\n" -" f'property {self._name!r} of {type(obj).__name__!r} object " -"has no deleter'\n" -" )\n" +" raise AttributeError\n" " self.fdel(obj)\n" "\n" " def getter(self, fget):\n" -" prop = type(self)(fget, self.fset, self.fdel, self.__doc__)\n" -" prop._name = self._name\n" -" return prop\n" +" return type(self)(fget, self.fset, self.fdel, self.__doc__)\n" "\n" " def setter(self, fset):\n" -" prop = type(self)(self.fget, fset, self.fdel, self.__doc__)\n" -" prop._name = self._name\n" -" return prop\n" +" return type(self)(self.fget, fset, self.fdel, self.__doc__)\n" "\n" " def deleter(self, fdel):\n" -" prop = type(self)(self.fget, self.fset, fdel, self.__doc__)\n" -" prop._name = self._name\n" -" return prop" +" return type(self)(self.fget, self.fset, fdel, self.__doc__)" msgstr "" -#: ../../howto/descriptor.rst:1132 +#: ../../howto/descriptor.rst:1122 msgid "" "The :func:`property` builtin helps whenever a user interface has granted " "attribute access and then subsequent changes require the intervention of a " "method." msgstr "" -#: ../../howto/descriptor.rst:1136 +#: ../../howto/descriptor.rst:1126 msgid "" "For instance, a spreadsheet class may grant access to a cell value through " "``Cell('b10').value``. Subsequent improvements to the program require the " @@ -1280,7 +1277,7 @@ msgid "" "descriptor:" msgstr "" -#: ../../howto/descriptor.rst:1142 +#: ../../howto/descriptor.rst:1132 msgid "" "class Cell:\n" " ...\n" @@ -1292,23 +1289,23 @@ msgid "" " return self._value" msgstr "" -#: ../../howto/descriptor.rst:1153 +#: ../../howto/descriptor.rst:1143 msgid "" -"Either the built-in :func:`property` or our :func:`Property` equivalent " +"Either the built-in :func:`property` or our :func:`!Property` equivalent " "would work in this example." msgstr "" -#: ../../howto/descriptor.rst:1158 +#: ../../howto/descriptor.rst:1148 msgid "Functions and methods" msgstr "" -#: ../../howto/descriptor.rst:1160 +#: ../../howto/descriptor.rst:1150 msgid "" "Python's object oriented features are built upon a function based " "environment. Using non-data descriptors, the two are merged seamlessly." msgstr "" -#: ../../howto/descriptor.rst:1163 +#: ../../howto/descriptor.rst:1153 msgid "" "Functions stored in class dictionaries get turned into methods when invoked. " "Methods only differ from regular functions in that the object instance is " @@ -1316,13 +1313,13 @@ msgid "" "*self* but could be called *this* or any other variable name." msgstr "" -#: ../../howto/descriptor.rst:1168 +#: ../../howto/descriptor.rst:1158 msgid "" "Methods can be created manually with :class:`types.MethodType` which is " "roughly equivalent to:" msgstr "" -#: ../../howto/descriptor.rst:1171 +#: ../../howto/descriptor.rst:1161 msgid "" "class MethodType:\n" " \"Emulate PyMethod_Type in Objects/classobject.c\"\n" @@ -1334,18 +1331,32 @@ msgid "" " def __call__(self, *args, **kwargs):\n" " func = self.__func__\n" " obj = self.__self__\n" -" return func(obj, *args, **kwargs)" +" return func(obj, *args, **kwargs)\n" +"\n" +" def __getattribute__(self, name):\n" +" \"Emulate method_getset() in Objects/classobject.c\"\n" +" if name == '__doc__':\n" +" return self.__func__.__doc__\n" +" return object.__getattribute__(self, name)\n" +"\n" +" def __getattr__(self, name):\n" +" \"Emulate method_getattro() in Objects/classobject.c\"\n" +" return getattr(self.__func__, name)\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" \"Emulate method_descr_get() in Objects/classobject.c\"\n" +" return self" msgstr "" -#: ../../howto/descriptor.rst:1185 +#: ../../howto/descriptor.rst:1189 msgid "" -"To support automatic creation of methods, functions include the :meth:" -"`__get__` method for binding methods during attribute access. This means " -"that functions are non-data descriptors that return bound methods during " -"dotted lookup from an instance. Here's how it works:" +"To support automatic creation of methods, functions include " +"the :meth:`~object.__get__` method for binding methods during attribute " +"access. This means that functions are non-data descriptors that return " +"bound methods during dotted lookup from an instance. Here's how it works:" msgstr "" -#: ../../howto/descriptor.rst:1190 +#: ../../howto/descriptor.rst:1194 msgid "" "class Function:\n" " ...\n" @@ -1357,28 +1368,34 @@ msgid "" " return MethodType(self, obj)" msgstr "" -#: ../../howto/descriptor.rst:1201 +#: ../../howto/descriptor.rst:1205 msgid "" "Running the following class in the interpreter shows how the function " "descriptor works in practice:" msgstr "" -#: ../../howto/descriptor.rst:1204 +#: ../../howto/descriptor.rst:1208 msgid "" "class D:\n" -" def f(self, x):\n" -" return x" +" def f(self):\n" +" return self\n" +"\n" +"class D2:\n" +" pass" msgstr "" "class D:\n" -" def f(self, x):\n" -" return x" +" def f(self):\n" +" return self\n" +"\n" +"class D2:\n" +" pass" -#: ../../howto/descriptor.rst:1210 +#: ../../howto/descriptor.rst:1226 msgid "" "The function has a :term:`qualified name` attribute to support introspection:" msgstr "" -#: ../../howto/descriptor.rst:1212 +#: ../../howto/descriptor.rst:1228 msgid "" ">>> D.f.__qualname__\n" "'D.f'" @@ -1386,13 +1403,14 @@ msgstr "" ">>> D.f.__qualname__\n" "'D.f'" -#: ../../howto/descriptor.rst:1217 +#: ../../howto/descriptor.rst:1233 msgid "" -"Accessing the function through the class dictionary does not invoke :meth:" -"`__get__`. Instead, it just returns the underlying function object::" +"Accessing the function through the class dictionary does not " +"invoke :meth:`~object.__get__`. Instead, it just returns the underlying " +"function object::" msgstr "" -#: ../../howto/descriptor.rst:1220 +#: ../../howto/descriptor.rst:1236 msgid "" ">>> D.__dict__['f']\n" "" @@ -1400,13 +1418,13 @@ msgstr "" ">>> D.__dict__['f']\n" "" -#: ../../howto/descriptor.rst:1223 +#: ../../howto/descriptor.rst:1239 msgid "" -"Dotted access from a class calls :meth:`__get__` which just returns the " -"underlying function unchanged::" +"Dotted access from a class calls :meth:`~object.__get__` which just returns " +"the underlying function unchanged::" msgstr "" -#: ../../howto/descriptor.rst:1226 +#: ../../howto/descriptor.rst:1242 msgid "" ">>> D.f\n" "" @@ -1414,13 +1432,14 @@ msgstr "" ">>> D.f\n" "" -#: ../../howto/descriptor.rst:1229 +#: ../../howto/descriptor.rst:1245 msgid "" "The interesting behavior occurs during dotted access from an instance. The " -"dotted lookup calls :meth:`__get__` which returns a bound method object::" +"dotted lookup calls :meth:`~object.__get__` which returns a bound method " +"object::" msgstr "" -#: ../../howto/descriptor.rst:1232 +#: ../../howto/descriptor.rst:1248 msgid "" ">>> d = D()\n" ">>> d.f\n" @@ -1430,13 +1449,13 @@ msgstr "" ">>> d.f\n" ">" -#: ../../howto/descriptor.rst:1236 +#: ../../howto/descriptor.rst:1252 msgid "" "Internally, the bound method stores the underlying function and the bound " "instance::" msgstr "" -#: ../../howto/descriptor.rst:1239 +#: ../../howto/descriptor.rst:1255 msgid "" ">>> d.f.__func__\n" "\n" @@ -1450,94 +1469,94 @@ msgstr "" ">>> d.f.__self__\n" "<__main__.D object at 0x00B18C90>" -#: ../../howto/descriptor.rst:1245 +#: ../../howto/descriptor.rst:1261 msgid "" "If you have ever wondered where *self* comes from in regular methods or " "where *cls* comes from in class methods, this is it!" msgstr "" -#: ../../howto/descriptor.rst:1250 +#: ../../howto/descriptor.rst:1266 msgid "Kinds of methods" msgstr "" -#: ../../howto/descriptor.rst:1252 +#: ../../howto/descriptor.rst:1268 msgid "" "Non-data descriptors provide a simple mechanism for variations on the usual " "patterns of binding functions into methods." msgstr "" -#: ../../howto/descriptor.rst:1255 +#: ../../howto/descriptor.rst:1271 msgid "" -"To recap, functions have a :meth:`__get__` method so that they can be " -"converted to a method when accessed as attributes. The non-data descriptor " -"transforms an ``obj.f(*args)`` call into ``f(obj, *args)``. Calling ``cls." -"f(*args)`` becomes ``f(*args)``." +"To recap, functions have a :meth:`~object.__get__` method so that they can " +"be converted to a method when accessed as attributes. The non-data " +"descriptor transforms an ``obj.f(*args)`` call into ``f(obj, *args)``. " +"Calling ``cls.f(*args)`` becomes ``f(*args)``." msgstr "" -#: ../../howto/descriptor.rst:1260 +#: ../../howto/descriptor.rst:1276 msgid "This chart summarizes the binding and its two most useful variants:" msgstr "" -#: ../../howto/descriptor.rst:1263 +#: ../../howto/descriptor.rst:1279 msgid "Transformation" msgstr "" -#: ../../howto/descriptor.rst:1263 +#: ../../howto/descriptor.rst:1279 msgid "Called from an object" msgstr "" -#: ../../howto/descriptor.rst:1263 +#: ../../howto/descriptor.rst:1279 msgid "Called from a class" msgstr "" -#: ../../howto/descriptor.rst:1266 +#: ../../howto/descriptor.rst:1282 msgid "function" msgstr "函式" -#: ../../howto/descriptor.rst:1266 +#: ../../howto/descriptor.rst:1282 msgid "f(obj, \\*args)" msgstr "f(obj, \\*args)" -#: ../../howto/descriptor.rst:1266 ../../howto/descriptor.rst:1268 +#: ../../howto/descriptor.rst:1282 ../../howto/descriptor.rst:1284 msgid "f(\\*args)" msgstr "f(\\*args)" -#: ../../howto/descriptor.rst:1268 +#: ../../howto/descriptor.rst:1284 msgid "staticmethod" msgstr "staticmethod" -#: ../../howto/descriptor.rst:1270 +#: ../../howto/descriptor.rst:1286 msgid "classmethod" msgstr "classmethod" -#: ../../howto/descriptor.rst:1270 +#: ../../howto/descriptor.rst:1286 msgid "f(type(obj), \\*args)" msgstr "f(type(obj), \\*args)" -#: ../../howto/descriptor.rst:1270 +#: ../../howto/descriptor.rst:1286 msgid "f(cls, \\*args)" msgstr "f(cls, \\*args)" -#: ../../howto/descriptor.rst:1275 +#: ../../howto/descriptor.rst:1291 msgid "Static methods" msgstr "" -#: ../../howto/descriptor.rst:1277 +#: ../../howto/descriptor.rst:1293 msgid "" "Static methods return the underlying function without changes. Calling " -"either ``c.f`` or ``C.f`` is the equivalent of a direct lookup into ``object." -"__getattribute__(c, \"f\")`` or ``object.__getattribute__(C, \"f\")``. As a " -"result, the function becomes identically accessible from either an object or " -"a class." +"either ``c.f`` or ``C.f`` is the equivalent of a direct lookup into " +"``object.__getattribute__(c, \"f\")`` or ``object.__getattribute__(C, " +"\"f\")``. As a result, the function becomes identically accessible from " +"either an object or a class." msgstr "" -#: ../../howto/descriptor.rst:1283 +#: ../../howto/descriptor.rst:1299 msgid "" "Good candidates for static methods are methods that do not reference the " "``self`` variable." msgstr "" -#: ../../howto/descriptor.rst:1286 +#: ../../howto/descriptor.rst:1302 msgid "" "For instance, a statistics package may include a container class for " "experimental data. The class provides normal methods for computing the " @@ -1546,16 +1565,16 @@ msgid "" "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) --> .9332`` or ``Sample.erf(1.5) --> .9332``." +"``s.erf(1.5) --> 0.9332`` or ``Sample.erf(1.5) --> 0.9332``." msgstr "" -#: ../../howto/descriptor.rst:1295 +#: ../../howto/descriptor.rst:1311 msgid "" "Since static methods return the underlying function with no changes, the " "example calls are unexciting:" msgstr "" -#: ../../howto/descriptor.rst:1298 +#: ../../howto/descriptor.rst:1314 msgid "" "class E:\n" " @staticmethod\n" @@ -1567,7 +1586,7 @@ msgstr "" " def f(x):\n" " return x * 10" -#: ../../howto/descriptor.rst:1305 +#: ../../howto/descriptor.rst:1321 msgid "" ">>> E.f(3)\n" "30\n" @@ -1579,13 +1598,13 @@ msgstr "" ">>> E().f(3)\n" "30" -#: ../../howto/descriptor.rst:1312 +#: ../../howto/descriptor.rst:1328 msgid "" -"Using the non-data descriptor protocol, a pure Python version of :func:" -"`staticmethod` would look like this:" +"Using the non-data descriptor protocol, a pure Python version " +"of :func:`staticmethod` would look like this:" msgstr "" -#: ../../howto/descriptor.rst:1315 +#: ../../howto/descriptor.rst:1331 msgid "" "import functools\n" "\n" @@ -1603,27 +1622,27 @@ msgid "" " return self.f(*args, **kwds)" msgstr "" -#: ../../howto/descriptor.rst:1332 +#: ../../howto/descriptor.rst:1348 msgid "" "The :func:`functools.update_wrapper` call adds a ``__wrapped__`` attribute " "that refers to the underlying function. Also it carries forward the " -"attributes necessary to make the wrapper look like the wrapped function: :" -"attr:`~function.__name__`, :attr:`~function.__qualname__`, :attr:`~function." -"__doc__`, and :attr:`~function.__annotations__`." +"attributes necessary to make the wrapper look like the wrapped " +"function: :attr:`~function.__name__`, :attr:`~function.__qualname__`, :attr:`~function.__doc__`, " +"and :attr:`~function.__annotations__`." msgstr "" -#: ../../howto/descriptor.rst:1401 +#: ../../howto/descriptor.rst:1417 msgid "Class methods" msgstr "" -#: ../../howto/descriptor.rst:1403 +#: ../../howto/descriptor.rst:1419 msgid "" "Unlike static methods, class methods prepend the class reference to the " "argument list before calling the function. This format is the same for " "whether the caller is an object or a class:" msgstr "" -#: ../../howto/descriptor.rst:1407 +#: ../../howto/descriptor.rst:1423 msgid "" "class F:\n" " @classmethod\n" @@ -1635,7 +1654,7 @@ msgstr "" " def f(cls, x):\n" " return cls.__name__, x" -#: ../../howto/descriptor.rst:1414 +#: ../../howto/descriptor.rst:1430 msgid "" ">>> F.f(3)\n" "('F', 3)\n" @@ -1647,7 +1666,7 @@ msgstr "" ">>> F().f(3)\n" "('F', 3)" -#: ../../howto/descriptor.rst:1421 +#: ../../howto/descriptor.rst:1437 msgid "" "This behavior is useful whenever the method only needs to have a class " "reference and does not rely on data stored in a specific instance. One use " @@ -1656,7 +1675,7 @@ msgid "" "of keys. The pure Python equivalent is:" msgstr "" -#: ../../howto/descriptor.rst:1427 +#: ../../howto/descriptor.rst:1443 msgid "" "class Dict(dict):\n" " @classmethod\n" @@ -1668,11 +1687,11 @@ msgid "" " return d" msgstr "" -#: ../../howto/descriptor.rst:1438 +#: ../../howto/descriptor.rst:1454 msgid "Now a new dictionary of unique keys can be constructed like this:" msgstr "" -#: ../../howto/descriptor.rst:1440 +#: ../../howto/descriptor.rst:1456 msgid "" ">>> d = Dict.fromkeys('abracadabra')\n" ">>> type(d) is Dict\n" @@ -1686,13 +1705,13 @@ msgstr "" ">>> d\n" "{'a': None, 'b': None, 'r': None, 'c': None, 'd': None}" -#: ../../howto/descriptor.rst:1448 +#: ../../howto/descriptor.rst:1464 msgid "" -"Using the non-data descriptor protocol, a pure Python version of :func:" -"`classmethod` would look like this:" +"Using the non-data descriptor protocol, a pure Python version " +"of :func:`classmethod` would look like this:" msgstr "" -#: ../../howto/descriptor.rst:1451 +#: ../../howto/descriptor.rst:1467 msgid "" "import functools\n" "\n" @@ -1706,71 +1725,37 @@ msgid "" " def __get__(self, obj, cls=None):\n" " if cls is None:\n" " cls = type(obj)\n" -" if hasattr(type(self.f), '__get__'):\n" -" # This code path was added in Python 3.9\n" -" # and was deprecated in Python 3.11.\n" -" return self.f.__get__(cls, cls)\n" " return MethodType(self.f, cls)" msgstr "" -#: ../../howto/descriptor.rst:1526 -msgid "" -"The code path for ``hasattr(type(self.f), '__get__')`` was added in Python " -"3.9 and makes it possible for :func:`classmethod` to support chained " -"decorators. For example, a classmethod and property could be chained " -"together. In Python 3.11, this functionality was deprecated." -msgstr "" - -#: ../../howto/descriptor.rst:1531 -msgid "" -"class G:\n" -" @classmethod\n" -" @property\n" -" def __doc__(cls):\n" -" return f'A doc for {cls.__name__!r}'" -msgstr "" -"class G:\n" -" @classmethod\n" -" @property\n" -" def __doc__(cls):\n" -" return f'A doc for {cls.__name__!r}'" - -#: ../../howto/descriptor.rst:1539 -msgid "" -">>> G.__doc__\n" -"\"A doc for 'G'\"" -msgstr "" -">>> G.__doc__\n" -"\"A doc for 'G'\"" - -#: ../../howto/descriptor.rst:1544 +#: ../../howto/descriptor.rst:1529 msgid "" "The :func:`functools.update_wrapper` call in ``ClassMethod`` adds a " "``__wrapped__`` attribute that refers to the underlying function. Also it " "carries forward the attributes necessary to make the wrapper look like the " -"wrapped function: :attr:`~function.__name__`, :attr:`~function." -"__qualname__`, :attr:`~function.__doc__`, and :attr:`~function." -"__annotations__`." +"wrapped " +"function: :attr:`~function.__name__`, :attr:`~function.__qualname__`, :attr:`~function.__doc__`, " +"and :attr:`~function.__annotations__`." msgstr "" -#: ../../howto/descriptor.rst:1553 +#: ../../howto/descriptor.rst:1538 msgid "Member objects and __slots__" msgstr "" -#: ../../howto/descriptor.rst:1555 +#: ../../howto/descriptor.rst:1540 msgid "" "When a class defines ``__slots__``, it replaces instance dictionaries with a " "fixed-length array of slot values. From a user point of view that has " "several effects:" msgstr "" -#: ../../howto/descriptor.rst:1559 +#: ../../howto/descriptor.rst:1544 msgid "" "1. Provides immediate detection of bugs due to misspelled attribute " "assignments. Only attribute names specified in ``__slots__`` are allowed:" msgstr "" -#: ../../howto/descriptor.rst:1562 +#: ../../howto/descriptor.rst:1547 msgid "" "class Vehicle:\n" " __slots__ = ('id_number', 'make', 'model')" @@ -1778,7 +1763,7 @@ msgstr "" "class Vehicle:\n" " __slots__ = ('id_number', 'make', 'model')" -#: ../../howto/descriptor.rst:1567 +#: ../../howto/descriptor.rst:1552 msgid "" ">>> auto = Vehicle()\n" ">>> auto.id_nubmer = 'VYE483814LQEX'\n" @@ -1792,13 +1777,13 @@ msgstr "" " ...\n" "AttributeError: 'Vehicle' object has no attribute 'id_nubmer'" -#: ../../howto/descriptor.rst:1575 +#: ../../howto/descriptor.rst:1560 msgid "" "2. Helps create immutable objects where descriptors manage access to private " "attributes stored in ``__slots__``:" msgstr "" -#: ../../howto/descriptor.rst:1578 +#: ../../howto/descriptor.rst:1563 msgid "" "class Immutable:\n" "\n" @@ -1818,7 +1803,7 @@ msgid "" " return self._name" msgstr "" -#: ../../howto/descriptor.rst:1596 +#: ../../howto/descriptor.rst:1581 msgid "" ">>> mark = Immutable('Botany', 'Mark Watney')\n" ">>> mark.dept\n" @@ -1844,7 +1829,7 @@ msgstr "" " ...\n" "AttributeError: 'Immutable' object has no attribute 'location'" -#: ../../howto/descriptor.rst:1610 +#: ../../howto/descriptor.rst:1595 msgid "" "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 " @@ -1852,19 +1837,19 @@ msgid "" "only matters when a large number of instances are going to be created." msgstr "" -#: ../../howto/descriptor.rst:1615 +#: ../../howto/descriptor.rst:1600 msgid "" "4. Improves speed. Reading instance variables is 35% faster with " "``__slots__`` (as measured with Python 3.10 on an Apple M1 processor)." msgstr "" -#: ../../howto/descriptor.rst:1618 +#: ../../howto/descriptor.rst:1603 msgid "" "5. Blocks tools like :func:`functools.cached_property` which require an " "instance dictionary to function correctly:" msgstr "" -#: ../../howto/descriptor.rst:1621 +#: ../../howto/descriptor.rst:1606 msgid "" "from functools import cached_property\n" "\n" @@ -1877,7 +1862,7 @@ msgid "" " for n in reversed(range(100_000)))" msgstr "" -#: ../../howto/descriptor.rst:1633 +#: ../../howto/descriptor.rst:1618 msgid "" ">>> CP().pi\n" "Traceback (most recent call last):\n" @@ -1889,7 +1874,7 @@ msgstr "" " ...\n" "TypeError: No '__dict__' attribute on 'CP' instance to cache 'pi' property." -#: ../../howto/descriptor.rst:1640 +#: ../../howto/descriptor.rst:1625 msgid "" "It is not possible to create an exact drop-in pure Python version of " "``__slots__`` because it requires direct access to C structures and control " @@ -1899,7 +1884,7 @@ msgid "" "managed by member descriptors:" msgstr "" -#: ../../howto/descriptor.rst:1647 +#: ../../howto/descriptor.rst:1632 msgid "" "null = object()\n" "\n" @@ -1938,13 +1923,13 @@ msgid "" " return f''" msgstr "" -#: ../../howto/descriptor.rst:1685 +#: ../../howto/descriptor.rst:1670 msgid "" -"The :meth:`type.__new__` method takes care of adding member objects to class " -"variables:" +"The :meth:`!type.__new__` method takes care of adding member objects to " +"class variables:" msgstr "" -#: ../../howto/descriptor.rst:1688 +#: ../../howto/descriptor.rst:1673 msgid "" "class Type(type):\n" " 'Simulate how the type metaclass adds member objects for slots'\n" @@ -1958,14 +1943,14 @@ msgid "" " return type.__new__(mcls, clsname, bases, mapping, **kwargs)" msgstr "" -#: ../../howto/descriptor.rst:1701 +#: ../../howto/descriptor.rst:1686 msgid "" "The :meth:`object.__new__` method takes care of creating instances that have " "slots instead of an instance dictionary. Here is a rough simulation in pure " "Python:" msgstr "" -#: ../../howto/descriptor.rst:1705 +#: ../../howto/descriptor.rst:1690 msgid "" "class Object:\n" " 'Simulate how object.__new__() allocates memory for __slots__'\n" @@ -1997,13 +1982,13 @@ msgid "" " super().__delattr__(name)" msgstr "" -#: ../../howto/descriptor.rst:1736 +#: ../../howto/descriptor.rst:1721 msgid "" -"To use the simulation in a real class, just inherit from :class:`Object` and " -"set the :term:`metaclass` to :class:`Type`:" +"To use the simulation in a real class, just inherit from :class:`!Object` " +"and set the :term:`metaclass` to :class:`Type`:" msgstr "" -#: ../../howto/descriptor.rst:1739 +#: ../../howto/descriptor.rst:1724 msgid "" "class H(Object, metaclass=Type):\n" " 'Instance variables stored in slots'\n" @@ -2015,12 +2000,12 @@ msgid "" " self.y = y" msgstr "" -#: ../../howto/descriptor.rst:1750 +#: ../../howto/descriptor.rst:1735 msgid "" "At this point, the metaclass has loaded member objects for *x* and *y*::" msgstr "" -#: ../../howto/descriptor.rst:1752 +#: ../../howto/descriptor.rst:1737 msgid "" ">>> from pprint import pp\n" ">>> pp(dict(vars(H)))\n" @@ -2040,13 +2025,13 @@ msgstr "" " 'x': ,\n" " 'y': }" -#: ../../howto/descriptor.rst:1771 +#: ../../howto/descriptor.rst:1756 msgid "" "When instances are created, they have a ``slot_values`` list where the " "attributes are stored:" msgstr "" -#: ../../howto/descriptor.rst:1774 +#: ../../howto/descriptor.rst:1759 msgid "" ">>> h = H(10, 20)\n" ">>> vars(h)\n" @@ -2062,11 +2047,11 @@ msgstr "" ">>> vars(h)\n" "{'_slotvalues': [55, 20]}" -#: ../../howto/descriptor.rst:1783 +#: ../../howto/descriptor.rst:1768 msgid "Misspelled or unassigned attributes will raise an exception:" msgstr "" -#: ../../howto/descriptor.rst:1785 +#: ../../howto/descriptor.rst:1770 msgid "" ">>> h.xz\n" "Traceback (most recent call last):\n" diff --git a/howto/enum.po b/howto/enum.po index e3434cb185..92490f02e6 100644 --- a/howto/enum.po +++ b/howto/enum.po @@ -1,40 +1,39 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. -# FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-02-19 00:13+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: ../../howto/enum.rst:3 +#: ../../howto/enum.rst:5 msgid "Enum HOWTO" msgstr "" -#: ../../howto/enum.rst:9 +#: ../../howto/enum.rst:11 msgid "" "An :class:`Enum` is a set of symbolic names bound to unique values. They " "are similar to global variables, but they offer a more useful :func:`repr`, " "grouping, type-safety, and a few other features." msgstr "" -#: ../../howto/enum.rst:13 +#: ../../howto/enum.rst:15 msgid "" "They are most useful when you have a variable that can take one of a limited " "selection of values. For example, the days of the week::" msgstr "" -#: ../../howto/enum.rst:16 +#: ../../howto/enum.rst:18 msgid "" ">>> from enum import Enum\n" ">>> class Weekday(Enum):\n" @@ -47,11 +46,11 @@ msgid "" "... SUNDAY = 7" msgstr "" -#: ../../howto/enum.rst:26 +#: ../../howto/enum.rst:28 msgid "Or perhaps the RGB primary colors::" msgstr "" -#: ../../howto/enum.rst:28 +#: ../../howto/enum.rst:30 msgid "" ">>> from enum import Enum\n" ">>> class Color(Enum):\n" @@ -60,17 +59,17 @@ msgid "" "... BLUE = 3" msgstr "" -#: ../../howto/enum.rst:34 +#: ../../howto/enum.rst:36 msgid "" "As you can see, creating an :class:`Enum` is as simple as writing a class " "that inherits from :class:`Enum` itself." msgstr "" -#: ../../howto/enum.rst:37 +#: ../../howto/enum.rst:39 msgid "Case of Enum Members" msgstr "" -#: ../../howto/enum.rst:39 +#: ../../howto/enum.rst:41 msgid "" "Because Enums are used to represent constants, and to help avoid issues with " "name clashes between mixin-class methods/attributes and enum names, we " @@ -78,14 +77,14 @@ msgid "" "that style in our examples." msgstr "" -#: ../../howto/enum.rst:44 +#: ../../howto/enum.rst:46 msgid "" "Depending on the nature of the enum a member's value may or may not be " "important, but either way that value can be used to get the corresponding " "member::" msgstr "" -#: ../../howto/enum.rst:48 +#: ../../howto/enum.rst:50 msgid "" ">>> Weekday(3)\n" "" @@ -93,14 +92,14 @@ msgstr "" ">>> Weekday(3)\n" "" -#: ../../howto/enum.rst:51 +#: ../../howto/enum.rst:53 msgid "" "As you can see, the ``repr()`` of a member shows the enum name, the member " "name, and the value. The ``str()`` of a member shows only the enum name and " "member name::" msgstr "" -#: ../../howto/enum.rst:55 +#: ../../howto/enum.rst:57 msgid "" ">>> print(Weekday.THURSDAY)\n" "Weekday.THURSDAY" @@ -108,23 +107,30 @@ msgstr "" ">>> print(Weekday.THURSDAY)\n" "Weekday.THURSDAY" -#: ../../howto/enum.rst:58 +#: ../../howto/enum.rst:60 msgid "The *type* of an enumeration member is the enum it belongs to::" msgstr "" -#: ../../howto/enum.rst:60 +#: ../../howto/enum.rst:62 msgid "" ">>> type(Weekday.MONDAY)\n" "\n" ">>> isinstance(Weekday.FRIDAY, Weekday)\n" "True" msgstr "" +">>> type(Weekday.MONDAY)\n" +"\n" +">>> isinstance(Weekday.FRIDAY, Weekday)\n" +"True>>> type(Weekday.MONDAY)\n" +"\n" +">>> isinstance(Weekday.FRIDAY, Weekday)\n" +"True" -#: ../../howto/enum.rst:65 -msgid "Enum members have an attribute that contains just their :attr:`name`::" +#: ../../howto/enum.rst:67 +msgid "Enum members have an attribute that contains just their :attr:`!name`::" msgstr "" -#: ../../howto/enum.rst:67 +#: ../../howto/enum.rst:69 msgid "" ">>> print(Weekday.TUESDAY.name)\n" "TUESDAY" @@ -132,11 +138,11 @@ msgstr "" ">>> print(Weekday.TUESDAY.name)\n" "TUESDAY" -#: ../../howto/enum.rst:70 -msgid "Likewise, they have an attribute for their :attr:`value`::" +#: ../../howto/enum.rst:72 +msgid "Likewise, they have an attribute for their :attr:`!value`::" msgstr "" -#: ../../howto/enum.rst:73 +#: ../../howto/enum.rst:75 msgid "" ">>> Weekday.WEDNESDAY.value\n" "3" @@ -144,29 +150,33 @@ msgstr "" ">>> Weekday.WEDNESDAY.value\n" "3" -#: ../../howto/enum.rst:76 +#: ../../howto/enum.rst:78 msgid "" "Unlike many languages that treat enumerations solely as name/value pairs, " "Python Enums can have behavior added. For example, :class:`datetime.date` " -"has two methods for returning the weekday: :meth:`weekday` and :meth:" -"`isoweekday`. The difference is that one of them counts from 0-6 and the " -"other from 1-7. Rather than keep track of that ourselves we can add a method " -"to the :class:`Weekday` enum to extract the day from the :class:`date` " -"instance and return the matching enum member::" +"has two methods for returning the weekday: :meth:`~datetime.date.weekday` " +"and :meth:`~datetime.date.isoweekday`. The difference is that one of them " +"counts from 0-6 and the other from 1-7. Rather than keep track of that " +"ourselves we can add a method to the :class:`!Weekday` enum to extract the " +"day from the :class:`~datetime.date` instance and return the matching enum " +"member::" msgstr "" -#: ../../howto/enum.rst:84 +#: ../../howto/enum.rst:87 msgid "" "@classmethod\n" "def from_date(cls, date):\n" " return cls(date.isoweekday())" msgstr "" +"@classmethod\n" +"def from_date(cls, date):\n" +" return cls(date.isoweekday())" -#: ../../howto/enum.rst:88 -msgid "The complete :class:`Weekday` enum now looks like this::" +#: ../../howto/enum.rst:91 +msgid "The complete :class:`!Weekday` enum now looks like this::" msgstr "" -#: ../../howto/enum.rst:90 +#: ../../howto/enum.rst:93 msgid "" ">>> class Weekday(Enum):\n" "... MONDAY = 1\n" @@ -194,32 +204,35 @@ msgstr "" "... def from_date(cls, date):\n" "... return cls(date.isoweekday())" -#: ../../howto/enum.rst:103 +#: ../../howto/enum.rst:106 msgid "Now we can find out what today is! Observe::" msgstr "" -#: ../../howto/enum.rst:105 +#: ../../howto/enum.rst:108 msgid "" ">>> from datetime import date\n" -">>> Weekday.from_date(date.today()) \n" +">>> Weekday.from_date(date.today())\n" "" msgstr "" +">>> from datetime import date\n" +">>> Weekday.from_date(date.today())\n" +"" -#: ../../howto/enum.rst:109 +#: ../../howto/enum.rst:112 msgid "" "Of course, if you're reading this on some other day, you'll see that day " "instead." msgstr "" -#: ../../howto/enum.rst:111 +#: ../../howto/enum.rst:114 msgid "" -"This :class:`Weekday` enum is great if our variable only needs one day, but " +"This :class:`!Weekday` enum is great if our variable only needs one day, but " "what if we need several? Maybe we're writing a function to plot chores " "during a week, and don't want to use a :class:`list` -- we could use a " "different type of :class:`Enum`::" msgstr "" -#: ../../howto/enum.rst:116 +#: ../../howto/enum.rst:119 msgid "" ">>> from enum import Flag\n" ">>> class Weekday(Flag):\n" @@ -241,19 +254,19 @@ msgstr "" "... SATURDAY = 32\n" "... SUNDAY = 64" -#: ../../howto/enum.rst:126 +#: ../../howto/enum.rst:129 msgid "" "We've changed two things: we're inherited from :class:`Flag`, and the values " "are all powers of 2." msgstr "" -#: ../../howto/enum.rst:129 +#: ../../howto/enum.rst:132 msgid "" -"Just like the original :class:`Weekday` enum above, we can have a single " +"Just like the original :class:`!Weekday` enum above, we can have a single " "selection::" msgstr "" -#: ../../howto/enum.rst:131 +#: ../../howto/enum.rst:134 msgid "" ">>> first_week_day = Weekday.MONDAY\n" ">>> first_week_day\n" @@ -263,13 +276,13 @@ msgstr "" ">>> first_week_day\n" "" -#: ../../howto/enum.rst:135 +#: ../../howto/enum.rst:138 msgid "" "But :class:`Flag` also allows us to combine several members into a single " "variable::" msgstr "" -#: ../../howto/enum.rst:138 +#: ../../howto/enum.rst:141 msgid "" ">>> weekend = Weekday.SATURDAY | Weekday.SUNDAY\n" ">>> weekend\n" @@ -279,11 +292,11 @@ msgstr "" ">>> weekend\n" "" -#: ../../howto/enum.rst:142 +#: ../../howto/enum.rst:145 msgid "You can even iterate over a :class:`Flag` variable::" msgstr "" -#: ../../howto/enum.rst:144 +#: ../../howto/enum.rst:147 msgid "" ">>> for day in weekend:\n" "... print(day)\n" @@ -295,31 +308,31 @@ msgstr "" "Weekday.SATURDAY\n" "Weekday.SUNDAY" -#: ../../howto/enum.rst:149 +#: ../../howto/enum.rst:152 msgid "Okay, let's get some chores set up::" msgstr "" -#: ../../howto/enum.rst:151 +#: ../../howto/enum.rst:154 msgid "" ">>> chores_for_ethan = {\n" -"... 'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | Weekday." -"FRIDAY,\n" +"... 'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | " +"Weekday.FRIDAY,\n" "... 'do the dishes': Weekday.TUESDAY | Weekday.THURSDAY,\n" "... 'answer SO questions': Weekday.SATURDAY,\n" "... }" msgstr "" ">>> chores_for_ethan = {\n" -"... 'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | Weekday." -"FRIDAY,\n" +"... 'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | " +"Weekday.FRIDAY,\n" "... 'do the dishes': Weekday.TUESDAY | Weekday.THURSDAY,\n" "... 'answer SO questions': Weekday.SATURDAY,\n" "... }" -#: ../../howto/enum.rst:157 +#: ../../howto/enum.rst:160 msgid "And a function to display the chores for a given day::" msgstr "" -#: ../../howto/enum.rst:159 +#: ../../howto/enum.rst:162 msgid "" ">>> def show_chores(chores, day):\n" "... for chore, days in chores.items():\n" @@ -337,13 +350,13 @@ msgstr "" ">>> show_chores(chores_for_ethan, Weekday.SATURDAY)\n" "answer SO questions" -#: ../../howto/enum.rst:167 +#: ../../howto/enum.rst:170 msgid "" "In cases where the actual values of the members do not matter, you can save " "yourself some work and use :func:`auto` for the values::" msgstr "" -#: ../../howto/enum.rst:170 +#: ../../howto/enum.rst:173 msgid "" ">>> from enum import auto\n" ">>> class Weekday(Flag):\n" @@ -367,18 +380,18 @@ msgstr "" "... SUNDAY = auto()\n" "... WEEKEND = SATURDAY | SUNDAY" -#: ../../howto/enum.rst:186 +#: ../../howto/enum.rst:189 msgid "Programmatic access to enumeration members and their attributes" msgstr "" -#: ../../howto/enum.rst:188 +#: ../../howto/enum.rst:191 msgid "" -"Sometimes it's useful to access members in enumerations programmatically (i." -"e. situations where ``Color.RED`` won't do because the exact color is not " +"Sometimes it's useful to access members in enumerations programmatically " +"(i.e. situations where ``Color.RED`` won't do because the exact color is not " "known at program-writing time). ``Enum`` allows such access::" msgstr "" -#: ../../howto/enum.rst:192 +#: ../../howto/enum.rst:195 msgid "" ">>> Color(1)\n" "\n" @@ -390,11 +403,11 @@ msgstr "" ">>> Color(3)\n" "" -#: ../../howto/enum.rst:197 +#: ../../howto/enum.rst:200 msgid "If you want to access enum members by *name*, use item access::" msgstr "" -#: ../../howto/enum.rst:199 +#: ../../howto/enum.rst:202 msgid "" ">>> Color['RED']\n" "\n" @@ -406,11 +419,12 @@ msgstr "" ">>> Color['GREEN']\n" "" -#: ../../howto/enum.rst:204 -msgid "If you have an enum member and need its :attr:`name` or :attr:`value`::" +#: ../../howto/enum.rst:207 +msgid "" +"If you have an enum member and need its :attr:`!name` or :attr:`!value`::" msgstr "" -#: ../../howto/enum.rst:206 +#: ../../howto/enum.rst:209 msgid "" ">>> member = Color.RED\n" ">>> member.name\n" @@ -424,15 +438,15 @@ msgstr "" ">>> member.value\n" "1" -#: ../../howto/enum.rst:214 +#: ../../howto/enum.rst:217 msgid "Duplicating enum members and values" msgstr "" -#: ../../howto/enum.rst:216 +#: ../../howto/enum.rst:219 msgid "Having two enum members with the same name is invalid::" msgstr "" -#: ../../howto/enum.rst:218 +#: ../../howto/enum.rst:221 msgid "" ">>> class Shape(Enum):\n" "... SQUARE = 2\n" @@ -450,7 +464,7 @@ msgstr "" "...\n" "TypeError: 'SQUARE' already defined as 2" -#: ../../howto/enum.rst:226 +#: ../../howto/enum.rst:229 msgid "" "However, an enum member can have other names associated with it. Given two " "entries ``A`` and ``B`` with the same value (and ``A`` defined first), ``B`` " @@ -459,7 +473,7 @@ msgid "" "member ``A``. By-name lookup of ``B`` will also return the member ``A``::" msgstr "" -#: ../../howto/enum.rst:232 +#: ../../howto/enum.rst:235 msgid "" ">>> class Shape(Enum):\n" "... SQUARE = 2\n" @@ -487,24 +501,24 @@ msgstr "" ">>> Shape(2)\n" "" -#: ../../howto/enum.rst:247 +#: ../../howto/enum.rst:250 msgid "" "Attempting to create a member with the same name as an already defined " "attribute (another member, a method, etc.) or attempting to create an " "attribute with the same name as a member is not allowed." msgstr "" -#: ../../howto/enum.rst:253 +#: ../../howto/enum.rst:256 msgid "Ensuring unique enumeration values" msgstr "" -#: ../../howto/enum.rst:255 +#: ../../howto/enum.rst:258 msgid "" "By default, enumerations allow multiple names as aliases for the same value. " "When this behavior isn't desired, you can use the :func:`unique` decorator::" msgstr "" -#: ../../howto/enum.rst:258 +#: ../../howto/enum.rst:261 msgid "" ">>> from enum import Enum, unique\n" ">>> @unique\n" @@ -530,15 +544,15 @@ msgstr "" "...\n" "ValueError: duplicate values found in : FOUR -> THREE" -#: ../../howto/enum.rst:272 +#: ../../howto/enum.rst:275 msgid "Using automatic values" msgstr "" -#: ../../howto/enum.rst:274 +#: ../../howto/enum.rst:277 msgid "If the exact value is unimportant you can use :class:`auto`::" msgstr "" -#: ../../howto/enum.rst:276 +#: ../../howto/enum.rst:279 msgid "" ">>> from enum import Enum, auto\n" ">>> class Color(Enum):\n" @@ -558,13 +572,13 @@ msgstr "" ">>> [member.value for member in Color]\n" "[1, 2, 3]" -#: ../../howto/enum.rst:285 +#: ../../howto/enum.rst:288 msgid "" -"The values are chosen by :func:`_generate_next_value_`, which can be " +"The values are chosen by :func:`~Enum._generate_next_value_`, which can be " "overridden::" msgstr "" -#: ../../howto/enum.rst:288 +#: ../../howto/enum.rst:291 msgid "" ">>> class AutoName(Enum):\n" "... @staticmethod\n" @@ -594,49 +608,50 @@ msgstr "" ">>> [member.value for member in Ordinal]\n" "['NORTH', 'SOUTH', 'EAST', 'WEST']" -#: ../../howto/enum.rst:304 +#: ../../howto/enum.rst:307 msgid "" -"The :meth:`_generate_next_value_` method must be defined before any members." +"The :meth:`~Enum._generate_next_value_` method must be defined before any " +"members." msgstr "" -#: ../../howto/enum.rst:307 +#: ../../howto/enum.rst:310 msgid "Iteration" msgstr "" -#: ../../howto/enum.rst:309 +#: ../../howto/enum.rst:312 msgid "Iterating over the members of an enum does not provide the aliases::" msgstr "" -#: ../../howto/enum.rst:311 +#: ../../howto/enum.rst:314 msgid "" ">>> list(Shape)\n" "[, , ]\n" ">>> list(Weekday)\n" -"[, , , , , , ]" +"[, , , " +", , , " +"]" msgstr "" ">>> list(Shape)\n" "[, , ]\n" ">>> list(Weekday)\n" -"[, , , , , , ]" +"[, , , " +", , , " +"]" -#: ../../howto/enum.rst:316 +#: ../../howto/enum.rst:319 msgid "" "Note that the aliases ``Shape.ALIAS_FOR_SQUARE`` and ``Weekday.WEEKEND`` " "aren't shown." msgstr "" -#: ../../howto/enum.rst:318 +#: ../../howto/enum.rst:321 msgid "" "The special attribute ``__members__`` is a read-only ordered mapping of " "names to members. It includes all names defined in the enumeration, " "including the aliases::" msgstr "" -#: ../../howto/enum.rst:322 +#: ../../howto/enum.rst:325 msgid "" ">>> for name, member in Shape.__members__.items():\n" "... name, member\n" @@ -654,13 +669,13 @@ msgstr "" "('CIRCLE', )\n" "('ALIAS_FOR_SQUARE', )" -#: ../../howto/enum.rst:330 +#: ../../howto/enum.rst:333 msgid "" "The ``__members__`` attribute can be used for detailed programmatic access " "to the enumeration members. For example, finding all the aliases::" msgstr "" -#: ../../howto/enum.rst:333 +#: ../../howto/enum.rst:336 msgid "" ">>> [name for name, member in Shape.__members__.items() if member.name != " "name]\n" @@ -670,21 +685,21 @@ msgstr "" "name]\n" "['ALIAS_FOR_SQUARE']" -#: ../../howto/enum.rst:338 +#: ../../howto/enum.rst:341 msgid "" "Aliases for flags include values with multiple flags set, such as ``3``, and " "no flags set, i.e. ``0``." msgstr "" -#: ../../howto/enum.rst:343 +#: ../../howto/enum.rst:346 msgid "Comparisons" msgstr "比較" -#: ../../howto/enum.rst:345 +#: ../../howto/enum.rst:348 msgid "Enumeration members are compared by identity::" msgstr "" -#: ../../howto/enum.rst:347 +#: ../../howto/enum.rst:350 msgid "" ">>> Color.RED is Color.RED\n" "True\n" @@ -700,13 +715,13 @@ msgstr "" ">>> Color.RED is not Color.BLUE\n" "True" -#: ../../howto/enum.rst:354 +#: ../../howto/enum.rst:357 msgid "" "Ordered comparisons between enumeration values are *not* supported. Enum " "members are not integers (but see `IntEnum`_ below)::" msgstr "" -#: ../../howto/enum.rst:357 +#: ../../howto/enum.rst:360 msgid "" ">>> Color.RED < Color.BLUE\n" "Traceback (most recent call last):\n" @@ -718,11 +733,11 @@ msgstr "" " File \"\", line 1, in \n" "TypeError: '<' not supported between instances of 'Color' and 'Color'" -#: ../../howto/enum.rst:362 +#: ../../howto/enum.rst:365 msgid "Equality comparisons are defined though::" msgstr "" -#: ../../howto/enum.rst:364 +#: ../../howto/enum.rst:367 msgid "" ">>> Color.BLUE == Color.RED\n" "False\n" @@ -738,14 +753,14 @@ msgstr "" ">>> Color.BLUE == Color.BLUE\n" "True" -#: ../../howto/enum.rst:371 +#: ../../howto/enum.rst:374 msgid "" "Comparisons against non-enumeration values will always compare not equal " "(again, :class:`IntEnum` was explicitly designed to behave differently, see " "below)::" msgstr "" -#: ../../howto/enum.rst:375 +#: ../../howto/enum.rst:378 msgid "" ">>> Color.BLUE == 2\n" "False" @@ -753,18 +768,18 @@ msgstr "" ">>> Color.BLUE == 2\n" "False" -#: ../../howto/enum.rst:380 +#: ../../howto/enum.rst:383 msgid "" "It is possible to reload modules -- if a reloaded module contains enums, " "they will be recreated, and the new members may not compare identical/equal " "to the original members." msgstr "" -#: ../../howto/enum.rst:385 +#: ../../howto/enum.rst:388 msgid "Allowed members and attributes of enumerations" msgstr "" -#: ../../howto/enum.rst:387 +#: ../../howto/enum.rst:390 msgid "" "Most of the examples above use integers for enumeration values. Using " "integers is short and handy (and provided by default by the `Functional " @@ -773,13 +788,13 @@ msgid "" "*is* important, enumerations can have arbitrary values." msgstr "" -#: ../../howto/enum.rst:393 +#: ../../howto/enum.rst:396 msgid "" "Enumerations are Python classes, and can have methods and special methods as " "usual. If we have this enumeration::" msgstr "" -#: ../../howto/enum.rst:396 +#: ../../howto/enum.rst:399 msgid "" ">>> class Mood(Enum):\n" "... FUNKY = 1\n" @@ -799,11 +814,11 @@ msgid "" "..." msgstr "" -#: ../../howto/enum.rst:413 +#: ../../howto/enum.rst:416 msgid "Then::" -msgstr "" +msgstr "然後: ::" -#: ../../howto/enum.rst:415 +#: ../../howto/enum.rst:418 msgid "" ">>> Mood.favorite_mood()\n" "\n" @@ -819,43 +834,44 @@ msgstr "" ">>> str(Mood.FUNKY)\n" "'my custom str! 1'" -#: ../../howto/enum.rst:422 +#: ../../howto/enum.rst:425 msgid "" "The rules for what is allowed are as follows: names that start and end with " "a single underscore are reserved by enum and cannot be used; all other " "attributes defined within an enumeration will become members of this " -"enumeration, with the exception of special methods (:meth:`__str__`, :meth:" -"`__add__`, etc.), descriptors (methods are also descriptors), and variable " -"names listed in :attr:`_ignore_`." +"enumeration, with the exception of special methods " +"(:meth:`~object.__str__`, :meth:`~object.__add__`, etc.), descriptors " +"(methods are also descriptors), and variable names listed " +"in :attr:`~Enum._ignore_`." msgstr "" -#: ../../howto/enum.rst:429 +#: ../../howto/enum.rst:432 msgid "" -"Note: if your enumeration defines :meth:`__new__` and/or :meth:`__init__`, " -"any value(s) given to the enum member will be passed into those methods. See " -"`Planet`_ for an example." +"Note: if your enumeration defines :meth:`~object.__new__` and/" +"or :meth:`~object.__init__`, any value(s) given to the enum member will be " +"passed into those methods. See `Planet`_ for an example." msgstr "" -#: ../../howto/enum.rst:435 +#: ../../howto/enum.rst:438 msgid "" -"The :meth:`__new__` method, if defined, is used during creation of the Enum " -"members; it is then replaced by Enum's :meth:`__new__` which is used after " -"class creation for lookup of existing members. See :ref:`new-vs-init` for " -"more details." +"The :meth:`~object.__new__` method, if defined, is used during creation of " +"the Enum members; it is then replaced by Enum's :meth:`~object.__new__` " +"which is used after class creation for lookup of existing members. " +"See :ref:`new-vs-init` for more details." msgstr "" -#: ../../howto/enum.rst:442 +#: ../../howto/enum.rst:445 msgid "Restricted Enum subclassing" msgstr "" -#: ../../howto/enum.rst:444 +#: ../../howto/enum.rst:447 msgid "" "A new :class:`Enum` class must have one base enum class, up to one concrete " "data type, and as many :class:`object`-based mixin classes as needed. The " "order of these base classes is::" msgstr "" -#: ../../howto/enum.rst:448 +#: ../../howto/enum.rst:451 msgid "" "class EnumName([mix-in, ...,] [data-type,] base-enum):\n" " pass" @@ -863,13 +879,13 @@ msgstr "" "class EnumName([mix-in, ...,] [data-type,] base-enum):\n" " pass" -#: ../../howto/enum.rst:451 +#: ../../howto/enum.rst:454 msgid "" "Also, subclassing an enumeration is allowed only if the enumeration does not " "define any members. So this is forbidden::" msgstr "" -#: ../../howto/enum.rst:454 +#: ../../howto/enum.rst:457 msgid "" ">>> class MoreColor(Color):\n" "... PINK = 17\n" @@ -885,11 +901,11 @@ msgstr "" "...\n" "TypeError: cannot extend " -#: ../../howto/enum.rst:461 +#: ../../howto/enum.rst:464 msgid "But this is allowed::" msgstr "但這是允許的:" -#: ../../howto/enum.rst:463 +#: ../../howto/enum.rst:466 msgid "" ">>> class Foo(Enum):\n" "... def some_behavior(self):\n" @@ -909,7 +925,7 @@ msgstr "" "... SAD = 2\n" "..." -#: ../../howto/enum.rst:472 +#: ../../howto/enum.rst:475 msgid "" "Allowing subclassing of enums that define members would lead to a violation " "of some important invariants of types and instances. On the other hand, it " @@ -917,17 +933,17 @@ msgid "" "enumerations. (See `OrderedEnum`_ for an example.)" msgstr "" -#: ../../howto/enum.rst:481 +#: ../../howto/enum.rst:484 msgid "Dataclass support" msgstr "" -#: ../../howto/enum.rst:483 +#: ../../howto/enum.rst:486 msgid "" -"When inheriting from a :class:`~dataclasses.dataclass`, the :meth:`~Enum." -"__repr__` omits the inherited class' name. For example::" +"When inheriting from a :class:`~dataclasses.dataclass`, " +"the :meth:`~Enum.__repr__` omits the inherited class' name. For example::" msgstr "" -#: ../../howto/enum.rst:486 +#: ../../howto/enum.rst:489 msgid "" ">>> from dataclasses import dataclass, field\n" ">>> @dataclass\n" @@ -957,27 +973,48 @@ msgstr "" ">>> Creature.DOG\n" "" -#: ../../howto/enum.rst:500 +#: ../../howto/enum.rst:503 msgid "" -"Use the :func:`!dataclass` argument ``repr=False`` to use the standard :func:" -"`repr`." +"Use the :func:`~dataclasses.dataclass` argument ``repr=False`` to use the " +"standard :func:`repr`." msgstr "" -#: ../../howto/enum.rst:503 +#: ../../howto/enum.rst:506 msgid "" "Only the dataclass fields are shown in the value area, not the dataclass' " "name." msgstr "" -#: ../../howto/enum.rst:509 +#: ../../howto/enum.rst:512 +msgid "" +"Adding :func:`~dataclasses.dataclass` decorator to :class:`Enum` and its " +"subclasses is not supported. It will not raise any errors, but it will " +"produce very strange results at runtime, such as members being equal to each " +"other::" +msgstr "" + +#: ../../howto/enum.rst:517 +msgid "" +">>> @dataclass # don't do this: it does not make any sense\n" +"... class Color(Enum):\n" +"... RED = 1\n" +"... BLUE = 2\n" +"...\n" +">>> Color.RED is Color.BLUE\n" +"False\n" +">>> Color.RED == Color.BLUE # problem is here: they should not be equal\n" +"True" +msgstr "" + +#: ../../howto/enum.rst:529 msgid "Pickling" msgstr "" -#: ../../howto/enum.rst:511 +#: ../../howto/enum.rst:531 msgid "Enumerations can be pickled and unpickled::" msgstr "" -#: ../../howto/enum.rst:513 +#: ../../howto/enum.rst:533 msgid "" ">>> from test.test_enum import Fruit\n" ">>> from pickle import dumps, loads\n" @@ -989,27 +1026,28 @@ msgstr "" ">>> Fruit.TOMATO is loads(dumps(Fruit.TOMATO))\n" "True" -#: ../../howto/enum.rst:518 +#: ../../howto/enum.rst:538 msgid "" "The usual restrictions for pickling apply: picklable enums must be defined " "in the top level of a module, since unpickling requires them to be " "importable from that module." msgstr "" -#: ../../howto/enum.rst:524 +#: ../../howto/enum.rst:544 msgid "" "With pickle protocol version 4 it is possible to easily pickle enums nested " "in other classes." msgstr "" -#: ../../howto/enum.rst:527 +#: ../../howto/enum.rst:547 msgid "" -"It is possible to modify how enum members are pickled/unpickled by defining :" -"meth:`__reduce_ex__` in the enumeration class. The default method is by-" -"value, but enums with complicated values may want to use by-name::" +"It is possible to modify how enum members are pickled/unpickled by " +"defining :meth:`~object.__reduce_ex__` in the enumeration class. The " +"default method is by-value, but enums with complicated values may want to " +"use by-name::" msgstr "" -#: ../../howto/enum.rst:531 +#: ../../howto/enum.rst:551 msgid "" ">>> import enum\n" ">>> class MyEnum(enum.Enum):\n" @@ -1019,22 +1057,22 @@ msgstr "" ">>> class MyEnum(enum.Enum):\n" "... __reduce_ex__ = enum.pickle_by_enum_name" -#: ../../howto/enum.rst:537 +#: ../../howto/enum.rst:557 msgid "" "Using by-name for flags is not recommended, as unnamed aliases will not " "unpickle." msgstr "" -#: ../../howto/enum.rst:542 +#: ../../howto/enum.rst:562 msgid "Functional API" msgstr "" -#: ../../howto/enum.rst:544 +#: ../../howto/enum.rst:564 msgid "" "The :class:`Enum` class is callable, providing the following functional API::" msgstr "" -#: ../../howto/enum.rst:546 +#: ../../howto/enum.rst:566 msgid "" ">>> Animal = Enum('Animal', 'ANT BEE CAT DOG')\n" ">>> Animal\n" @@ -1052,13 +1090,13 @@ msgstr "" ">>> list(Animal)\n" "[, , , ]" -#: ../../howto/enum.rst:554 +#: ../../howto/enum.rst:574 msgid "" "The semantics of this API resemble :class:`~collections.namedtuple`. The " "first argument of the call to :class:`Enum` is the name of the enumeration." msgstr "" -#: ../../howto/enum.rst:557 +#: ../../howto/enum.rst:577 msgid "" "The second argument is the *source* of enumeration member names. It can be " "a whitespace-separated string of names, a sequence of names, a sequence of 2-" @@ -1067,10 +1105,10 @@ msgid "" "enumerations; the others auto-assign increasing integers starting with 1 " "(use the ``start`` parameter to specify a different starting value). A new " "class derived from :class:`Enum` is returned. In other words, the above " -"assignment to :class:`Animal` is equivalent to::" +"assignment to :class:`!Animal` is equivalent to::" msgstr "" -#: ../../howto/enum.rst:566 +#: ../../howto/enum.rst:586 msgid "" ">>> class Animal(Enum):\n" "... ANT = 1\n" @@ -1086,14 +1124,14 @@ msgstr "" "... DOG = 4\n" "..." -#: ../../howto/enum.rst:573 +#: ../../howto/enum.rst:593 msgid "" "The reason for defaulting to ``1`` as the starting number and not ``0`` is " "that ``0`` is ``False`` in a boolean sense, but by default enum members all " "evaluate to ``True``." msgstr "" -#: ../../howto/enum.rst:577 +#: ../../howto/enum.rst:597 msgid "" "Pickling enums created with the functional API can be tricky as frame stack " "implementation details are used to try and figure out which module the " @@ -1102,36 +1140,36 @@ msgid "" "Jython). The solution is to specify the module name explicitly as follows::" msgstr "" -#: ../../howto/enum.rst:583 +#: ../../howto/enum.rst:603 msgid ">>> Animal = Enum('Animal', 'ANT BEE CAT DOG', module=__name__)" msgstr ">>> Animal = Enum('Animal', 'ANT BEE CAT DOG', module=__name__)" -#: ../../howto/enum.rst:587 +#: ../../howto/enum.rst:607 msgid "" "If ``module`` is not supplied, and Enum cannot determine what it is, the new " "Enum members will not be unpicklable; to keep errors closer to the source, " "pickling will be disabled." msgstr "" -#: ../../howto/enum.rst:591 +#: ../../howto/enum.rst:611 msgid "" -"The new pickle protocol 4 also, in some circumstances, relies on :attr:" -"`~definition.__qualname__` being set to the location where pickle will be " +"The new pickle protocol 4 also, in some circumstances, relies " +"on :attr:`~type.__qualname__` being set to the location where pickle will be " "able to find the class. For example, if the class was made available in " "class SomeData in the global scope::" msgstr "" -#: ../../howto/enum.rst:596 +#: ../../howto/enum.rst:616 msgid "" ">>> Animal = Enum('Animal', 'ANT BEE CAT DOG', qualname='SomeData.Animal')" msgstr "" ">>> Animal = Enum('Animal', 'ANT BEE CAT DOG', qualname='SomeData.Animal')" -#: ../../howto/enum.rst:598 +#: ../../howto/enum.rst:618 msgid "The complete signature is::" msgstr "" -#: ../../howto/enum.rst:600 +#: ../../howto/enum.rst:620 msgid "" "Enum(\n" " value='NewEnumName',\n" @@ -1153,81 +1191,81 @@ msgstr "" " start=1,\n" " )" -#: ../../howto/enum.rst:610 +#: ../../howto/enum.rst:630 msgid "*value*: What the new enum class will record as its name." msgstr "" -#: ../../howto/enum.rst:612 +#: ../../howto/enum.rst:632 msgid "" "*names*: The enum members. This can be a whitespace- or comma-separated " "string (values will start at 1 unless otherwise specified)::" msgstr "" -#: ../../howto/enum.rst:615 +#: ../../howto/enum.rst:635 msgid "'RED GREEN BLUE' | 'RED,GREEN,BLUE' | 'RED, GREEN, BLUE'" msgstr "'RED GREEN BLUE' | 'RED,GREEN,BLUE' | 'RED, GREEN, BLUE'" -#: ../../howto/enum.rst:617 +#: ../../howto/enum.rst:637 msgid "or an iterator of names::" msgstr "" -#: ../../howto/enum.rst:619 +#: ../../howto/enum.rst:639 msgid "['RED', 'GREEN', 'BLUE']" msgstr "['RED', 'GREEN', 'BLUE']" -#: ../../howto/enum.rst:621 +#: ../../howto/enum.rst:641 msgid "or an iterator of (name, value) pairs::" msgstr "" -#: ../../howto/enum.rst:623 +#: ../../howto/enum.rst:643 msgid "[('CYAN', 4), ('MAGENTA', 5), ('YELLOW', 6)]" msgstr "[('CYAN', 4), ('MAGENTA', 5), ('YELLOW', 6)]" -#: ../../howto/enum.rst:625 +#: ../../howto/enum.rst:645 msgid "or a mapping::" msgstr "" -#: ../../howto/enum.rst:627 +#: ../../howto/enum.rst:647 msgid "{'CHARTREUSE': 7, 'SEA_GREEN': 11, 'ROSEMARY': 42}" msgstr "{'CHARTREUSE': 7, 'SEA_GREEN': 11, 'ROSEMARY': 42}" -#: ../../howto/enum.rst:629 +#: ../../howto/enum.rst:649 msgid "*module*: name of module where new enum class can be found." msgstr "" -#: ../../howto/enum.rst:631 +#: ../../howto/enum.rst:651 msgid "*qualname*: where in module new enum class can be found." msgstr "" -#: ../../howto/enum.rst:633 +#: ../../howto/enum.rst:653 msgid "*type*: type to mix in to new enum class." msgstr "" -#: ../../howto/enum.rst:635 +#: ../../howto/enum.rst:655 msgid "*start*: number to start counting at if only names are passed in." msgstr "" -#: ../../howto/enum.rst:637 +#: ../../howto/enum.rst:657 msgid "The *start* parameter was added." msgstr "" -#: ../../howto/enum.rst:642 +#: ../../howto/enum.rst:662 msgid "Derived Enumerations" msgstr "" -#: ../../howto/enum.rst:645 +#: ../../howto/enum.rst:665 msgid "IntEnum" -msgstr "" +msgstr "IntEnum" -#: ../../howto/enum.rst:647 +#: ../../howto/enum.rst:667 msgid "" -"The first variation of :class:`Enum` that is provided is also a subclass of :" -"class:`int`. Members of an :class:`IntEnum` can be compared to integers; by " -"extension, integer enumerations of different types can also be compared to " -"each other::" +"The first variation of :class:`Enum` that is provided is also a subclass " +"of :class:`int`. Members of an :class:`IntEnum` can be compared to " +"integers; by extension, integer enumerations of different types can also be " +"compared to each other::" msgstr "" -#: ../../howto/enum.rst:652 +#: ../../howto/enum.rst:672 msgid "" ">>> from enum import IntEnum\n" ">>> class Shape(IntEnum):\n" @@ -1261,13 +1299,13 @@ msgstr "" ">>> Shape.CIRCLE == Request.POST\n" "True" -#: ../../howto/enum.rst:668 +#: ../../howto/enum.rst:688 msgid "" "However, they still can't be compared to standard :class:`Enum` " "enumerations::" msgstr "" -#: ../../howto/enum.rst:670 +#: ../../howto/enum.rst:690 msgid "" ">>> class Shape(IntEnum):\n" "... CIRCLE = 1\n" @@ -1291,12 +1329,12 @@ msgstr "" ">>> Shape.CIRCLE == Color.RED\n" "False" -#: ../../howto/enum.rst:681 +#: ../../howto/enum.rst:701 msgid "" ":class:`IntEnum` values behave like integers in other ways you'd expect::" msgstr "" -#: ../../howto/enum.rst:683 +#: ../../howto/enum.rst:703 msgid "" ">>> int(Shape.CIRCLE)\n" "1\n" @@ -1312,11 +1350,11 @@ msgstr "" ">>> [i for i in range(Shape.SQUARE)]\n" "[0, 1]" -#: ../../howto/enum.rst:692 +#: ../../howto/enum.rst:712 msgid "StrEnum" msgstr "StrEnum" -#: ../../howto/enum.rst:694 +#: ../../howto/enum.rst:714 msgid "" "The second variation of :class:`Enum` that is provided is also a subclass " "of :class:`str`. Members of a :class:`StrEnum` can be compared to strings; " @@ -1324,37 +1362,37 @@ msgid "" "each other." msgstr "" -#: ../../howto/enum.rst:703 +#: ../../howto/enum.rst:723 msgid "IntFlag" msgstr "IntFlag" -#: ../../howto/enum.rst:705 +#: ../../howto/enum.rst:725 msgid "" "The next variation of :class:`Enum` provided, :class:`IntFlag`, is also " "based on :class:`int`. The difference being :class:`IntFlag` members can be " "combined using the bitwise operators (&, \\|, ^, ~) and the result is still " -"an :class:`IntFlag` member, if possible. Like :class:`IntEnum`, :class:" -"`IntFlag` members are also integers and can be used wherever an :class:`int` " -"is used." +"an :class:`IntFlag` member, if possible. " +"Like :class:`IntEnum`, :class:`IntFlag` members are also integers and can be " +"used wherever an :class:`int` is used." msgstr "" -#: ../../howto/enum.rst:713 +#: ../../howto/enum.rst:733 msgid "" "Any operation on an :class:`IntFlag` member besides the bit-wise operations " "will lose the :class:`IntFlag` membership." msgstr "" -#: ../../howto/enum.rst:716 +#: ../../howto/enum.rst:736 msgid "" "Bit-wise operations that result in invalid :class:`IntFlag` values will lose " "the :class:`IntFlag` membership. See :class:`FlagBoundary` for details." msgstr "" -#: ../../howto/enum.rst:723 +#: ../../howto/enum.rst:743 msgid "Sample :class:`IntFlag` class::" msgstr "" -#: ../../howto/enum.rst:725 +#: ../../howto/enum.rst:745 msgid "" ">>> from enum import IntFlag\n" ">>> class Perm(IntFlag):\n" @@ -1384,11 +1422,11 @@ msgstr "" ">>> Perm.R in RW\n" "True" -#: ../../howto/enum.rst:739 +#: ../../howto/enum.rst:759 msgid "It is also possible to name the combinations::" msgstr "" -#: ../../howto/enum.rst:741 +#: ../../howto/enum.rst:761 msgid "" ">>> class Perm(IntFlag):\n" "... R = 4\n" @@ -1416,20 +1454,20 @@ msgstr "" ">>> Perm(7)\n" "" -#: ../../howto/enum.rst:756 +#: ../../howto/enum.rst:776 msgid "" "Named combinations are considered aliases. Aliases do not show up during " "iteration, but can be returned from by-value lookups." msgstr "" -#: ../../howto/enum.rst:761 +#: ../../howto/enum.rst:781 msgid "" "Another important difference between :class:`IntFlag` and :class:`Enum` is " -"that if no flags are set (the value is 0), its boolean evaluation is :data:" -"`False`::" +"that if no flags are set (the value is 0), its boolean evaluation " +"is :data:`False`::" msgstr "" -#: ../../howto/enum.rst:764 +#: ../../howto/enum.rst:784 msgid "" ">>> Perm.R & Perm.X\n" "\n" @@ -1441,13 +1479,13 @@ msgstr "" ">>> bool(Perm.R & Perm.X)\n" "False" -#: ../../howto/enum.rst:769 +#: ../../howto/enum.rst:789 msgid "" "Because :class:`IntFlag` members are also subclasses of :class:`int` they " "can be combined with them (but may lose :class:`IntFlag` membership::" msgstr "" -#: ../../howto/enum.rst:772 +#: ../../howto/enum.rst:792 msgid "" ">>> Perm.X | 4\n" "\n" @@ -1461,13 +1499,13 @@ msgstr "" ">>> Perm.X + 8\n" "9" -#: ../../howto/enum.rst:780 +#: ../../howto/enum.rst:800 msgid "" "The negation operator, ``~``, always returns an :class:`IntFlag` member with " "a positive value::" msgstr "" -#: ../../howto/enum.rst:783 +#: ../../howto/enum.rst:803 msgid "" ">>> (~Perm.X).value == (Perm.R|Perm.W).value == 6\n" "True" @@ -1475,11 +1513,11 @@ msgstr "" ">>> (~Perm.X).value == (Perm.R|Perm.W).value == 6\n" "True" -#: ../../howto/enum.rst:786 +#: ../../howto/enum.rst:806 msgid ":class:`IntFlag` members can also be iterated over::" -msgstr "" +msgstr ":class:`IntFlag` 成員也可以被疊代:" -#: ../../howto/enum.rst:788 +#: ../../howto/enum.rst:808 msgid "" ">>> list(RW)\n" "[, ]" @@ -1487,27 +1525,27 @@ msgstr "" ">>> list(RW)\n" "[, ]" -#: ../../howto/enum.rst:795 +#: ../../howto/enum.rst:815 msgid "Flag" msgstr "Flag" -#: ../../howto/enum.rst:797 +#: ../../howto/enum.rst:817 msgid "" "The last variation is :class:`Flag`. Like :class:`IntFlag`, :class:`Flag` " -"members can be combined using the bitwise operators (&, \\|, ^, ~). Unlike :" -"class:`IntFlag`, they cannot be combined with, nor compared against, any " -"other :class:`Flag` enumeration, nor :class:`int`. While it is possible to " -"specify the values directly it is recommended to use :class:`auto` as the " +"members can be combined using the bitwise operators (&, \\|, ^, ~). " +"Unlike :class:`IntFlag`, they cannot be combined with, nor compared against, " +"any other :class:`Flag` enumeration, nor :class:`int`. While it is possible " +"to specify the values directly it is recommended to use :class:`auto` as the " "value and let :class:`Flag` select an appropriate value." msgstr "" -#: ../../howto/enum.rst:806 +#: ../../howto/enum.rst:826 msgid "" "Like :class:`IntFlag`, if a combination of :class:`Flag` members results in " "no flags being set, the boolean evaluation is :data:`False`::" msgstr "" -#: ../../howto/enum.rst:809 +#: ../../howto/enum.rst:829 msgid "" ">>> from enum import Flag, auto\n" ">>> class Color(Flag):\n" @@ -1531,13 +1569,13 @@ msgstr "" ">>> bool(Color.RED & Color.GREEN)\n" "False" -#: ../../howto/enum.rst:820 +#: ../../howto/enum.rst:840 msgid "" "Individual flags should have values that are powers of two (1, 2, 4, " "8, ...), while combinations of flags will not::" msgstr "" -#: ../../howto/enum.rst:823 +#: ../../howto/enum.rst:843 msgid "" ">>> class Color(Flag):\n" "... RED = auto()\n" @@ -1557,13 +1595,13 @@ msgstr "" ">>> Color.WHITE\n" "" -#: ../../howto/enum.rst:832 +#: ../../howto/enum.rst:852 msgid "" "Giving a name to the \"no flags set\" condition does not change its boolean " "value::" msgstr "" -#: ../../howto/enum.rst:835 +#: ../../howto/enum.rst:855 msgid "" ">>> class Color(Flag):\n" "... BLACK = 0\n" @@ -1587,11 +1625,11 @@ msgstr "" ">>> bool(Color.BLACK)\n" "False" -#: ../../howto/enum.rst:846 +#: ../../howto/enum.rst:866 msgid ":class:`Flag` members can also be iterated over::" -msgstr "" +msgstr ":class:`Flag` 成員也可以被疊代:" -#: ../../howto/enum.rst:848 +#: ../../howto/enum.rst:868 msgid "" ">>> purple = Color.RED | Color.BLUE\n" ">>> list(purple)\n" @@ -1601,119 +1639,122 @@ msgstr "" ">>> list(purple)\n" "[, ]" -#: ../../howto/enum.rst:856 +#: ../../howto/enum.rst:876 msgid "" "For the majority of new code, :class:`Enum` and :class:`Flag` are strongly " "recommended, since :class:`IntEnum` and :class:`IntFlag` break some semantic " "promises of an enumeration (by being comparable to integers, and thus by " -"transitivity to other unrelated enumerations). :class:`IntEnum` and :class:" -"`IntFlag` should be used only in cases where :class:`Enum` and :class:`Flag` " -"will not do; for example, when integer constants are replaced with " -"enumerations, or for interoperability with other systems." +"transitivity to other unrelated enumerations). :class:`IntEnum` " +"and :class:`IntFlag` should be used only in cases where :class:`Enum` " +"and :class:`Flag` will not do; for example, when integer constants are " +"replaced with enumerations, or for interoperability with other systems." msgstr "" -#: ../../howto/enum.rst:866 +#: ../../howto/enum.rst:886 msgid "Others" msgstr "其他" -#: ../../howto/enum.rst:868 +#: ../../howto/enum.rst:888 msgid "" "While :class:`IntEnum` is part of the :mod:`enum` module, it would be very " "simple to implement independently::" msgstr "" -#: ../../howto/enum.rst:871 +#: ../../howto/enum.rst:891 msgid "" -"class IntEnum(int, Enum):\n" +"class IntEnum(int, ReprEnum): # or Enum instead of ReprEnum\n" " pass" msgstr "" -"class IntEnum(int, Enum):\n" +"class IntEnum(int, ReprEnum): # 或用 Enum 取代 ReprEnum\n" " pass" -#: ../../howto/enum.rst:874 +#: ../../howto/enum.rst:894 msgid "" "This demonstrates how similar derived enumerations can be defined; for " -"example a :class:`FloatEnum` that mixes in :class:`float` instead of :class:" -"`int`." +"example a :class:`!FloatEnum` that mixes in :class:`float` instead " +"of :class:`int`." msgstr "" -#: ../../howto/enum.rst:877 +#: ../../howto/enum.rst:897 msgid "Some rules:" msgstr "一些規則:" -#: ../../howto/enum.rst:879 +#: ../../howto/enum.rst:899 msgid "" -"When subclassing :class:`Enum`, mix-in types must appear before :class:" -"`Enum` itself in the sequence of bases, as in the :class:`IntEnum` example " -"above." +"When subclassing :class:`Enum`, mix-in types must appear before " +"the :class:`Enum` class itself in the sequence of bases, as in " +"the :class:`IntEnum` example above." msgstr "" -#: ../../howto/enum.rst:882 +#: ../../howto/enum.rst:902 msgid "" -"Mix-in types must be subclassable. For example, :class:`bool` and :class:" -"`range` are not subclassable and will throw an error during Enum creation if " -"used as the mix-in type." +"Mix-in types must be subclassable. For example, :class:`bool` " +"and :class:`range` are not subclassable and will throw an error during Enum " +"creation if used as the mix-in type." msgstr "" -#: ../../howto/enum.rst:885 +#: ../../howto/enum.rst:905 msgid "" "While :class:`Enum` can have members of any type, once you mix in an " -"additional type, all the members must have values of that type, e.g. :class:" -"`int` above. This restriction does not apply to mix-ins which only add " -"methods and don't specify another type." +"additional type, all the members must have values of that type, " +"e.g. :class:`int` above. This restriction does not apply to mix-ins which " +"only add methods and don't specify another type." msgstr "" -#: ../../howto/enum.rst:889 +#: ../../howto/enum.rst:909 msgid "" -"When another data type is mixed in, the :attr:`value` attribute is *not the " -"same* as the enum member itself, although it is equivalent and will compare " -"equal." +"When another data type is mixed in, the :attr:`~Enum.value` attribute is " +"*not the same* as the enum member itself, although it is equivalent and will " +"compare equal." msgstr "" -#: ../../howto/enum.rst:892 +#: ../../howto/enum.rst:912 msgid "" -"A ``data type`` is a mixin that defines :meth:`__new__`, or a :class:" -"`~dataclasses.dataclass`" +"A ``data type`` is a mixin that defines :meth:`~object.__new__`, or " +"a :class:`~dataclasses.dataclass`" msgstr "" -#: ../../howto/enum.rst:894 +#: ../../howto/enum.rst:914 msgid "" -"%-style formatting: ``%s`` and ``%r`` call the :class:`Enum` class's :meth:" -"`__str__` and :meth:`__repr__` respectively; other codes (such as ``%i`` or " -"``%h`` for IntEnum) treat the enum member as its mixed-in type." +"%-style formatting: ``%s`` and ``%r`` call the :class:`Enum` " +"class's :meth:`~object.__str__` and :meth:`~object.__repr__` respectively; " +"other codes (such as ``%i`` or ``%h`` for IntEnum) treat the enum member as " +"its mixed-in type." msgstr "" -#: ../../howto/enum.rst:897 +#: ../../howto/enum.rst:917 msgid "" -":ref:`Formatted string literals `, :meth:`str.format`, and :func:" -"`format` will use the enum's :meth:`__str__` method." +":ref:`Formatted string literals `, :meth:`str.format`, " +"and :func:`format` will use the enum's :meth:`~object.__str__` method." msgstr "" -#: ../../howto/enum.rst:902 +#: ../../howto/enum.rst:922 msgid "" "Because :class:`IntEnum`, :class:`IntFlag`, and :class:`StrEnum` are " -"designed to be drop-in replacements for existing constants, their :meth:" -"`__str__` method has been reset to their data types' :meth:`__str__` method." +"designed to be drop-in replacements for existing constants, " +"their :meth:`~object.__str__` method has been reset to their data " +"types' :meth:`~object.__str__` method." msgstr "" -#: ../../howto/enum.rst:910 -msgid "When to use :meth:`__new__` vs. :meth:`__init__`" +#: ../../howto/enum.rst:930 +msgid "When to use :meth:`~object.__new__` vs. :meth:`~object.__init__`" msgstr "" -#: ../../howto/enum.rst:912 +#: ../../howto/enum.rst:932 msgid "" -":meth:`__new__` must be used whenever you want to customize the actual value " -"of the :class:`Enum` member. Any other modifications may go in either :meth:" -"`__new__` or :meth:`__init__`, with :meth:`__init__` being preferred." +":meth:`~object.__new__` must be used whenever you want to customize the " +"actual value of the :class:`Enum` member. Any other modifications may go in " +"either :meth:`~object.__new__` or :meth:`~object.__init__`, " +"with :meth:`~object.__init__` being preferred." msgstr "" -#: ../../howto/enum.rst:916 +#: ../../howto/enum.rst:936 msgid "" "For example, if you want to pass several items to the constructor, but only " "want one of them to be the value::" msgstr "" -#: ../../howto/enum.rst:919 +#: ../../howto/enum.rst:939 msgid "" ">>> class Coordinate(bytes, Enum):\n" "... \"\"\"\n" @@ -1738,99 +1779,114 @@ msgid "" "Coordinate.VY" msgstr "" -#: ../../howto/enum.rst:943 +#: ../../howto/enum.rst:963 msgid "" "*Do not* call ``super().__new__()``, as the lookup-only ``__new__`` is the " "one that is found; instead, use the data type directly." msgstr "" -#: ../../howto/enum.rst:948 +#: ../../howto/enum.rst:968 msgid "Finer Points" msgstr "" -#: ../../howto/enum.rst:951 +#: ../../howto/enum.rst:971 msgid "Supported ``__dunder__`` names" -msgstr "" +msgstr "有支援的 ``__dunder__`` 名稱" -#: ../../howto/enum.rst:953 +#: ../../howto/enum.rst:973 msgid "" -":attr:`__members__` is a read-only ordered mapping of ``member_name``:" -"``member`` items. It is only available on the class." +":attr:`~enum.EnumType.__members__` is a read-only ordered mapping of " +"``member_name``:``member`` items. It is only available on the class." msgstr "" -#: ../../howto/enum.rst:956 +#: ../../howto/enum.rst:976 msgid "" -":meth:`__new__`, if specified, must create and return the enum members; it " -"is also a very good idea to set the member's :attr:`_value_` appropriately. " -"Once all the members are created it is no longer used." +":meth:`~object.__new__`, if specified, must create and return the enum " +"members; it is also a very good idea to set the " +"member's :attr:`~Enum._value_` appropriately. Once all the members are " +"created it is no longer used." msgstr "" -#: ../../howto/enum.rst:962 +#: ../../howto/enum.rst:982 msgid "Supported ``_sunder_`` names" -msgstr "" +msgstr "有支援的 ``_sunder_`` 名稱" + +#: ../../howto/enum.rst:984 +msgid ":attr:`~Enum._name_` -- name of the member" +msgstr ":attr:`~Enum._name_` -- 成員的名稱" -#: ../../howto/enum.rst:964 -msgid "``_name_`` -- name of the member" -msgstr "``_name_`` -- 成員的名稱" +#: ../../howto/enum.rst:985 +msgid ":attr:`~Enum._value_` -- value of the member; can be set in ``__new__``" +msgstr "" -#: ../../howto/enum.rst:965 +#: ../../howto/enum.rst:986 msgid "" -"``_value_`` -- value of the member; can be set / modified in ``__new__``" +":meth:`~Enum._missing_` -- a lookup function used when a value is not found; " +"may be overridden" msgstr "" -#: ../../howto/enum.rst:967 +#: ../../howto/enum.rst:988 msgid "" -"``_missing_`` -- a lookup function used when a value is not found; may be " -"overridden" +":attr:`~Enum._ignore_` -- a list of names, either as a :class:`list` or " +"a :class:`str`, that will not be transformed into members, and will be " +"removed from the final class" msgstr "" -#: ../../howto/enum.rst:969 +#: ../../howto/enum.rst:991 msgid "" -"``_ignore_`` -- a list of names, either as a :class:`list` or a :class:" -"`str`, that will not be transformed into members, and will be removed from " -"the final class" +":meth:`~Enum._generate_next_value_` -- used to get an appropriate value for " +"an enum member; may be overridden" msgstr "" -#: ../../howto/enum.rst:972 +#: ../../howto/enum.rst:993 msgid "" -"``_order_`` -- used in Python 2/3 code to ensure member order is consistent " -"(class attribute, removed during class creation)" +":meth:`~EnumType._add_alias_` -- adds a new name as an alias to an existing " +"member." msgstr "" -#: ../../howto/enum.rst:974 +#: ../../howto/enum.rst:995 msgid "" -"``_generate_next_value_`` -- used by the `Functional API`_ and by :class:" -"`auto` to get an appropriate value for an enum member; may be overridden" +":meth:`~EnumType._add_value_alias_` -- adds a new value as an alias to an " +"existing member. See `MultiValueEnum`_ for an example." msgstr "" -#: ../../howto/enum.rst:980 +#: ../../howto/enum.rst:1000 msgid "" -"For standard :class:`Enum` classes the next value chosen is the last value " -"seen incremented by one." +"For standard :class:`Enum` classes the next value chosen is the highest " +"value seen incremented by one." msgstr "" -#: ../../howto/enum.rst:983 +#: ../../howto/enum.rst:1003 msgid "" "For :class:`Flag` classes the next value chosen will be the next highest " -"power-of-two, regardless of the last value seen." +"power-of-two." msgstr "" -#: ../../howto/enum.rst:986 +#: ../../howto/enum.rst:1006 +msgid "" +"Prior versions would use the last seen value instead of the highest value." +msgstr "" + +#: ../../howto/enum.rst:1009 msgid "``_missing_``, ``_order_``, ``_generate_next_value_``" msgstr "``_missing_``、``_order_``、``_generate_next_value_``" -#: ../../howto/enum.rst:987 +#: ../../howto/enum.rst:1010 msgid "``_ignore_``" msgstr "``_ignore_``" -#: ../../howto/enum.rst:989 +#: ../../howto/enum.rst:1011 +msgid "``_add_alias_``, ``_add_value_alias_``" +msgstr "``_add_alias_``、``_add_value_alias_``" + +#: ../../howto/enum.rst:1013 msgid "" -"To help keep Python 2 / Python 3 code in sync an :attr:`_order_` attribute " -"can be provided. It will be checked against the actual order of the " -"enumeration and raise an error if the two do not match::" +"To help keep Python 2 / Python 3 code in sync an :attr:`~Enum._order_` " +"attribute can be provided. It will be checked against the actual order of " +"the enumeration and raise an error if the two do not match::" msgstr "" -#: ../../howto/enum.rst:993 +#: ../../howto/enum.rst:1017 msgid "" ">>> class Color(Enum):\n" "... _order_ = 'RED GREEN BLUE'\n" @@ -1856,27 +1912,27 @@ msgstr "" " ['RED', 'BLUE', 'GREEN']\n" " ['RED', 'GREEN', 'BLUE']" -#: ../../howto/enum.rst:1007 +#: ../../howto/enum.rst:1031 msgid "" -"In Python 2 code the :attr:`_order_` attribute is necessary as definition " -"order is lost before it can be recorded." +"In Python 2 code the :attr:`~Enum._order_` attribute is necessary as " +"definition order is lost before it can be recorded." msgstr "" -#: ../../howto/enum.rst:1012 +#: ../../howto/enum.rst:1036 msgid "_Private__names" msgstr "_Private__names" -#: ../../howto/enum.rst:1014 +#: ../../howto/enum.rst:1038 msgid "" ":ref:`Private names ` are not converted to enum " "members, but remain normal attributes." msgstr "" -#: ../../howto/enum.rst:1021 +#: ../../howto/enum.rst:1045 msgid "``Enum`` member type" msgstr "" -#: ../../howto/enum.rst:1023 +#: ../../howto/enum.rst:1047 msgid "" "Enum members are instances of their enum class, and are normally accessed as " "``EnumClass.member``. In certain situations, such as writing custom enum " @@ -1886,18 +1942,18 @@ msgid "" "strongly recommended." msgstr "" -#: ../../howto/enum.rst:1034 +#: ../../howto/enum.rst:1058 msgid "Creating members that are mixed with other data types" msgstr "" -#: ../../howto/enum.rst:1036 +#: ../../howto/enum.rst:1060 msgid "" "When subclassing other data types, such as :class:`int` or :class:`str`, " "with an :class:`Enum`, all values after the ``=`` are passed to that data " "type's constructor. For example::" msgstr "" -#: ../../howto/enum.rst:1040 +#: ../../howto/enum.rst:1064 msgid "" ">>> class MyEnum(IntEnum): # help(int) -> int(x, base=10) -> integer\n" "... example = '11', 16 # so x='11' and base=16\n" @@ -1905,21 +1961,26 @@ msgid "" ">>> MyEnum.example.value # and hex(11) is...\n" "17" msgstr "" +">>> class MyEnum(IntEnum): # help(int) -> int(x, base=10) -> integer\n" +"... example = '11', 16 # 所以 x='11' 且 base=16\n" +"...\n" +">>> MyEnum.example.value # 且 hex(11) 為...\n" +"17" -#: ../../howto/enum.rst:1048 +#: ../../howto/enum.rst:1072 msgid "Boolean value of ``Enum`` classes and members" msgstr "" -#: ../../howto/enum.rst:1050 +#: ../../howto/enum.rst:1074 msgid "" -"Enum classes that are mixed with non-:class:`Enum` types (such as :class:" -"`int`, :class:`str`, etc.) are evaluated according to the mixed-in type's " -"rules; otherwise, all members evaluate as :data:`True`. To make your own " -"enum's boolean evaluation depend on the member's value add the following to " -"your class::" +"Enum classes that are mixed with non-:class:`Enum` types (such " +"as :class:`int`, :class:`str`, etc.) are evaluated according to the mixed-in " +"type's rules; otherwise, all members evaluate as :data:`True`. To make your " +"own enum's boolean evaluation depend on the member's value add the following " +"to your class::" msgstr "" -#: ../../howto/enum.rst:1056 +#: ../../howto/enum.rst:1080 msgid "" "def __bool__(self):\n" " return bool(self.value)" @@ -1927,48 +1988,48 @@ msgstr "" "def __bool__(self):\n" " return bool(self.value)" -#: ../../howto/enum.rst:1059 +#: ../../howto/enum.rst:1083 msgid "Plain :class:`Enum` classes always evaluate as :data:`True`." msgstr "" -#: ../../howto/enum.rst:1063 +#: ../../howto/enum.rst:1087 msgid "``Enum`` classes with methods" msgstr "" -#: ../../howto/enum.rst:1065 +#: ../../howto/enum.rst:1089 msgid "" "If you give your enum subclass extra methods, like the `Planet`_ class " "below, those methods will show up in a :func:`dir` of the member, but not of " "the class::" msgstr "" -#: ../../howto/enum.rst:1069 +#: ../../howto/enum.rst:1093 msgid "" -">>> dir(Planet) \n" +">>> dir(Planet)\n" "['EARTH', 'JUPITER', 'MARS', 'MERCURY', 'NEPTUNE', 'SATURN', 'URANUS', " "'VENUS', '__class__', '__doc__', '__members__', '__module__']\n" -">>> dir(Planet.EARTH) \n" +">>> dir(Planet.EARTH)\n" "['__class__', '__doc__', '__module__', 'mass', 'name', 'radius', " "'surface_gravity', 'value']" msgstr "" -">>> dir(Planet) \n" +">>> dir(Planet)\n" "['EARTH', 'JUPITER', 'MARS', 'MERCURY', 'NEPTUNE', 'SATURN', 'URANUS', " "'VENUS', '__class__', '__doc__', '__members__', '__module__']\n" -">>> dir(Planet.EARTH) \n" +">>> dir(Planet.EARTH)\n" "['__class__', '__doc__', '__module__', 'mass', 'name', 'radius', " "'surface_gravity', 'value']" -#: ../../howto/enum.rst:1076 +#: ../../howto/enum.rst:1100 msgid "Combining members of ``Flag``" -msgstr "" +msgstr "``Flag`` 的成員組合" -#: ../../howto/enum.rst:1078 +#: ../../howto/enum.rst:1102 msgid "" "Iterating over a combination of :class:`Flag` members will only return the " "members that are comprised of a single bit::" msgstr "" -#: ../../howto/enum.rst:1081 +#: ../../howto/enum.rst:1105 msgid "" ">>> class Color(Flag):\n" "... RED = auto()\n" @@ -1984,15 +2045,15 @@ msgid "" "" msgstr "" -#: ../../howto/enum.rst:1096 +#: ../../howto/enum.rst:1120 msgid "``Flag`` and ``IntFlag`` minutia" msgstr "" -#: ../../howto/enum.rst:1098 +#: ../../howto/enum.rst:1122 msgid "Using the following snippet for our examples::" msgstr "" -#: ../../howto/enum.rst:1100 +#: ../../howto/enum.rst:1124 msgid "" ">>> class Color(IntFlag):\n" "... BLACK = 0\n" @@ -2012,23 +2073,23 @@ msgstr "" "... WHITE = RED | GREEN | BLUE\n" "..." -#: ../../howto/enum.rst:1109 +#: ../../howto/enum.rst:1133 msgid "the following are true:" msgstr "" -#: ../../howto/enum.rst:1111 +#: ../../howto/enum.rst:1135 msgid "single-bit flags are canonical" msgstr "" -#: ../../howto/enum.rst:1112 +#: ../../howto/enum.rst:1136 msgid "multi-bit and zero-bit flags are aliases" msgstr "" -#: ../../howto/enum.rst:1113 +#: ../../howto/enum.rst:1137 msgid "only canonical flags are returned during iteration::" msgstr "" -#: ../../howto/enum.rst:1115 +#: ../../howto/enum.rst:1139 msgid "" ">>> list(Color.WHITE)\n" "[, , ]" @@ -2036,13 +2097,13 @@ msgstr "" ">>> list(Color.WHITE)\n" "[, , ]" -#: ../../howto/enum.rst:1118 +#: ../../howto/enum.rst:1142 msgid "" "negating a flag or flag set returns a new flag/flag set with the " "corresponding positive integer value::" msgstr "" -#: ../../howto/enum.rst:1121 +#: ../../howto/enum.rst:1145 msgid "" ">>> Color.BLUE\n" "\n" @@ -2056,11 +2117,11 @@ msgstr "" ">>> ~Color.BLUE\n" "" -#: ../../howto/enum.rst:1127 +#: ../../howto/enum.rst:1151 msgid "names of pseudo-flags are constructed from their members' names::" msgstr "" -#: ../../howto/enum.rst:1129 +#: ../../howto/enum.rst:1153 msgid "" ">>> (Color.RED | Color.GREEN).name\n" "'RED|GREEN'\n" @@ -2074,11 +2135,11 @@ msgid "" "True" msgstr "" -#: ../../howto/enum.rst:1140 +#: ../../howto/enum.rst:1164 msgid "multi-bit flags, aka aliases, can be returned from operations::" msgstr "" -#: ../../howto/enum.rst:1142 +#: ../../howto/enum.rst:1166 msgid "" ">>> Color.RED | Color.BLUE\n" "\n" @@ -2098,13 +2159,13 @@ msgstr "" ">>> Color(0)\n" "" -#: ../../howto/enum.rst:1151 +#: ../../howto/enum.rst:1175 msgid "" "membership / containment checking: zero-valued flags are always considered " "to be contained::" msgstr "" -#: ../../howto/enum.rst:1154 +#: ../../howto/enum.rst:1178 msgid "" ">>> Color.BLACK in Color.WHITE\n" "True" @@ -2112,13 +2173,13 @@ msgstr "" ">>> Color.BLACK in Color.WHITE\n" "True" -#: ../../howto/enum.rst:1157 +#: ../../howto/enum.rst:1181 msgid "" "otherwise, only if all bits of one flag are in the other flag will True be " "returned::" msgstr "" -#: ../../howto/enum.rst:1160 +#: ../../howto/enum.rst:1184 msgid "" ">>> Color.PURPLE in Color.WHITE\n" "True\n" @@ -2132,109 +2193,110 @@ msgstr "" ">>> Color.GREEN in Color.PURPLE\n" "False" -#: ../../howto/enum.rst:1166 +#: ../../howto/enum.rst:1190 msgid "" "There is a new boundary mechanism that controls how out-of-range / invalid " "bits are handled: ``STRICT``, ``CONFORM``, ``EJECT``, and ``KEEP``:" msgstr "" -#: ../../howto/enum.rst:1169 +#: ../../howto/enum.rst:1193 msgid "STRICT --> raises an exception when presented with invalid values" -msgstr "" +msgstr "STRICT --> 當遇到無效值時引發例外" -#: ../../howto/enum.rst:1170 +#: ../../howto/enum.rst:1194 msgid "CONFORM --> discards any invalid bits" -msgstr "" +msgstr "CONFORM --> 捨棄任何無效位元" -#: ../../howto/enum.rst:1171 +#: ../../howto/enum.rst:1195 msgid "EJECT --> lose Flag status and become a normal int with the given value" -msgstr "" +msgstr "EJECT --> 失去 Flag 狀態並成為具有給定值的普通 int" -#: ../../howto/enum.rst:1172 +#: ../../howto/enum.rst:1196 msgid "KEEP --> keep the extra bits" -msgstr "" +msgstr "KEEP --> 保留額外位元" -#: ../../howto/enum.rst:1174 +#: ../../howto/enum.rst:1198 msgid "keeps Flag status and extra bits" -msgstr "" +msgstr "保留 Flag 狀態和額外位元" -#: ../../howto/enum.rst:1175 +#: ../../howto/enum.rst:1199 msgid "extra bits do not show up in iteration" msgstr "" -#: ../../howto/enum.rst:1176 +#: ../../howto/enum.rst:1200 msgid "extra bits do show up in repr() and str()" msgstr "" -#: ../../howto/enum.rst:1178 +#: ../../howto/enum.rst:1202 msgid "" "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)." +"``EJECT``, and the default for ``_convert_`` is ``KEEP`` (see " +"``ssl.Options`` for an example of when ``KEEP`` is needed)." msgstr "" -#: ../../howto/enum.rst:1186 +#: ../../howto/enum.rst:1210 msgid "How are Enums and Flags different?" -msgstr "" +msgstr "Enums 和 Flags 有何不同?" -#: ../../howto/enum.rst:1188 +#: ../../howto/enum.rst:1212 msgid "" -"Enums have a custom metaclass that affects many aspects of both derived :" -"class:`Enum` classes and their instances (members)." +"Enums have a custom metaclass that affects many aspects of both " +"derived :class:`Enum` classes and their instances (members)." msgstr "" -#: ../../howto/enum.rst:1193 +#: ../../howto/enum.rst:1217 msgid "Enum Classes" -msgstr "" +msgstr "Enum 類別" -#: ../../howto/enum.rst:1195 +#: ../../howto/enum.rst:1219 msgid "" -"The :class:`EnumType` metaclass is responsible for providing the :meth:" -"`__contains__`, :meth:`__dir__`, :meth:`__iter__` and other methods that " -"allow one to do things with an :class:`Enum` class that fail on a typical " -"class, such as ``list(Color)`` or ``some_enum_var in Color``. :class:" -"`EnumType` is responsible for ensuring that various other methods on the " -"final :class:`Enum` class are correct (such as :meth:`__new__`, :meth:" -"`__getnewargs__`, :meth:`__str__` and :meth:`__repr__`)." +"The :class:`EnumType` metaclass is responsible for providing " +"the :meth:`~object.__contains__`, :meth:`~object.__dir__`, :meth:`~object.__iter__` " +"and other methods that allow one to do things with an :class:`Enum` class " +"that fail on a typical class, such as ``list(Color)`` or ``some_enum_var in " +"Color``. :class:`EnumType` is responsible for ensuring that various other " +"methods on the final :class:`Enum` class are correct (such " +"as :meth:`~object.__new__`, :meth:`~object.__getnewargs__`, :meth:`~object.__str__` " +"and :meth:`~object.__repr__`)." msgstr "" -#: ../../howto/enum.rst:1204 +#: ../../howto/enum.rst:1228 msgid "Flag Classes" -msgstr "" +msgstr "Flag 類別" -#: ../../howto/enum.rst:1206 +#: ../../howto/enum.rst:1230 msgid "" "Flags have an expanded view of aliasing: to be canonical, the value of a " "flag needs to be a power-of-two value, and not a duplicate name. So, in " -"addition to the :class:`Enum` 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 " +"addition to the :class:`Enum` 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." msgstr "" -#: ../../howto/enum.rst:1212 +#: ../../howto/enum.rst:1236 msgid "Enum Members (aka instances)" msgstr "" -#: ../../howto/enum.rst:1214 +#: ../../howto/enum.rst:1238 msgid "" -"The most interesting thing about enum members is that they are singletons. :" -"class:`EnumType` creates them all while it is creating the enum class " -"itself, and then puts a custom :meth:`__new__` in place to ensure that no " -"new ones are ever instantiated by returning only the existing member " -"instances." +"The most interesting thing about enum members is that they are " +"singletons. :class:`EnumType` creates them all while it is creating the enum " +"class itself, and then puts a custom :meth:`~object.__new__` in place to " +"ensure that no new ones are ever instantiated by returning only the existing " +"member instances." msgstr "" -#: ../../howto/enum.rst:1220 +#: ../../howto/enum.rst:1244 msgid "Flag Members" -msgstr "" +msgstr "Flag 成員" -#: ../../howto/enum.rst:1222 +#: ../../howto/enum.rst:1246 msgid "" "Flag members can be iterated over just like the :class:`Flag` class, and " "only the canonical members will be returned. For example::" msgstr "" -#: ../../howto/enum.rst:1225 +#: ../../howto/enum.rst:1249 msgid "" ">>> list(Color)\n" "[, , ]" @@ -2242,17 +2304,17 @@ msgstr "" ">>> list(Color)\n" "[, , ]" -#: ../../howto/enum.rst:1228 +#: ../../howto/enum.rst:1252 msgid "(Note that ``BLACK``, ``PURPLE``, and ``WHITE`` do not show up.)" msgstr "" -#: ../../howto/enum.rst:1230 +#: ../../howto/enum.rst:1254 msgid "" "Inverting a flag member returns the corresponding positive value, rather " "than a negative value --- for example::" msgstr "" -#: ../../howto/enum.rst:1233 +#: ../../howto/enum.rst:1257 msgid "" ">>> ~Color.RED\n" "" @@ -2260,13 +2322,13 @@ msgstr "" ">>> ~Color.RED\n" "" -#: ../../howto/enum.rst:1236 +#: ../../howto/enum.rst:1260 msgid "" "Flag members have a length corresponding to the number of power-of-two " "values they contain. For example::" msgstr "" -#: ../../howto/enum.rst:1239 +#: ../../howto/enum.rst:1263 msgid "" ">>> len(Color.PURPLE)\n" "2" @@ -2274,62 +2336,63 @@ msgstr "" ">>> len(Color.PURPLE)\n" "2" -#: ../../howto/enum.rst:1246 +#: ../../howto/enum.rst:1270 msgid "Enum Cookbook" msgstr "" -#: ../../howto/enum.rst:1249 +#: ../../howto/enum.rst:1273 msgid "" -"While :class:`Enum`, :class:`IntEnum`, :class:`StrEnum`, :class:`Flag`, and :" -"class:`IntFlag` are expected to cover the majority of use-cases, they cannot " -"cover them all. Here are recipes for some different types of enumerations " -"that can be used directly, or as examples for creating one's own." +"While :class:`Enum`, :class:`IntEnum`, :class:`StrEnum`, :class:`Flag`, " +"and :class:`IntFlag` are expected to cover the majority of use-cases, they " +"cannot cover them all. Here are recipes for some different types of " +"enumerations that can be used directly, or as examples for creating one's " +"own." msgstr "" -#: ../../howto/enum.rst:1256 +#: ../../howto/enum.rst:1280 msgid "Omitting values" -msgstr "" +msgstr "省略值" -#: ../../howto/enum.rst:1258 +#: ../../howto/enum.rst:1282 msgid "" "In many use-cases, one doesn't care what the actual value of an enumeration " "is. There are several ways to define this type of simple enumeration:" msgstr "" -#: ../../howto/enum.rst:1261 +#: ../../howto/enum.rst:1285 msgid "use instances of :class:`auto` for the value" msgstr "" -#: ../../howto/enum.rst:1262 +#: ../../howto/enum.rst:1286 msgid "use instances of :class:`object` as the value" msgstr "" -#: ../../howto/enum.rst:1263 +#: ../../howto/enum.rst:1287 msgid "use a descriptive string as the value" msgstr "" -#: ../../howto/enum.rst:1264 +#: ../../howto/enum.rst:1288 msgid "" -"use a tuple as the value and a custom :meth:`__new__` to replace the tuple " -"with an :class:`int` value" +"use a tuple as the value and a custom :meth:`~object.__new__` to replace the " +"tuple with an :class:`int` value" msgstr "" -#: ../../howto/enum.rst:1267 +#: ../../howto/enum.rst:1291 msgid "" "Using any of these methods signifies to the user that these values are not " "important, and also enables one to add, remove, or reorder members without " "having to renumber the remaining members." msgstr "" -#: ../../howto/enum.rst:1273 +#: ../../howto/enum.rst:1297 msgid "Using :class:`auto`" msgstr "使用 :class:`auto`" -#: ../../howto/enum.rst:1275 +#: ../../howto/enum.rst:1299 msgid "Using :class:`auto` would look like::" -msgstr "" +msgstr "使用 :class:`auto` 會像這樣: ::" -#: ../../howto/enum.rst:1277 +#: ../../howto/enum.rst:1301 msgid "" ">>> class Color(Enum):\n" "... RED = auto()\n" @@ -2347,22 +2410,22 @@ msgstr "" ">>> Color.GREEN\n" "" -#: ../../howto/enum.rst:1287 +#: ../../howto/enum.rst:1311 msgid "Using :class:`object`" msgstr "使用 :class:`object`" -#: ../../howto/enum.rst:1289 +#: ../../howto/enum.rst:1313 msgid "Using :class:`object` would look like::" -msgstr "" +msgstr "使用 :class:`object` 會像這樣: ::" -#: ../../howto/enum.rst:1291 +#: ../../howto/enum.rst:1315 msgid "" ">>> class Color(Enum):\n" "... RED = object()\n" "... GREEN = object()\n" "... BLUE = object()\n" "...\n" -">>> Color.GREEN \n" +">>> Color.GREEN\n" ">" msgstr "" ">>> class Color(Enum):\n" @@ -2370,16 +2433,16 @@ msgstr "" "... GREEN = object()\n" "... BLUE = object()\n" "...\n" -">>> Color.GREEN \n" +">>> Color.GREEN\n" ">" -#: ../../howto/enum.rst:1299 +#: ../../howto/enum.rst:1323 msgid "" -"This is also a good example of why you might want to write your own :meth:" -"`__repr__`::" +"This is also a good example of why you might want to write your " +"own :meth:`~object.__repr__`::" msgstr "" -#: ../../howto/enum.rst:1302 +#: ../../howto/enum.rst:1326 msgid "" ">>> class Color(Enum):\n" "... RED = object()\n" @@ -2401,15 +2464,15 @@ msgstr "" ">>> Color.GREEN\n" "" -#: ../../howto/enum.rst:1315 +#: ../../howto/enum.rst:1339 msgid "Using a descriptive string" msgstr "" -#: ../../howto/enum.rst:1317 +#: ../../howto/enum.rst:1341 msgid "Using a string as the value would look like::" msgstr "" -#: ../../howto/enum.rst:1319 +#: ../../howto/enum.rst:1343 msgid "" ">>> class Color(Enum):\n" "... RED = 'stop'\n" @@ -2427,15 +2490,15 @@ msgstr "" ">>> Color.GREEN\n" "" -#: ../../howto/enum.rst:1329 -msgid "Using a custom :meth:`__new__`" -msgstr "" +#: ../../howto/enum.rst:1353 +msgid "Using a custom :meth:`~object.__new__`" +msgstr "使用自訂的 :meth:`~object.__new__`" -#: ../../howto/enum.rst:1331 -msgid "Using an auto-numbering :meth:`__new__` would look like::" +#: ../../howto/enum.rst:1355 +msgid "Using an auto-numbering :meth:`~object.__new__` would look like::" msgstr "" -#: ../../howto/enum.rst:1333 +#: ../../howto/enum.rst:1357 msgid "" ">>> class AutoNumber(Enum):\n" "... def __new__(cls):\n" @@ -2467,13 +2530,13 @@ msgstr "" ">>> Color.GREEN\n" "" -#: ../../howto/enum.rst:1348 +#: ../../howto/enum.rst:1372 msgid "" "To make a more general purpose ``AutoNumber``, add ``*args`` to the " "signature::" msgstr "" -#: ../../howto/enum.rst:1350 +#: ../../howto/enum.rst:1374 msgid "" ">>> class AutoNumber(Enum):\n" "... def __new__(cls, *args): # this is the only change from above\n" @@ -2484,13 +2547,13 @@ msgid "" "..." msgstr "" -#: ../../howto/enum.rst:1358 +#: ../../howto/enum.rst:1382 msgid "" "Then when you inherit from ``AutoNumber`` you can write your own " "``__init__`` to handle any extra arguments::" msgstr "" -#: ../../howto/enum.rst:1361 +#: ../../howto/enum.rst:1385 msgid "" ">>> class Swatch(AutoNumber):\n" "... def __init__(self, pantone='unknown'):\n" @@ -2507,35 +2570,35 @@ msgid "" "'unknown'" msgstr "" -#: ../../howto/enum.rst:1377 +#: ../../howto/enum.rst:1401 msgid "" -"The :meth:`__new__` method, if defined, is used during creation of the Enum " -"members; it is then replaced by Enum's :meth:`__new__` which is used after " -"class creation for lookup of existing members." +"The :meth:`~object.__new__` method, if defined, is used during creation of " +"the Enum members; it is then replaced by Enum's :meth:`~object.__new__` " +"which is used after class creation for lookup of existing members." msgstr "" -#: ../../howto/enum.rst:1383 +#: ../../howto/enum.rst:1407 msgid "" "*Do not* call ``super().__new__()``, as the lookup-only ``__new__`` is the " "one that is found; instead, use the data type directly -- e.g.::" msgstr "" -#: ../../howto/enum.rst:1386 +#: ../../howto/enum.rst:1410 msgid "obj = int.__new__(cls, value)" msgstr "obj = int.__new__(cls, value)" -#: ../../howto/enum.rst:1390 +#: ../../howto/enum.rst:1414 msgid "OrderedEnum" msgstr "OrderedEnum" -#: ../../howto/enum.rst:1392 +#: ../../howto/enum.rst:1416 msgid "" "An ordered enumeration that is not based on :class:`IntEnum` and so " "maintains the normal :class:`Enum` invariants (such as not being comparable " "to other enumerations)::" msgstr "" -#: ../../howto/enum.rst:1396 +#: ../../howto/enum.rst:1420 msgid "" ">>> class OrderedEnum(Enum):\n" "... def __ge__(self, other):\n" @@ -2593,17 +2656,17 @@ msgstr "" ">>> Grade.C < Grade.A\n" "True" -#: ../../howto/enum.rst:1426 +#: ../../howto/enum.rst:1450 msgid "DuplicateFreeEnum" msgstr "DuplicateFreeEnum" -#: ../../howto/enum.rst:1428 +#: ../../howto/enum.rst:1452 msgid "" "Raises an error if a duplicate member value is found instead of creating an " "alias::" msgstr "" -#: ../../howto/enum.rst:1431 +#: ../../howto/enum.rst:1455 msgid "" ">>> class DuplicateFreeEnum(Enum):\n" "... def __init__(self, *args):\n" @@ -2627,24 +2690,52 @@ msgid "" "ValueError: aliases not allowed in DuplicateFreeEnum: 'GRENE' --> 'GREEN'" msgstr "" -#: ../../howto/enum.rst:1453 +#: ../../howto/enum.rst:1477 msgid "" "This is a useful example for subclassing Enum to add or change other " "behaviors as well as disallowing aliases. If the only desired change is " "disallowing aliases, the :func:`unique` decorator can be used instead." msgstr "" -#: ../../howto/enum.rst:1459 +#: ../../howto/enum.rst:1483 +msgid "MultiValueEnum" +msgstr "MultiValueEnum" + +#: ../../howto/enum.rst:1485 +msgid "Supports having more than one value per member::" +msgstr "" + +#: ../../howto/enum.rst:1487 +msgid "" +">>> class MultiValueEnum(Enum):\n" +"... def __new__(cls, value, *values):\n" +"... self = object.__new__(cls)\n" +"... self._value_ = value\n" +"... for v in values:\n" +"... self._add_value_alias_(v)\n" +"... return self\n" +"...\n" +">>> class DType(MultiValueEnum):\n" +"... float32 = 'f', 8\n" +"... double64 = 'd', 9\n" +"...\n" +">>> DType('f')\n" +"\n" +">>> DType(9)\n" +"" +msgstr "" + +#: ../../howto/enum.rst:1506 msgid "Planet" msgstr "" -#: ../../howto/enum.rst:1461 +#: ../../howto/enum.rst:1508 msgid "" -"If :meth:`__new__` or :meth:`__init__` is defined, the value of the enum " -"member will be passed to those methods::" +"If :meth:`~object.__new__` or :meth:`~object.__init__` is defined, the value " +"of the enum member will be passed to those methods::" msgstr "" -#: ../../howto/enum.rst:1464 +#: ../../howto/enum.rst:1511 msgid "" ">>> class Planet(Enum):\n" "... MERCURY = (3.303e+23, 2.4397e6)\n" @@ -2670,15 +2761,15 @@ msgid "" "9.802652743337129" msgstr "" -#: ../../howto/enum.rst:1490 +#: ../../howto/enum.rst:1537 msgid "TimePeriod" msgstr "" -#: ../../howto/enum.rst:1492 -msgid "An example to show the :attr:`_ignore_` attribute in use::" +#: ../../howto/enum.rst:1539 +msgid "An example to show the :attr:`~Enum._ignore_` attribute in use::" msgstr "" -#: ../../howto/enum.rst:1494 +#: ../../howto/enum.rst:1541 msgid "" ">>> from datetime import timedelta\n" ">>> class Period(timedelta, Enum):\n" @@ -2689,18 +2780,18 @@ msgid "" "... Period['day_%d' % i] = i\n" "...\n" ">>> list(Period)[:2]\n" -"[, ]\n" +"[, ]\n" ">>> list(Period)[-2:]\n" -"[, ]" +"[, ]" msgstr "" -#: ../../howto/enum.rst:1511 +#: ../../howto/enum.rst:1558 msgid "Subclassing EnumType" -msgstr "" +msgstr "子類別化 EnumType" -#: ../../howto/enum.rst:1513 +#: ../../howto/enum.rst:1560 msgid "" "While most enum needs can be met by customizing :class:`Enum` subclasses, " "either with class decorators or custom functions, :class:`EnumType` can be " diff --git a/howto/free-threading-extensions.po b/howto/free-threading-extensions.po new file mode 100644 index 0000000000..42af41a8d9 --- /dev/null +++ b/howto/free-threading-extensions.po @@ -0,0 +1,500 @@ +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.13\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-07-24 00:16+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" +"Language: zh_TW\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../../howto/free-threading-extensions.rst:7 +msgid "C API Extension Support for Free Threading" +msgstr "支援自由執行緒的 C API 擴充" + +#: ../../howto/free-threading-extensions.rst:9 +msgid "" +"Starting with the 3.13 release, CPython has experimental support for running " +"with the :term:`global interpreter lock` (GIL) disabled in a configuration " +"called :term:`free threading`. This document describes how to adapt C API " +"extensions to support free threading." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:16 +msgid "Identifying the Free-Threaded Build in C" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:18 +msgid "" +"The CPython C API exposes the ``Py_GIL_DISABLED`` macro: in the free-" +"threaded build it's defined to ``1``, and in the regular build it's not " +"defined. You can use it to enable code that only runs under the free-" +"threaded build::" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:22 +msgid "" +"#ifdef Py_GIL_DISABLED\n" +"/* code that only runs in the free-threaded build */\n" +"#endif" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:28 +msgid "" +"On Windows, this macro is not defined automatically, but must be specified " +"to the compiler when building. The :func:`sysconfig.get_config_var` function " +"can be used to determine whether the current running interpreter had the " +"macro defined." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:35 +msgid "Module Initialization" +msgstr "模組初始化" + +#: ../../howto/free-threading-extensions.rst:37 +msgid "" +"Extension modules need to explicitly indicate that they support running with " +"the GIL disabled; otherwise importing the extension will raise a warning and " +"enable the GIL at runtime." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:41 +msgid "" +"There are two ways to indicate that an extension module supports running " +"with the GIL disabled depending on whether the extension uses multi-phase or " +"single-phase initialization." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:46 +msgid "Multi-Phase Initialization" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:48 +msgid "" +"Extensions that use multi-phase initialization (i.e., :c:func:" +"`PyModuleDef_Init`) should add a :c:data:`Py_mod_gil` slot in the module " +"definition. If your extension supports older versions of CPython, you " +"should guard the slot with a :c:data:`PY_VERSION_HEX` check." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:55 +msgid "" +"static struct PyModuleDef_Slot module_slots[] = {\n" +" ...\n" +"#if PY_VERSION_HEX >= 0x030D0000\n" +" {Py_mod_gil, Py_MOD_GIL_NOT_USED},\n" +"#endif\n" +" {0, NULL}\n" +"};\n" +"\n" +"static struct PyModuleDef moduledef = {\n" +" PyModuleDef_HEAD_INIT,\n" +" .m_slots = module_slots,\n" +" ...\n" +"};" +msgstr "" +"static struct PyModuleDef_Slot module_slots[] = {\n" +" ...\n" +"#if PY_VERSION_HEX >= 0x030D0000\n" +" {Py_mod_gil, Py_MOD_GIL_NOT_USED},\n" +"#endif\n" +" {0, NULL}\n" +"};\n" +"\n" +"static struct PyModuleDef moduledef = {\n" +" PyModuleDef_HEAD_INIT,\n" +" .m_slots = module_slots,\n" +" ...\n" +"};" + +#: ../../howto/free-threading-extensions.rst:71 +msgid "Single-Phase Initialization" +msgstr "單一階段初始化 (Single-Phase Initialization)" + +#: ../../howto/free-threading-extensions.rst:73 +msgid "" +"Extensions that use single-phase initialization (i.e., :c:func:" +"`PyModule_Create`) should call :c:func:`PyUnstable_Module_SetGIL` 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." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:81 +msgid "" +"static struct PyModuleDef moduledef = {\n" +" PyModuleDef_HEAD_INIT,\n" +" ...\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_mymodule(void)\n" +"{\n" +" PyObject *m = PyModule_Create(&moduledef);\n" +" if (m == NULL) {\n" +" return NULL;\n" +" }\n" +"#ifdef Py_GIL_DISABLED\n" +" PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);\n" +"#endif\n" +" return m;\n" +"}" +msgstr "" +"static struct PyModuleDef moduledef = {\n" +" PyModuleDef_HEAD_INIT,\n" +" ...\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_mymodule(void)\n" +"{\n" +" PyObject *m = PyModule_Create(&moduledef);\n" +" if (m == NULL) {\n" +" return NULL;\n" +" }\n" +"#ifdef Py_GIL_DISABLED\n" +" PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);\n" +"#endif\n" +" return m;\n" +"}" + +#: ../../howto/free-threading-extensions.rst:101 +msgid "General API Guidelines" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:103 +msgid "Most of the C API is thread-safe, but there are some exceptions." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:105 +msgid "" +"**Struct Fields**: Accessing fields in Python C API objects or structs " +"directly is not thread-safe if the field may be concurrently modified." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:107 +msgid "" +"**Macros**: Accessor macros like :c:macro:`PyList_GET_ITEM` and :c:macro:" +"`PyList_SET_ITEM` do not perform any error checking or locking. These macros " +"are not thread-safe if the container object may be modified concurrently." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:111 +msgid "" +"**Borrowed References**: C API functions that return :term:`borrowed " +"references ` may not be thread-safe if the containing " +"object is modified concurrently. See the section on :ref:`borrowed " +"references ` for more information." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:118 +msgid "Container Thread Safety" +msgstr "容器執行緒安全性" + +#: ../../howto/free-threading-extensions.rst:120 +msgid "" +"Containers like :c:struct:`PyListObject`, :c:struct:`PyDictObject`, and :c:" +"struct:`PySetObject` perform internal locking in the free-threaded build. " +"For example, the :c:func:`PyList_Append` will lock the list before appending " +"an item." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:128 +msgid "``PyDict_Next``" +msgstr "``PyDict_Next``" + +#: ../../howto/free-threading-extensions.rst:130 +msgid "" +"A notable exception is :c:func:`PyDict_Next`, which does not lock the " +"dictionary. You should use :c:macro:`Py_BEGIN_CRITICAL_SECTION` to protect " +"the dictionary while iterating over it if the dictionary may be concurrently " +"modified::" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:135 +msgid "" +"Py_BEGIN_CRITICAL_SECTION(dict);\n" +"PyObject *key, *value;\n" +"Py_ssize_t pos = 0;\n" +"while (PyDict_Next(dict, &pos, &key, &value)) {\n" +" ...\n" +"}\n" +"Py_END_CRITICAL_SECTION();" +msgstr "" +"Py_BEGIN_CRITICAL_SECTION(dict);\n" +"PyObject *key, *value;\n" +"Py_ssize_t pos = 0;\n" +"while (PyDict_Next(dict, &pos, &key, &value)) {\n" +" ...\n" +"}\n" +"Py_END_CRITICAL_SECTION();" + +#: ../../howto/free-threading-extensions.rst:145 +msgid "Borrowed References" +msgstr "借用參照" + +#: ../../howto/free-threading-extensions.rst:149 +msgid "" +"Some C API functions return :term:`borrowed references `. These APIs are not thread-safe if the containing object is " +"modified concurrently. For example, it's not safe to use :c:func:" +"`PyList_GetItem` if the list may be modified concurrently." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:154 +msgid "" +"The following table lists some borrowed reference APIs and their " +"replacements that return :term:`strong references `." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:158 +msgid "Borrowed reference API" +msgstr "借用參照 API" + +#: ../../howto/free-threading-extensions.rst:158 +msgid "Strong reference API" +msgstr "強參照 API" + +#: ../../howto/free-threading-extensions.rst:160 +msgid ":c:func:`PyList_GetItem`" +msgstr ":c:func:`PyList_GetItem`" + +#: ../../howto/free-threading-extensions.rst:160 +#: ../../howto/free-threading-extensions.rst:162 +msgid ":c:func:`PyList_GetItemRef`" +msgstr ":c:func:`PyList_GetItemRef`" + +#: ../../howto/free-threading-extensions.rst:162 +msgid ":c:func:`PyList_GET_ITEM`" +msgstr ":c:func:`PyList_GET_ITEM`" + +#: ../../howto/free-threading-extensions.rst:164 +msgid ":c:func:`PyDict_GetItem`" +msgstr ":c:func:`PyDict_GetItem`" + +#: ../../howto/free-threading-extensions.rst:164 +#: ../../howto/free-threading-extensions.rst:166 +msgid ":c:func:`PyDict_GetItemRef`" +msgstr ":c:func:`PyDict_GetItemRef`" + +#: ../../howto/free-threading-extensions.rst:166 +msgid ":c:func:`PyDict_GetItemWithError`" +msgstr ":c:func:`PyDict_GetItemWithError`" + +#: ../../howto/free-threading-extensions.rst:168 +msgid ":c:func:`PyDict_GetItemString`" +msgstr ":c:func:`PyDict_GetItemString`" + +#: ../../howto/free-threading-extensions.rst:168 +msgid ":c:func:`PyDict_GetItemStringRef`" +msgstr ":c:func:`PyDict_GetItemStringRef`" + +#: ../../howto/free-threading-extensions.rst:170 +msgid ":c:func:`PyDict_SetDefault`" +msgstr ":c:func:`PyDict_SetDefault`" + +#: ../../howto/free-threading-extensions.rst:170 +msgid ":c:func:`PyDict_SetDefaultRef`" +msgstr ":c:func:`PyDict_SetDefaultRef`" + +#: ../../howto/free-threading-extensions.rst:172 +msgid ":c:func:`PyDict_Next`" +msgstr ":c:func:`PyDict_Next`" + +#: ../../howto/free-threading-extensions.rst:172 +msgid "none (see :ref:`PyDict_Next`)" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:174 +msgid ":c:func:`PyWeakref_GetObject`" +msgstr ":c:func:`PyWeakref_GetObject`" + +#: ../../howto/free-threading-extensions.rst:174 +#: ../../howto/free-threading-extensions.rst:176 +msgid ":c:func:`PyWeakref_GetRef`" +msgstr ":c:func:`PyWeakref_GetRef`" + +#: ../../howto/free-threading-extensions.rst:176 +msgid ":c:func:`PyWeakref_GET_OBJECT`" +msgstr ":c:func:`PyWeakref_GET_OBJECT`" + +#: ../../howto/free-threading-extensions.rst:178 +msgid ":c:func:`PyImport_AddModule`" +msgstr ":c:func:`PyImport_AddModule`" + +#: ../../howto/free-threading-extensions.rst:178 +msgid ":c:func:`PyImport_AddModuleRef`" +msgstr ":c:func:`PyImport_AddModuleRef`" + +#: ../../howto/free-threading-extensions.rst:181 +msgid "" +"Not all APIs that return borrowed references are problematic. For example, :" +"c:func:`PyTuple_GetItem` is safe because tuples are immutable. Similarly, " +"not all uses of the above APIs are problematic. For example, :c:func:" +"`PyDict_GetItem` 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." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:189 +msgid "" +"Some of these functions were added in Python 3.13. You can use the " +"`pythoncapi-compat `_ package " +"to provide implementations of these functions for older Python versions." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:197 +msgid "Memory Allocation APIs" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:199 +msgid "" +"Python's memory management C API provides functions in three different :ref:" +"`allocation domains `: \"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." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:208 +msgid "" +"Search for uses of :c:func:`PyObject_Malloc` in your extension and check " +"that the allocated memory is used for Python objects. Use :c:func:" +"`PyMem_Malloc` to allocate buffers instead of :c:func:`PyObject_Malloc`." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:215 +msgid "Thread State and GIL APIs" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:217 +msgid "" +"Python provides a set of functions and macros to manage thread state and the " +"GIL, such as:" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:220 +msgid ":c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release`" +msgstr ":c:func:`PyGILState_Ensure` 和 :c:func:`PyGILState_Release`" + +#: ../../howto/free-threading-extensions.rst:221 +msgid ":c:func:`PyEval_SaveThread` and :c:func:`PyEval_RestoreThread`" +msgstr ":c:func:`PyEval_SaveThread` 和 :c:func:`PyEval_RestoreThread`" + +#: ../../howto/free-threading-extensions.rst:222 +msgid ":c:macro:`Py_BEGIN_ALLOW_THREADS` and :c:macro:`Py_END_ALLOW_THREADS`" +msgstr ":c:macro:`Py_BEGIN_ALLOW_THREADS` 和 :c:macro:`Py_END_ALLOW_THREADS`" + +#: ../../howto/free-threading-extensions.rst:224 +msgid "" +"These functions should still be used in the free-threaded build to manage " +"thread state even when the :term:`GIL` is disabled. For example, if you " +"create a thread outside of Python, you must call :c:func:`PyGILState_Ensure` " +"before calling into the Python API to ensure that the thread has a valid " +"Python thread state." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:230 +msgid "" +"You should continue to call :c:func:`PyEval_SaveThread` or :c:macro:" +"`Py_BEGIN_ALLOW_THREADS` around blocking operations, such as I/O or lock " +"acquisitions, to allow other threads to run the :term:`cyclic garbage " +"collector `." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:237 +msgid "Protecting Internal Extension State" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:239 +msgid "" +"Your extension may have internal state that was previously protected by the " +"GIL. You may need to add locking to protect this state. The approach will " +"depend on your extension, but some common patterns include:" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:243 +msgid "" +"**Caches**: global caches are a common source of shared state. Consider " +"using a lock to protect the cache or disabling it in the free-threaded build " +"if the cache is not critical for performance." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:246 +msgid "" +"**Global State**: global state may need to be protected by a lock or moved " +"to thread local storage. C11 and C++11 provide the ``thread_local`` or " +"``_Thread_local`` for `thread-local storage `_." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:253 +msgid "Building Extensions for the Free-Threaded Build" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:255 +msgid "" +"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." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:258 +msgid "" +"`pypa/manylinux `_ supports the free-" +"threaded build, with the ``t`` suffix, such as ``python3.13t``." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:260 +msgid "" +"`pypa/cibuildwheel `_ supports the " +"free-threaded build if you set `CIBW_ENABLE to cpython-freethreading " +"`_." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:265 +msgid "Limited C API and Stable ABI" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:267 +msgid "" +"The free-threaded build does not currently support the :ref:`Limited C API " +"` or the stable ABI. If you use `setuptools `_ 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." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:275 +msgid "" +"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." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:281 +msgid "Windows" +msgstr "Windows" + +#: ../../howto/free-threading-extensions.rst:283 +msgid "" +"Due to a limitation of the official Windows installer, you will need to " +"manually define ``Py_GIL_DISABLED=1`` when building extensions from source." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:288 +msgid "" +"`Porting Extension Modules to Support Free-Threading `_: A community-maintained porting guide for " +"extension authors." +msgstr "" diff --git a/howto/free-threading-python.po b/howto/free-threading-python.po new file mode 100644 index 0000000000..ada1b6f51f --- /dev/null +++ b/howto/free-threading-python.po @@ -0,0 +1,257 @@ +# Copyright (C) 2001-2024, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.13\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" +"Language: zh_TW\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../../howto/free-threading-python.rst:5 +msgid "Python experimental support for free threading" +msgstr "Python 自由執行緒的實驗性支援" + +#: ../../howto/free-threading-python.rst:7 +msgid "" +"Starting with the 3.13 release, CPython has experimental support for a build " +"of Python called :term:`free threading` where the :term:`global interpreter " +"lock` (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." +msgstr "" + +#: ../../howto/free-threading-python.rst:14 +msgid "" +"**The free-threaded mode is experimental** and work is ongoing to improve " +"it: expect some bugs and a substantial single-threaded performance hit." +msgstr "" + +#: ../../howto/free-threading-python.rst:17 +msgid "" +"This document describes the implications of free threading for Python code. " +"See :ref:`freethreading-extensions-howto` for information on how to write C " +"extensions that support the free-threaded build." +msgstr "" + +#: ../../howto/free-threading-python.rst:23 +msgid "" +":pep:`703` – Making the Global Interpreter Lock Optional in CPython for an " +"overall description of free-threaded Python." +msgstr "" + +#: ../../howto/free-threading-python.rst:28 +msgid "Installation" +msgstr "安裝" + +#: ../../howto/free-threading-python.rst:30 +msgid "" +"Starting with Python 3.13, the official macOS and Windows installers " +"optionally support installing free-threaded Python binaries. The installers " +"are available at https://www.python.org/downloads/." +msgstr "" + +#: ../../howto/free-threading-python.rst:34 +msgid "" +"For information on other platforms, see the `Installing a Free-Threaded " +"Python `_, a " +"community-maintained installation guide for installing free-threaded Python." +msgstr "" + +#: ../../howto/free-threading-python.rst:38 +msgid "" +"When building CPython from source, the :option:`--disable-gil` configure " +"option should be used to build a free-threaded Python interpreter." +msgstr "" + +#: ../../howto/free-threading-python.rst:43 +msgid "Identifying free-threaded Python" +msgstr "" + +#: ../../howto/free-threading-python.rst:45 +msgid "" +"To check if the current interpreter supports free-threading, :option:`python " +"-VV <-V>` and :data:`sys.version` contain \"experimental free-threading " +"build\". The new :func:`sys._is_gil_enabled` function can be used to check " +"whether the GIL is actually disabled in the running process." +msgstr "" + +#: ../../howto/free-threading-python.rst:50 +msgid "" +"The ``sysconfig.get_config_var(\"Py_GIL_DISABLED\")`` configuration variable " +"can be used to determine whether the build supports free threading. If the " +"variable is set to ``1``, then the build supports free threading. This is " +"the recommended mechanism for decisions related to the build configuration." +msgstr "" + +#: ../../howto/free-threading-python.rst:57 +msgid "The global interpreter lock in free-threaded Python" +msgstr "" + +#: ../../howto/free-threading-python.rst:59 +msgid "" +"Free-threaded builds of CPython support optionally running with the GIL " +"enabled at runtime using the environment variable :envvar:`PYTHON_GIL` or " +"the command-line option :option:`-X gil`." +msgstr "" + +#: ../../howto/free-threading-python.rst:63 +msgid "" +"The GIL may also automatically be enabled when importing a C-API extension " +"module that is not explicitly marked as supporting free threading. A " +"warning will be printed in this case." +msgstr "" + +#: ../../howto/free-threading-python.rst:67 +msgid "" +"In addition to individual package documentation, the following websites " +"track the status of popular packages support for free threading:" +msgstr "" + +#: ../../howto/free-threading-python.rst:70 +msgid "https://py-free-threading.github.io/tracking/" +msgstr "https://py-free-threading.github.io/tracking/" + +#: ../../howto/free-threading-python.rst:71 +msgid "https://hugovk.github.io/free-threaded-wheels/" +msgstr "https://hugovk.github.io/free-threaded-wheels/" + +#: ../../howto/free-threading-python.rst:75 +msgid "Thread safety" +msgstr "執行緒安全" + +#: ../../howto/free-threading-python.rst:77 +msgid "" +"The free-threaded build of CPython aims to provide similar thread-safety " +"behavior at the Python level to the default GIL-enabled build. Built-in " +"types like :class:`dict`, :class:`list`, and :class:`set` 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." +msgstr "" + +#: ../../howto/free-threading-python.rst:88 +msgid "" +"It's recommended to use the :class:`threading.Lock` or other synchronization " +"primitives instead of relying on the internal locks of built-in types, when " +"possible." +msgstr "" + +#: ../../howto/free-threading-python.rst:94 +msgid "Known limitations" +msgstr "已知限制" + +#: ../../howto/free-threading-python.rst:96 +msgid "" +"This section describes known limitations of the free-threaded CPython build." +msgstr "" + +#: ../../howto/free-threading-python.rst:99 +msgid "Immortalization" +msgstr "不滅化 (Immortalization)" + +#: ../../howto/free-threading-python.rst:101 +msgid "" +"The free-threaded build of the 3.13 release makes some objects :term:" +"`immortal`. Immortal objects are not deallocated and have reference counts " +"that are never modified. This is done to avoid reference count contention " +"that would prevent efficient multi-threaded scaling." +msgstr "" + +#: ../../howto/free-threading-python.rst:106 +msgid "" +"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:" +msgstr "" + +#: ../../howto/free-threading-python.rst:109 +msgid "" +":ref:`function ` objects declared at the module level" +msgstr "在模組層級宣告的\\ :ref:`函式 `\\ 物件" + +#: ../../howto/free-threading-python.rst:110 +msgid ":ref:`method ` descriptors" +msgstr ":ref:`方法 `\\ 描述器" + +#: ../../howto/free-threading-python.rst:111 +msgid ":ref:`code ` objects" +msgstr ":ref:`程式碼 `\\ 物件" + +#: ../../howto/free-threading-python.rst:112 +msgid ":term:`module` objects and their dictionaries" +msgstr ":term:`模組 `\\ 物件及其字典" + +#: ../../howto/free-threading-python.rst:113 +msgid ":ref:`classes ` (type objects)" +msgstr ":ref:`類別 `\\ (型別物件)" + +#: ../../howto/free-threading-python.rst:115 +msgid "" +"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." +msgstr "" + +#: ../../howto/free-threading-python.rst:119 +msgid "" +"Additionally, numeric and string literals in the code as well as strings " +"returned by :func:`sys.intern` are also immortalized. This behavior is " +"expected to remain in the 3.14 free-threaded build." +msgstr "" + +#: ../../howto/free-threading-python.rst:125 +msgid "Frame objects" +msgstr "" + +#: ../../howto/free-threading-python.rst:127 +msgid "" +"It is not safe to access :ref:`frame ` objects from other " +"threads and doing so may cause your program to crash . This means that :" +"func:`sys._current_frames` is generally not safe to use in a free-threaded " +"build. Functions like :func:`inspect.currentframe` and :func:`sys." +"_getframe` are generally safe as long as the resulting frame object is not " +"passed to another thread." +msgstr "" + +#: ../../howto/free-threading-python.rst:135 +msgid "Iterators" +msgstr "疊代器" + +#: ../../howto/free-threading-python.rst:137 +msgid "" +"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." +msgstr "" + +#: ../../howto/free-threading-python.rst:143 +msgid "Single-threaded performance" +msgstr "單執行緒效能" + +#: ../../howto/free-threading-python.rst:145 +msgid "" +"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 `_ 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`) 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." +msgstr "" diff --git a/howto/functional.po b/howto/functional.po index b615ce6e3c..f302283661 100644 --- a/howto/functional.po +++ b/howto/functional.po @@ -5,9 +5,9 @@ # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-07-04 00:16+0000\n" "PO-Revision-Date: 2018-05-23 14:36+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -18,15 +18,15 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../howto/functional.rst:3 +#: ../../howto/functional.rst:5 msgid "Functional Programming HOWTO" -msgstr "函式編程 HOWTO" +msgstr "函式程式設計 HOWTO" #: ../../howto/functional.rst:0 msgid "Author" msgstr "作者" -#: ../../howto/functional.rst:5 +#: ../../howto/functional.rst:7 msgid "A. M. Kuchling" msgstr "A. M. Kuchling" @@ -34,11 +34,11 @@ msgstr "A. M. Kuchling" msgid "Release" msgstr "發佈版本" -#: ../../howto/functional.rst:6 +#: ../../howto/functional.rst:8 msgid "0.32" msgstr "0.32" -#: ../../howto/functional.rst:8 +#: ../../howto/functional.rst:10 msgid "" "In this document, we'll take a tour of Python's features suitable for " "implementing programs in a functional style. After an introduction to the " @@ -47,30 +47,30 @@ msgid "" "such as :mod:`itertools` and :mod:`functools`." msgstr "" -#: ../../howto/functional.rst:16 +#: ../../howto/functional.rst:18 msgid "Introduction" msgstr "簡介" -#: ../../howto/functional.rst:18 +#: ../../howto/functional.rst:20 msgid "" "This section explains the basic concept of functional programming; if you're " "just interested in learning about Python language features, skip to the next " "section on :ref:`functional-howto-iterators`." msgstr "" -#: ../../howto/functional.rst:22 +#: ../../howto/functional.rst:24 msgid "" "Programming languages support decomposing problems in several different ways:" msgstr "" -#: ../../howto/functional.rst:24 +#: ../../howto/functional.rst:26 msgid "" "Most programming languages are **procedural**: programs are lists of " "instructions that tell the computer what to do with the program's input. C, " "Pascal, and even Unix shells are procedural languages." msgstr "" -#: ../../howto/functional.rst:28 +#: ../../howto/functional.rst:30 msgid "" "In **declarative** languages, you write a specification that describes the " "problem to be solved, and the language implementation figures out how to " @@ -80,7 +80,7 @@ msgid "" "indexes, which subclauses should be performed first, etc." msgstr "" -#: ../../howto/functional.rst:35 +#: ../../howto/functional.rst:37 msgid "" "**Object-oriented** programs manipulate collections of objects. Objects " "have internal state and support methods that query or modify this internal " @@ -89,7 +89,7 @@ msgid "" "force the use of object-oriented features." msgstr "" -#: ../../howto/functional.rst:41 +#: ../../howto/functional.rst:43 msgid "" "**Functional** programming decomposes a problem into a set of functions. " "Ideally, functions only take inputs and produce outputs, and don't have any " @@ -98,7 +98,7 @@ msgid "" "other variants) and Haskell." msgstr "" -#: ../../howto/functional.rst:47 +#: ../../howto/functional.rst:49 msgid "" "The designers of some computer languages choose to emphasize one particular " "approach to programming. This often makes it difficult to write programs " @@ -111,7 +111,7 @@ msgid "" "functional, for example." msgstr "" -#: ../../howto/functional.rst:58 +#: ../../howto/functional.rst:60 msgid "" "In a functional program, input flows through a set of functions. Each " "function operates on its input and produces some output. Functional style " @@ -122,7 +122,7 @@ msgid "" "runs; every function's output must only depend on its input." msgstr "" -#: ../../howto/functional.rst:66 +#: ../../howto/functional.rst:68 msgid "" "Some languages are very strict about purity and don't even have assignment " "statements such as ``a=3`` or ``c = a + b``, but it's difficult to avoid all " @@ -133,7 +133,7 @@ msgid "" "for a second." msgstr "" -#: ../../howto/functional.rst:73 +#: ../../howto/functional.rst:75 msgid "" "Python programs written in functional style usually won't go to the extreme " "of avoiding all I/O or all assignments; instead, they'll provide a " @@ -143,7 +143,7 @@ msgid "" "other side effects." msgstr "" -#: ../../howto/functional.rst:79 +#: ../../howto/functional.rst:81 msgid "" "Functional programming can be considered the opposite of object-oriented " "programming. Objects are little capsules containing some internal state " @@ -155,40 +155,40 @@ msgid "" "objects in your application (e-mail messages, transactions, etc.)." msgstr "" -#: ../../howto/functional.rst:88 +#: ../../howto/functional.rst:90 msgid "" "Functional design may seem like an odd constraint to work under. Why should " "you avoid objects and side effects? There are theoretical and practical " "advantages to the functional style:" msgstr "" -#: ../../howto/functional.rst:92 +#: ../../howto/functional.rst:94 msgid "Formal provability." -msgstr "" +msgstr "形式可證明性 (Formal provability)。" -#: ../../howto/functional.rst:93 +#: ../../howto/functional.rst:95 msgid "Modularity." -msgstr "" +msgstr "模組化 (Modularity)。" -#: ../../howto/functional.rst:94 +#: ../../howto/functional.rst:96 msgid "Composability." -msgstr "" +msgstr "可組合性 (Composability)。" -#: ../../howto/functional.rst:95 +#: ../../howto/functional.rst:97 msgid "Ease of debugging and testing." -msgstr "" +msgstr "容易除錯與測試。" -#: ../../howto/functional.rst:99 +#: ../../howto/functional.rst:101 msgid "Formal provability" -msgstr "" +msgstr "形式可證明性" -#: ../../howto/functional.rst:101 +#: ../../howto/functional.rst:103 msgid "" "A theoretical benefit is that it's easier to construct a mathematical proof " "that a functional program is correct." msgstr "" -#: ../../howto/functional.rst:104 +#: ../../howto/functional.rst:106 msgid "" "For a long time researchers have been interested in finding ways to " "mathematically prove programs correct. This is different from testing a " @@ -198,7 +198,7 @@ msgid "" "the right result for all possible inputs." msgstr "" -#: ../../howto/functional.rst:111 +#: ../../howto/functional.rst:113 msgid "" "The technique used to prove programs correct is to write down " "**invariants**, properties of the input data and of the program's variables " @@ -209,7 +209,7 @@ msgid "" "invariants should match the desired conditions on the program's output." msgstr "" -#: ../../howto/functional.rst:119 +#: ../../howto/functional.rst:121 msgid "" "Functional programming's avoidance of assignments arose because assignments " "are difficult to handle with this technique; assignments can break " @@ -217,7 +217,7 @@ msgid "" "invariants that can be propagated onward." msgstr "" -#: ../../howto/functional.rst:124 +#: ../../howto/functional.rst:126 msgid "" "Unfortunately, proving programs correct is largely impractical and not " "relevant to Python software. Even trivial programs require proofs that are " @@ -229,11 +229,11 @@ msgid "" "wrongly believe you've proved the program correct." msgstr "" -#: ../../howto/functional.rst:135 +#: ../../howto/functional.rst:137 msgid "Modularity" -msgstr "" +msgstr "模組化" -#: ../../howto/functional.rst:137 +#: ../../howto/functional.rst:139 msgid "" "A more practical benefit of functional programming is that it forces you to " "break apart your problem into small pieces. Programs are more modular as a " @@ -242,15 +242,15 @@ msgid "" "Small functions are also easier to read and to check for errors." msgstr "" -#: ../../howto/functional.rst:145 +#: ../../howto/functional.rst:147 msgid "Ease of debugging and testing" -msgstr "" +msgstr "容易除錯與測試" -#: ../../howto/functional.rst:147 +#: ../../howto/functional.rst:149 msgid "Testing and debugging a functional-style program is easier." msgstr "" -#: ../../howto/functional.rst:149 +#: ../../howto/functional.rst:151 msgid "" "Debugging is simplified because functions are generally small and clearly " "specified. When a program doesn't work, each function is an interface point " @@ -259,7 +259,7 @@ msgid "" "responsible for a bug." msgstr "" -#: ../../howto/functional.rst:154 +#: ../../howto/functional.rst:156 msgid "" "Testing is easier because each function is a potential subject for a unit " "test. Functions don't depend on system state that needs to be replicated " @@ -267,11 +267,11 @@ msgid "" "and then check that the output matches expectations." msgstr "" -#: ../../howto/functional.rst:161 +#: ../../howto/functional.rst:163 msgid "Composability" -msgstr "" +msgstr "可組合性" -#: ../../howto/functional.rst:163 +#: ../../howto/functional.rst:165 msgid "" "As you work on a functional-style program, you'll write a number of " "functions with varying inputs and outputs. Some of these functions will be " @@ -282,24 +282,24 @@ msgid "" "different situations." msgstr "" -#: ../../howto/functional.rst:170 +#: ../../howto/functional.rst:172 msgid "" "Over time you'll form a personal library of utilities. Often you'll " "assemble new programs by arranging existing functions in a new configuration " "and writing a few functions specialized for the current task." msgstr "" -#: ../../howto/functional.rst:178 +#: ../../howto/functional.rst:180 msgid "Iterators" -msgstr "" +msgstr "疊代器" -#: ../../howto/functional.rst:180 +#: ../../howto/functional.rst:182 msgid "" "I'll start by looking at a Python language feature that's an important " "foundation for writing functional-style programs: iterators." msgstr "" -#: ../../howto/functional.rst:183 +#: ../../howto/functional.rst:185 msgid "" "An iterator is an object representing a stream of data; this object returns " "the data one element at a time. A Python iterator must support a method " @@ -310,7 +310,7 @@ msgid "" "reasonable to write an iterator that produces an infinite stream of data." msgstr "" -#: ../../howto/functional.rst:191 +#: ../../howto/functional.rst:193 msgid "" "The built-in :func:`iter` function takes an arbitrary object and tries to " "return an iterator that will return the object's contents or elements, " @@ -320,11 +320,11 @@ msgid "" "an iterator for it." msgstr "" -#: ../../howto/functional.rst:198 +#: ../../howto/functional.rst:200 msgid "You can experiment with the iteration interface manually:" msgstr "" -#: ../../howto/functional.rst:216 +#: ../../howto/functional.rst:218 msgid "" "Python expects iterable objects in several different contexts, the most " "important being the :keyword:`for` statement. In the statement ``for X in " @@ -332,7 +332,7 @@ msgid "" "an iterator. These two statements are equivalent::" msgstr "" -#: ../../howto/functional.rst:222 +#: ../../howto/functional.rst:224 msgid "" "for i in iter(obj):\n" " print(i)\n" @@ -346,19 +346,19 @@ msgstr "" "for i in obj:\n" " print(i)" -#: ../../howto/functional.rst:228 +#: ../../howto/functional.rst:230 msgid "" "Iterators can be materialized as lists or tuples by using the :func:`list` " "or :func:`tuple` constructor functions:" msgstr "" -#: ../../howto/functional.rst:237 +#: ../../howto/functional.rst:239 msgid "" "Sequence unpacking also supports iterators: if you know an iterator will " "return N elements, you can unpack them into an N-tuple:" msgstr "" -#: ../../howto/functional.rst:246 +#: ../../howto/functional.rst:248 msgid "" "Built-in functions such as :func:`max` and :func:`min` can take a single " "iterator argument and will return the largest or smallest element. The " @@ -369,7 +369,7 @@ msgid "" "stream, the ``\"in\"`` and ``\"not in\"`` operators won't return either." msgstr "" -#: ../../howto/functional.rst:254 +#: ../../howto/functional.rst:256 msgid "" "Note that you can only go forward in an iterator; there's no way to get the " "previous element, reset the iterator, or make a copy of it. Iterator " @@ -380,24 +380,24 @@ msgid "" "new iterator." msgstr "" -#: ../../howto/functional.rst:264 +#: ../../howto/functional.rst:266 msgid "Data Types That Support Iterators" msgstr "" -#: ../../howto/functional.rst:266 +#: ../../howto/functional.rst:268 msgid "" "We've already seen how lists and tuples support iterators. In fact, any " "Python sequence type, such as strings, will automatically support creation " "of an iterator." msgstr "" -#: ../../howto/functional.rst:270 +#: ../../howto/functional.rst:272 msgid "" "Calling :func:`iter` on a dictionary returns an iterator that will loop over " "the dictionary's keys::" msgstr "" -#: ../../howto/functional.rst:273 +#: ../../howto/functional.rst:275 msgid "" ">>> m = {'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6,\n" "... 'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12}\n" @@ -433,14 +433,14 @@ msgstr "" "Nov 11\n" "Dec 12" -#: ../../howto/functional.rst:290 +#: ../../howto/functional.rst:292 msgid "" "Note that starting with Python 3.7, dictionary iteration order is guaranteed " "to be the same as the insertion order. In earlier versions, the behaviour " "was unspecified and could vary between implementations." msgstr "" -#: ../../howto/functional.rst:294 +#: ../../howto/functional.rst:296 msgid "" "Applying :func:`iter` to a dictionary always loops over the keys, but " "dictionaries have methods that return other iterators. If you want to " @@ -448,33 +448,33 @@ msgid "" "`~dict.values` or :meth:`~dict.items` methods to get an appropriate iterator." msgstr "" -#: ../../howto/functional.rst:300 +#: ../../howto/functional.rst:302 msgid "" "The :func:`dict` constructor can accept an iterator that returns a finite " "stream of ``(key, value)`` tuples:" msgstr "" -#: ../../howto/functional.rst:307 +#: ../../howto/functional.rst:309 msgid "" "Files also support iteration by calling the :meth:`~io.TextIOBase.readline` " "method until there are no more lines in the file. This means you can read " "each line of a file like this::" msgstr "" -#: ../../howto/functional.rst:311 +#: ../../howto/functional.rst:313 msgid "" "for line in file:\n" " # do something for each line\n" " ..." msgstr "" -#: ../../howto/functional.rst:315 +#: ../../howto/functional.rst:317 msgid "" "Sets can take their contents from an iterable and let you iterate over the " "set's elements::" msgstr "" -#: ../../howto/functional.rst:318 +#: ../../howto/functional.rst:320 msgid "" ">>> S = {2, 3, 5, 7, 11, 13}\n" ">>> for i in S:\n" @@ -496,11 +496,11 @@ msgstr "" "11\n" "13" -#: ../../howto/functional.rst:331 +#: ../../howto/functional.rst:333 msgid "Generator expressions and list comprehensions" -msgstr "" +msgstr "產生器運算式與串列綜合運算式" -#: ../../howto/functional.rst:333 +#: ../../howto/functional.rst:335 msgid "" "Two common operations on an iterator's output are 1) performing some " "operation for every element, 2) selecting a subset of elements that meet " @@ -509,7 +509,7 @@ msgid "" "containing a given substring." msgstr "" -#: ../../howto/functional.rst:339 +#: ../../howto/functional.rst:341 msgid "" "List comprehensions and generator expressions (short form: \"listcomps\" and " "\"genexps\") are a concise notation for such operations, borrowed from the " @@ -517,7 +517,7 @@ msgid "" "strip all the whitespace from a stream of strings with the following code::" msgstr "" -#: ../../howto/functional.rst:344 +#: ../../howto/functional.rst:346 msgid "" ">>> line_list = [' line 1\\n', 'line 2 \\n', ' \\n', '']\n" "\n" @@ -527,13 +527,20 @@ msgid "" ">>> # List comprehension -- returns list\n" ">>> stripped_list = [line.strip() for line in line_list]" msgstr "" +">>> line_list = [' line 1\\n', 'line 2 \\n', ' \\n', '']\n" +"\n" +">>> # 產生器運算式 -- 回傳疊代器\n" +">>> stripped_iter = (line.strip() for line in line_list)\n" +"\n" +">>> # 串列綜合運算式 -- 回傳串列\n" +">>> stripped_list = [line.strip() for line in line_list]" -#: ../../howto/functional.rst:352 +#: ../../howto/functional.rst:354 msgid "" "You can select only certain elements by adding an ``\"if\"`` condition::" msgstr "" -#: ../../howto/functional.rst:354 +#: ../../howto/functional.rst:356 msgid "" ">>> stripped_list = [line.strip() for line in line_list\n" "... if line != \"\"]" @@ -541,7 +548,7 @@ msgstr "" ">>> stripped_list = [line.strip() for line in line_list\n" "... if line != \"\"]" -#: ../../howto/functional.rst:357 +#: ../../howto/functional.rst:359 msgid "" "With a list comprehension, you get back a Python list; ``stripped_list`` is " "a list containing the resulting lines, not an iterator. Generator " @@ -552,14 +559,14 @@ msgid "" "preferable in these situations." msgstr "" -#: ../../howto/functional.rst:364 +#: ../../howto/functional.rst:366 msgid "" "Generator expressions are surrounded by parentheses (\"()\") and list " "comprehensions are surrounded by square brackets (\"[]\"). Generator " "expressions have the form::" msgstr "" -#: ../../howto/functional.rst:368 +#: ../../howto/functional.rst:370 msgid "" "( expression for expr in sequence1\n" " if condition1\n" @@ -581,13 +588,13 @@ msgstr "" " for exprN in sequenceN\n" " if conditionN )" -#: ../../howto/functional.rst:378 +#: ../../howto/functional.rst:380 msgid "" "Again, for a list comprehension only the outside brackets are different " "(square brackets instead of parentheses)." msgstr "" -#: ../../howto/functional.rst:381 +#: ../../howto/functional.rst:383 msgid "" "The elements of the generated output will be the successive values of " "``expression``. The ``if`` clauses are all optional; if present, " @@ -595,18 +602,18 @@ msgid "" "is true." msgstr "" -#: ../../howto/functional.rst:385 +#: ../../howto/functional.rst:387 msgid "" "Generator expressions always have to be written inside parentheses, but the " "parentheses signalling a function call also count. If you want to create an " "iterator that will be immediately passed to a function you can write::" msgstr "" -#: ../../howto/functional.rst:389 +#: ../../howto/functional.rst:391 msgid "obj_total = sum(obj.count for obj in list_all_objects())" msgstr "obj_total = sum(obj.count for obj in list_all_objects())" -#: ../../howto/functional.rst:391 +#: ../../howto/functional.rst:393 msgid "" "The ``for...in`` clauses contain the sequences to be iterated over. The " "sequences do not have to be the same length, because they are iterated over " @@ -616,13 +623,13 @@ msgid "" "``sequence2``." msgstr "" -#: ../../howto/functional.rst:397 +#: ../../howto/functional.rst:399 msgid "" "To put it another way, a list comprehension or generator expression is " "equivalent to the following Python code::" msgstr "" -#: ../../howto/functional.rst:400 +#: ../../howto/functional.rst:402 msgid "" "for expr1 in sequence1:\n" " if not (condition1):\n" @@ -639,7 +646,7 @@ msgid "" " # the expression." msgstr "" -#: ../../howto/functional.rst:414 +#: ../../howto/functional.rst:416 msgid "" "This means that when there are multiple ``for...in`` clauses but no ``if`` " "clauses, the length of the resulting output will be equal to the product of " @@ -647,14 +654,14 @@ msgid "" "output list is 9 elements long:" msgstr "" -#: ../../howto/functional.rst:426 +#: ../../howto/functional.rst:428 msgid "" "To avoid introducing an ambiguity into Python's grammar, if ``expression`` " "is creating a tuple, it must be surrounded with parentheses. The first list " "comprehension below is a syntax error, while the second one is correct::" msgstr "" -#: ../../howto/functional.rst:430 +#: ../../howto/functional.rst:432 msgid "" "# Syntax error\n" "[x, y for x in seq1 for y in seq2]\n" @@ -666,18 +673,18 @@ msgstr "" "# 正確\n" "[(x, y) for x in seq1 for y in seq2]" -#: ../../howto/functional.rst:437 +#: ../../howto/functional.rst:439 msgid "Generators" -msgstr "" +msgstr "產生器" -#: ../../howto/functional.rst:439 +#: ../../howto/functional.rst:441 msgid "" "Generators are a special class of functions that simplify the task of " "writing iterators. Regular functions compute a value and return it, but " "generators return an iterator that returns a stream of values." msgstr "" -#: ../../howto/functional.rst:443 +#: ../../howto/functional.rst:445 msgid "" "You're doubtless familiar with how regular function calls work in Python or " "C. When you call a function, it gets a private namespace where its local " @@ -690,18 +697,18 @@ msgid "" "thought of as resumable functions." msgstr "" -#: ../../howto/functional.rst:452 +#: ../../howto/functional.rst:454 msgid "Here's the simplest example of a generator function:" -msgstr "" +msgstr "以下是最簡單的產生器函式範例:" -#: ../../howto/functional.rst:458 +#: ../../howto/functional.rst:460 msgid "" "Any function containing a :keyword:`yield` keyword is a generator function; " "this is detected by Python's :term:`bytecode` compiler which compiles the " "function specially as a result." msgstr "" -#: ../../howto/functional.rst:462 +#: ../../howto/functional.rst:464 msgid "" "When you call a generator function, it doesn't return a single value; " "instead it returns a generator object that supports the iterator protocol. " @@ -713,17 +720,17 @@ msgid "" "method, the function will resume executing." msgstr "" -#: ../../howto/functional.rst:471 +#: ../../howto/functional.rst:473 msgid "Here's a sample usage of the ``generate_ints()`` generator:" -msgstr "" +msgstr "以下是 ``generate_ints()`` 產生器的使用範例:" -#: ../../howto/functional.rst:488 +#: ../../howto/functional.rst:490 msgid "" "You could equally write ``for i in generate_ints(5)``, or ``a, b, c = " "generate_ints(3)``." msgstr "" -#: ../../howto/functional.rst:491 +#: ../../howto/functional.rst:493 msgid "" "Inside a generator function, ``return value`` causes " "``StopIteration(value)`` to be raised from the :meth:`~generator.__next__` " @@ -731,7 +738,7 @@ msgid "" "procession of values ends and the generator cannot yield any further values." msgstr "" -#: ../../howto/functional.rst:496 +#: ../../howto/functional.rst:498 msgid "" "You could achieve the effect of generators manually by writing your own " "class and storing all the local variables of the generator as instance " @@ -741,7 +748,7 @@ msgid "" "complicated generator, writing a corresponding class can be much messier." msgstr "" -#: ../../howto/functional.rst:504 +#: ../../howto/functional.rst:506 msgid "" "The test suite included with Python's library, :source:`Lib/test/" "test_generators.py`, contains a number of more interesting examples. Here's " @@ -749,7 +756,7 @@ msgid "" "generators recursively. ::" msgstr "" -#: ../../howto/functional.rst:509 +#: ../../howto/functional.rst:511 msgid "" "# A recursive generator that generates Tree leaves in in-order.\n" "def inorder(t):\n" @@ -763,7 +770,7 @@ msgid "" " yield x" msgstr "" -#: ../../howto/functional.rst:520 +#: ../../howto/functional.rst:522 msgid "" "Two other examples in ``test_generators.py`` produce solutions for the N-" "Queens problem (placing N queens on an NxN chess board so that no queen " @@ -772,11 +779,11 @@ msgid "" "twice)." msgstr "" -#: ../../howto/functional.rst:528 +#: ../../howto/functional.rst:530 msgid "Passing values into a generator" msgstr "" -#: ../../howto/functional.rst:530 +#: ../../howto/functional.rst:532 msgid "" "In Python 2.4 and earlier, generators only produced output. Once a " "generator's code was invoked to create an iterator, there was no way to pass " @@ -786,18 +793,18 @@ msgid "" "these approaches are messy." msgstr "" -#: ../../howto/functional.rst:537 +#: ../../howto/functional.rst:539 msgid "" "In Python 2.5 there's a simple way to pass values into a generator. :keyword:" "`yield` became an expression, returning a value that can be assigned to a " "variable or otherwise operated on::" msgstr "" -#: ../../howto/functional.rst:541 +#: ../../howto/functional.rst:543 msgid "val = (yield i)" msgstr "val = (yield i)" -#: ../../howto/functional.rst:543 +#: ../../howto/functional.rst:545 msgid "" "I recommend that you **always** put parentheses around a ``yield`` " "expression when you're doing something with the returned value, as in the " @@ -805,7 +812,7 @@ msgid "" "always add them instead of having to remember when they're needed." msgstr "" -#: ../../howto/functional.rst:548 +#: ../../howto/functional.rst:550 msgid "" "(:pep:`342` explains the exact rules, which are that a ``yield``-expression " "must always be parenthesized except when it occurs at the top-level " @@ -814,7 +821,7 @@ msgid "" "operation, as in ``val = (yield i) + 12``.)" msgstr "" -#: ../../howto/functional.rst:554 +#: ../../howto/functional.rst:556 msgid "" "Values are sent into a generator by calling its :meth:`send(value) " "` method. This method resumes the generator's code and the " @@ -822,13 +829,13 @@ msgid "" "`~generator.__next__` method is called, the ``yield`` returns ``None``." msgstr "" -#: ../../howto/functional.rst:559 +#: ../../howto/functional.rst:561 msgid "" "Here's a simple counter that increments by 1 and allows changing the value " "of the internal counter." msgstr "" -#: ../../howto/functional.rst:562 +#: ../../howto/functional.rst:564 msgid "" "def counter(maximum):\n" " i = 0\n" @@ -840,12 +847,21 @@ msgid "" " else:\n" " i += 1" msgstr "" +"def counter(maximum):\n" +" i = 0\n" +" while i < maximum:\n" +" val = (yield i)\n" +" # 如有提供值則改變計數器\n" +" if val is not None:\n" +" i = val\n" +" else:\n" +" i += 1" -#: ../../howto/functional.rst:574 +#: ../../howto/functional.rst:576 msgid "And here's an example of changing the counter:" msgstr "" -#: ../../howto/functional.rst:591 +#: ../../howto/functional.rst:593 msgid "" "Because ``yield`` will often be returning ``None``, you should always check " "for this case. Don't just use its value in expressions unless you're sure " @@ -853,22 +869,22 @@ msgid "" "resume your generator function." msgstr "" -#: ../../howto/functional.rst:596 +#: ../../howto/functional.rst:598 msgid "" "In addition to :meth:`~generator.send`, there are two other methods on " "generators:" msgstr "" -#: ../../howto/functional.rst:599 +#: ../../howto/functional.rst:601 msgid "" ":meth:`throw(value) ` is used to raise an exception inside " "the generator; the exception is raised by the ``yield`` expression where the " "generator's execution is paused." msgstr "" -#: ../../howto/functional.rst:603 +#: ../../howto/functional.rst:605 msgid "" -":meth:`~generator.close` raises a :exc:`GeneratorExit` exception inside the " +":meth:`~generator.close` sends a :exc:`GeneratorExit` exception to the " "generator to terminate the iteration. On receiving this exception, the " "generator's code must either raise :exc:`GeneratorExit` or :exc:" "`StopIteration`; catching the exception and doing anything else is illegal " @@ -877,20 +893,20 @@ msgid "" "collected." msgstr "" -#: ../../howto/functional.rst:611 +#: ../../howto/functional.rst:613 msgid "" "If you need to run cleanup code when a :exc:`GeneratorExit` occurs, I " "suggest using a ``try: ... finally:`` suite instead of catching :exc:" "`GeneratorExit`." msgstr "" -#: ../../howto/functional.rst:614 +#: ../../howto/functional.rst:616 msgid "" "The cumulative effect of these changes is to turn generators from one-way " "producers of information into both producers and consumers." msgstr "" -#: ../../howto/functional.rst:617 +#: ../../howto/functional.rst:619 msgid "" "Generators also become **coroutines**, a more generalized form of " "subroutines. Subroutines are entered at one point and exited at another " @@ -899,36 +915,38 @@ msgid "" "statements)." msgstr "" -#: ../../howto/functional.rst:624 +#: ../../howto/functional.rst:626 msgid "Built-in functions" msgstr "內建函式" -#: ../../howto/functional.rst:626 +#: ../../howto/functional.rst:628 msgid "" "Let's look in more detail at built-in functions often used with iterators." msgstr "" -#: ../../howto/functional.rst:628 +#: ../../howto/functional.rst:630 msgid "" "Two of Python's built-in functions, :func:`map` and :func:`filter` duplicate " "the features of generator expressions:" msgstr "" -#: ../../howto/functional.rst:631 +#: ../../howto/functional.rst:633 msgid "" ":func:`map(f, iterA, iterB, ...) ` returns an iterator over the sequence" -msgstr "" +msgstr ":func:`map(f, iterA, iterB, ...) ` 回傳一個元素為序列的疊代器" -#: ../../howto/functional.rst:632 +#: ../../howto/functional.rst:634 msgid "" "``f(iterA[0], iterB[0]), f(iterA[1], iterB[1]), f(iterA[2], iterB[2]), ...``." msgstr "" +"``f(iterA[0], iterB[0]), f(iterA[1], iterB[1]), f(iterA[2], iterB[2]), ..." +"``。" -#: ../../howto/functional.rst:642 +#: ../../howto/functional.rst:644 msgid "You can of course achieve the same effect with a list comprehension." msgstr "" -#: ../../howto/functional.rst:644 +#: ../../howto/functional.rst:646 msgid "" ":func:`filter(predicate, iter) ` returns an iterator over all the " "sequence elements that meet a certain condition, and is similarly duplicated " @@ -937,18 +955,18 @@ msgid "" "must take a single value." msgstr "" -#: ../../howto/functional.rst:657 +#: ../../howto/functional.rst:659 msgid "This can also be written as a list comprehension:" msgstr "" -#: ../../howto/functional.rst:663 +#: ../../howto/functional.rst:665 msgid "" ":func:`enumerate(iter, start=0) ` counts off the elements in the " "iterable returning 2-tuples containing the count (from *start*) and each " "element. ::" msgstr "" -#: ../../howto/functional.rst:667 +#: ../../howto/functional.rst:669 msgid "" ">>> for item in enumerate(['subject', 'verb', 'object']):\n" "... print(item)\n" @@ -962,13 +980,13 @@ msgstr "" "(1, 'verb')\n" "(2, 'object')" -#: ../../howto/functional.rst:673 +#: ../../howto/functional.rst:675 msgid "" ":func:`enumerate` is often used when looping through a list and recording " "the indexes at which certain conditions are met::" msgstr "" -#: ../../howto/functional.rst:676 +#: ../../howto/functional.rst:678 msgid "" "f = open('data.txt', 'r')\n" "for i, line in enumerate(f):\n" @@ -980,7 +998,7 @@ msgstr "" " if line.strip() == '':\n" " print('Blank line at line #%i' % i)" -#: ../../howto/functional.rst:681 +#: ../../howto/functional.rst:683 msgid "" ":func:`sorted(iterable, key=None, reverse=False) ` collects all the " "elements of the iterable into a list, sorts the list, and returns the sorted " @@ -988,25 +1006,25 @@ msgid "" "constructed list's :meth:`~list.sort` method. ::" msgstr "" -#: ../../howto/functional.rst:686 +#: ../../howto/functional.rst:688 msgid "" ">>> import random\n" ">>> # Generate 8 random numbers between [0, 10000)\n" ">>> rand_list = random.sample(range(10000), 8)\n" -">>> rand_list \n" +">>> rand_list\n" "[769, 7953, 9828, 6431, 8442, 9878, 6213, 2207]\n" -">>> sorted(rand_list) \n" +">>> sorted(rand_list)\n" "[769, 2207, 6213, 6431, 7953, 8442, 9828, 9878]\n" -">>> sorted(rand_list, reverse=True) \n" +">>> sorted(rand_list, reverse=True)\n" "[9878, 9828, 8442, 7953, 6431, 6213, 2207, 769]" msgstr "" -#: ../../howto/functional.rst:696 +#: ../../howto/functional.rst:698 msgid "" "(For a more detailed discussion of sorting, see the :ref:`sortinghowto`.)" msgstr "" -#: ../../howto/functional.rst:699 +#: ../../howto/functional.rst:701 msgid "" "The :func:`any(iter) ` and :func:`all(iter) ` built-ins look at " "the truth values of an iterable's contents. :func:`any` returns ``True`` if " @@ -1014,13 +1032,13 @@ msgid "" "``True`` if all of the elements are true values:" msgstr "" -#: ../../howto/functional.rst:718 +#: ../../howto/functional.rst:720 msgid "" ":func:`zip(iterA, iterB, ...) ` takes one element from each iterable " "and returns them in a tuple::" msgstr "" -#: ../../howto/functional.rst:721 +#: ../../howto/functional.rst:723 msgid "" "zip(['a', 'b', 'c'], (1, 2, 3)) =>\n" " ('a', 1), ('b', 2), ('c', 3)" @@ -1028,7 +1046,7 @@ msgstr "" "zip(['a', 'b', 'c'], (1, 2, 3)) =>\n" " ('a', 1), ('b', 2), ('c', 3)" -#: ../../howto/functional.rst:724 +#: ../../howto/functional.rst:726 msgid "" "It doesn't construct an in-memory list and exhaust all the input iterators " "before returning; instead tuples are constructed and returned only if " @@ -1036,14 +1054,14 @@ msgid "" "evaluation `__.)" msgstr "" -#: ../../howto/functional.rst:729 +#: ../../howto/functional.rst:731 msgid "" "This iterator is intended to be used with iterables that are all of the same " "length. If the iterables are of different lengths, the resulting stream " "will be the same length as the shortest iterable. ::" msgstr "" -#: ../../howto/functional.rst:733 +#: ../../howto/functional.rst:735 msgid "" "zip(['a', 'b'], (1, 2, 3)) =>\n" " ('a', 1), ('b', 2)" @@ -1051,49 +1069,49 @@ msgstr "" "zip(['a', 'b'], (1, 2, 3)) =>\n" " ('a', 1), ('b', 2)" -#: ../../howto/functional.rst:736 +#: ../../howto/functional.rst:738 msgid "" "You should avoid doing this, though, because an element may be taken from " "the longer iterators and discarded. This means you can't go on to use the " "iterators further because you risk skipping a discarded element." msgstr "" -#: ../../howto/functional.rst:742 +#: ../../howto/functional.rst:744 msgid "The itertools module" msgstr "itertools 模組" -#: ../../howto/functional.rst:744 +#: ../../howto/functional.rst:746 msgid "" "The :mod:`itertools` module contains a number of commonly used iterators as " "well as functions for combining several iterators. This section will " "introduce the module's contents by showing small examples." msgstr "" -#: ../../howto/functional.rst:748 +#: ../../howto/functional.rst:750 msgid "The module's functions fall into a few broad classes:" msgstr "" -#: ../../howto/functional.rst:750 +#: ../../howto/functional.rst:752 msgid "Functions that create a new iterator based on an existing iterator." msgstr "" -#: ../../howto/functional.rst:751 +#: ../../howto/functional.rst:753 msgid "Functions for treating an iterator's elements as function arguments." msgstr "" -#: ../../howto/functional.rst:752 +#: ../../howto/functional.rst:754 msgid "Functions for selecting portions of an iterator's output." msgstr "" -#: ../../howto/functional.rst:753 +#: ../../howto/functional.rst:755 msgid "A function for grouping an iterator's output." msgstr "" -#: ../../howto/functional.rst:756 +#: ../../howto/functional.rst:758 msgid "Creating new iterators" msgstr "建立新的疊代器" -#: ../../howto/functional.rst:758 +#: ../../howto/functional.rst:760 msgid "" ":func:`itertools.count(start, step) ` returns an infinite " "stream of evenly spaced values. You can optionally supply the starting " @@ -1101,7 +1119,7 @@ msgid "" "defaults to 1::" msgstr "" -#: ../../howto/functional.rst:762 +#: ../../howto/functional.rst:764 msgid "" "itertools.count() =>\n" " 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...\n" @@ -1117,7 +1135,7 @@ msgstr "" "itertools.count(10, 5) =>\n" " 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, ..." -#: ../../howto/functional.rst:769 +#: ../../howto/functional.rst:771 msgid "" ":func:`itertools.cycle(iter) ` saves a copy of the contents " "of a provided iterable and returns a new iterator that returns its elements " @@ -1125,7 +1143,7 @@ msgid "" "infinitely. ::" msgstr "" -#: ../../howto/functional.rst:773 +#: ../../howto/functional.rst:775 msgid "" "itertools.cycle([1, 2, 3, 4, 5]) =>\n" " 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, ..." @@ -1133,14 +1151,14 @@ msgstr "" "itertools.cycle([1, 2, 3, 4, 5]) =>\n" " 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, ..." -#: ../../howto/functional.rst:776 +#: ../../howto/functional.rst:778 msgid "" ":func:`itertools.repeat(elem, [n]) ` returns the provided " "element *n* times, or returns the element endlessly if *n* is not " "provided. ::" msgstr "" -#: ../../howto/functional.rst:779 +#: ../../howto/functional.rst:781 msgid "" "itertools.repeat('abc') =>\n" " abc, abc, abc, abc, abc, abc, abc, abc, abc, abc, ...\n" @@ -1152,7 +1170,7 @@ msgstr "" "itertools.repeat('abc', 5) =>\n" " abc, abc, abc, abc, abc" -#: ../../howto/functional.rst:784 +#: ../../howto/functional.rst:786 msgid "" ":func:`itertools.chain(iterA, iterB, ...) ` takes an " "arbitrary number of iterables as input, and returns all the elements of the " @@ -1160,7 +1178,7 @@ msgid "" "the iterables have been exhausted. ::" msgstr "" -#: ../../howto/functional.rst:789 +#: ../../howto/functional.rst:791 msgid "" "itertools.chain(['a', 'b', 'c'], (1, 2, 3)) =>\n" " a, b, c, 1, 2, 3" @@ -1168,7 +1186,7 @@ msgstr "" "itertools.chain(['a', 'b', 'c'], (1, 2, 3)) =>\n" " a, b, c, 1, 2, 3" -#: ../../howto/functional.rst:792 +#: ../../howto/functional.rst:794 msgid "" ":func:`itertools.islice(iter, [start], stop, [step]) ` " "returns a stream that's a slice of the iterator. With a single *stop* " @@ -1179,7 +1197,7 @@ msgid "" "*step*. ::" msgstr "" -#: ../../howto/functional.rst:799 +#: ../../howto/functional.rst:801 msgid "" "itertools.islice(range(10), 8) =>\n" " 0, 1, 2, 3, 4, 5, 6, 7\n" @@ -1195,7 +1213,7 @@ msgstr "" "itertools.islice(range(10), 2, 8, 2) =>\n" " 2, 4, 6" -#: ../../howto/functional.rst:806 +#: ../../howto/functional.rst:808 msgid "" ":func:`itertools.tee(iter, [n]) ` replicates an iterator; it " "returns *n* independent iterators that will all return the contents of the " @@ -1205,7 +1223,7 @@ msgid "" "and one of the new iterators is consumed more than the others. ::" msgstr "" -#: ../../howto/functional.rst:814 +#: ../../howto/functional.rst:816 msgid "" "itertools.tee( itertools.count() ) =>\n" " iterA, iterB\n" @@ -1225,11 +1243,11 @@ msgstr "" "and iterB ->\n" " 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ..." -#: ../../howto/functional.rst:825 +#: ../../howto/functional.rst:827 msgid "Calling functions on elements" msgstr "" -#: ../../howto/functional.rst:827 +#: ../../howto/functional.rst:829 msgid "" "The :mod:`operator` module contains a set of functions corresponding to " "Python's operators. Some examples are :func:`operator.add(a, b) ` assumes that the " "iterable will return a stream of tuples, and calls *func* using these tuples " "as the arguments::" msgstr "" -#: ../../howto/functional.rst:837 +#: ../../howto/functional.rst:839 msgid "" "itertools.starmap(os.path.join,\n" " [('/bin', 'python'), ('/usr', 'bin', 'java'),\n" @@ -1259,24 +1277,24 @@ msgstr "" "=>\n" " /bin/python, /usr/bin/java, /usr/bin/perl, /usr/bin/ruby" -#: ../../howto/functional.rst:845 +#: ../../howto/functional.rst:847 msgid "Selecting elements" msgstr "" -#: ../../howto/functional.rst:847 +#: ../../howto/functional.rst:849 msgid "" "Another group of functions chooses a subset of an iterator's elements based " "on a predicate." msgstr "" -#: ../../howto/functional.rst:850 +#: ../../howto/functional.rst:852 msgid "" ":func:`itertools.filterfalse(predicate, iter) ` is " "the opposite of :func:`filter`, returning all elements for which the " "predicate returns false::" msgstr "" -#: ../../howto/functional.rst:854 +#: ../../howto/functional.rst:856 msgid "" "itertools.filterfalse(is_even, itertools.count()) =>\n" " 1, 3, 5, 7, 9, 11, 13, 15, ..." @@ -1284,14 +1302,14 @@ msgstr "" "itertools.filterfalse(is_even, itertools.count()) =>\n" " 1, 3, 5, 7, 9, 11, 13, 15, ..." -#: ../../howto/functional.rst:857 +#: ../../howto/functional.rst:859 msgid "" ":func:`itertools.takewhile(predicate, iter) ` returns " "elements for as long as the predicate returns true. Once the predicate " "returns false, the iterator will signal the end of its results. ::" msgstr "" -#: ../../howto/functional.rst:861 +#: ../../howto/functional.rst:863 msgid "" "def less_than_10(x):\n" " return x < 10\n" @@ -1311,14 +1329,14 @@ msgstr "" "itertools.takewhile(is_even, itertools.count()) =>\n" " 0" -#: ../../howto/functional.rst:870 +#: ../../howto/functional.rst:872 msgid "" ":func:`itertools.dropwhile(predicate, iter) ` discards " "elements while the predicate returns true, and then returns the rest of the " "iterable's results. ::" msgstr "" -#: ../../howto/functional.rst:874 +#: ../../howto/functional.rst:876 msgid "" "itertools.dropwhile(less_than_10, itertools.count()) =>\n" " 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...\n" @@ -1332,7 +1350,7 @@ msgstr "" "itertools.dropwhile(is_even, itertools.count()) =>\n" " 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ..." -#: ../../howto/functional.rst:880 +#: ../../howto/functional.rst:882 msgid "" ":func:`itertools.compress(data, selectors) ` takes two " "iterators and returns only those elements of *data* for which the " @@ -1340,7 +1358,7 @@ msgid "" "is exhausted::" msgstr "" -#: ../../howto/functional.rst:884 +#: ../../howto/functional.rst:886 msgid "" "itertools.compress([1, 2, 3, 4, 5], [True, True, False, False, True]) =>\n" " 1, 2, 5" @@ -1348,18 +1366,18 @@ msgstr "" "itertools.compress([1, 2, 3, 4, 5], [True, True, False, False, True]) =>\n" " 1, 2, 5" -#: ../../howto/functional.rst:889 +#: ../../howto/functional.rst:891 msgid "Combinatoric functions" msgstr "" -#: ../../howto/functional.rst:891 +#: ../../howto/functional.rst:893 msgid "" "The :func:`itertools.combinations(iterable, r) ` " "returns an iterator giving all possible *r*-tuple combinations of the " "elements contained in *iterable*. ::" msgstr "" -#: ../../howto/functional.rst:895 +#: ../../howto/functional.rst:897 msgid "" "itertools.combinations([1, 2, 3, 4, 5], 2) =>\n" " (1, 2), (1, 3), (1, 4), (1, 5),\n" @@ -1383,7 +1401,7 @@ msgstr "" " (2, 3, 4), (2, 3, 5), (2, 4, 5),\n" " (3, 4, 5)" -#: ../../howto/functional.rst:906 +#: ../../howto/functional.rst:908 msgid "" "The elements within each tuple remain in the same order as *iterable* " "returned them. For example, the number 1 is always before 2, 3, 4, or 5 in " @@ -1392,7 +1410,7 @@ msgid "" "constraint on the order, returning all possible arrangements of length *r*::" msgstr "" -#: ../../howto/functional.rst:913 +#: ../../howto/functional.rst:915 msgid "" "itertools.permutations([1, 2, 3, 4, 5], 2) =>\n" " (1, 2), (1, 3), (1, 4), (1, 5),\n" @@ -1418,19 +1436,19 @@ msgstr "" " ...\n" " (5, 4, 3, 2, 1)" -#: ../../howto/functional.rst:925 +#: ../../howto/functional.rst:927 msgid "" "If you don't supply a value for *r* the length of the iterable is used, " "meaning that all the elements are permuted." msgstr "" -#: ../../howto/functional.rst:928 +#: ../../howto/functional.rst:930 msgid "" "Note that these functions produce all of the possible combinations by " "position and don't require that the contents of *iterable* are unique::" msgstr "" -#: ../../howto/functional.rst:931 +#: ../../howto/functional.rst:933 msgid "" "itertools.permutations('aba', 3) =>\n" " ('a', 'b', 'a'), ('a', 'a', 'b'), ('b', 'a', 'a'),\n" @@ -1440,13 +1458,13 @@ msgstr "" " ('a', 'b', 'a'), ('a', 'a', 'b'), ('b', 'a', 'a'),\n" " ('b', 'a', 'a'), ('a', 'a', 'b'), ('a', 'b', 'a')" -#: ../../howto/functional.rst:935 +#: ../../howto/functional.rst:937 msgid "" "The identical tuple ``('a', 'a', 'b')`` occurs twice, but the two 'a' " "strings came from different positions." msgstr "" -#: ../../howto/functional.rst:938 +#: ../../howto/functional.rst:940 msgid "" "The :func:`itertools.combinations_with_replacement(iterable, r) ` function relaxes a different constraint: " @@ -1455,7 +1473,7 @@ msgid "" "the second element is selected. ::" msgstr "" -#: ../../howto/functional.rst:944 +#: ../../howto/functional.rst:946 msgid "" "itertools.combinations_with_replacement([1, 2, 3, 4, 5], 2) =>\n" " (1, 1), (1, 2), (1, 3), (1, 4), (1, 5),\n" @@ -1471,11 +1489,11 @@ msgstr "" " (4, 4), (4, 5),\n" " (5, 5)" -#: ../../howto/functional.rst:953 +#: ../../howto/functional.rst:955 msgid "Grouping elements" msgstr "" -#: ../../howto/functional.rst:955 +#: ../../howto/functional.rst:957 msgid "" "The last function I'll discuss, :func:`itertools.groupby(iter, " "key_func=None) `, is the most complicated. " @@ -1484,14 +1502,14 @@ msgid "" "key is simply each element itself." msgstr "" -#: ../../howto/functional.rst:960 +#: ../../howto/functional.rst:962 msgid "" ":func:`~itertools.groupby` collects all the consecutive elements from the " "underlying iterable that have the same key value, and returns a stream of 2-" "tuples containing a key value and an iterator for the elements with that key." msgstr "" -#: ../../howto/functional.rst:966 +#: ../../howto/functional.rst:968 msgid "" "city_list = [('Decatur', 'AL'), ('Huntsville', 'AL'), ('Selma', 'AL'),\n" " ('Anchorage', 'AK'), ('Nome', 'AK'),\n" @@ -1537,7 +1555,7 @@ msgstr "" "iterator-3 =>\n" " ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'), ('Tucson', 'AZ')" -#: ../../howto/functional.rst:988 +#: ../../howto/functional.rst:990 msgid "" ":func:`~itertools.groupby` assumes that the underlying iterable's contents " "will already be sorted based on the key. Note that the returned iterators " @@ -1545,11 +1563,11 @@ msgid "" "iterator-1 before requesting iterator-2 and its corresponding key." msgstr "" -#: ../../howto/functional.rst:995 +#: ../../howto/functional.rst:997 msgid "The functools module" msgstr "functools 模組" -#: ../../howto/functional.rst:997 +#: ../../howto/functional.rst:999 msgid "" "The :mod:`functools` module contains some higher-order functions. A **higher-" "order function** takes one or more functions as input and returns a new " @@ -1557,7 +1575,7 @@ msgid "" "partial` function." msgstr "" -#: ../../howto/functional.rst:1002 +#: ../../howto/functional.rst:1004 msgid "" "For programs written in a functional style, you'll sometimes want to " "construct variants of existing functions that have some of the parameters " @@ -1567,7 +1585,7 @@ msgid "" "\"partial function application\"." msgstr "" -#: ../../howto/functional.rst:1008 +#: ../../howto/functional.rst:1010 msgid "" "The constructor for :func:`~functools.partial` takes the arguments " "``(function, arg1, arg2, ..., kwarg1=value1, kwarg2=value2)``. The " @@ -1575,11 +1593,11 @@ msgid "" "with the filled-in arguments." msgstr "" -#: ../../howto/functional.rst:1013 +#: ../../howto/functional.rst:1015 msgid "Here's a small but realistic example::" msgstr "以下是個很小但實際的範例: ::" -#: ../../howto/functional.rst:1015 +#: ../../howto/functional.rst:1017 msgid "" "import functools\n" "\n" @@ -1592,7 +1610,7 @@ msgid "" "server_log('Unable to open socket')" msgstr "" -#: ../../howto/functional.rst:1025 +#: ../../howto/functional.rst:1027 msgid "" ":func:`functools.reduce(func, iter, [initial_value]) ` " "cumulatively performs an operation on all the iterable's elements and, " @@ -1607,7 +1625,7 @@ msgid "" "``func(initial_value, A)`` is the first calculation. ::" msgstr "" -#: ../../howto/functional.rst:1037 +#: ../../howto/functional.rst:1039 msgid "" ">>> import operator, functools\n" ">>> functools.reduce(operator.concat, ['A', 'BB', 'C'])\n" @@ -1633,20 +1651,20 @@ msgstr "" ">>> functools.reduce(operator.mul, [], 1)\n" "1" -#: ../../howto/functional.rst:1049 +#: ../../howto/functional.rst:1051 msgid "" "If you use :func:`operator.add` with :func:`functools.reduce`, you'll add up " "all the elements of the iterable. This case is so common that there's a " "special built-in called :func:`sum` to compute it:" msgstr "" -#: ../../howto/functional.rst:1061 +#: ../../howto/functional.rst:1063 msgid "" "For many uses of :func:`functools.reduce`, though, it can be clearer to just " "write the obvious :keyword:`for` loop::" msgstr "" -#: ../../howto/functional.rst:1064 +#: ../../howto/functional.rst:1066 msgid "" "import functools\n" "# Instead of:\n" @@ -1658,7 +1676,7 @@ msgid "" " product *= i" msgstr "" -#: ../../howto/functional.rst:1073 +#: ../../howto/functional.rst:1075 msgid "" "A related function is :func:`itertools.accumulate(iterable, func=operator." "add) `. It performs the same calculation, but instead " @@ -1666,7 +1684,7 @@ msgid "" "iterator that also yields each partial result::" msgstr "" -#: ../../howto/functional.rst:1078 +#: ../../howto/functional.rst:1080 msgid "" "itertools.accumulate([1, 2, 3, 4, 5]) =>\n" " 1, 3, 6, 10, 15\n" @@ -1680,11 +1698,11 @@ msgstr "" "itertools.accumulate([1, 2, 3, 4, 5], operator.mul) =>\n" " 1, 2, 6, 24, 120" -#: ../../howto/functional.rst:1086 +#: ../../howto/functional.rst:1088 msgid "The operator module" msgstr "operator 模組" -#: ../../howto/functional.rst:1088 +#: ../../howto/functional.rst:1090 msgid "" "The :mod:`operator` module was mentioned earlier. It contains a set of " "functions corresponding to Python's operators. These functions are often " @@ -1692,55 +1710,55 @@ msgid "" "functions that perform a single operation." msgstr "" -#: ../../howto/functional.rst:1093 +#: ../../howto/functional.rst:1095 msgid "Some of the functions in this module are:" msgstr "" -#: ../../howto/functional.rst:1095 +#: ../../howto/functional.rst:1097 msgid "" "Math operations: ``add()``, ``sub()``, ``mul()``, ``floordiv()``, " "``abs()``, ..." msgstr "" "數學運算:``add()``、``sub()``、``mul()``、``floordiv()``、``abs()``..." -#: ../../howto/functional.rst:1096 +#: ../../howto/functional.rst:1098 msgid "Logical operations: ``not_()``, ``truth()``." msgstr "" -#: ../../howto/functional.rst:1097 +#: ../../howto/functional.rst:1099 msgid "Bitwise operations: ``and_()``, ``or_()``, ``invert()``." msgstr "" -#: ../../howto/functional.rst:1098 +#: ../../howto/functional.rst:1100 msgid "" "Comparisons: ``eq()``, ``ne()``, ``lt()``, ``le()``, ``gt()``, and ``ge()``." msgstr "" -#: ../../howto/functional.rst:1099 +#: ../../howto/functional.rst:1101 msgid "Object identity: ``is_()``, ``is_not()``." msgstr "" -#: ../../howto/functional.rst:1101 +#: ../../howto/functional.rst:1103 msgid "Consult the operator module's documentation for a complete list." msgstr "" -#: ../../howto/functional.rst:1105 +#: ../../howto/functional.rst:1107 msgid "Small functions and the lambda expression" msgstr "" -#: ../../howto/functional.rst:1107 +#: ../../howto/functional.rst:1109 msgid "" "When writing functional-style programs, you'll often need little functions " "that act as predicates or that combine elements in some way." msgstr "" -#: ../../howto/functional.rst:1110 +#: ../../howto/functional.rst:1112 msgid "" "If there's a Python built-in or a module function that's suitable, you don't " "need to define a new function at all::" msgstr "" -#: ../../howto/functional.rst:1113 +#: ../../howto/functional.rst:1115 msgid "" "stripped_lines = [line.strip() for line in lines]\n" "existing_files = filter(os.path.exists, file_list)" @@ -1748,7 +1766,7 @@ msgstr "" "stripped_lines = [line.strip() for line in lines]\n" "existing_files = filter(os.path.exists, file_list)" -#: ../../howto/functional.rst:1116 +#: ../../howto/functional.rst:1118 msgid "" "If the function you need doesn't exist, you need to write it. One way to " "write small functions is to use the :keyword:`lambda` expression. " @@ -1757,7 +1775,7 @@ msgid "" "expression::" msgstr "" -#: ../../howto/functional.rst:1121 +#: ../../howto/functional.rst:1123 msgid "" "adder = lambda x, y: x+y\n" "\n" @@ -1767,13 +1785,13 @@ msgstr "" "\n" "print_assign = lambda name, value: name + '=' + str(value)" -#: ../../howto/functional.rst:1125 +#: ../../howto/functional.rst:1127 msgid "" "An alternative is to just use the ``def`` statement and define a function in " "the usual way::" msgstr "" -#: ../../howto/functional.rst:1128 +#: ../../howto/functional.rst:1130 msgid "" "def adder(x, y):\n" " return x + y\n" @@ -1787,13 +1805,13 @@ msgstr "" "def print_assign(name, value):\n" " return name + '=' + str(value)" -#: ../../howto/functional.rst:1134 +#: ../../howto/functional.rst:1136 msgid "" "Which alternative is preferable? That's a style question; my usual course " "is to avoid using ``lambda``." msgstr "" -#: ../../howto/functional.rst:1137 +#: ../../howto/functional.rst:1139 msgid "" "One reason for my preference is that ``lambda`` is quite limited in the " "functions it can define. The result has to be computable as a single " @@ -1803,7 +1821,7 @@ msgid "" "that's hard to read. Quick, what's the following code doing? ::" msgstr "" -#: ../../howto/functional.rst:1144 +#: ../../howto/functional.rst:1146 msgid "" "import functools\n" "total = functools.reduce(lambda a, b: (0, a[1] + b[1]), items)[1]" @@ -1811,14 +1829,14 @@ msgstr "" "import functools\n" "total = functools.reduce(lambda a, b: (0, a[1] + b[1]), items)[1]" -#: ../../howto/functional.rst:1147 +#: ../../howto/functional.rst:1149 msgid "" "You can figure it out, but it takes time to disentangle the expression to " "figure out what's going on. Using a short nested ``def`` statements makes " "things a little bit better::" msgstr "" -#: ../../howto/functional.rst:1151 +#: ../../howto/functional.rst:1153 msgid "" "import functools\n" "def combine(a, b):\n" @@ -1832,11 +1850,11 @@ msgstr "" "\n" "total = functools.reduce(combine, items)[1]" -#: ../../howto/functional.rst:1157 +#: ../../howto/functional.rst:1159 msgid "But it would be best of all if I had simply used a ``for`` loop::" msgstr "" -#: ../../howto/functional.rst:1159 +#: ../../howto/functional.rst:1161 msgid "" "total = 0\n" "for a, b in items:\n" @@ -1846,59 +1864,59 @@ msgstr "" "for a, b in items:\n" " total += b" -#: ../../howto/functional.rst:1163 +#: ../../howto/functional.rst:1165 msgid "Or the :func:`sum` built-in and a generator expression::" msgstr "" -#: ../../howto/functional.rst:1165 +#: ../../howto/functional.rst:1167 msgid "total = sum(b for a, b in items)" msgstr "total = sum(b for a, b in items)" -#: ../../howto/functional.rst:1167 +#: ../../howto/functional.rst:1169 msgid "" "Many uses of :func:`functools.reduce` are clearer when written as ``for`` " "loops." msgstr "" -#: ../../howto/functional.rst:1169 +#: ../../howto/functional.rst:1171 msgid "" "Fredrik Lundh once suggested the following set of rules for refactoring uses " "of ``lambda``:" msgstr "" -#: ../../howto/functional.rst:1172 +#: ../../howto/functional.rst:1174 msgid "Write a lambda function." msgstr "" -#: ../../howto/functional.rst:1173 +#: ../../howto/functional.rst:1175 msgid "Write a comment explaining what the heck that lambda does." msgstr "" -#: ../../howto/functional.rst:1174 +#: ../../howto/functional.rst:1176 msgid "" "Study the comment for a while, and think of a name that captures the essence " "of the comment." msgstr "" -#: ../../howto/functional.rst:1176 +#: ../../howto/functional.rst:1178 msgid "Convert the lambda to a def statement, using that name." msgstr "" -#: ../../howto/functional.rst:1177 +#: ../../howto/functional.rst:1179 msgid "Remove the comment." msgstr "" -#: ../../howto/functional.rst:1179 +#: ../../howto/functional.rst:1181 msgid "" "I really like these rules, but you're free to disagree about whether this " "lambda-free style is better." msgstr "" -#: ../../howto/functional.rst:1184 +#: ../../howto/functional.rst:1186 msgid "Revision History and Acknowledgements" msgstr "" -#: ../../howto/functional.rst:1186 +#: ../../howto/functional.rst:1188 msgid "" "The author would like to thank the following people for offering " "suggestions, corrections and assistance with various drafts of this article: " @@ -1906,40 +1924,40 @@ msgid "" "Krell, Leandro Lameiro, Jussi Salmela, Collin Winter, Blake Winton." msgstr "" -#: ../../howto/functional.rst:1191 +#: ../../howto/functional.rst:1193 msgid "Version 0.1: posted June 30 2006." msgstr "" -#: ../../howto/functional.rst:1193 +#: ../../howto/functional.rst:1195 msgid "Version 0.11: posted July 1 2006. Typo fixes." msgstr "" -#: ../../howto/functional.rst:1195 +#: ../../howto/functional.rst:1197 msgid "" "Version 0.2: posted July 10 2006. Merged genexp and listcomp sections into " "one. Typo fixes." msgstr "" -#: ../../howto/functional.rst:1198 +#: ../../howto/functional.rst:1200 msgid "" "Version 0.21: Added more references suggested on the tutor mailing list." msgstr "" -#: ../../howto/functional.rst:1200 +#: ../../howto/functional.rst:1202 msgid "" "Version 0.30: Adds a section on the ``functional`` module written by Collin " "Winter; adds short section on the operator module; a few other edits." msgstr "" -#: ../../howto/functional.rst:1205 +#: ../../howto/functional.rst:1207 msgid "References" msgstr "" -#: ../../howto/functional.rst:1208 +#: ../../howto/functional.rst:1210 msgid "General" msgstr "" -#: ../../howto/functional.rst:1210 +#: ../../howto/functional.rst:1212 msgid "" "**Structure and Interpretation of Computer Programs**, by Harold Abelson and " "Gerald Jay Sussman with Julie Sussman. The book can be found at https://" @@ -1950,24 +1968,24 @@ msgid "" "functional-style Python code." msgstr "" -#: ../../howto/functional.rst:1218 +#: ../../howto/functional.rst:1220 msgid "" -"https://www.defmacro.org/ramblings/fp.html: A general introduction to " +"https://defmacro.org/2006/06/19/fp.html: A general introduction to " "functional programming that uses Java examples and has a lengthy historical " "introduction." msgstr "" -#: ../../howto/functional.rst:1221 +#: ../../howto/functional.rst:1223 msgid "" "https://en.wikipedia.org/wiki/Functional_programming: General Wikipedia " "entry describing functional programming." msgstr "" -#: ../../howto/functional.rst:1224 +#: ../../howto/functional.rst:1226 msgid "https://en.wikipedia.org/wiki/Coroutine: Entry for coroutines." msgstr "https://en.wikipedia.org/wiki/Coroutine: 協程 (coroutines) 的條目。" -#: ../../howto/functional.rst:1226 +#: ../../howto/functional.rst:1228 msgid "" "https://en.wikipedia.org/wiki/Partial_application: Entry for the concept of " "partial function application." @@ -1975,16 +1993,16 @@ msgstr "" "https://en.wikipedia.org/wiki/Partial_application: 偏函式 (partial " "application) 概念的條目。" -#: ../../howto/functional.rst:1228 +#: ../../howto/functional.rst:1230 msgid "" "https://en.wikipedia.org/wiki/Currying: Entry for the concept of currying." msgstr "https://en.wikipedia.org/wiki/Currying: currying 概念的條目。" -#: ../../howto/functional.rst:1231 +#: ../../howto/functional.rst:1233 msgid "Python-specific" -msgstr "" +msgstr "Python 特有的" -#: ../../howto/functional.rst:1233 +#: ../../howto/functional.rst:1235 msgid "" "https://gnosis.cx/TPiP/: The first chapter of David Mertz's book :title-" "reference:`Text Processing in Python` discusses functional programming for " @@ -1992,7 +2010,7 @@ msgid "" "Text Processing\"." msgstr "" -#: ../../howto/functional.rst:1238 +#: ../../howto/functional.rst:1240 msgid "" "Mertz also wrote a 3-part series of articles on functional programming for " "IBM's DeveloperWorks site; see `part 1 `__," msgstr "" -#: ../../howto/functional.rst:1246 +#: ../../howto/functional.rst:1248 msgid "Python documentation" msgstr "Python 說明文件" -#: ../../howto/functional.rst:1248 +#: ../../howto/functional.rst:1250 msgid "Documentation for the :mod:`itertools` module." msgstr ":mod:`itertools` 模組的說明文件。" -#: ../../howto/functional.rst:1250 +#: ../../howto/functional.rst:1252 msgid "Documentation for the :mod:`functools` module." msgstr ":mod:`functools` 模組的說明文件。" -#: ../../howto/functional.rst:1252 +#: ../../howto/functional.rst:1254 msgid "Documentation for the :mod:`operator` module." msgstr ":mod:`operator` 模組的說明文件。" -#: ../../howto/functional.rst:1254 +#: ../../howto/functional.rst:1256 msgid ":pep:`289`: \"Generator Expressions\"" msgstr ":pep:`289`:「產生器運算式 (Generator Expressions)」" -#: ../../howto/functional.rst:1256 +#: ../../howto/functional.rst:1258 msgid "" ":pep:`342`: \"Coroutines via Enhanced Generators\" describes the new " "generator features in Python 2.5." diff --git a/howto/gdb_helpers.po b/howto/gdb_helpers.po index b838b7cb85..1fb852831b 100644 --- a/howto/gdb_helpers.po +++ b/howto/gdb_helpers.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-12 00:04+0000\n" +"POT-Creation-Date: 2024-12-06 00:14+0000\n" "PO-Revision-Date: 2024-05-11 14:42+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -139,7 +139,7 @@ msgstr "" #: ../../howto/gdb_helpers.rst:68 msgid "add-auto-load-safe-path /path/to/cpython" -msgstr "" +msgstr "add-auto-load-safe-path /path/to/cpython" #: ../../howto/gdb_helpers.rst:70 msgid "You can also add multiple paths, separated by ``:``." @@ -391,16 +391,20 @@ msgstr "" #: ../../howto/gdb_helpers.rst:183 msgid "" "The internal structure can be revealed with a cast to :c:expr:`PyLongObject " -"*`:" -msgstr "可以透過轉換 (cast) 為 :c:expr:`PyLongObject *` 來揭示內部結構:" +"*`::" +msgstr "可以透過轉換 (cast) 為 :c:expr:`PyLongObject *` 來揭示內部結構: ::" #: ../../howto/gdb_helpers.rst:185 msgid "" -"(gdb) p *(PyLongObject*)some_python_integer $5 = {ob_base = {ob_base = " -"{ob_refcnt = 8, ob_type = 0x3dad39f5e0}, ob_size = 1}, ob_digit = {42}}" +"(gdb) p *(PyLongObject*)some_python_integer\n" +"$5 = {ob_base = {ob_base = {ob_refcnt = 8, ob_type = 0x3dad39f5e0}, ob_size " +"= 1},\n" +"ob_digit = {42}}" msgstr "" -"(gdb) p *(PyLongObject*)some_python_integer $5 = {ob_base = {ob_base = " -"{ob_refcnt = 8, ob_type = 0x3dad39f5e0}, ob_size = 1}, ob_digit = {42}}" +"(gdb) p *(PyLongObject*)some_python_integer\n" +"$5 = {ob_base = {ob_base = {ob_refcnt = 8, ob_type = 0x3dad39f5e0}, ob_size " +"= 1},\n" +"ob_digit = {42}}" #: ../../howto/gdb_helpers.rst:189 msgid "" @@ -461,8 +465,8 @@ msgid "" "(if any) for the current frame in the selected thread. The current line is " "marked with a \">\"::" msgstr "" -"該擴充功能新增了一個 ``py-list`` 命令,該命令列出了所選執行緒中當前 frame 的 " -"Python 原始程式碼(如果有)。當前的列會標有 \">\": ::" +"該擴充功能新增了一個 ``py-list`` 命令,該命令列出了所選執行緒中目前 frame 的 " +"Python 原始程式碼(如果有)。目前的列會標有 \">\": ::" #: ../../howto/gdb_helpers.rst:216 msgid "" @@ -479,6 +483,18 @@ msgid "" " 910 except KeyboardInterrupt:\n" " 911 # properly quit on a keyboard interrupt..." msgstr "" +"(gdb) py-list\n" +" 901 if options.profile:\n" +" 902 options.profile = False\n" +" 903 profile_me()\n" +" 904 return\n" +" 905\n" +">906 u = UI()\n" +" 907 if not u.quit:\n" +" 908 try:\n" +" 909 gtk.main()\n" +" 910 except KeyboardInterrupt:\n" +" 911 # properly quit on a keyboard interrupt..." #: ../../howto/gdb_helpers.rst:229 msgid "" @@ -803,7 +819,7 @@ msgid "" "looks in locals within the current thread, then globals, then finally " "builtins::" msgstr "" -"``py-print`` 命令查找 Python 名稱並嘗試列印它。它在當前執行緒中尋找局部變數," +"``py-print`` 命令查找 Python 名稱並嘗試列印它。它在目前執行緒中尋找局部變數," "然後是全域變數,最後是內建變數: ::" #: ../../howto/gdb_helpers.rst:346 @@ -843,7 +859,7 @@ msgid "" "The ``py-locals`` command looks up all Python locals within the current " "Python frame in the selected thread, and prints their representations::" msgstr "" -"``py-locals`` 命令尋找所選執行緒中當前 Python frame 內的所有 Python 局部變" +"``py-locals`` 命令尋找所選執行緒中目前 Python frame 內的所有 Python 局部變" "數,並列印它們的表示: ::" #: ../../howto/gdb_helpers.rst:365 @@ -933,6 +949,23 @@ msgid "" "1547 with test_support.temp_cwd(TESTCWD, quiet=True):\n" ">1548 main()" msgstr "" +"(gdb) py-bt\n" +"(output snipped)\n" +"#68 Frame 0xaa4560, for file Lib/test/regrtest.py, line 1548, in " +"()\n" +" main()\n" +"(gdb) frame 68\n" +"#68 0x00000000004cd1e6 in PyEval_EvalFrameEx (f=Frame 0xaa4560, for file Lib/" +"test/regrtest.py, line 1548, in (), throwflag=0) at Python/ceval." +"c:2665\n" +"2665 x = call_function(&sp, oparg);\n" +"(gdb) py-list\n" +"1543 # 在暫時改變 CWD 到一個臨時且可寫入的目錄的\n" +"1544 # 情境管理器中運行測試。\n" +"1545 # 如果無法建立或更改 CWD,則使用原始的 CWD。\n" +"1546 # 原始 CWD 可從 test_support.SAVEDCWD 獲得。\n" +"1547 with test_support.temp_cwd(TESTCWD, quiet=True):\n" +">1548 main()" #: ../../howto/gdb_helpers.rst:411 msgid "" @@ -952,6 +985,13 @@ msgid "" "* 1 Thread 0x7ffff7fe2700 (LWP 10145) 0x00000038e46d73e3 in select () at ../" "sysdeps/unix/syscall-template.S:82" msgstr "" +"(gdb) info threads\n" +" 105 Thread 0x7fffefa18710 (LWP 10260) sem_wait () at ../nptl/sysdeps/unix/" +"sysv/linux/x86_64/sem_wait.S:86\n" +" 104 Thread 0x7fffdf5fe710 (LWP 10259) sem_wait () at ../nptl/sysdeps/unix/" +"sysv/linux/x86_64/sem_wait.S:86\n" +"* 1 Thread 0x7ffff7fe2700 (LWP 10145) 0x00000038e46d73e3 in select () at ../" +"sysdeps/unix/syscall-template.S:82" #: ../../howto/gdb_helpers.rst:419 msgid "" @@ -1043,3 +1083,80 @@ msgid "" ", , _RLock__count=1) at remote " +"0xd7ff40>, count_owner=(1, 140737213728528), count=1, " +"owner=140737213728528)\n" +" self.__block.acquire()\n" +"#8 Frame 0x7fffac001640, for file /home/david/coding/python-svn/Lib/" +"threading.py, line 269, in wait " +"(self=<_Condition(_Condition__lock=<_RLock(_Verbose__verbose=False, " +"_RLock__owner=140737354016512, _RLock__block=, _RLock__count=1) at remote 0xd7ff40>, acquire=, _is_owned=, " +"_release_save=, release=, _acquire_restore=, " +"_Verbose__verbose=False, _Condition__waiters=[]) at remote 0xd7fd10>, " +"timeout=None, waiter=, saved_state=(1, " +"140737213728528))\n" +" self._acquire_restore(saved_state)\n" +"#12 Frame 0x7fffb8001a10, for file /home/david/coding/python-svn/Lib/test/" +"lock_tests.py, line 348, in f ()\n" +" cond.wait()\n" +"#16 Frame 0x7fffb8001c40, for file /home/david/coding/python-svn/Lib/test/" +"lock_tests.py, line 37, in task (tid=140737213728528)\n" +" f()\n" +"\n" +"Thread 104 (Thread 0x7fffdf5fe710 (LWP 10259)):\n" +"#5 Frame 0x7fffe4001580, for file /home/david/coding/python-svn/Lib/" +"threading.py, line 155, in _acquire_restore " +"(self=<_RLock(_Verbose__verbose=False, _RLock__owner=140737354016512, " +"_RLock__block=, _RLock__count=1) at remote " +"0xd7ff40>, count_owner=(1, 140736940992272), count=1, " +"owner=140736940992272)\n" +" self.__block.acquire()\n" +"#8 Frame 0x7fffc8002090, for file /home/david/coding/python-svn/Lib/" +"threading.py, line 269, in wait " +"(self=<_Condition(_Condition__lock=<_RLock(_Verbose__verbose=False, " +"_RLock__owner=140737354016512, _RLock__block=, _RLock__count=1) at remote 0xd7ff40>, acquire=, _is_owned=, " +"_release_save=, release=, _acquire_restore=, " +"_Verbose__verbose=False, _Condition__waiters=[]) at remote 0xd7fd10>, " +"timeout=None, waiter=, saved_state=(1, " +"140736940992272))\n" +" self._acquire_restore(saved_state)\n" +"#12 Frame 0x7fffac001c90, for file /home/david/coding/python-svn/Lib/test/" +"lock_tests.py, line 348, in f ()\n" +" cond.wait()\n" +"#16 Frame 0x7fffac0011c0, for file /home/david/coding/python-svn/Lib/test/" +"lock_tests.py, line 37, in task (tid=140736940992272)\n" +" f()\n" +"\n" +"Thread 1 (Thread 0x7ffff7fe2700 (LWP 10145)):\n" +"#5 Frame 0xcb5380, for file /home/david/coding/python-svn/Lib/test/" +"lock_tests.py, line 16, in _wait ()\n" +" time.sleep(0.01)\n" +"#8 Frame 0x7fffd00024a0, for file /home/david/coding/python-svn/Lib/test/" +"lock_tests.py, line 378, in _check_notify " +"(self=, skipped=[], _mirrorOutput=False, testsRun=39, " +"buffer=False, _original_stderr=, " +"_stdout_buffer=, " +"_stderr_buffer=, " +"_moduleSetUpFailed=False, expectedFailures=[], errors=[], " +"_previousTestClass=, unexpectedSuccesses=[], " +"failures=[], shouldStop=False, failfast=False) at remote 0xc185a0>, " +"_threads=(0,), _cleanups=[], _type_equality_funcs={: , : " +", : " +", : " +", , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-06-26 18:54+0800\n" +"POT-Creation-Date: 2024-10-04 00:13+0000\n" "PO-Revision-Date: 2021-07-05 12:45+0800\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -26,15 +26,115 @@ msgstr "Python 如何達成任務" #: ../../howto/index.rst:5 msgid "" -"Python HOWTOs are documents that cover a single, specific topic, and attempt " -"to cover it fairly completely. Modelled 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." +"Python HOWTOs are documents that cover a specific topic in-depth. Modeled on " +"the Linux Documentation Project's HOWTO collection, this collection is an " +"effort to foster documentation that's more detailed than the Python Library " +"Reference." msgstr "" -"「Python 如何達成任務 (HOWTOs)」是一系列的說明文件,其內容會盡量完整地涵蓋某" -"些單一、特定的主題。以 Linux 說明文件專案的 HOWTO 系列為模範,本系列的目標是" -"提供比 Python 函式庫參考手冊更實用的說明文件。" +"「Python 如何達成任務 (HOWTOs)」是一系列的說明文件,其內容會深度地涵蓋某些特" +"定的主題。以 Linux 說明文件專案的 HOWTO 系列為模範,本系列的目標是提供比 " +"Python 函式庫參考手冊更實用的說明文件。" -#: ../../howto/index.rst:11 -msgid "Currently, the HOWTOs are:" -msgstr "目前有以下這些任務指南:" +#: ../../howto/index.rst:38 +msgid "General:" +msgstr "" + +#: ../../howto/index.rst:40 +msgid ":ref:`annotations-howto`" +msgstr ":ref:`annotations-howto`" + +#: ../../howto/index.rst:41 +msgid ":ref:`argparse-tutorial`" +msgstr ":ref:`argparse-tutorial`" + +#: ../../howto/index.rst:42 +msgid ":ref:`descriptorhowto`" +msgstr ":ref:`descriptorhowto`" + +#: ../../howto/index.rst:43 +msgid ":ref:`enum-howto`" +msgstr ":ref:`enum-howto`" + +#: ../../howto/index.rst:44 +msgid ":ref:`functional-howto`" +msgstr ":ref:`functional-howto`" + +#: ../../howto/index.rst:45 +msgid ":ref:`ipaddress-howto`" +msgstr ":ref:`ipaddress-howto`" + +#: ../../howto/index.rst:46 +msgid ":ref:`logging-howto`" +msgstr ":ref:`logging-howto`" + +#: ../../howto/index.rst:47 +msgid ":ref:`logging-cookbook`" +msgstr ":ref:`logging-cookbook`" + +#: ../../howto/index.rst:48 +msgid ":ref:`regex-howto`" +msgstr ":ref:`regex-howto`" + +#: ../../howto/index.rst:49 +msgid ":ref:`sortinghowto`" +msgstr ":ref:`sortinghowto`" + +#: ../../howto/index.rst:50 +msgid ":ref:`unicode-howto`" +msgstr ":ref:`unicode-howto`" + +#: ../../howto/index.rst:51 +msgid ":ref:`urllib-howto`" +msgstr ":ref:`urllib-howto`" + +#: ../../howto/index.rst:53 +msgid "Advanced development:" +msgstr "" + +#: ../../howto/index.rst:55 +msgid ":ref:`curses-howto`" +msgstr ":ref:`curses-howto`" + +#: ../../howto/index.rst:56 +msgid ":ref:`freethreading-python-howto`" +msgstr ":ref:`freethreading-python-howto`" + +#: ../../howto/index.rst:57 +msgid ":ref:`freethreading-extensions-howto`" +msgstr ":ref:`freethreading-extensions-howto`" + +#: ../../howto/index.rst:58 +msgid ":ref:`isolating-extensions-howto`" +msgstr ":ref:`isolating-extensions-howto`" + +#: ../../howto/index.rst:59 +msgid ":ref:`python_2.3_mro`" +msgstr ":ref:`python_2.3_mro`" + +#: ../../howto/index.rst:60 +msgid ":ref:`socket-howto`" +msgstr ":ref:`socket-howto`" + +#: ../../howto/index.rst:61 +msgid ":ref:`timerfd-howto`" +msgstr ":ref:`timerfd-howto`" + +#: ../../howto/index.rst:62 +msgid ":ref:`cporting-howto`" +msgstr ":ref:`cporting-howto`" + +#: ../../howto/index.rst:64 +msgid "Debugging and profiling:" +msgstr "" + +#: ../../howto/index.rst:66 +msgid ":ref:`gdb`" +msgstr ":ref:`gdb`" + +#: ../../howto/index.rst:67 +msgid ":ref:`instrumentation`" +msgstr ":ref:`instrumentation`" + +#: ../../howto/index.rst:68 +msgid ":ref:`perf_profiling`" +msgstr ":ref:`perf_profiling`" diff --git a/howto/instrumentation.po b/howto/instrumentation.po index a09a97c9c3..d9f39551eb 100644 --- a/howto/instrumentation.po +++ b/howto/instrumentation.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2023-08-17 22:17+0800\n" @@ -503,6 +503,9 @@ msgid "" " show-call-hierarchy.stp \\\n" " -c \"./python test.py\"" msgstr "" +"$ stap \\\n" +" show-call-hierarchy.stp \\\n" +" -c \"./python test.py\"" #: ../../howto/instrumentation.rst:238 msgid "" @@ -711,6 +714,24 @@ msgid "" " frameptr = $arg4\n" "}" msgstr "" +"/*\n" +" 提供一個更高階、在 function__entry 和 function__return 標記上的包裝:\n" +" \\*/\n" +"probe python.function.entry = process(\"python\").mark(\"function__entry\")\n" +"{\n" +" filename = user_string($arg1);\n" +" funcname = user_string($arg2);\n" +" lineno = $arg3;\n" +" frameptr = $arg4\n" +"}\n" +"probe python.function.return = process(\"python\")." +"mark(\"function__return\")\n" +"{\n" +" filename = user_string($arg1);\n" +" funcname = user_string($arg2);\n" +" lineno = $arg3;\n" +" frameptr = $arg4\n" +"}" #: ../../howto/instrumentation.rst:372 msgid "" diff --git a/howto/ipaddress.po b/howto/ipaddress.po index 2e0e5b2546..b4124f004d 100644 --- a/howto/ipaddress.po +++ b/howto/ipaddress.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-02-19 00:13+0000\n" "PO-Revision-Date: 2024-07-20 16:09+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -54,7 +53,7 @@ msgstr "" #: ../../howto/ipaddress.rst:24 msgid "Creating Address/Network/Interface objects" -msgstr "" +msgstr "建立 Address/Network/Interface 物件" #: ../../howto/ipaddress.rst:26 msgid "" @@ -146,8 +145,8 @@ msgstr "定義網路" #: ../../howto/ipaddress.rst:84 msgid "" -"Host addresses are usually grouped together into IP networks, so :mod:" -"`ipaddress` provides a way to create, inspect and manipulate network " +"Host addresses are usually grouped together into IP networks, " +"so :mod:`ipaddress` provides a way to create, inspect and manipulate network " "definitions. IP network objects are constructed from strings that define the " "range of host addresses that are part of that network. The simplest form for " "that information is a \"network address/network prefix\" pair, where the " @@ -243,11 +242,11 @@ msgid "" "network, neither the address nor the network classes are sufficient. " "Notation like ``192.0.2.1/24`` is commonly used by network engineers and the " "people who write tools for firewalls and routers as shorthand for \"the host " -"``192.0.2.1`` on the network ``192.0.2.0/24``\", Accordingly, :mod:" -"`ipaddress` provides a set of hybrid classes that associate an address with " -"a particular network. The interface for creation is identical to that for " -"defining network objects, except that the address portion isn't constrained " -"to being a network address." +"``192.0.2.1`` on the network ``192.0.2.0/24``\", " +"Accordingly, :mod:`ipaddress` provides a set of hybrid classes that " +"associate an address with a particular network. The interface for creation " +"is identical to that for defining network objects, except that the address " +"portion isn't constrained to being a network address." msgstr "" #: ../../howto/ipaddress.rst:152 @@ -258,13 +257,13 @@ msgstr "" #: ../../howto/ipaddress.rst:157 msgid "Inspecting Address/Network/Interface Objects" -msgstr "" +msgstr "檢視 Address/Network/Interface 物件" #: ../../howto/ipaddress.rst:159 msgid "" "You've gone to the trouble of creating an IPv(4|6)(Address|Network|" -"Interface) object, so you probably want to get information about it. :mod:" -"`ipaddress` tries to make doing this easy and intuitive." +"Interface) object, so you probably want to get information about " +"it. :mod:`ipaddress` tries to make doing this easy and intuitive." msgstr "" #: ../../howto/ipaddress.rst:163 @@ -335,7 +334,7 @@ msgstr "" msgid "" ">>> net4 = ipaddress.ip_network('192.0.2.0/24')\n" ">>> for x in net4.hosts():\n" -"... print(x) \n" +"... print(x)\n" "192.0.2.1\n" "192.0.2.2\n" "192.0.2.3\n" @@ -347,7 +346,7 @@ msgid "" msgstr "" ">>> net4 = ipaddress.ip_network('192.0.2.0/24')\n" ">>> for x in net4.hosts():\n" -"... print(x) \n" +"... print(x)\n" "192.0.2.1\n" "192.0.2.2\n" "192.0.2.3\n" @@ -436,6 +435,8 @@ msgid "" "if address in network:\n" " # do something" msgstr "" +"if address in network:\n" +" # 做某些事情" #: ../../howto/ipaddress.rst:259 msgid "Containment testing is done efficiently based on the network prefix::" @@ -457,7 +458,7 @@ msgstr "" #: ../../howto/ipaddress.rst:269 msgid "Comparisons" -msgstr "" +msgstr "比較" #: ../../howto/ipaddress.rst:271 msgid "" @@ -521,9 +522,9 @@ msgstr "" #: ../../howto/ipaddress.rst:305 msgid "" "To support use cases where it is useful to have access to this additional " -"detail, the individual class constructors actually raise the :exc:" -"`ValueError` subclasses :exc:`ipaddress.AddressValueError` and :exc:" -"`ipaddress.NetmaskValueError` to indicate exactly which part of the " +"detail, the individual class constructors actually raise " +"the :exc:`ValueError` subclasses :exc:`ipaddress.AddressValueError` " +"and :exc:`ipaddress.NetmaskValueError` to indicate exactly which part of the " "definition failed to parse correctly." msgstr "" @@ -587,3 +588,7 @@ msgid "" "except ValueError:\n" " print('address/netmask is invalid for IPv4:', address)" msgstr "" +"try:\n" +" network = ipaddress.IPv4Network(address)\n" +"except ValueError:\n" +" print('address/netmask is invalid for IPv4:', address)" diff --git a/howto/isolating-extensions.po b/howto/isolating-extensions.po index 87030d9e45..bdaa271023 100644 --- a/howto/isolating-extensions.po +++ b/howto/isolating-extensions.po @@ -6,12 +6,13 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-07-03 00:17+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -159,6 +160,13 @@ msgid "" ">>> old_binascii == binascii\n" "False" msgstr "" +">>> import sys\n" +">>> import binascii\n" +">>> old_binascii = binascii\n" +">>> del sys.modules['binascii']\n" +">>> import binascii # 建立一個新的模組物件\n" +">>> old_binascii == binascii\n" +"False" #: ../../howto/isolating-extensions.rst:103 msgid "" @@ -264,8 +272,8 @@ msgstr "" msgid "" "If it is necessary to use process-global state, the simplest way to avoid " "issues with multiple interpreters is to explicitly prevent a module from " -"being loaded more than once per process—see `Opt-Out: Limiting to One Module " -"Object per Process`_." +"being loaded more than once per process—see :ref:`isolating-extensions-" +"optout`." msgstr "" #: ../../howto/isolating-extensions.rst:175 @@ -321,11 +329,11 @@ msgid "" "c>`__; example module initialization shown at the bottom of the file." msgstr "" -#: ../../howto/isolating-extensions.rst:211 +#: ../../howto/isolating-extensions.rst:213 msgid "Opt-Out: Limiting to One Module Object per Process" msgstr "" -#: ../../howto/isolating-extensions.rst:213 +#: ../../howto/isolating-extensions.rst:215 msgid "" "A non-negative ``PyModuleDef.m_size`` signals that a module supports " "multiple interpreters correctly. If this is not yet the case for your " @@ -333,35 +341,51 @@ msgid "" "For example::" msgstr "" -#: ../../howto/isolating-extensions.rst:218 +#: ../../howto/isolating-extensions.rst:220 msgid "" +"// A process-wide flag\n" "static int loaded = 0;\n" "\n" +"// Mutex to provide thread safety (only needed for free-threaded Python)\n" +"static PyMutex modinit_mutex = {0};\n" +"\n" "static int\n" "exec_module(PyObject* module)\n" "{\n" +" PyMutex_Lock(&modinit_mutex);\n" " if (loaded) {\n" +" PyMutex_Unlock(&modinit_mutex);\n" " PyErr_SetString(PyExc_ImportError,\n" " \"cannot load module more than once per process\");\n" " return -1;\n" " }\n" " loaded = 1;\n" +" PyMutex_Unlock(&modinit_mutex);\n" " // ... rest of initialization\n" "}" msgstr "" -#: ../../howto/isolating-extensions.rst:234 +#: ../../howto/isolating-extensions.rst:242 +msgid "" +"If your module's :c:member:`PyModuleDef.m_clear` function is able to prepare " +"for future re-initialization, it should clear the ``loaded`` flag. In this " +"case, your module won't support multiple instances existing *concurrently*, " +"but it will, for example, support being loaded after Python runtime shutdown " +"(:c:func:`Py_FinalizeEx`) and re-initialization (:c:func:`Py_Initialize`)." +msgstr "" + +#: ../../howto/isolating-extensions.rst:251 msgid "Module State Access from Functions" msgstr "" -#: ../../howto/isolating-extensions.rst:236 +#: ../../howto/isolating-extensions.rst:253 msgid "" "Accessing the state from module-level functions is straightforward. " "Functions get the module object as their first argument; for extracting the " "state, you can use ``PyModule_GetState``::" msgstr "" -#: ../../howto/isolating-extensions.rst:240 +#: ../../howto/isolating-extensions.rst:257 msgid "" "static PyObject *\n" "func(PyObject *module, PyObject *args)\n" @@ -374,25 +398,25 @@ msgid "" "}" msgstr "" -#: ../../howto/isolating-extensions.rst:251 +#: ../../howto/isolating-extensions.rst:268 msgid "" "``PyModule_GetState`` may return ``NULL`` without setting an exception if " "there is no module state, i.e. ``PyModuleDef.m_size`` was zero. In your own " "module, you're in control of ``m_size``, so this is easy to prevent." msgstr "" -#: ../../howto/isolating-extensions.rst:258 +#: ../../howto/isolating-extensions.rst:275 msgid "Heap Types" msgstr "" -#: ../../howto/isolating-extensions.rst:260 +#: ../../howto/isolating-extensions.rst:277 msgid "" "Traditionally, types defined in C code are *static*; that is, ``static " "PyTypeObject`` structures defined directly in code and initialized using " "``PyType_Ready()``." msgstr "" -#: ../../howto/isolating-extensions.rst:264 +#: ../../howto/isolating-extensions.rst:281 msgid "" "Such types are necessarily shared across the process. Sharing them between " "module objects requires paying attention to any state they own or access. To " @@ -400,7 +424,7 @@ msgid "" "for example, you can't set ``str.myattribute = 123``." msgstr "" -#: ../../howto/isolating-extensions.rst:270 +#: ../../howto/isolating-extensions.rst:287 msgid "" "Sharing truly immutable objects between interpreters is fine, as long as " "they don't provide access to mutable objects. However, in CPython, every " @@ -410,7 +434,7 @@ msgid "" "process-wide GIL." msgstr "" -#: ../../howto/isolating-extensions.rst:277 +#: ../../howto/isolating-extensions.rst:294 msgid "" "Because they are immutable and process-global, static types cannot access " "\"their\" module state. If any method of such a type requires access to " @@ -419,15 +443,15 @@ msgid "" "Python's ``class`` statement." msgstr "" -#: ../../howto/isolating-extensions.rst:284 +#: ../../howto/isolating-extensions.rst:301 msgid "For new modules, using heap types by default is a good rule of thumb." msgstr "" -#: ../../howto/isolating-extensions.rst:288 +#: ../../howto/isolating-extensions.rst:305 msgid "Changing Static Types to Heap Types" msgstr "" -#: ../../howto/isolating-extensions.rst:290 +#: ../../howto/isolating-extensions.rst:307 msgid "" "Static types can be converted to heap types, but note that the heap type API " "was not designed for \"lossless\" conversion from static types—that is, " @@ -437,101 +461,101 @@ msgid "" "slots). Always test the details that are important to you." msgstr "" -#: ../../howto/isolating-extensions.rst:299 +#: ../../howto/isolating-extensions.rst:316 msgid "" "Watch out for the following two points in particular (but note that this is " "not a comprehensive list):" msgstr "" -#: ../../howto/isolating-extensions.rst:302 +#: ../../howto/isolating-extensions.rst:319 msgid "" "Unlike static types, heap type objects are mutable by default. Use the :c:" "macro:`Py_TPFLAGS_IMMUTABLETYPE` flag to prevent mutability." msgstr "" -#: ../../howto/isolating-extensions.rst:304 +#: ../../howto/isolating-extensions.rst:321 msgid "" "Heap types inherit :c:member:`~PyTypeObject.tp_new` by default, so it may " "become possible to instantiate them from Python code. You can prevent this " "with the :c:macro:`Py_TPFLAGS_DISALLOW_INSTANTIATION` flag." msgstr "" -#: ../../howto/isolating-extensions.rst:310 +#: ../../howto/isolating-extensions.rst:327 msgid "Defining Heap Types" msgstr "" -#: ../../howto/isolating-extensions.rst:312 +#: ../../howto/isolating-extensions.rst:329 msgid "" "Heap types can be created by filling a :c:struct:`PyType_Spec` structure, a " "description or \"blueprint\" of a class, and calling :c:func:" "`PyType_FromModuleAndSpec` to construct a new class object." msgstr "" -#: ../../howto/isolating-extensions.rst:317 +#: ../../howto/isolating-extensions.rst:334 msgid "" "Other functions, like :c:func:`PyType_FromSpec`, can also create heap types, " "but :c:func:`PyType_FromModuleAndSpec` associates the module with the class, " "allowing access to the module state from methods." msgstr "" -#: ../../howto/isolating-extensions.rst:321 +#: ../../howto/isolating-extensions.rst:338 msgid "" "The class should generally be stored in *both* the module state (for safe " "access from C) and the module's ``__dict__`` (for access from Python code)." msgstr "" -#: ../../howto/isolating-extensions.rst:327 +#: ../../howto/isolating-extensions.rst:344 msgid "Garbage-Collection Protocol" msgstr "" -#: ../../howto/isolating-extensions.rst:329 +#: ../../howto/isolating-extensions.rst:346 msgid "" "Instances of heap types hold a reference to their type. This ensures that " "the type isn't destroyed before all its instances are, but may result in " "reference cycles that need to be broken by the garbage collector." msgstr "" -#: ../../howto/isolating-extensions.rst:334 +#: ../../howto/isolating-extensions.rst:351 msgid "" "To avoid memory leaks, instances of heap types must implement the garbage " "collection protocol. That is, heap types should:" msgstr "" -#: ../../howto/isolating-extensions.rst:338 +#: ../../howto/isolating-extensions.rst:355 msgid "Have the :c:macro:`Py_TPFLAGS_HAVE_GC` flag." msgstr "" -#: ../../howto/isolating-extensions.rst:339 +#: ../../howto/isolating-extensions.rst:356 msgid "" "Define a traverse function using ``Py_tp_traverse``, which visits the type " "(e.g. using ``Py_VISIT(Py_TYPE(self))``)." msgstr "" -#: ../../howto/isolating-extensions.rst:342 +#: ../../howto/isolating-extensions.rst:359 msgid "" "Please refer to the documentation of :c:macro:`Py_TPFLAGS_HAVE_GC` and :c:" "member:`~PyTypeObject.tp_traverse` for additional considerations." msgstr "" -#: ../../howto/isolating-extensions.rst:346 +#: ../../howto/isolating-extensions.rst:363 msgid "" "The API for defining heap types grew organically, leaving it somewhat " "awkward to use in its current state. The following sections will guide you " "through common issues." msgstr "" -#: ../../howto/isolating-extensions.rst:352 +#: ../../howto/isolating-extensions.rst:369 msgid "``tp_traverse`` in Python 3.8 and lower" msgstr "" -#: ../../howto/isolating-extensions.rst:354 +#: ../../howto/isolating-extensions.rst:371 msgid "" "The requirement to visit the type from ``tp_traverse`` was added in Python " "3.9. If you support Python 3.8 and lower, the traverse function must *not* " "visit the type, so it must be more complicated::" msgstr "" -#: ../../howto/isolating-extensions.rst:358 +#: ../../howto/isolating-extensions.rst:375 msgid "" "static int my_traverse(PyObject *self, visitproc visit, void *arg)\n" "{\n" @@ -549,27 +573,27 @@ msgstr "" " return 0;\n" "}" -#: ../../howto/isolating-extensions.rst:366 +#: ../../howto/isolating-extensions.rst:383 msgid "" "Unfortunately, :c:data:`Py_Version` was only added in Python 3.11. As a " "replacement, use:" msgstr "" -#: ../../howto/isolating-extensions.rst:369 +#: ../../howto/isolating-extensions.rst:386 msgid ":c:macro:`PY_VERSION_HEX`, if not using the stable ABI, or" msgstr "" -#: ../../howto/isolating-extensions.rst:370 +#: ../../howto/isolating-extensions.rst:387 msgid "" ":py:data:`sys.version_info` (via :c:func:`PySys_GetObject` and :c:func:" "`PyArg_ParseTuple`)." msgstr "" -#: ../../howto/isolating-extensions.rst:375 +#: ../../howto/isolating-extensions.rst:392 msgid "Delegating ``tp_traverse``" msgstr "" -#: ../../howto/isolating-extensions.rst:377 +#: ../../howto/isolating-extensions.rst:394 msgid "" "If your traverse function delegates to the :c:member:`~PyTypeObject." "tp_traverse` of its base class (or another type), ensure that " @@ -577,19 +601,19 @@ msgid "" "expected to visit the type in ``tp_traverse``." msgstr "" -#: ../../howto/isolating-extensions.rst:382 +#: ../../howto/isolating-extensions.rst:399 msgid "For example, if your traverse function includes::" msgstr "" -#: ../../howto/isolating-extensions.rst:384 +#: ../../howto/isolating-extensions.rst:401 msgid "base->tp_traverse(self, visit, arg)" msgstr "base->tp_traverse(self, visit, arg)" -#: ../../howto/isolating-extensions.rst:386 +#: ../../howto/isolating-extensions.rst:403 msgid "...and ``base`` may be a static type, then it should also include::" msgstr "" -#: ../../howto/isolating-extensions.rst:388 +#: ../../howto/isolating-extensions.rst:405 msgid "" "if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) {\n" " // a heap type's tp_traverse already visited Py_TYPE(self)\n" @@ -600,38 +624,38 @@ msgid "" "}" msgstr "" -#: ../../howto/isolating-extensions.rst:396 +#: ../../howto/isolating-extensions.rst:413 msgid "" "It is not necessary to handle the type's reference count in :c:member:" "`~PyTypeObject.tp_new` and :c:member:`~PyTypeObject.tp_clear`." msgstr "" -#: ../../howto/isolating-extensions.rst:401 +#: ../../howto/isolating-extensions.rst:418 msgid "Defining ``tp_dealloc``" msgstr "" -#: ../../howto/isolating-extensions.rst:403 +#: ../../howto/isolating-extensions.rst:420 msgid "" "If your type has a custom :c:member:`~PyTypeObject.tp_dealloc` function, it " "needs to:" msgstr "" -#: ../../howto/isolating-extensions.rst:406 +#: ../../howto/isolating-extensions.rst:423 msgid "" "call :c:func:`PyObject_GC_UnTrack` before any fields are invalidated, and" msgstr "" -#: ../../howto/isolating-extensions.rst:407 +#: ../../howto/isolating-extensions.rst:424 msgid "decrement the reference count of the type." msgstr "" -#: ../../howto/isolating-extensions.rst:409 +#: ../../howto/isolating-extensions.rst:426 msgid "" "To keep the type valid while ``tp_free`` is called, the type's refcount " "needs to be decremented *after* the instance is deallocated. For example::" msgstr "" -#: ../../howto/isolating-extensions.rst:412 +#: ../../howto/isolating-extensions.rst:429 msgid "" "static void my_dealloc(PyObject *self)\n" "{\n" @@ -651,57 +675,57 @@ msgstr "" " Py_DECREF(type);\n" "}" -#: ../../howto/isolating-extensions.rst:421 +#: ../../howto/isolating-extensions.rst:438 msgid "" "The default ``tp_dealloc`` function does this, so if your type does *not* " "override ``tp_dealloc`` you don't need to add it." msgstr "" -#: ../../howto/isolating-extensions.rst:427 +#: ../../howto/isolating-extensions.rst:444 msgid "Not overriding ``tp_free``" msgstr "" -#: ../../howto/isolating-extensions.rst:429 +#: ../../howto/isolating-extensions.rst:446 msgid "" "The :c:member:`~PyTypeObject.tp_free` slot of a heap type must be set to :c:" "func:`PyObject_GC_Del`. This is the default; do not override it." msgstr "" -#: ../../howto/isolating-extensions.rst:435 +#: ../../howto/isolating-extensions.rst:452 msgid "Avoiding ``PyObject_New``" msgstr "" -#: ../../howto/isolating-extensions.rst:437 +#: ../../howto/isolating-extensions.rst:454 msgid "GC-tracked objects need to be allocated using GC-aware functions." msgstr "" -#: ../../howto/isolating-extensions.rst:439 -msgid "If you use use :c:func:`PyObject_New` or :c:func:`PyObject_NewVar`:" +#: ../../howto/isolating-extensions.rst:456 +msgid "If you use :c:func:`PyObject_New` or :c:func:`PyObject_NewVar`:" msgstr "" -#: ../../howto/isolating-extensions.rst:441 +#: ../../howto/isolating-extensions.rst:458 msgid "" "Get and call type's :c:member:`~PyTypeObject.tp_alloc` slot, if possible. " "That is, replace ``TYPE *o = PyObject_New(TYPE, typeobj)`` with::" msgstr "" -#: ../../howto/isolating-extensions.rst:444 +#: ../../howto/isolating-extensions.rst:461 msgid "TYPE *o = typeobj->tp_alloc(typeobj, 0);" msgstr "TYPE *o = typeobj->tp_alloc(typeobj, 0);" -#: ../../howto/isolating-extensions.rst:446 +#: ../../howto/isolating-extensions.rst:463 msgid "" "Replace ``o = PyObject_NewVar(TYPE, typeobj, size)`` with the same, but use " "size instead of the 0." msgstr "" -#: ../../howto/isolating-extensions.rst:449 +#: ../../howto/isolating-extensions.rst:466 msgid "" "If the above is not possible (e.g. inside a custom ``tp_alloc``), call :c:" "func:`PyObject_GC_New` or :c:func:`PyObject_GC_NewVar`::" msgstr "" -#: ../../howto/isolating-extensions.rst:452 +#: ../../howto/isolating-extensions.rst:469 msgid "" "TYPE *o = PyObject_GC_New(TYPE, typeobj);\n" "\n" @@ -711,24 +735,24 @@ msgstr "" "\n" "TYPE *o = PyObject_GC_NewVar(TYPE, typeobj, size);" -#: ../../howto/isolating-extensions.rst:458 +#: ../../howto/isolating-extensions.rst:475 msgid "Module State Access from Classes" msgstr "" -#: ../../howto/isolating-extensions.rst:460 +#: ../../howto/isolating-extensions.rst:477 msgid "" "If you have a type object defined with :c:func:`PyType_FromModuleAndSpec`, " "you can call :c:func:`PyType_GetModule` to get the associated module, and " "then :c:func:`PyModule_GetState` to get the module's state." msgstr "" -#: ../../howto/isolating-extensions.rst:464 +#: ../../howto/isolating-extensions.rst:481 msgid "" "To save a some tedious error-handling boilerplate code, you can combine " "these two steps with :c:func:`PyType_GetModuleState`, resulting in::" msgstr "" -#: ../../howto/isolating-extensions.rst:467 +#: ../../howto/isolating-extensions.rst:484 msgid "" "my_struct *state = (my_struct*)PyType_GetModuleState(type);\n" "if (state == NULL) {\n" @@ -740,11 +764,11 @@ msgstr "" " return NULL;\n" "}" -#: ../../howto/isolating-extensions.rst:474 +#: ../../howto/isolating-extensions.rst:491 msgid "Module State Access from Regular Methods" msgstr "" -#: ../../howto/isolating-extensions.rst:476 +#: ../../howto/isolating-extensions.rst:493 msgid "" "Accessing the module-level state from methods of a class is somewhat more " "complicated, but is possible thanks to API introduced in Python 3.9. To get " @@ -752,27 +776,27 @@ msgid "" "module state from it." msgstr "" -#: ../../howto/isolating-extensions.rst:481 +#: ../../howto/isolating-extensions.rst:498 msgid "" "The largest roadblock is getting *the class a method was defined in*, or " "that method's \"defining class\" for short. The defining class can have a " "reference to the module it is part of." msgstr "" -#: ../../howto/isolating-extensions.rst:485 +#: ../../howto/isolating-extensions.rst:502 msgid "" "Do not confuse the defining class with ``Py_TYPE(self)``. If the method is " "called on a *subclass* of your type, ``Py_TYPE(self)`` will refer to that " "subclass, which may be defined in different module than yours." msgstr "" -#: ../../howto/isolating-extensions.rst:490 +#: ../../howto/isolating-extensions.rst:507 msgid "" "The following Python code can illustrate the concept. ``Base." "get_defining_class`` returns ``Base`` even if ``type(self) == Sub``:" msgstr "" -#: ../../howto/isolating-extensions.rst:494 +#: ../../howto/isolating-extensions.rst:511 msgid "" "class Base:\n" " def get_type_of_self(self):\n" @@ -794,7 +818,7 @@ msgstr "" "class Sub(Base):\n" " pass" -#: ../../howto/isolating-extensions.rst:506 +#: ../../howto/isolating-extensions.rst:523 msgid "" "For a method to get its \"defining class\", it must use the :ref:" "`METH_METHOD | METH_FASTCALL | METH_KEYWORDS `__." +"Discussions about improving the situation are best held on the `discuss " +"forum under c-api tag `__." msgstr "" -#: ../../howto/isolating-extensions.rst:617 +#: ../../howto/isolating-extensions.rst:633 msgid "Per-Class Scope" msgstr "" -#: ../../howto/isolating-extensions.rst:619 +#: ../../howto/isolating-extensions.rst:635 msgid "" "It is currently (as of Python 3.11) not possible to attach state to " "individual *types* without relying on CPython implementation details (which " @@ -945,11 +968,11 @@ msgid "" "per-class scope)." msgstr "" -#: ../../howto/isolating-extensions.rst:626 +#: ../../howto/isolating-extensions.rst:642 msgid "Lossless Conversion to Heap Types" msgstr "" -#: ../../howto/isolating-extensions.rst:628 +#: ../../howto/isolating-extensions.rst:644 msgid "" "The heap type API was not designed for \"lossless\" conversion from static " "types; that is, creating a type that works exactly like a given static type." diff --git a/howto/logging-cookbook.po b/howto/logging-cookbook.po index dace5941c5..d4055b489d 100644 --- a/howto/logging-cookbook.po +++ b/howto/logging-cookbook.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-07-10 00:16+0000\n" "PO-Revision-Date: 2018-05-23 14:36+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -445,10 +445,11 @@ msgstr "" #: ../../howto/logging-cookbook.rst:335 msgid "" "This configuration does *almost* what we want, except that ``sys.stdout`` " -"would show messages of severity ``ERROR`` and above 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``:" +"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``:" msgstr "" #: ../../howto/logging-cookbook.rst:341 @@ -682,6 +683,22 @@ msgid "" "s.close()\n" "print('complete')" msgstr "" +"#!/usr/bin/env python\n" +"import socket, sys, struct\n" +"\n" +"with open(sys.argv[1], 'rb') as f:\n" +" data_to_send = f.read()\n" +"\n" +"HOST = 'localhost'\n" +"PORT = 9999\n" +"s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n" +"print('connecting...')\n" +"s.connect((HOST, PORT))\n" +"print('sending config...')\n" +"s.send(struct.pack('>L', len(data_to_send)))\n" +"s.send(data_to_send)\n" +"s.close()\n" +"print('complete')" #: ../../howto/logging-cookbook.rst:547 msgid "Dealing with handlers that block" @@ -1101,11 +1118,32 @@ msgid "" "configured ports clash with something else in your test environment." msgstr "" -#: ../../howto/logging-cookbook.rst:843 +#: ../../howto/logging-cookbook.rst:838 +msgid "" +"The default configuration uses a TCP socket on port 9020. You can use a Unix " +"Domain socket instead of a TCP socket by doing the following:" +msgstr "" + +#: ../../howto/logging-cookbook.rst:841 +msgid "" +"In :file:`listener.json`, add a ``socket`` key with the path to the domain " +"socket you want to use. If this key is present, the listener listens on the " +"corresponding domain socket and not on a TCP socket (the ``port`` key is " +"ignored)." +msgstr "" + +#: ../../howto/logging-cookbook.rst:846 +msgid "" +"In :file:`webapp.json`, change the socket handler configuration dictionary " +"so that the ``host`` value is the path to the domain socket, and set the " +"``port`` value to ``null``." +msgstr "" + +#: ../../howto/logging-cookbook.rst:856 msgid "Adding contextual information to your logging output" msgstr "" -#: ../../howto/logging-cookbook.rst:845 +#: ../../howto/logging-cookbook.rst:858 msgid "" "Sometimes you want logging output to contain contextual information in " "addition to the parameters passed to the logging call. For example, in a " @@ -1121,11 +1159,11 @@ msgid "" "`Logger` instances becomes effectively unbounded." msgstr "" -#: ../../howto/logging-cookbook.rst:860 +#: ../../howto/logging-cookbook.rst:873 msgid "Using LoggerAdapters to impart contextual information" msgstr "" -#: ../../howto/logging-cookbook.rst:862 +#: ../../howto/logging-cookbook.rst:875 msgid "" "An easy way in which you can pass contextual information to be output along " "with logging event information is to use the :class:`LoggerAdapter` class. " @@ -1136,7 +1174,7 @@ msgid "" "types of instances interchangeably." msgstr "" -#: ../../howto/logging-cookbook.rst:870 +#: ../../howto/logging-cookbook.rst:883 msgid "" "When you create an instance of :class:`LoggerAdapter`, you pass it a :class:" "`Logger` instance and a dict-like object which contains your contextual " @@ -1147,7 +1185,7 @@ msgid "" "of :class:`LoggerAdapter`::" msgstr "" -#: ../../howto/logging-cookbook.rst:878 +#: ../../howto/logging-cookbook.rst:891 msgid "" "def debug(self, msg, /, *args, **kwargs):\n" " \"\"\"\n" @@ -1158,7 +1196,7 @@ msgid "" " self.logger.debug(msg, *args, **kwargs)" msgstr "" -#: ../../howto/logging-cookbook.rst:886 +#: ../../howto/logging-cookbook.rst:899 msgid "" "The :meth:`~LoggerAdapter.process` method of :class:`LoggerAdapter` is where " "the contextual information is added to the logging output. It's passed the " @@ -1171,7 +1209,7 @@ msgid "" "be silently overwritten." msgstr "" -#: ../../howto/logging-cookbook.rst:895 +#: ../../howto/logging-cookbook.rst:908 msgid "" "The advantage of using 'extra' is that the values in the dict-like object " "are merged into the :class:`LogRecord` instance's __dict__, allowing you to " @@ -1182,7 +1220,7 @@ msgid "" "`~LoggerAdapter.process` to do what you need. Here is a simple example::" msgstr "" -#: ../../howto/logging-cookbook.rst:903 +#: ../../howto/logging-cookbook.rst:916 msgid "" "class CustomAdapter(logging.LoggerAdapter):\n" " \"\"\"\n" @@ -1193,27 +1231,27 @@ msgid "" " return '[%s] %s' % (self.extra['connid'], msg), kwargs" msgstr "" -#: ../../howto/logging-cookbook.rst:911 +#: ../../howto/logging-cookbook.rst:924 msgid "which you can use like this::" msgstr "" -#: ../../howto/logging-cookbook.rst:913 +#: ../../howto/logging-cookbook.rst:926 msgid "" "logger = logging.getLogger(__name__)\n" "adapter = CustomAdapter(logger, {'connid': some_conn_id})" msgstr "" -#: ../../howto/logging-cookbook.rst:916 +#: ../../howto/logging-cookbook.rst:929 msgid "" "Then any events that you log to the adapter will have the value of " "``some_conn_id`` prepended to the log messages." msgstr "" -#: ../../howto/logging-cookbook.rst:920 +#: ../../howto/logging-cookbook.rst:933 msgid "Using objects other than dicts to pass contextual information" msgstr "" -#: ../../howto/logging-cookbook.rst:922 +#: ../../howto/logging-cookbook.rst:935 msgid "" "You don't need to pass an actual dict to a :class:`LoggerAdapter` - you " "could pass an instance of a class which implements ``__getitem__`` and " @@ -1222,11 +1260,11 @@ msgid "" "would be constant)." msgstr "" -#: ../../howto/logging-cookbook.rst:931 +#: ../../howto/logging-cookbook.rst:944 msgid "Using Filters to impart contextual information" msgstr "" -#: ../../howto/logging-cookbook.rst:933 +#: ../../howto/logging-cookbook.rst:946 msgid "" "You can also add contextual information to log output using a user-defined :" "class:`Filter`. ``Filter`` instances are allowed to modify the " @@ -1235,7 +1273,7 @@ msgid "" "class:`Formatter`." msgstr "" -#: ../../howto/logging-cookbook.rst:938 +#: ../../howto/logging-cookbook.rst:951 msgid "" "For example in a web application, the request being processed (or at least, " "the interesting parts of it) can be stored in a threadlocal (:class:" @@ -1247,7 +1285,7 @@ msgid "" "an example script::" msgstr "" -#: ../../howto/logging-cookbook.rst:947 +#: ../../howto/logging-cookbook.rst:960 msgid "" "import logging\n" "from random import choice\n" @@ -1290,11 +1328,11 @@ msgid "" "'parameters')" msgstr "" -#: ../../howto/logging-cookbook.rst:984 +#: ../../howto/logging-cookbook.rst:997 msgid "which, when run, produces something like:" msgstr "" -#: ../../howto/logging-cookbook.rst:986 +#: ../../howto/logging-cookbook.rst:999 msgid "" "2010-09-06 22:38:15,292 a.b.c DEBUG IP: 123.231.231.123 User: fred A " "debug message\n" @@ -1322,11 +1360,11 @@ msgid "" "message at INFO level with 2 parameters" msgstr "" -#: ../../howto/logging-cookbook.rst:1002 +#: ../../howto/logging-cookbook.rst:1015 msgid "Use of ``contextvars``" msgstr "" -#: ../../howto/logging-cookbook.rst:1004 +#: ../../howto/logging-cookbook.rst:1017 msgid "" "Since Python 3.7, the :mod:`contextvars` module has provided context-local " "storage which works for both :mod:`threading` and :mod:`asyncio` processing " @@ -1336,7 +1374,7 @@ msgid "" "attributes handled by web applications." msgstr "" -#: ../../howto/logging-cookbook.rst:1010 +#: ../../howto/logging-cookbook.rst:1023 msgid "" "For the purposes of illustration, say that you have different web " "applications, each independent of the other but running in the same Python " @@ -1347,11 +1385,11 @@ msgid "" "information such as client IP, HTTP request method and client username?" msgstr "" -#: ../../howto/logging-cookbook.rst:1017 +#: ../../howto/logging-cookbook.rst:1030 msgid "Let's assume that the library can be simulated by the following code:" msgstr "" -#: ../../howto/logging-cookbook.rst:1019 +#: ../../howto/logging-cookbook.rst:1032 msgid "" "# webapplib.py\n" "import logging\n" @@ -1366,14 +1404,14 @@ msgid "" " time.sleep(0.01)" msgstr "" -#: ../../howto/logging-cookbook.rst:1033 +#: ../../howto/logging-cookbook.rst:1046 msgid "" "We can simulate the multiple web applications by means of two simple " "classes, ``Request`` and ``WebApp``. These simulate how real threaded web " "applications work - each request is handled by a thread:" msgstr "" -#: ../../howto/logging-cookbook.rst:1037 +#: ../../howto/logging-cookbook.rst:1050 msgid "" "# main.py\n" "import argparse\n" @@ -1528,7 +1566,7 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:1177 +#: ../../howto/logging-cookbook.rst:1190 msgid "" "If you run the above, you should find that roughly half the requests go " "into :file:`app1.log` and the rest into :file:`app2.log`, and the all the " @@ -1539,7 +1577,7 @@ msgid "" "illustrated by the following shell output:" msgstr "" -#: ../../howto/logging-cookbook.rst:1184 +#: ../../howto/logging-cookbook.rst:1197 msgid "" "~/logging-contextual-webapp$ python main.py\n" "app1 processed 51 requests\n" @@ -1594,11 +1632,11 @@ msgid "" "147" msgstr "" -#: ../../howto/logging-cookbook.rst:1224 +#: ../../howto/logging-cookbook.rst:1237 msgid "Imparting contextual information in handlers" msgstr "" -#: ../../howto/logging-cookbook.rst:1226 +#: ../../howto/logging-cookbook.rst:1239 msgid "" "Each :class:`~Handler` has its own chain of filters. If you want to add " "contextual information to a :class:`LogRecord` without leaking it to other " @@ -1606,7 +1644,7 @@ msgid "" "instead of modifying it in-place, as shown in the following script::" msgstr "" -#: ../../howto/logging-cookbook.rst:1231 +#: ../../howto/logging-cookbook.rst:1244 msgid "" "import copy\n" "import logging\n" @@ -1627,12 +1665,30 @@ msgid "" "\n" " logger.info('A log message')" msgstr "" +"import copy\n" +"import logging\n" +"\n" +"def filter(record: logging.LogRecord):\n" +" record = copy.copy(record)\n" +" record.user = 'jim'\n" +" return record\n" +"\n" +"if __name__ == '__main__':\n" +" logger = logging.getLogger()\n" +" logger.setLevel(logging.INFO)\n" +" handler = logging.StreamHandler()\n" +" formatter = logging.Formatter('%(message)s from %(user)-8s')\n" +" handler.setFormatter(formatter)\n" +" handler.addFilter(filter)\n" +" logger.addHandler(handler)\n" +"\n" +" logger.info('A log message')" -#: ../../howto/logging-cookbook.rst:1253 +#: ../../howto/logging-cookbook.rst:1266 msgid "Logging to a single file from multiple processes" msgstr "" -#: ../../howto/logging-cookbook.rst:1255 +#: ../../howto/logging-cookbook.rst:1268 msgid "" "Although logging is thread-safe, and logging to a single file from multiple " "threads in a single process *is* supported, logging to a single file from " @@ -1648,18 +1704,15 @@ msgid "" "you to adapt in your own applications." msgstr "" -#: ../../howto/logging-cookbook.rst:1268 +#: ../../howto/logging-cookbook.rst:1281 msgid "" "You could also write your own handler which uses the :class:" "`~multiprocessing.Lock` class from the :mod:`multiprocessing` module to " -"serialize access to the file from your processes. The existing :class:" -"`FileHandler` and subclasses do not make use of :mod:`multiprocessing` at " -"present, though they may do so in the future. Note that at present, the :mod:" -"`multiprocessing` module does not provide working lock functionality on all " -"platforms (see https://bugs.python.org/issue3770)." +"serialize access to the file from your processes. The stdlib :class:" +"`FileHandler` and subclasses do not make use of :mod:`multiprocessing`." msgstr "" -#: ../../howto/logging-cookbook.rst:1278 +#: ../../howto/logging-cookbook.rst:1288 msgid "" "Alternatively, you can use a ``Queue`` and a :class:`QueueHandler` to send " "all logging events to one of the processes in your multi-process " @@ -1674,7 +1727,7 @@ msgid "" "requirements::" msgstr "" -#: ../../howto/logging-cookbook.rst:1289 +#: ../../howto/logging-cookbook.rst:1299 msgid "" "# You'll need these imports in your own code\n" "import logging\n" @@ -1794,13 +1847,13 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:1394 +#: ../../howto/logging-cookbook.rst:1404 msgid "" "A variant of the above script keeps the logging in the main process, in a " "separate thread::" msgstr "" -#: ../../howto/logging-cookbook.rst:1397 +#: ../../howto/logging-cookbook.rst:1407 msgid "" "import logging\n" "import logging.config\n" @@ -1897,7 +1950,7 @@ msgid "" " lp.join()" msgstr "" -#: ../../howto/logging-cookbook.rst:1489 +#: ../../howto/logging-cookbook.rst:1499 msgid "" "This variant shows how you can e.g. apply configuration for particular " "loggers - e.g. the ``foo`` logger has a special handler which stores all " @@ -1907,36 +1960,36 @@ msgid "" "appropriate destinations." msgstr "" -#: ../../howto/logging-cookbook.rst:1496 +#: ../../howto/logging-cookbook.rst:1506 msgid "Using concurrent.futures.ProcessPoolExecutor" -msgstr "" +msgstr "使用 concurrent.futures.ProcessPoolExecutor" -#: ../../howto/logging-cookbook.rst:1498 +#: ../../howto/logging-cookbook.rst:1508 msgid "" "If you want to use :class:`concurrent.futures.ProcessPoolExecutor` to start " "your worker processes, you need to create the queue slightly differently. " "Instead of" msgstr "" -#: ../../howto/logging-cookbook.rst:1502 +#: ../../howto/logging-cookbook.rst:1512 msgid "queue = multiprocessing.Queue(-1)" -msgstr "" +msgstr "queue = multiprocessing.Queue(-1)" -#: ../../howto/logging-cookbook.rst:1506 +#: ../../howto/logging-cookbook.rst:1516 msgid "you should use" msgstr "" -#: ../../howto/logging-cookbook.rst:1508 +#: ../../howto/logging-cookbook.rst:1518 msgid "" "queue = multiprocessing.Manager().Queue(-1) # also works with the examples " "above" msgstr "" -#: ../../howto/logging-cookbook.rst:1512 +#: ../../howto/logging-cookbook.rst:1522 msgid "and you can then replace the worker creation from this::" msgstr "" -#: ../../howto/logging-cookbook.rst:1514 +#: ../../howto/logging-cookbook.rst:1524 msgid "" "workers = []\n" "for i in range(10):\n" @@ -1948,22 +2001,22 @@ msgid "" " w.join()" msgstr "" -#: ../../howto/logging-cookbook.rst:1523 +#: ../../howto/logging-cookbook.rst:1533 msgid "to this (remembering to first import :mod:`concurrent.futures`)::" msgstr "" -#: ../../howto/logging-cookbook.rst:1525 +#: ../../howto/logging-cookbook.rst:1535 msgid "" "with concurrent.futures.ProcessPoolExecutor(max_workers=10) as executor:\n" " for i in range(10):\n" " executor.submit(worker_process, queue, worker_configurer)" msgstr "" -#: ../../howto/logging-cookbook.rst:1530 +#: ../../howto/logging-cookbook.rst:1540 msgid "Deploying Web applications using Gunicorn and uWSGI" msgstr "" -#: ../../howto/logging-cookbook.rst:1532 +#: ../../howto/logging-cookbook.rst:1542 msgid "" "When deploying Web applications using `Gunicorn `_ or " "`uWSGI `_ (or similar), " @@ -1975,11 +2028,11 @@ msgid "" "listener in production`_ for more details." msgstr "" -#: ../../howto/logging-cookbook.rst:1542 +#: ../../howto/logging-cookbook.rst:1552 msgid "Using file rotation" msgstr "" -#: ../../howto/logging-cookbook.rst:1547 +#: ../../howto/logging-cookbook.rst:1557 msgid "" "Sometimes you want to let a log file grow to a certain size, then open a new " "file and log to that. You may want to keep a certain number of these files, " @@ -1988,7 +2041,7 @@ msgid "" "usage pattern, the logging package provides a :class:`RotatingFileHandler`::" msgstr "" -#: ../../howto/logging-cookbook.rst:1553 +#: ../../howto/logging-cookbook.rst:1563 msgid "" "import glob\n" "import logging\n" @@ -2017,13 +2070,13 @@ msgid "" " print(filename)" msgstr "" -#: ../../howto/logging-cookbook.rst:1579 +#: ../../howto/logging-cookbook.rst:1589 msgid "" "The result should be 6 separate files, each with part of the log history for " "the application:" msgstr "" -#: ../../howto/logging-cookbook.rst:1582 +#: ../../howto/logging-cookbook.rst:1592 msgid "" "logging_rotatingfile_example.out\n" "logging_rotatingfile_example.out.1\n" @@ -2033,7 +2086,7 @@ msgid "" "logging_rotatingfile_example.out.5" msgstr "" -#: ../../howto/logging-cookbook.rst:1591 +#: ../../howto/logging-cookbook.rst:1601 msgid "" "The most current file is always :file:`logging_rotatingfile_example.out`, " "and each time it reaches the size limit it is renamed with the suffix " @@ -2041,17 +2094,17 @@ msgid "" "(``.1`` becomes ``.2``, etc.) and the ``.6`` file is erased." msgstr "" -#: ../../howto/logging-cookbook.rst:1596 +#: ../../howto/logging-cookbook.rst:1606 msgid "" "Obviously this example sets the log length much too small as an extreme " "example. You would want to set *maxBytes* to an appropriate value." msgstr "" -#: ../../howto/logging-cookbook.rst:1604 +#: ../../howto/logging-cookbook.rst:1614 msgid "Use of alternative formatting styles" msgstr "" -#: ../../howto/logging-cookbook.rst:1606 +#: ../../howto/logging-cookbook.rst:1616 msgid "" "When logging was added to the Python standard library, the only way of " "formatting messages with variable content was to use the %-formatting " @@ -2060,7 +2113,7 @@ msgid "" "Python 2.6)." msgstr "" -#: ../../howto/logging-cookbook.rst:1612 +#: ../../howto/logging-cookbook.rst:1622 msgid "" "Logging (as of 3.2) provides improved support for these two additional " "formatting styles. The :class:`Formatter` class been enhanced to take an " @@ -2073,7 +2126,7 @@ msgid "" "session to show the possibilities:" msgstr "" -#: ../../howto/logging-cookbook.rst:1622 +#: ../../howto/logging-cookbook.rst:1632 msgid "" ">>> import logging\n" ">>> root = logging.getLogger()\n" @@ -2098,21 +2151,21 @@ msgid "" ">>>" msgstr "" -#: ../../howto/logging-cookbook.rst:1646 +#: ../../howto/logging-cookbook.rst:1656 msgid "" "Note that the formatting of logging messages for final output to logs is " "completely independent of how an individual logging message is constructed. " "That can still use %-formatting, as shown here::" msgstr "" -#: ../../howto/logging-cookbook.rst:1650 +#: ../../howto/logging-cookbook.rst:1660 msgid "" ">>> logger.error('This is an%s %s %s', 'other,', 'ERROR,', 'message')\n" "2010-10-28 15:19:29,833 foo.bar ERROR This is another, ERROR, message\n" ">>>" msgstr "" -#: ../../howto/logging-cookbook.rst:1654 +#: ../../howto/logging-cookbook.rst:1664 msgid "" "Logging calls (``logger.debug()``, ``logger.info()`` etc.) only take " "positional parameters for the actual logging message itself, with keyword " @@ -2128,7 +2181,7 @@ msgid "" "strings." msgstr "" -#: ../../howto/logging-cookbook.rst:1667 +#: ../../howto/logging-cookbook.rst:1677 msgid "" "There is, however, a way that you can use {}- and $- formatting to construct " "your individual log messages. Recall that for a message you can use an " @@ -2137,7 +2190,7 @@ msgid "" "the following two classes::" msgstr "" -#: ../../howto/logging-cookbook.rst:1673 ../../howto/logging-cookbook.rst:2761 +#: ../../howto/logging-cookbook.rst:1683 ../../howto/logging-cookbook.rst:2771 msgid "" "class BraceMessage:\n" " def __init__(self, fmt, /, *args, **kwargs):\n" @@ -2175,7 +2228,7 @@ msgstr "" " from string import Template\n" " return Template(self.fmt).substitute(**self.kwargs)" -#: ../../howto/logging-cookbook.rst:1691 +#: ../../howto/logging-cookbook.rst:1701 msgid "" "Either of these can be used in place of a format string, to allow {}- or $-" "formatting to be used to build the actual \"message\" part which appears in " @@ -2186,14 +2239,14 @@ msgid "" "used as a synonym/alias for :func:`gettext.gettext` or its brethren)." msgstr "" -#: ../../howto/logging-cookbook.rst:1699 +#: ../../howto/logging-cookbook.rst:1709 msgid "" "The above classes are not included in Python, though they're easy enough to " "copy and paste into your own code. They can be used as follows (assuming " "that they're declared in a module called ``wherever``):" msgstr "" -#: ../../howto/logging-cookbook.rst:1703 +#: ../../howto/logging-cookbook.rst:1713 msgid "" ">>> from wherever import BraceMessage as __\n" ">>> print(__('Message with {0} {name}', 2, name='placeholders'))\n" @@ -2212,14 +2265,14 @@ msgid "" ">>>" msgstr "" -#: ../../howto/logging-cookbook.rst:1721 +#: ../../howto/logging-cookbook.rst:1731 msgid "" "While the above examples use ``print()`` to show how the formatting works, " "you would of course use ``logger.debug()`` or similar to actually log using " "this approach." msgstr "" -#: ../../howto/logging-cookbook.rst:1725 +#: ../../howto/logging-cookbook.rst:1735 msgid "" "One thing to note is that you pay no significant performance penalty with " "this approach: the actual formatting happens not when you make the logging " @@ -2230,13 +2283,13 @@ msgid "" "sugar for a constructor call to one of the :samp:`{XXX}Message` classes." msgstr "" -#: ../../howto/logging-cookbook.rst:1733 +#: ../../howto/logging-cookbook.rst:1743 msgid "" "If you prefer, you can use a :class:`LoggerAdapter` to achieve a similar " "effect to the above, as in the following example::" msgstr "" -#: ../../howto/logging-cookbook.rst:1736 +#: ../../howto/logging-cookbook.rst:1746 msgid "" "import logging\n" "\n" @@ -2265,17 +2318,17 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:1762 +#: ../../howto/logging-cookbook.rst:1772 msgid "" "The above script should log the message ``Hello, world!`` when run with " "Python 3.8 or later." msgstr "" -#: ../../howto/logging-cookbook.rst:1771 +#: ../../howto/logging-cookbook.rst:1781 msgid "Customizing ``LogRecord``" msgstr "" -#: ../../howto/logging-cookbook.rst:1773 +#: ../../howto/logging-cookbook.rst:1783 msgid "" "Every logging event is represented by a :class:`LogRecord` instance. When an " "event is logged and not filtered out by a logger's level, a :class:" @@ -2286,13 +2339,13 @@ msgid "" "was done:" msgstr "" -#: ../../howto/logging-cookbook.rst:1780 +#: ../../howto/logging-cookbook.rst:1790 msgid "" ":meth:`Logger.makeRecord`, which is called in the normal process of logging " "an event. This invoked :class:`LogRecord` directly to create an instance." msgstr "" -#: ../../howto/logging-cookbook.rst:1783 +#: ../../howto/logging-cookbook.rst:1793 msgid "" ":func:`makeLogRecord`, which is called with a dictionary containing " "attributes to be added to the LogRecord. This is typically invoked when a " @@ -2301,27 +2354,27 @@ msgid "" "`~handlers.HTTPHandler`)." msgstr "" -#: ../../howto/logging-cookbook.rst:1789 +#: ../../howto/logging-cookbook.rst:1799 msgid "" "This has usually meant that if you need to do anything special with a :class:" "`LogRecord`, you've had to do one of the following." msgstr "" -#: ../../howto/logging-cookbook.rst:1792 +#: ../../howto/logging-cookbook.rst:1802 msgid "" "Create your own :class:`Logger` subclass, which overrides :meth:`Logger." "makeRecord`, and set it using :func:`~logging.setLoggerClass` before any " "loggers that you care about are instantiated." msgstr "" -#: ../../howto/logging-cookbook.rst:1795 +#: ../../howto/logging-cookbook.rst:1805 msgid "" "Add a :class:`Filter` to a logger or handler, which does the necessary " "special manipulation you need when its :meth:`~Filter.filter` method is " "called." msgstr "" -#: ../../howto/logging-cookbook.rst:1799 +#: ../../howto/logging-cookbook.rst:1809 msgid "" "The first approach would be a little unwieldy in the scenario where (say) " "several different libraries wanted to do different things. Each would " @@ -2329,7 +2382,7 @@ msgid "" "last would win." msgstr "" -#: ../../howto/logging-cookbook.rst:1804 +#: ../../howto/logging-cookbook.rst:1814 msgid "" "The second approach works reasonably well for many cases, but does not allow " "you to e.g. use a specialized subclass of :class:`LogRecord`. Library " @@ -2338,11 +2391,11 @@ msgid "" "would do simply by adding new packages or modules and doing ::" msgstr "" -#: ../../howto/logging-cookbook.rst:1810 +#: ../../howto/logging-cookbook.rst:1820 msgid "logger = logging.getLogger(__name__)" msgstr "logger = logging.getLogger(__name__)" -#: ../../howto/logging-cookbook.rst:1812 +#: ../../howto/logging-cookbook.rst:1822 msgid "" "at module level). It's probably one too many things to think about. " "Developers could also add the filter to a :class:`~logging.NullHandler` " @@ -2352,7 +2405,7 @@ msgid "" "developer." msgstr "" -#: ../../howto/logging-cookbook.rst:1818 +#: ../../howto/logging-cookbook.rst:1828 msgid "" "In Python 3.2 and later, :class:`~logging.LogRecord` creation is done " "through a factory, which you can specify. The factory is just a callable you " @@ -2362,7 +2415,7 @@ msgid "" "`LogRecord` is the default setting for the factory." msgstr "" -#: ../../howto/logging-cookbook.rst:1825 +#: ../../howto/logging-cookbook.rst:1835 msgid "" "This approach allows a custom factory to control all aspects of LogRecord " "creation. For example, you could return a subclass, or just add some " @@ -2370,7 +2423,7 @@ msgid "" "this::" msgstr "" -#: ../../howto/logging-cookbook.rst:1829 +#: ../../howto/logging-cookbook.rst:1839 msgid "" "old_factory = logging.getLogRecordFactory()\n" "\n" @@ -2382,7 +2435,7 @@ msgid "" "logging.setLogRecordFactory(record_factory)" msgstr "" -#: ../../howto/logging-cookbook.rst:1838 +#: ../../howto/logging-cookbook.rst:1848 msgid "" "This pattern allows different libraries to chain factories together, and as " "long as they don't overwrite each other's attributes or unintentionally " @@ -2392,22 +2445,22 @@ msgid "" "used when the use of a :class:`Filter` does not provide the desired result." msgstr "" -#: ../../howto/logging-cookbook.rst:1850 +#: ../../howto/logging-cookbook.rst:1860 msgid "Subclassing QueueHandler and QueueListener- a ZeroMQ example" msgstr "" -#: ../../howto/logging-cookbook.rst:1853 ../../howto/logging-cookbook.rst:1986 +#: ../../howto/logging-cookbook.rst:1863 ../../howto/logging-cookbook.rst:1996 msgid "Subclass ``QueueHandler``" msgstr "" -#: ../../howto/logging-cookbook.rst:1855 +#: ../../howto/logging-cookbook.rst:1865 msgid "" "You can use a :class:`QueueHandler` subclass to send messages to other kinds " "of queues, for example a ZeroMQ 'publish' socket. In the example below,the " "socket is created separately and passed to the handler (as its 'queue')::" msgstr "" -#: ../../howto/logging-cookbook.rst:1859 +#: ../../howto/logging-cookbook.rst:1869 msgid "" "import zmq # using pyzmq, the Python binding for ZeroMQ\n" "import json # for serializing records portably\n" @@ -2424,13 +2477,13 @@ msgid "" "handler = ZeroMQSocketHandler(sock)" msgstr "" -#: ../../howto/logging-cookbook.rst:1874 +#: ../../howto/logging-cookbook.rst:1884 msgid "" "Of course there are other ways of organizing this, for example passing in " "the data needed by the handler to create the socket::" msgstr "" -#: ../../howto/logging-cookbook.rst:1877 +#: ../../howto/logging-cookbook.rst:1887 msgid "" "class ZeroMQSocketHandler(QueueHandler):\n" " def __init__(self, uri, socktype=zmq.PUB, ctx=None):\n" @@ -2446,17 +2499,17 @@ msgid "" " self.queue.close()" msgstr "" -#: ../../howto/logging-cookbook.rst:1892 ../../howto/logging-cookbook.rst:1922 +#: ../../howto/logging-cookbook.rst:1902 ../../howto/logging-cookbook.rst:1932 msgid "Subclass ``QueueListener``" msgstr "" -#: ../../howto/logging-cookbook.rst:1894 +#: ../../howto/logging-cookbook.rst:1904 msgid "" "You can also subclass :class:`QueueListener` to get messages from other " "kinds of queues, for example a ZeroMQ 'subscribe' socket. Here's an example::" msgstr "" -#: ../../howto/logging-cookbook.rst:1897 +#: ../../howto/logging-cookbook.rst:1907 msgid "" "class ZeroMQSocketListener(QueueListener):\n" " def __init__(self, uri, /, *handlers, **kwargs):\n" @@ -2472,11 +2525,11 @@ msgid "" " return logging.makeLogRecord(msg)" msgstr "" -#: ../../howto/logging-cookbook.rst:1912 +#: ../../howto/logging-cookbook.rst:1922 msgid "Subclassing QueueHandler and QueueListener- a ``pynng`` example" msgstr "" -#: ../../howto/logging-cookbook.rst:1914 +#: ../../howto/logging-cookbook.rst:1924 msgid "" "In a similar way to the above section, we can implement a listener and " "handler using :pypi:`pynng`, which is a Python binding to `NNG `_ of the Django documentation." msgstr "" -#: ../../howto/logging-cookbook.rst:2160 +#: ../../howto/logging-cookbook.rst:2170 msgid "Using a rotator and namer to customize log rotation processing" msgstr "" -#: ../../howto/logging-cookbook.rst:2162 +#: ../../howto/logging-cookbook.rst:2172 msgid "" "An example of how you can define a namer and rotator is given in the " "following runnable script, which shows gzip compression of the log file::" msgstr "" -#: ../../howto/logging-cookbook.rst:2165 +#: ../../howto/logging-cookbook.rst:2175 msgid "" "import gzip\n" "import logging\n" @@ -2859,12 +2912,12 @@ msgstr "" "for i in range(1000):\n" " root.info(f'Message no. {i + 1}')" -#: ../../howto/logging-cookbook.rst:2193 +#: ../../howto/logging-cookbook.rst:2203 msgid "" "After running this, you will see six new files, five of which are compressed:" msgstr "" -#: ../../howto/logging-cookbook.rst:2195 +#: ../../howto/logging-cookbook.rst:2205 msgid "" "$ ls rotated.log*\n" "rotated.log rotated.log.2.gz rotated.log.4.gz\n" @@ -2882,11 +2935,11 @@ msgstr "" "2023-01-20 02:28:17,767 Message no. 997\n" "2023-01-20 02:28:17,767 Message no. 998" -#: ../../howto/logging-cookbook.rst:2206 +#: ../../howto/logging-cookbook.rst:2216 msgid "A more elaborate multiprocessing example" msgstr "" -#: ../../howto/logging-cookbook.rst:2208 +#: ../../howto/logging-cookbook.rst:2218 msgid "" "The following working example shows how logging can be used with " "multiprocessing using configuration files. The configurations are fairly " @@ -2894,7 +2947,7 @@ msgid "" "in a real multiprocessing scenario." msgstr "" -#: ../../howto/logging-cookbook.rst:2213 +#: ../../howto/logging-cookbook.rst:2223 msgid "" "In the example, the main process spawns a listener process and some worker " "processes. Each of the main process, the listener and the workers have three " @@ -2907,13 +2960,13 @@ msgid "" "own scenario." msgstr "" -#: ../../howto/logging-cookbook.rst:2223 +#: ../../howto/logging-cookbook.rst:2233 msgid "" "Here's the script - the docstrings and the comments hopefully explain how it " "works::" msgstr "" -#: ../../howto/logging-cookbook.rst:2226 +#: ../../howto/logging-cookbook.rst:2236 msgid "" "import logging\n" "import logging.config\n" @@ -3136,11 +3189,11 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:2435 +#: ../../howto/logging-cookbook.rst:2445 msgid "Inserting a BOM into messages sent to a SysLogHandler" msgstr "" -#: ../../howto/logging-cookbook.rst:2437 +#: ../../howto/logging-cookbook.rst:2447 msgid "" ":rfc:`5424` requires that a Unicode message be sent to a syslog daemon as a " "set of bytes which have the following structure: an optional pure-ASCII " @@ -3149,7 +3202,7 @@ msgid "" "<5424#section-6>`.)" msgstr "" -#: ../../howto/logging-cookbook.rst:2443 +#: ../../howto/logging-cookbook.rst:2453 msgid "" "In Python 3.1, code was added to :class:`~logging.handlers.SysLogHandler` to " "insert a BOM into the message, but unfortunately, it was implemented " @@ -3157,7 +3210,7 @@ msgid "" "hence not allowing any pure-ASCII component to appear before it." msgstr "" -#: ../../howto/logging-cookbook.rst:2449 +#: ../../howto/logging-cookbook.rst:2459 msgid "" "As this behaviour is broken, the incorrect BOM insertion code is being " "removed from Python 3.2.4 and later. However, it is not being replaced, and " @@ -3166,37 +3219,37 @@ msgid "" "encoded using UTF-8, then you need to do the following:" msgstr "" -#: ../../howto/logging-cookbook.rst:2455 +#: ../../howto/logging-cookbook.rst:2465 msgid "" "Attach a :class:`~logging.Formatter` instance to your :class:`~logging." "handlers.SysLogHandler` instance, with a format string such as::" msgstr "" -#: ../../howto/logging-cookbook.rst:2459 +#: ../../howto/logging-cookbook.rst:2469 msgid "'ASCII section\\ufeffUnicode section'" msgstr "" -#: ../../howto/logging-cookbook.rst:2461 +#: ../../howto/logging-cookbook.rst:2471 msgid "" "The Unicode code point U+FEFF, when encoded using UTF-8, will be encoded as " "a UTF-8 BOM -- the byte-string ``b'\\xef\\xbb\\xbf'``." msgstr "" -#: ../../howto/logging-cookbook.rst:2464 +#: ../../howto/logging-cookbook.rst:2474 msgid "" "Replace the ASCII section with whatever placeholders you like, but make sure " "that the data that appears in there after substitution is always ASCII (that " "way, it will remain unchanged after UTF-8 encoding)." msgstr "" -#: ../../howto/logging-cookbook.rst:2468 +#: ../../howto/logging-cookbook.rst:2478 msgid "" "Replace the Unicode section with whatever placeholders you like; if the data " "which appears there after substitution contains characters outside the ASCII " "range, that's fine -- it will be encoded using UTF-8." msgstr "" -#: ../../howto/logging-cookbook.rst:2472 +#: ../../howto/logging-cookbook.rst:2482 msgid "" "The formatted message *will* be encoded using UTF-8 encoding by " "``SysLogHandler``. If you follow the above rules, you should be able to " @@ -3205,11 +3258,11 @@ msgid "" "daemon may complain." msgstr "" -#: ../../howto/logging-cookbook.rst:2479 +#: ../../howto/logging-cookbook.rst:2489 msgid "Implementing structured logging" msgstr "" -#: ../../howto/logging-cookbook.rst:2481 +#: ../../howto/logging-cookbook.rst:2491 msgid "" "Although most logging messages are intended for reading by humans, and thus " "not readily machine-parseable, there might be circumstances where you want " @@ -3221,7 +3274,7 @@ msgid "" "machine-parseable manner::" msgstr "" -#: ../../howto/logging-cookbook.rst:2489 +#: ../../howto/logging-cookbook.rst:2499 msgid "" "import json\n" "import logging\n" @@ -3240,11 +3293,11 @@ msgid "" "logging.info(_('message 1', foo='bar', bar='baz', num=123, fnum=123.456))" msgstr "" -#: ../../howto/logging-cookbook.rst:2505 +#: ../../howto/logging-cookbook.rst:2515 msgid "If the above script is run, it prints:" msgstr "" -#: ../../howto/logging-cookbook.rst:2507 +#: ../../howto/logging-cookbook.rst:2517 msgid "" "message 1 >>> {\"fnum\": 123.456, \"num\": 123, \"bar\": \"baz\", \"foo\": " "\"bar\"}" @@ -3252,19 +3305,19 @@ msgstr "" "message 1 >>> {\"fnum\": 123.456, \"num\": 123, \"bar\": \"baz\", \"foo\": " "\"bar\"}" -#: ../../howto/logging-cookbook.rst:2511 ../../howto/logging-cookbook.rst:2553 +#: ../../howto/logging-cookbook.rst:2521 ../../howto/logging-cookbook.rst:2563 msgid "" "Note that the order of items might be different according to the version of " "Python used." msgstr "" -#: ../../howto/logging-cookbook.rst:2514 +#: ../../howto/logging-cookbook.rst:2524 msgid "" "If you need more specialised processing, you can use a custom JSON encoder, " "as in the following complete example::" msgstr "" -#: ../../howto/logging-cookbook.rst:2517 +#: ../../howto/logging-cookbook.rst:2527 msgid "" "import json\n" "import logging\n" @@ -3297,19 +3350,19 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:2547 +#: ../../howto/logging-cookbook.rst:2557 msgid "When the above script is run, it prints:" msgstr "" -#: ../../howto/logging-cookbook.rst:2549 +#: ../../howto/logging-cookbook.rst:2559 msgid "message 1 >>> {\"snowman\": \"\\u2603\", \"set_value\": [1, 2, 3]}" msgstr "message 1 >>> {\"snowman\": \"\\u2603\", \"set_value\": [1, 2, 3]}" -#: ../../howto/logging-cookbook.rst:2562 +#: ../../howto/logging-cookbook.rst:2572 msgid "Customizing handlers with :func:`dictConfig`" msgstr "" -#: ../../howto/logging-cookbook.rst:2564 +#: ../../howto/logging-cookbook.rst:2574 msgid "" "There are times when you want to customize logging handlers in particular " "ways, and if you use :func:`dictConfig` you may be able to do this without " @@ -3319,7 +3372,7 @@ msgid "" "customize handler creation using a plain function such as::" msgstr "" -#: ../../howto/logging-cookbook.rst:2571 +#: ../../howto/logging-cookbook.rst:2581 msgid "" "def owned_file_handler(filename, mode='a', encoding=None, owner=None):\n" " if owner:\n" @@ -3335,13 +3388,13 @@ msgstr "" " shutil.chown(filename, *owner)\n" " return logging.FileHandler(filename, mode, encoding)" -#: ../../howto/logging-cookbook.rst:2578 +#: ../../howto/logging-cookbook.rst:2588 msgid "" "You can then specify, in a logging configuration passed to :func:" "`dictConfig`, that a logging handler be created by calling this function::" msgstr "" -#: ../../howto/logging-cookbook.rst:2581 +#: ../../howto/logging-cookbook.rst:2591 msgid "" "LOGGING = {\n" " 'version': 1,\n" @@ -3374,14 +3427,14 @@ msgid "" "}" msgstr "" -#: ../../howto/logging-cookbook.rst:2611 +#: ../../howto/logging-cookbook.rst:2621 msgid "" "In this example I am setting the ownership using the ``pulse`` user and " "group, just for the purposes of illustration. Putting it together into a " "working script, ``chowntest.py``::" msgstr "" -#: ../../howto/logging-cookbook.rst:2615 +#: ../../howto/logging-cookbook.rst:2625 msgid "" "import logging, logging.config, os, shutil\n" "\n" @@ -3427,11 +3480,11 @@ msgid "" "logger.debug('A debug message')" msgstr "" -#: ../../howto/logging-cookbook.rst:2658 +#: ../../howto/logging-cookbook.rst:2668 msgid "To run this, you will probably need to run as ``root``:" msgstr "" -#: ../../howto/logging-cookbook.rst:2660 +#: ../../howto/logging-cookbook.rst:2670 msgid "" "$ sudo python3.3 chowntest.py\n" "$ cat chowntest.log\n" @@ -3440,7 +3493,7 @@ msgid "" "-rw-r--r-- 1 pulse pulse 55 2013-11-05 09:34 chowntest.log" msgstr "" -#: ../../howto/logging-cookbook.rst:2668 +#: ../../howto/logging-cookbook.rst:2678 msgid "" "Note that this example uses Python 3.3 because that's where :func:`shutil." "chown` makes an appearance. This approach should work with any Python " @@ -3449,25 +3502,25 @@ msgid "" "change using e.g. :func:`os.chown`." msgstr "" -#: ../../howto/logging-cookbook.rst:2674 +#: ../../howto/logging-cookbook.rst:2684 msgid "" "In practice, the handler-creating function may be in a utility module " "somewhere in your project. Instead of the line in the configuration::" msgstr "" -#: ../../howto/logging-cookbook.rst:2677 +#: ../../howto/logging-cookbook.rst:2687 msgid "'()': owned_file_handler," msgstr "'()': owned_file_handler," -#: ../../howto/logging-cookbook.rst:2679 +#: ../../howto/logging-cookbook.rst:2689 msgid "you could use e.g.::" msgstr "" -#: ../../howto/logging-cookbook.rst:2681 +#: ../../howto/logging-cookbook.rst:2691 msgid "'()': 'ext://project.util.owned_file_handler'," msgstr "'()': 'ext://project.util.owned_file_handler'," -#: ../../howto/logging-cookbook.rst:2683 +#: ../../howto/logging-cookbook.rst:2693 msgid "" "where ``project.util`` can be replaced with the actual name of the package " "where the function resides. In the above working script, using ``'ext://" @@ -3475,25 +3528,25 @@ msgid "" "resolved by :func:`dictConfig` from the ``ext://`` specification." msgstr "" -#: ../../howto/logging-cookbook.rst:2688 +#: ../../howto/logging-cookbook.rst:2698 msgid "" "This example hopefully also points the way to how you could implement other " "types of file change - e.g. setting specific POSIX permission bits - in the " "same way, using :func:`os.chmod`." msgstr "" -#: ../../howto/logging-cookbook.rst:2692 +#: ../../howto/logging-cookbook.rst:2702 msgid "" "Of course, the approach could also be extended to types of handler other " "than a :class:`~logging.FileHandler` - for example, one of the rotating file " "handlers, or a different type of handler altogether." msgstr "" -#: ../../howto/logging-cookbook.rst:2702 +#: ../../howto/logging-cookbook.rst:2712 msgid "Using particular formatting styles throughout your application" msgstr "" -#: ../../howto/logging-cookbook.rst:2704 +#: ../../howto/logging-cookbook.rst:2714 msgid "" "In Python 3.2, the :class:`~logging.Formatter` gained a ``style`` keyword " "parameter which, while defaulting to ``%`` for backward compatibility, " @@ -3504,7 +3557,7 @@ msgid "" "is constructed." msgstr "" -#: ../../howto/logging-cookbook.rst:2711 +#: ../../howto/logging-cookbook.rst:2721 msgid "" "Logging calls (:meth:`~Logger.debug`, :meth:`~Logger.info` etc.) only take " "positional parameters for the actual logging message itself, with keyword " @@ -3519,7 +3572,7 @@ msgid "" "calls which are out there in existing code will be using %-format strings." msgstr "" -#: ../../howto/logging-cookbook.rst:2723 +#: ../../howto/logging-cookbook.rst:2733 msgid "" "There have been suggestions to associate format styles with specific " "loggers, but that approach also runs into backward compatibility problems " @@ -3527,7 +3580,7 @@ msgid "" "formatting." msgstr "" -#: ../../howto/logging-cookbook.rst:2727 +#: ../../howto/logging-cookbook.rst:2737 msgid "" "For logging to work interoperably between any third-party libraries and your " "code, decisions about formatting need to be made at the level of the " @@ -3535,11 +3588,11 @@ msgid "" "formatting styles can be accommodated." msgstr "" -#: ../../howto/logging-cookbook.rst:2734 +#: ../../howto/logging-cookbook.rst:2744 msgid "Using LogRecord factories" msgstr "" -#: ../../howto/logging-cookbook.rst:2736 +#: ../../howto/logging-cookbook.rst:2746 msgid "" "In Python 3.2, along with the :class:`~logging.Formatter` changes mentioned " "above, the logging package gained the ability to allow users to set their " @@ -3554,17 +3607,17 @@ msgid "" "implementation does." msgstr "" -#: ../../howto/logging-cookbook.rst:2747 +#: ../../howto/logging-cookbook.rst:2757 msgid "" "Refer to the reference documentation on :func:`setLogRecordFactory` and :" "class:`LogRecord` for more information." msgstr "" -#: ../../howto/logging-cookbook.rst:2752 +#: ../../howto/logging-cookbook.rst:2762 msgid "Using custom message objects" msgstr "" -#: ../../howto/logging-cookbook.rst:2754 +#: ../../howto/logging-cookbook.rst:2764 msgid "" "There is another, perhaps simpler way that you can use {}- and $- formatting " "to construct your individual log messages. You may recall (from :ref:" @@ -3574,7 +3627,7 @@ msgid "" "following two classes::" msgstr "" -#: ../../howto/logging-cookbook.rst:2779 +#: ../../howto/logging-cookbook.rst:2789 msgid "" "Either of these can be used in place of a format string, to allow {}- or $-" "formatting to be used to build the actual \"message\" part which appears in " @@ -3585,13 +3638,13 @@ msgid "" "using ``_`` for localization)." msgstr "" -#: ../../howto/logging-cookbook.rst:2787 +#: ../../howto/logging-cookbook.rst:2797 msgid "" "Examples of this approach are given below. Firstly, formatting with :meth:" "`str.format`::" msgstr "" -#: ../../howto/logging-cookbook.rst:2790 +#: ../../howto/logging-cookbook.rst:2800 msgid "" ">>> __ = BraceMessage\n" ">>> print(__('Message with {0} {1}', 2, 'placeholders'))\n" @@ -3606,11 +3659,11 @@ msgid "" "Message with coordinates: (0.50, 0.50)" msgstr "" -#: ../../howto/logging-cookbook.rst:2801 +#: ../../howto/logging-cookbook.rst:2811 msgid "Secondly, formatting with :class:`string.Template`::" msgstr "" -#: ../../howto/logging-cookbook.rst:2803 +#: ../../howto/logging-cookbook.rst:2813 msgid "" ">>> __ = DollarMessage\n" ">>> print(__('Message with $num $what', num=2, what='placeholders'))\n" @@ -3618,7 +3671,7 @@ msgid "" ">>>" msgstr "" -#: ../../howto/logging-cookbook.rst:2808 +#: ../../howto/logging-cookbook.rst:2818 msgid "" "One thing to note is that you pay no significant performance penalty with " "this approach: the actual formatting happens not when you make the logging " @@ -3630,11 +3683,11 @@ msgid "" "shown above." msgstr "" -#: ../../howto/logging-cookbook.rst:2822 +#: ../../howto/logging-cookbook.rst:2832 msgid "Configuring filters with :func:`dictConfig`" msgstr "" -#: ../../howto/logging-cookbook.rst:2824 +#: ../../howto/logging-cookbook.rst:2834 msgid "" "You *can* configure filters using :func:`~logging.config.dictConfig`, though " "it might not be obvious at first glance how to do it (hence this recipe). " @@ -3649,7 +3702,7 @@ msgid "" "complete example::" msgstr "" -#: ../../howto/logging-cookbook.rst:2835 +#: ../../howto/logging-cookbook.rst:2845 msgid "" "import logging\n" "import logging.config\n" @@ -3735,26 +3788,26 @@ msgstr "" " logging.debug('hello')\n" " logging.debug('hello - noshow')" -#: ../../howto/logging-cookbook.rst:2877 +#: ../../howto/logging-cookbook.rst:2887 msgid "" "This example shows how you can pass configuration data to the callable which " "constructs the instance, in the form of keyword parameters. When run, the " "above script will print:" msgstr "" -#: ../../howto/logging-cookbook.rst:2881 +#: ../../howto/logging-cookbook.rst:2891 msgid "changed: hello" msgstr "changed: hello" -#: ../../howto/logging-cookbook.rst:2885 +#: ../../howto/logging-cookbook.rst:2895 msgid "which shows that the filter is working as configured." msgstr "" -#: ../../howto/logging-cookbook.rst:2887 +#: ../../howto/logging-cookbook.rst:2897 msgid "A couple of extra points to note:" msgstr "" -#: ../../howto/logging-cookbook.rst:2889 +#: ../../howto/logging-cookbook.rst:2899 msgid "" "If you can't refer to the callable directly in the configuration (e.g. if it " "lives in a different module, and you can't import it directly where the " @@ -3764,7 +3817,7 @@ msgid "" "the above example." msgstr "" -#: ../../howto/logging-cookbook.rst:2896 +#: ../../howto/logging-cookbook.rst:2906 msgid "" "As well as for filters, this technique can also be used to configure custom " "handlers and formatters. See :ref:`logging-config-dict-userdef` for more " @@ -3773,11 +3826,11 @@ msgid "" "above." msgstr "" -#: ../../howto/logging-cookbook.rst:2905 +#: ../../howto/logging-cookbook.rst:2915 msgid "Customized exception formatting" msgstr "" -#: ../../howto/logging-cookbook.rst:2907 +#: ../../howto/logging-cookbook.rst:2917 msgid "" "There might be times when you want to do customized exception formatting - " "for argument's sake, let's say you want exactly one line per logged event, " @@ -3785,7 +3838,7 @@ msgid "" "formatter class, as shown in the following example::" msgstr "" -#: ../../howto/logging-cookbook.rst:2912 +#: ../../howto/logging-cookbook.rst:2922 msgid "" "import logging\n" "\n" @@ -3824,11 +3877,11 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:2948 +#: ../../howto/logging-cookbook.rst:2958 msgid "When run, this produces a file with exactly two lines:" msgstr "" -#: ../../howto/logging-cookbook.rst:2950 +#: ../../howto/logging-cookbook.rst:2960 msgid "" "28/01/2015 07:21:23|INFO|Sample message|\n" "28/01/2015 07:21:23|ERROR|ZeroDivisionError: integer division or modulo by " @@ -3842,18 +3895,18 @@ msgstr "" "in main\\n x = 1 / 0\\nZeroDivisionError: integer division or modulo by " "zero'|" -#: ../../howto/logging-cookbook.rst:2955 +#: ../../howto/logging-cookbook.rst:2965 msgid "" "While the above treatment is simplistic, it points the way to how exception " "information can be formatted to your liking. The :mod:`traceback` module may " "be helpful for more specialized needs." msgstr "" -#: ../../howto/logging-cookbook.rst:2962 +#: ../../howto/logging-cookbook.rst:2972 msgid "Speaking logging messages" msgstr "" -#: ../../howto/logging-cookbook.rst:2964 +#: ../../howto/logging-cookbook.rst:2974 msgid "" "There might be situations when it is desirable to have logging messages " "rendered in an audible rather than a visible format. This is easy to do if " @@ -3870,7 +3923,7 @@ msgid "" "approach, which assumes that the ``espeak`` TTS package is available::" msgstr "" -#: ../../howto/logging-cookbook.rst:2977 +#: ../../howto/logging-cookbook.rst:2987 msgid "" "import logging\n" "import subprocess\n" @@ -3902,24 +3955,24 @@ msgid "" " sys.exit(main())" msgstr "" -#: ../../howto/logging-cookbook.rst:3006 +#: ../../howto/logging-cookbook.rst:3016 msgid "" "When run, this script should say \"Hello\" and then \"Goodbye\" in a female " "voice." msgstr "" -#: ../../howto/logging-cookbook.rst:3008 +#: ../../howto/logging-cookbook.rst:3018 msgid "" "The above approach can, of course, be adapted to other TTS systems and even " "other systems altogether which can process messages via external programs " "run from a command line." msgstr "" -#: ../../howto/logging-cookbook.rst:3016 +#: ../../howto/logging-cookbook.rst:3026 msgid "Buffering logging messages and outputting them conditionally" msgstr "" -#: ../../howto/logging-cookbook.rst:3018 +#: ../../howto/logging-cookbook.rst:3028 msgid "" "There might be situations where you want to log messages in a temporary area " "and only output them if a certain condition occurs. For example, you may " @@ -3929,7 +3982,7 @@ msgid "" "debug information to be output as well as the error." msgstr "" -#: ../../howto/logging-cookbook.rst:3025 +#: ../../howto/logging-cookbook.rst:3035 msgid "" "Here is an example which shows how you could do this using a decorator for " "your functions where you want logging to behave this way. It makes use of " @@ -3942,7 +3995,7 @@ msgid "" "subclass of ``MemoryHandler`` if you want custom flushing behavior." msgstr "" -#: ../../howto/logging-cookbook.rst:3035 +#: ../../howto/logging-cookbook.rst:3045 msgid "" "The example script has a simple function, ``foo``, which just cycles through " "all the logging levels, writing to ``sys.stderr`` to say what level it's " @@ -3951,7 +4004,7 @@ msgid "" "levels - otherwise, it only logs at DEBUG, INFO and WARNING levels." msgstr "" -#: ../../howto/logging-cookbook.rst:3041 +#: ../../howto/logging-cookbook.rst:3051 msgid "" "The script just arranges to decorate ``foo`` with a decorator which will do " "the conditional logging that's required. The decorator takes a logger as a " @@ -3963,11 +4016,11 @@ msgid "" "respectively." msgstr "" -#: ../../howto/logging-cookbook.rst:3049 +#: ../../howto/logging-cookbook.rst:3059 msgid "Here's the script::" msgstr "" -#: ../../howto/logging-cookbook.rst:3051 +#: ../../howto/logging-cookbook.rst:3061 msgid "" "import logging\n" "from logging.handlers import MemoryHandler\n" @@ -4033,11 +4086,11 @@ msgid "" " assert decorated_foo(True)" msgstr "" -#: ../../howto/logging-cookbook.rst:3112 +#: ../../howto/logging-cookbook.rst:3122 msgid "When this script is run, the following output should be observed:" msgstr "" -#: ../../howto/logging-cookbook.rst:3114 +#: ../../howto/logging-cookbook.rst:3124 msgid "" "Calling undecorated foo with False\n" "about to log at DEBUG ...\n" @@ -4066,29 +4119,29 @@ msgid "" "Actually logged at CRITICAL" msgstr "" -#: ../../howto/logging-cookbook.rst:3142 +#: ../../howto/logging-cookbook.rst:3152 msgid "" "As you can see, actual logging output only occurs when an event is logged " "whose severity is ERROR or greater, but in that case, any previous events at " "lower severities are also logged." msgstr "" -#: ../../howto/logging-cookbook.rst:3146 +#: ../../howto/logging-cookbook.rst:3156 msgid "You can of course use the conventional means of decoration::" msgstr "" -#: ../../howto/logging-cookbook.rst:3148 +#: ../../howto/logging-cookbook.rst:3158 msgid "" "@log_if_errors(logger)\n" "def foo(fail=False):\n" " ..." msgstr "" -#: ../../howto/logging-cookbook.rst:3156 +#: ../../howto/logging-cookbook.rst:3166 msgid "Sending logging messages to email, with buffering" msgstr "" -#: ../../howto/logging-cookbook.rst:3158 +#: ../../howto/logging-cookbook.rst:3168 msgid "" "To illustrate how you can send log messages via email, so that a set number " "of messages are sent per email, you can subclass :class:`~logging.handlers." @@ -4099,7 +4152,7 @@ msgid "" "argument to see the required and optional arguments.)" msgstr "" -#: ../../howto/logging-cookbook.rst:3166 +#: ../../howto/logging-cookbook.rst:3176 msgid "" "import logging\n" "import logging.handlers\n" @@ -4167,7 +4220,7 @@ msgid "" " h.close()" msgstr "" -#: ../../howto/logging-cookbook.rst:3230 +#: ../../howto/logging-cookbook.rst:3240 msgid "" "If you run this script and your SMTP server is correctly set up, you should " "find that it sends eleven emails to the addressee you specify. The first ten " @@ -4175,17 +4228,17 @@ msgid "" "messages. That makes up 102 messages as specified in the script." msgstr "" -#: ../../howto/logging-cookbook.rst:3238 +#: ../../howto/logging-cookbook.rst:3248 msgid "Formatting times using UTC (GMT) via configuration" msgstr "" -#: ../../howto/logging-cookbook.rst:3240 +#: ../../howto/logging-cookbook.rst:3250 msgid "" "Sometimes you want to format times using UTC, which can be done using a " "class such as ``UTCFormatter``, shown below::" msgstr "" -#: ../../howto/logging-cookbook.rst:3243 +#: ../../howto/logging-cookbook.rst:3253 msgid "" "import logging\n" "import time\n" @@ -4194,7 +4247,7 @@ msgid "" " converter = time.gmtime" msgstr "" -#: ../../howto/logging-cookbook.rst:3249 +#: ../../howto/logging-cookbook.rst:3259 msgid "" "and you can then use the ``UTCFormatter`` in your code instead of :class:" "`~logging.Formatter`. If you want to do that via configuration, you can use " @@ -4202,7 +4255,7 @@ msgid "" "the following complete example::" msgstr "" -#: ../../howto/logging-cookbook.rst:3254 +#: ../../howto/logging-cookbook.rst:3264 msgid "" "import logging\n" "import logging.config\n" @@ -4243,27 +4296,29 @@ msgid "" " logging.warning('The local time is %s', time.asctime())" msgstr "" -#: ../../howto/logging-cookbook.rst:3292 +#: ../../howto/logging-cookbook.rst:3302 msgid "When this script is run, it should print something like:" msgstr "" -#: ../../howto/logging-cookbook.rst:3294 +#: ../../howto/logging-cookbook.rst:3304 msgid "" "2015-10-17 12:53:29,501 The local time is Sat Oct 17 13:53:29 2015\n" "2015-10-17 13:53:29,501 The local time is Sat Oct 17 13:53:29 2015" msgstr "" +"2015-10-17 12:53:29,501 The local time is Sat Oct 17 13:53:29 2015\n" +"2015-10-17 13:53:29,501 The local time is Sat Oct 17 13:53:29 2015" -#: ../../howto/logging-cookbook.rst:3299 +#: ../../howto/logging-cookbook.rst:3309 msgid "" "showing how the time is formatted both as local time and UTC, one for each " "handler." msgstr "" -#: ../../howto/logging-cookbook.rst:3306 +#: ../../howto/logging-cookbook.rst:3316 msgid "Using a context manager for selective logging" msgstr "" -#: ../../howto/logging-cookbook.rst:3308 +#: ../../howto/logging-cookbook.rst:3318 msgid "" "There are times when it would be useful to temporarily change the logging " "configuration and revert it back after doing something. For this, a context " @@ -4273,7 +4328,7 @@ msgid "" "scope of the context manager::" msgstr "" -#: ../../howto/logging-cookbook.rst:3315 +#: ../../howto/logging-cookbook.rst:3325 msgid "" "import logging\n" "import sys\n" @@ -4302,7 +4357,7 @@ msgid "" " # implicit return of None => don't swallow exceptions" msgstr "" -#: ../../howto/logging-cookbook.rst:3341 +#: ../../howto/logging-cookbook.rst:3351 msgid "" "If you specify a level value, the logger's level is set to that value in the " "scope of the with block covered by the context manager. If you specify a " @@ -4311,13 +4366,13 @@ msgid "" "block exit - you could do this if you don't need the handler any more." msgstr "" -#: ../../howto/logging-cookbook.rst:3347 +#: ../../howto/logging-cookbook.rst:3357 msgid "" "To illustrate how it works, we can add the following block of code to the " "above::" msgstr "" -#: ../../howto/logging-cookbook.rst:3350 +#: ../../howto/logging-cookbook.rst:3360 msgid "" "if __name__ == '__main__':\n" " logger = logging.getLogger('foo')\n" @@ -4337,7 +4392,7 @@ msgid "" " logger.debug('7. This should not appear.')" msgstr "" -#: ../../howto/logging-cookbook.rst:3365 +#: ../../howto/logging-cookbook.rst:3375 msgid "" "We initially set the logger's level to ``INFO``, so message #1 appears and " "message #2 doesn't. We then change the level to ``DEBUG`` temporarily in the " @@ -4350,11 +4405,11 @@ msgid "" "(like message #1) whereas message #7 doesn't (just like message #2)." msgstr "" -#: ../../howto/logging-cookbook.rst:3375 +#: ../../howto/logging-cookbook.rst:3385 msgid "If we run the resulting script, the result is as follows:" msgstr "" -#: ../../howto/logging-cookbook.rst:3377 +#: ../../howto/logging-cookbook.rst:3387 msgid "" "$ python logctx.py\n" "1. This should appear just once on stderr.\n" @@ -4364,23 +4419,23 @@ msgid "" "6. This should appear just once on stderr." msgstr "" -#: ../../howto/logging-cookbook.rst:3386 +#: ../../howto/logging-cookbook.rst:3396 msgid "" "If we run it again, but pipe ``stderr`` to ``/dev/null``, we see the " "following, which is the only message written to ``stdout``:" msgstr "" -#: ../../howto/logging-cookbook.rst:3389 +#: ../../howto/logging-cookbook.rst:3399 msgid "" "$ python logctx.py 2>/dev/null\n" "5. This should appear twice - once on stderr and once on stdout." msgstr "" -#: ../../howto/logging-cookbook.rst:3394 +#: ../../howto/logging-cookbook.rst:3404 msgid "Once again, but piping ``stdout`` to ``/dev/null``, we get:" msgstr "" -#: ../../howto/logging-cookbook.rst:3396 +#: ../../howto/logging-cookbook.rst:3406 msgid "" "$ python logctx.py >/dev/null\n" "1. This should appear just once on stderr.\n" @@ -4389,42 +4444,42 @@ msgid "" "6. This should appear just once on stderr." msgstr "" -#: ../../howto/logging-cookbook.rst:3404 +#: ../../howto/logging-cookbook.rst:3414 msgid "" "In this case, the message #5 printed to ``stdout`` doesn't appear, as " "expected." msgstr "" -#: ../../howto/logging-cookbook.rst:3406 +#: ../../howto/logging-cookbook.rst:3416 msgid "" "Of course, the approach described here can be generalised, for example to " "attach logging filters temporarily. Note that the above code works in Python " "2 as well as Python 3." msgstr "" -#: ../../howto/logging-cookbook.rst:3414 +#: ../../howto/logging-cookbook.rst:3424 msgid "A CLI application starter template" msgstr "" -#: ../../howto/logging-cookbook.rst:3416 +#: ../../howto/logging-cookbook.rst:3426 msgid "Here's an example which shows how you can:" msgstr "" -#: ../../howto/logging-cookbook.rst:3418 +#: ../../howto/logging-cookbook.rst:3428 msgid "Use a logging level based on command-line arguments" msgstr "" -#: ../../howto/logging-cookbook.rst:3419 +#: ../../howto/logging-cookbook.rst:3429 msgid "" "Dispatch to multiple subcommands in separate files, all logging at the same " "level in a consistent way" msgstr "" -#: ../../howto/logging-cookbook.rst:3421 +#: ../../howto/logging-cookbook.rst:3431 msgid "Make use of simple, minimal configuration" msgstr "" -#: ../../howto/logging-cookbook.rst:3423 +#: ../../howto/logging-cookbook.rst:3433 msgid "" "Suppose we have a command-line application whose job is to stop, start or " "restart some services. This could be organised for the purposes of " @@ -4435,7 +4490,7 @@ msgid "" "``logging.INFO``. Here's one way that ``app.py`` could be written::" msgstr "" -#: ../../howto/logging-cookbook.rst:3431 +#: ../../howto/logging-cookbook.rst:3441 msgid "" "import argparse\n" "import importlib\n" @@ -4482,13 +4537,13 @@ msgid "" " sys.exit(main())" msgstr "" -#: ../../howto/logging-cookbook.rst:3472 +#: ../../howto/logging-cookbook.rst:3482 msgid "" "And the ``start``, ``stop`` and ``restart`` commands can be implemented in " "separate modules, like so for starting::" msgstr "" -#: ../../howto/logging-cookbook.rst:3475 +#: ../../howto/logging-cookbook.rst:3485 msgid "" "# start.py\n" "import logging\n" @@ -4501,11 +4556,11 @@ msgid "" " logger.info('Started the \\'%s\\' service.', options.name)" msgstr "" -#: ../../howto/logging-cookbook.rst:3485 +#: ../../howto/logging-cookbook.rst:3495 msgid "and thus for stopping::" msgstr "" -#: ../../howto/logging-cookbook.rst:3487 +#: ../../howto/logging-cookbook.rst:3497 msgid "" "# stop.py\n" "import logging\n" @@ -4527,11 +4582,11 @@ msgid "" " logger.info('Stopped the %s service%s.', services, plural)" msgstr "" -#: ../../howto/logging-cookbook.rst:3506 +#: ../../howto/logging-cookbook.rst:3516 msgid "and similarly for restarting::" msgstr "" -#: ../../howto/logging-cookbook.rst:3508 +#: ../../howto/logging-cookbook.rst:3518 msgid "" "# restart.py\n" "import logging\n" @@ -4553,13 +4608,13 @@ msgid "" " logger.info('Restarted the %s service%s.', services, plural)" msgstr "" -#: ../../howto/logging-cookbook.rst:3527 +#: ../../howto/logging-cookbook.rst:3537 msgid "" "If we run this application with the default log level, we get output like " "this:" msgstr "" -#: ../../howto/logging-cookbook.rst:3529 +#: ../../howto/logging-cookbook.rst:3539 msgid "" "$ python app.py start foo\n" "INFO start Started the 'foo' service.\n" @@ -4571,19 +4626,19 @@ msgid "" "INFO restart Restarted the 'foo', 'bar' and 'baz' services." msgstr "" -#: ../../howto/logging-cookbook.rst:3540 +#: ../../howto/logging-cookbook.rst:3550 msgid "" "The first word is the logging level, and the second word is the module or " "package name of the place where the event was logged." msgstr "" -#: ../../howto/logging-cookbook.rst:3543 +#: ../../howto/logging-cookbook.rst:3553 msgid "" "If we change the logging level, then we can change the information sent to " "the log. For example, if we want more information:" msgstr "" -#: ../../howto/logging-cookbook.rst:3546 +#: ../../howto/logging-cookbook.rst:3556 msgid "" "$ python app.py --log-level DEBUG start foo\n" "DEBUG start About to start foo\n" @@ -4598,28 +4653,28 @@ msgid "" "INFO restart Restarted the 'foo', 'bar' and 'baz' services." msgstr "" -#: ../../howto/logging-cookbook.rst:3560 +#: ../../howto/logging-cookbook.rst:3570 msgid "And if we want less:" msgstr "" -#: ../../howto/logging-cookbook.rst:3562 +#: ../../howto/logging-cookbook.rst:3572 msgid "" "$ python app.py --log-level WARNING start foo\n" "$ python app.py --log-level WARNING stop foo bar\n" "$ python app.py --log-level WARNING restart foo bar baz" msgstr "" -#: ../../howto/logging-cookbook.rst:3568 +#: ../../howto/logging-cookbook.rst:3578 msgid "" "In this case, the commands don't print anything to the console, since " "nothing at ``WARNING`` level or above is logged by them." msgstr "" -#: ../../howto/logging-cookbook.rst:3574 +#: ../../howto/logging-cookbook.rst:3584 msgid "A Qt GUI for logging" msgstr "" -#: ../../howto/logging-cookbook.rst:3576 +#: ../../howto/logging-cookbook.rst:3586 msgid "" "A question that comes up from time to time is about how to log to a GUI " "application. The `Qt `_ framework is a popular cross-" @@ -4627,7 +4682,7 @@ msgid "" "`PyQt5` libraries." msgstr "" -#: ../../howto/logging-cookbook.rst:3581 +#: ../../howto/logging-cookbook.rst:3591 msgid "" "The following example shows how to log to a Qt GUI. This introduces a simple " "``QtHandler`` class which takes a callable, which should be a slot in the " @@ -4637,14 +4692,14 @@ msgid "" "logging messages at random levels with random short delays in between)." msgstr "" -#: ../../howto/logging-cookbook.rst:3588 +#: ../../howto/logging-cookbook.rst:3598 msgid "" "The worker thread is implemented using Qt's ``QThread`` class rather than " "the :mod:`threading` module, as there are circumstances where one has to use " "``QThread``, which offers better integration with other ``Qt`` components." msgstr "" -#: ../../howto/logging-cookbook.rst:3592 +#: ../../howto/logging-cookbook.rst:3602 msgid "" "The code should work with recent releases of any of ``PySide6``, ``PyQt6``, " "``PySide2`` or ``PyQt5``. You should be able to adapt the approach to " @@ -4652,7 +4707,7 @@ msgid "" "more detailed information." msgstr "" -#: ../../howto/logging-cookbook.rst:3597 +#: ../../howto/logging-cookbook.rst:3607 msgid "" "import datetime\n" "import logging\n" @@ -4903,11 +4958,11 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:3829 +#: ../../howto/logging-cookbook.rst:3839 msgid "Logging to syslog with RFC5424 support" msgstr "" -#: ../../howto/logging-cookbook.rst:3831 +#: ../../howto/logging-cookbook.rst:3841 msgid "" "Although :rfc:`5424` dates from 2009, most syslog servers are configured by " "default to use the older :rfc:`3164`, which hails from 2001. When " @@ -4917,14 +4972,14 @@ msgid "" "handlers.SysLogHandler` functionality has not been updated." msgstr "" -#: ../../howto/logging-cookbook.rst:3838 +#: ../../howto/logging-cookbook.rst:3848 msgid "" "RFC 5424 contains some useful features such as support for structured data, " "and if you need to be able to log to a syslog server with support for it, " "you can do so with a subclassed handler which looks something like this::" msgstr "" -#: ../../howto/logging-cookbook.rst:3842 +#: ../../howto/logging-cookbook.rst:3852 msgid "" "import datetime\n" "import logging.handlers\n" @@ -4994,7 +5049,7 @@ msgid "" "{sdata} {msg}'" msgstr "" -#: ../../howto/logging-cookbook.rst:3904 +#: ../../howto/logging-cookbook.rst:3914 msgid "" "You'll need to be familiar with RFC 5424 to fully understand the above code, " "and it may be that you have slightly different needs (e.g. for how you pass " @@ -5003,7 +5058,7 @@ msgid "" "using something like this::" msgstr "" -#: ../../howto/logging-cookbook.rst:3909 +#: ../../howto/logging-cookbook.rst:3919 msgid "" "sd = {\n" " 'foo@12345': {'bar': 'baz', 'baz': 'bozz', 'fizz': r'buzz'},\n" @@ -5013,12 +5068,19 @@ msgid "" "i = 1\n" "logger.debug('Message %d', i, extra=extra)" msgstr "" +"sd = {\n" +" 'foo@12345': {'bar': 'baz', 'baz': 'bozz', 'fizz': r'buzz'},\n" +" 'foo@54321': {'rab': 'baz', 'zab': 'bozz', 'zzif': r'buzz'}\n" +"}\n" +"extra = {'structured_data': sd}\n" +"i = 1\n" +"logger.debug('Message %d', i, extra=extra)" -#: ../../howto/logging-cookbook.rst:3918 +#: ../../howto/logging-cookbook.rst:3928 msgid "How to treat a logger like an output stream" msgstr "" -#: ../../howto/logging-cookbook.rst:3920 +#: ../../howto/logging-cookbook.rst:3930 msgid "" "Sometimes, you need to interface to a third-party API which expects a file-" "like object to write to, but you want to direct the API's output to a " @@ -5026,7 +5088,7 @@ msgid "" "API. Here's a short script illustrating such a class:" msgstr "" -#: ../../howto/logging-cookbook.rst:3925 +#: ../../howto/logging-cookbook.rst:3935 msgid "" "import logging\n" "\n" @@ -5064,31 +5126,37 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:3960 +#: ../../howto/logging-cookbook.rst:3970 msgid "When this script is run, it prints" msgstr "" -#: ../../howto/logging-cookbook.rst:3962 +#: ../../howto/logging-cookbook.rst:3972 msgid "" "INFO:demo:An INFO message\n" "DEBUG:demo:A DEBUG message" msgstr "" +"INFO:demo:An INFO message\n" +"DEBUG:demo:A DEBUG message" -#: ../../howto/logging-cookbook.rst:3967 +#: ../../howto/logging-cookbook.rst:3977 msgid "" "You could also use ``LoggerWriter`` to redirect ``sys.stdout`` and ``sys." "stderr`` by doing something like this:" msgstr "" -#: ../../howto/logging-cookbook.rst:3970 +#: ../../howto/logging-cookbook.rst:3980 msgid "" "import sys\n" "\n" "sys.stdout = LoggerWriter(logger, logging.INFO)\n" "sys.stderr = LoggerWriter(logger, logging.WARNING)" msgstr "" +"import sys\n" +"\n" +"sys.stdout = LoggerWriter(logger, logging.INFO)\n" +"sys.stderr = LoggerWriter(logger, logging.WARNING)" -#: ../../howto/logging-cookbook.rst:3977 +#: ../../howto/logging-cookbook.rst:3987 msgid "" "You should do this *after* configuring logging for your needs. In the above " "example, the :func:`~logging.basicConfig` call does this (using the ``sys." @@ -5096,7 +5164,7 @@ msgid "" "Then, you'd get this kind of result:" msgstr "" -#: ../../howto/logging-cookbook.rst:3982 +#: ../../howto/logging-cookbook.rst:3992 msgid "" ">>> print('Foo')\n" "INFO:demo:Foo\n" @@ -5104,32 +5172,37 @@ msgid "" "WARNING:demo:Bar\n" ">>>" msgstr "" +">>> print('Foo')\n" +"INFO:demo:Foo\n" +">>> print('Bar', file=sys.stderr)\n" +"WARNING:demo:Bar\n" +">>>" -#: ../../howto/logging-cookbook.rst:3990 +#: ../../howto/logging-cookbook.rst:4000 msgid "" "Of course, the examples above show output according to the format used by :" "func:`~logging.basicConfig`, but you can use a different formatter when you " "configure logging." msgstr "" -#: ../../howto/logging-cookbook.rst:3994 +#: ../../howto/logging-cookbook.rst:4004 msgid "" "Note that with the above scheme, you are somewhat at the mercy of buffering " "and the sequence of write calls which you are intercepting. For example, " "with the definition of ``LoggerWriter`` above, if you have the snippet" msgstr "" -#: ../../howto/logging-cookbook.rst:3998 +#: ../../howto/logging-cookbook.rst:4008 msgid "" "sys.stderr = LoggerWriter(logger, logging.WARNING)\n" "1 / 0" msgstr "" -#: ../../howto/logging-cookbook.rst:4003 +#: ../../howto/logging-cookbook.rst:4013 msgid "then running the script results in" msgstr "" -#: ../../howto/logging-cookbook.rst:4005 +#: ../../howto/logging-cookbook.rst:4015 msgid "" "WARNING:demo:Traceback (most recent call last):\n" "\n" @@ -5148,7 +5221,7 @@ msgid "" "WARNING:demo:division by zero" msgstr "" -#: ../../howto/logging-cookbook.rst:4021 +#: ../../howto/logging-cookbook.rst:4031 msgid "" "As you can see, this output isn't ideal. That's because the underlying code " "which writes to ``sys.stderr`` makes multiple writes, each of which results " @@ -5158,7 +5231,7 @@ msgid "" "``LoggerWriter``:" msgstr "" -#: ../../howto/logging-cookbook.rst:4027 +#: ../../howto/logging-cookbook.rst:4037 msgid "" "class BufferingLoggerWriter(LoggerWriter):\n" " def __init__(self, logger, level):\n" @@ -5177,14 +5250,30 @@ msgid "" " for part in parts:\n" " self.logger.log(self.level, part)" msgstr "" +"class BufferingLoggerWriter(LoggerWriter):\n" +" def __init__(self, logger, level):\n" +" super().__init__(logger, level)\n" +" self.buffer = ''\n" +"\n" +" def write(self, message):\n" +" if '\\n' not in message:\n" +" self.buffer += message\n" +" else:\n" +" parts = message.split('\\n')\n" +" if self.buffer:\n" +" s = self.buffer + parts.pop(0)\n" +" self.logger.log(self.level, s)\n" +" self.buffer = parts.pop()\n" +" for part in parts:\n" +" self.logger.log(self.level, part)" -#: ../../howto/logging-cookbook.rst:4046 +#: ../../howto/logging-cookbook.rst:4056 msgid "" "This just buffers up stuff until a newline is seen, and then logs complete " "lines. With this approach, you get better output:" msgstr "" -#: ../../howto/logging-cookbook.rst:4049 +#: ../../howto/logging-cookbook.rst:4059 msgid "" "WARNING:demo:Traceback (most recent call last):\n" "WARNING:demo: File \"/home/runner/cookbook-loggerwriter/main.py\", line 55, " @@ -5195,12 +5284,146 @@ msgid "" "WARNING:demo: 1/0\n" "WARNING:demo:ZeroDivisionError: division by zero" msgstr "" +"WARNING:demo:Traceback (most recent call last):\n" +"WARNING:demo: File \"/home/runner/cookbook-loggerwriter/main.py\", line 55, " +"in \n" +"WARNING:demo: main()\n" +"WARNING:demo: File \"/home/runner/cookbook-loggerwriter/main.py\", line 52, " +"in main\n" +"WARNING:demo: 1/0\n" +"WARNING:demo:ZeroDivisionError: division by zero" + +#: ../../howto/logging-cookbook.rst:4069 +msgid "How to uniformly handle newlines in logging output" +msgstr "" -#: ../../howto/logging-cookbook.rst:4062 +#: ../../howto/logging-cookbook.rst:4071 +msgid "" +"Usually, messages that are logged (say to console or file) consist of a " +"single line of text. However, sometimes there is a need to handle messages " +"with multiple lines - whether because a logging format string contains " +"newlines, or logged data contains newlines. If you want to handle such " +"messages uniformly, so that each line in the logged message appears " +"uniformly formatted as if it was logged separately, you can do this using a " +"handler mixin, as in the following snippet:" +msgstr "" + +#: ../../howto/logging-cookbook.rst:4079 +msgid "" +"# Assume this is in a module mymixins.py\n" +"import copy\n" +"\n" +"class MultilineMixin:\n" +" def emit(self, record):\n" +" s = record.getMessage()\n" +" if '\\n' not in s:\n" +" super().emit(record)\n" +" else:\n" +" lines = s.splitlines()\n" +" rec = copy.copy(record)\n" +" rec.args = None\n" +" for line in lines:\n" +" rec.msg = line\n" +" super().emit(rec)" +msgstr "" + +#: ../../howto/logging-cookbook.rst:4097 +msgid "You can use the mixin as in the following script:" +msgstr "" + +#: ../../howto/logging-cookbook.rst:4099 +msgid "" +"import logging\n" +"\n" +"from mymixins import MultilineMixin\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"\n" +"class StreamHandler(MultilineMixin, logging.StreamHandler):\n" +" pass\n" +"\n" +"if __name__ == '__main__':\n" +" logging.basicConfig(level=logging.DEBUG, format='%(asctime)s " +"%(levelname)-9s %(message)s',\n" +" handlers = [StreamHandler()])\n" +" logger.debug('Single line')\n" +" logger.debug('Multiple lines:\\nfool me once ...')\n" +" logger.debug('Another single line')\n" +" logger.debug('Multiple lines:\\n%s', 'fool me ...\\ncan\\'t get fooled " +"again')" +msgstr "" + +#: ../../howto/logging-cookbook.rst:4118 +msgid "The script, when run, prints something like:" +msgstr "" + +#: ../../howto/logging-cookbook.rst:4120 +msgid "" +"2025-07-02 13:54:47,234 DEBUG Single line\n" +"2025-07-02 13:54:47,234 DEBUG Multiple lines:\n" +"2025-07-02 13:54:47,234 DEBUG fool me once ...\n" +"2025-07-02 13:54:47,234 DEBUG Another single line\n" +"2025-07-02 13:54:47,234 DEBUG Multiple lines:\n" +"2025-07-02 13:54:47,234 DEBUG fool me ...\n" +"2025-07-02 13:54:47,234 DEBUG can't get fooled again" +msgstr "" + +#: ../../howto/logging-cookbook.rst:4130 +msgid "" +"If, on the other hand, you are concerned about `log injection `_, you can use a formatter which " +"escapes newlines, as per the following example:" +msgstr "" + +#: ../../howto/logging-cookbook.rst:4134 +msgid "" +"import logging\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"\n" +"class EscapingFormatter(logging.Formatter):\n" +" def format(self, record):\n" +" s = super().format(record)\n" +" return s.replace('\\n', r'\\n')\n" +"\n" +"if __name__ == '__main__':\n" +" h = logging.StreamHandler()\n" +" h.setFormatter(EscapingFormatter('%(asctime)s %(levelname)-9s " +"%(message)s'))\n" +" logging.basicConfig(level=logging.DEBUG, handlers = [h])\n" +" logger.debug('Single line')\n" +" logger.debug('Multiple lines:\\nfool me once ...')\n" +" logger.debug('Another single line')\n" +" logger.debug('Multiple lines:\\n%s', 'fool me ...\\ncan\\'t get fooled " +"again')" +msgstr "" + +#: ../../howto/logging-cookbook.rst:4154 +msgid "" +"You can, of course, use whatever escaping scheme makes the most sense for " +"you. The script, when run, should produce output like this:" +msgstr "" + +#: ../../howto/logging-cookbook.rst:4157 +msgid "" +"2025-07-09 06:47:33,783 DEBUG Single line\n" +"2025-07-09 06:47:33,783 DEBUG Multiple lines:\\nfool me once ...\n" +"2025-07-09 06:47:33,783 DEBUG Another single line\n" +"2025-07-09 06:47:33,783 DEBUG Multiple lines:\\nfool me ...\\ncan't get " +"fooled again" +msgstr "" + +#: ../../howto/logging-cookbook.rst:4164 +msgid "" +"Escaping behaviour can't be the stdlib default , as it would break backwards " +"compatibility." +msgstr "" + +#: ../../howto/logging-cookbook.rst:4170 msgid "Patterns to avoid" msgstr "" -#: ../../howto/logging-cookbook.rst:4064 +#: ../../howto/logging-cookbook.rst:4172 msgid "" "Although the preceding sections have described ways of doing things you " "might need to do or deal with, it is worth mentioning some usage patterns " @@ -5208,11 +5431,11 @@ msgid "" "The following sections are in no particular order." msgstr "" -#: ../../howto/logging-cookbook.rst:4070 +#: ../../howto/logging-cookbook.rst:4178 msgid "Opening the same log file multiple times" msgstr "" -#: ../../howto/logging-cookbook.rst:4072 +#: ../../howto/logging-cookbook.rst:4180 msgid "" "On Windows, you will generally not be able to open the same file multiple " "times as this will lead to a \"file is in use by another process\" error. " @@ -5220,32 +5443,32 @@ msgid "" "file multiple times. This could be done accidentally, for example by:" msgstr "" -#: ../../howto/logging-cookbook.rst:4077 +#: ../../howto/logging-cookbook.rst:4185 msgid "" "Adding a file handler more than once which references the same file (e.g. by " "a copy/paste/forget-to-change error)." msgstr "" -#: ../../howto/logging-cookbook.rst:4080 +#: ../../howto/logging-cookbook.rst:4188 msgid "" "Opening two files that look different, as they have different names, but are " "the same because one is a symbolic link to the other." msgstr "" -#: ../../howto/logging-cookbook.rst:4083 +#: ../../howto/logging-cookbook.rst:4191 msgid "" "Forking a process, following which both parent and child have a reference to " "the same file. This might be through use of the :mod:`multiprocessing` " "module, for example." msgstr "" -#: ../../howto/logging-cookbook.rst:4087 +#: ../../howto/logging-cookbook.rst:4195 msgid "" "Opening a file multiple times might *appear* to work most of the time, but " "can lead to a number of problems in practice:" msgstr "" -#: ../../howto/logging-cookbook.rst:4090 +#: ../../howto/logging-cookbook.rst:4198 msgid "" "Logging output can be garbled because multiple threads or processes try to " "write to the same file. Although logging guards against concurrent use of " @@ -5254,7 +5477,7 @@ msgid "" "different handler instances which happen to point to the same file." msgstr "" -#: ../../howto/logging-cookbook.rst:4096 +#: ../../howto/logging-cookbook.rst:4204 msgid "" "An attempt to delete a file (e.g. during file rotation) silently fails, " "because there is another reference pointing to it. This can lead to " @@ -5264,17 +5487,17 @@ msgid "" "being supposedly in place." msgstr "" -#: ../../howto/logging-cookbook.rst:4103 +#: ../../howto/logging-cookbook.rst:4211 msgid "" "Use the techniques outlined in :ref:`multiple-processes` to circumvent such " "issues." msgstr "" -#: ../../howto/logging-cookbook.rst:4107 +#: ../../howto/logging-cookbook.rst:4215 msgid "Using loggers as attributes in a class or passing them as parameters" msgstr "" -#: ../../howto/logging-cookbook.rst:4109 +#: ../../howto/logging-cookbook.rst:4217 msgid "" "While there might be unusual cases where you'll need to do this, in general " "there is no point because loggers are singletons. Code can always access a " @@ -5285,13 +5508,13 @@ msgid "" "module (and not the class) is the unit of software decomposition." msgstr "" -#: ../../howto/logging-cookbook.rst:4118 +#: ../../howto/logging-cookbook.rst:4226 msgid "" "Adding handlers other than :class:`~logging.NullHandler` to a logger in a " "library" msgstr "" -#: ../../howto/logging-cookbook.rst:4120 +#: ../../howto/logging-cookbook.rst:4228 msgid "" "Configuring logging by adding handlers, formatters and filters is the " "responsibility of the application developer, not the library developer. If " @@ -5299,11 +5522,11 @@ msgid "" "your loggers other than a :class:`~logging.NullHandler` instance." msgstr "" -#: ../../howto/logging-cookbook.rst:4126 +#: ../../howto/logging-cookbook.rst:4234 msgid "Creating a lot of loggers" msgstr "" -#: ../../howto/logging-cookbook.rst:4128 +#: ../../howto/logging-cookbook.rst:4236 msgid "" "Loggers are singletons that are never freed during a script execution, and " "so creating lots of loggers will use up memory which can't then be freed. " @@ -5314,38 +5537,38 @@ msgid "" "occasionally slightly more fine-grained than that)." msgstr "" -#: ../../howto/logging-cookbook.rst:4139 +#: ../../howto/logging-cookbook.rst:4247 msgid "Other resources" -msgstr "" +msgstr "其他資源" -#: ../../howto/logging-cookbook.rst:4143 +#: ../../howto/logging-cookbook.rst:4251 msgid "Module :mod:`logging`" msgstr ":mod:`logging` 模組" -#: ../../howto/logging-cookbook.rst:4144 +#: ../../howto/logging-cookbook.rst:4252 msgid "API reference for the logging module." msgstr "" -#: ../../howto/logging-cookbook.rst:4146 +#: ../../howto/logging-cookbook.rst:4254 msgid "Module :mod:`logging.config`" msgstr ":mod:`logging.config` 模組" -#: ../../howto/logging-cookbook.rst:4147 +#: ../../howto/logging-cookbook.rst:4255 msgid "Configuration API for the logging module." msgstr "" -#: ../../howto/logging-cookbook.rst:4149 +#: ../../howto/logging-cookbook.rst:4257 msgid "Module :mod:`logging.handlers`" msgstr ":mod:`logging.handlers` 模組" -#: ../../howto/logging-cookbook.rst:4150 +#: ../../howto/logging-cookbook.rst:4258 msgid "Useful handlers included with the logging module." msgstr "" -#: ../../howto/logging-cookbook.rst:4152 +#: ../../howto/logging-cookbook.rst:4260 msgid ":ref:`Basic Tutorial `" msgstr ":ref:`基礎教學 `" -#: ../../howto/logging-cookbook.rst:4154 +#: ../../howto/logging-cookbook.rst:4262 msgid ":ref:`Advanced Tutorial `" msgstr ":ref:`進階教學 `" diff --git a/howto/logging.po b/howto/logging.po index f254457fed..42a56983bc 100644 --- a/howto/logging.po +++ b/howto/logging.po @@ -6,9 +6,9 @@ # 文俊 高 , 2016 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-07 03:11+0800\n" +"POT-Creation-Date: 2025-07-22 00:17+0000\n" "PO-Revision-Date: 2018-05-23 14:36+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -19,7 +19,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../howto/logging.rst:3 +#: ../../howto/logging.rst:5 msgid "Logging HOWTO" msgstr "如何使用 Logging 模組" @@ -27,21 +27,21 @@ msgstr "如何使用 Logging 模組" msgid "Author" msgstr "作者" -#: ../../howto/logging.rst:5 +#: ../../howto/logging.rst:7 msgid "Vinay Sajip " msgstr "Vinay Sajip " -#: ../../howto/logging.rst:11 +#: ../../howto/logging.rst:13 msgid "" "This page contains tutorial information. For links to reference information " "and a logging cookbook, please see :ref:`tutorial-ref-links`." msgstr "" -#: ../../howto/logging.rst:15 +#: ../../howto/logging.rst:17 msgid "Basic Logging Tutorial" msgstr "基礎 Logging 指南" -#: ../../howto/logging.rst:17 +#: ../../howto/logging.rst:19 msgid "" "Logging is a means of tracking events that happen when some software runs. " "The software's developer adds logging calls to their code to indicate that " @@ -56,11 +56,11 @@ msgstr "" "述。這段訊息可能包含一些因為此事件發生而改變的資料。開發者也可以指派事件的重" "要程度,重要程度有時候也會被稱作 *程度* 或是 *嚴重性* 。" -#: ../../howto/logging.rst:26 +#: ../../howto/logging.rst:28 msgid "When to use logging" msgstr "什麼時候使用 logging" -#: ../../howto/logging.rst:28 +#: ../../howto/logging.rst:30 msgid "" "You can access logging functionality by creating a logger via ``logger = " "getLogger(__name__)``, and then calling the logger's :meth:`~Logger.debug`, :" @@ -70,158 +70,158 @@ msgid "" "each of a set of common tasks, the best tool to use for that task." msgstr "" -#: ../../howto/logging.rst:36 +#: ../../howto/logging.rst:38 msgid "Task you want to perform" msgstr "" -#: ../../howto/logging.rst:36 +#: ../../howto/logging.rst:38 msgid "The best tool for the task" msgstr "" -#: ../../howto/logging.rst:38 +#: ../../howto/logging.rst:40 msgid "" "Display console output for ordinary usage of a command line script or program" msgstr "" -#: ../../howto/logging.rst:38 +#: ../../howto/logging.rst:40 msgid ":func:`print`" msgstr ":func:`print`" -#: ../../howto/logging.rst:42 +#: ../../howto/logging.rst:44 msgid "" "Report events that occur during normal operation of a program (e.g. for " "status monitoring or fault investigation)" msgstr "" -#: ../../howto/logging.rst:42 +#: ../../howto/logging.rst:44 msgid "" "A logger's :meth:`~Logger.info` (or :meth:`~Logger.debug` method for very " "detailed output for diagnostic purposes)" msgstr "" -#: ../../howto/logging.rst:47 +#: ../../howto/logging.rst:49 msgid "Issue a warning regarding a particular runtime event" msgstr "" -#: ../../howto/logging.rst:47 +#: ../../howto/logging.rst:49 msgid "" ":func:`warnings.warn` in library code if the issue is avoidable and the " "client application should be modified to eliminate the warning" msgstr "" -#: ../../howto/logging.rst:52 +#: ../../howto/logging.rst:54 msgid "" "A logger's :meth:`~Logger.warning` method if there is nothing the client " "application can do about the situation, but the event should still be noted" msgstr "" -#: ../../howto/logging.rst:58 +#: ../../howto/logging.rst:60 msgid "Report an error regarding a particular runtime event" msgstr "" -#: ../../howto/logging.rst:58 +#: ../../howto/logging.rst:60 msgid "Raise an exception" msgstr "" -#: ../../howto/logging.rst:61 +#: ../../howto/logging.rst:63 msgid "" "Report suppression of an error without raising an exception (e.g. error " "handler in a long-running server process)" msgstr "" -#: ../../howto/logging.rst:61 +#: ../../howto/logging.rst:63 msgid "" "A logger's :meth:`~Logger.error`, :meth:`~Logger.exception` or :meth:" "`~Logger.critical` method as appropriate for the specific error and " "application domain" msgstr "" -#: ../../howto/logging.rst:68 +#: ../../howto/logging.rst:70 msgid "" "The logger methods are named after the level or severity of the events they " "are used to track. The standard levels and their applicability are described " "below (in increasing order of severity):" msgstr "" -#: ../../howto/logging.rst:75 ../../howto/logging.rst:874 +#: ../../howto/logging.rst:77 ../../howto/logging.rst:875 msgid "Level" msgstr "" -#: ../../howto/logging.rst:75 +#: ../../howto/logging.rst:77 msgid "When it's used" msgstr "" -#: ../../howto/logging.rst:77 ../../howto/logging.rst:884 +#: ../../howto/logging.rst:79 ../../howto/logging.rst:885 msgid "``DEBUG``" msgstr "``DEBUG``" -#: ../../howto/logging.rst:77 +#: ../../howto/logging.rst:79 msgid "" "Detailed information, typically of interest only when diagnosing problems." msgstr "" -#: ../../howto/logging.rst:80 ../../howto/logging.rst:882 +#: ../../howto/logging.rst:82 ../../howto/logging.rst:883 msgid "``INFO``" msgstr "``INFO``" -#: ../../howto/logging.rst:80 +#: ../../howto/logging.rst:82 msgid "Confirmation that things are working as expected." msgstr "" -#: ../../howto/logging.rst:83 ../../howto/logging.rst:880 +#: ../../howto/logging.rst:85 ../../howto/logging.rst:881 msgid "``WARNING``" msgstr "``WARNING``" -#: ../../howto/logging.rst:83 +#: ../../howto/logging.rst:85 msgid "" "An indication that something unexpected happened, or indicative of some " "problem in the near future (e.g. 'disk space low'). The software is still " "working as expected." msgstr "" -#: ../../howto/logging.rst:88 ../../howto/logging.rst:878 +#: ../../howto/logging.rst:90 ../../howto/logging.rst:879 msgid "``ERROR``" msgstr "``ERROR``" -#: ../../howto/logging.rst:88 +#: ../../howto/logging.rst:90 msgid "" "Due to a more serious problem, the software has not been able to perform " "some function." msgstr "" -#: ../../howto/logging.rst:91 ../../howto/logging.rst:876 +#: ../../howto/logging.rst:93 ../../howto/logging.rst:877 msgid "``CRITICAL``" msgstr "``CRITICAL``" -#: ../../howto/logging.rst:91 +#: ../../howto/logging.rst:93 msgid "" "A serious error, indicating that the program itself may be unable to " "continue running." msgstr "" -#: ../../howto/logging.rst:95 +#: ../../howto/logging.rst:97 msgid "" -"The default level is ``WARNING``, which means that only events of this level " -"and above will be tracked, unless the logging package is configured to do " -"otherwise." +"The default level is ``WARNING``, which means that only events of this " +"severity and higher will be tracked, unless the logging package is " +"configured to do otherwise." msgstr "" -#: ../../howto/logging.rst:99 +#: ../../howto/logging.rst:100 msgid "" "Events that are tracked can be handled in different ways. The simplest way " "of handling tracked events is to print them to the console. Another common " "way is to write them to a disk file." msgstr "" -#: ../../howto/logging.rst:107 +#: ../../howto/logging.rst:108 msgid "A simple example" msgstr "一個簡單範例" -#: ../../howto/logging.rst:109 +#: ../../howto/logging.rst:110 msgid "A very simple example is::" msgstr "一個非常簡單的例子是: ::" -#: ../../howto/logging.rst:111 +#: ../../howto/logging.rst:112 msgid "" "import logging\n" "logging.warning('Watch out!') # will print a message to the console\n" @@ -231,15 +231,15 @@ msgstr "" "logging.warning('Watch out!') # 將會印出訊息至控制台\n" "logging.info('I told you so') # 不會印出任何東西" -#: ../../howto/logging.rst:115 +#: ../../howto/logging.rst:116 msgid "If you type these lines into a script and run it, you'll see:" msgstr "" -#: ../../howto/logging.rst:117 +#: ../../howto/logging.rst:118 msgid "WARNING:root:Watch out!" msgstr "WARNING:root:Watch out!" -#: ../../howto/logging.rst:121 +#: ../../howto/logging.rst:122 msgid "" "printed out on the console. The ``INFO`` message doesn't appear because the " "default level is ``WARNING``. The printed message includes the indication of " @@ -248,7 +248,7 @@ msgid "" "need that; formatting options will also be explained later." msgstr "" -#: ../../howto/logging.rst:127 +#: ../../howto/logging.rst:128 msgid "" "Notice that in this example, we use functions directly on the ``logging`` " "module, like ``logging.debug``, rather than creating a logger and calling " @@ -260,11 +260,11 @@ msgid "" "methods." msgstr "" -#: ../../howto/logging.rst:136 +#: ../../howto/logging.rst:137 msgid "Logging to a file" msgstr "" -#: ../../howto/logging.rst:138 +#: ../../howto/logging.rst:139 msgid "" "A very common situation is that of recording logging events in a file, so " "let's look at that next. Be sure to try the following in a newly started " @@ -272,7 +272,7 @@ msgid "" "above::" msgstr "" -#: ../../howto/logging.rst:142 +#: ../../howto/logging.rst:143 msgid "" "import logging\n" "logger = logging.getLogger(__name__)\n" @@ -284,7 +284,7 @@ msgid "" "logger.error('And non-ASCII stuff, too, like Øresund and Malmö')" msgstr "" -#: ../../howto/logging.rst:150 +#: ../../howto/logging.rst:151 msgid "" "The *encoding* argument was added. In earlier Python versions, or if not " "specified, the encoding used is the default value used by :func:`open`. " @@ -293,13 +293,13 @@ msgid "" "values and the default, see the documentation for :func:`open`." msgstr "" -#: ../../howto/logging.rst:157 +#: ../../howto/logging.rst:158 msgid "" "And now if we open the file and look at what we have, we should find the log " "messages:" msgstr "" -#: ../../howto/logging.rst:160 +#: ../../howto/logging.rst:161 msgid "" "DEBUG:__main__:This message should go to the log file\n" "INFO:__main__:So should this\n" @@ -307,40 +307,40 @@ msgid "" "ERROR:__main__:And non-ASCII stuff, too, like Øresund and Malmö" msgstr "" -#: ../../howto/logging.rst:167 +#: ../../howto/logging.rst:168 msgid "" "This example also shows how you can set the logging level which acts as the " "threshold for tracking. In this case, because we set the threshold to " "``DEBUG``, all of the messages were printed." msgstr "" -#: ../../howto/logging.rst:171 +#: ../../howto/logging.rst:172 msgid "" "If you want to set the logging level from a command-line option such as:" msgstr "" -#: ../../howto/logging.rst:173 +#: ../../howto/logging.rst:174 msgid "--log=INFO" msgstr "--log=INFO" -#: ../../howto/logging.rst:177 +#: ../../howto/logging.rst:178 msgid "" "and you have the value of the parameter passed for ``--log`` in some " "variable *loglevel*, you can use::" msgstr "" -#: ../../howto/logging.rst:180 +#: ../../howto/logging.rst:181 msgid "getattr(logging, loglevel.upper())" msgstr "getattr(logging, loglevel.upper())" -#: ../../howto/logging.rst:182 +#: ../../howto/logging.rst:183 msgid "" "to get the value which you'll pass to :func:`basicConfig` via the *level* " "argument. You may want to error check any user input value, perhaps as in " "the following example::" msgstr "" -#: ../../howto/logging.rst:186 +#: ../../howto/logging.rst:187 msgid "" "# assuming loglevel is bound to the string value obtained from the\n" "# command line argument. Convert to upper case to allow the user to\n" @@ -351,14 +351,14 @@ msgid "" "logging.basicConfig(level=numeric_level, ...)" msgstr "" -#: ../../howto/logging.rst:194 +#: ../../howto/logging.rst:195 msgid "" "The call to :func:`basicConfig` should come *before* any calls to a logger's " "methods such as :meth:`~Logger.debug`, :meth:`~Logger.info`, etc. Otherwise, " "that logging event may not be handled in the desired manner." msgstr "" -#: ../../howto/logging.rst:198 +#: ../../howto/logging.rst:199 msgid "" "If you run the above script several times, the messages from successive runs " "are appended to the file *example.log*. If you want each run to start " @@ -366,7 +366,7 @@ msgid "" "*filemode* argument, by changing the call in the above example to::" msgstr "" -#: ../../howto/logging.rst:203 +#: ../../howto/logging.rst:204 msgid "" "logging.basicConfig(filename='example.log', filemode='w', level=logging." "DEBUG)" @@ -374,23 +374,23 @@ msgstr "" "logging.basicConfig(filename='example.log', filemode='w', level=logging." "DEBUG)" -#: ../../howto/logging.rst:205 +#: ../../howto/logging.rst:206 msgid "" "The output will be the same as before, but the log file is no longer " "appended to, so the messages from earlier runs are lost." msgstr "" -#: ../../howto/logging.rst:210 +#: ../../howto/logging.rst:211 msgid "Logging variable data" msgstr "" -#: ../../howto/logging.rst:212 +#: ../../howto/logging.rst:213 msgid "" "To log variable data, use a format string for the event description message " "and append the variable data as arguments. For example::" msgstr "" -#: ../../howto/logging.rst:215 +#: ../../howto/logging.rst:216 msgid "" "import logging\n" "logging.warning('%s before you %s', 'Look', 'leap!')" @@ -398,15 +398,15 @@ msgstr "" "import logging\n" "logging.warning('%s before you %s', 'Look', 'leap!')" -#: ../../howto/logging.rst:218 +#: ../../howto/logging.rst:219 msgid "will display:" msgstr "" -#: ../../howto/logging.rst:220 +#: ../../howto/logging.rst:221 msgid "WARNING:root:Look before you leap!" msgstr "WARNING:root:Look before you leap!" -#: ../../howto/logging.rst:224 +#: ../../howto/logging.rst:225 msgid "" "As you can see, merging of variable data into the event description message " "uses the old, %-style of string formatting. This is for backwards " @@ -416,17 +416,17 @@ msgid "" "tutorial: see :ref:`formatting-styles` for more information." msgstr "" -#: ../../howto/logging.rst:233 +#: ../../howto/logging.rst:234 msgid "Changing the format of displayed messages" msgstr "" -#: ../../howto/logging.rst:235 +#: ../../howto/logging.rst:236 msgid "" "To change the format which is used to display messages, you need to specify " "the format you want to use::" msgstr "" -#: ../../howto/logging.rst:238 +#: ../../howto/logging.rst:239 msgid "" "import logging\n" "logging.basicConfig(format='%(levelname)s:%(message)s', level=logging." @@ -436,18 +436,18 @@ msgid "" "logging.warning('And this, too')" msgstr "" -#: ../../howto/logging.rst:244 +#: ../../howto/logging.rst:245 msgid "which would print:" msgstr "" -#: ../../howto/logging.rst:246 +#: ../../howto/logging.rst:247 msgid "" "DEBUG:This message should appear on the console\n" "INFO:So should this\n" "WARNING:And this, too" msgstr "" -#: ../../howto/logging.rst:252 +#: ../../howto/logging.rst:253 msgid "" "Notice that the 'root' which appeared in earlier examples has disappeared. " "For a full set of things that can appear in format strings, you can refer to " @@ -457,39 +457,39 @@ msgid "" "This is described in the next section." msgstr "" -#: ../../howto/logging.rst:261 +#: ../../howto/logging.rst:262 msgid "Displaying the date/time in messages" msgstr "" -#: ../../howto/logging.rst:263 +#: ../../howto/logging.rst:264 msgid "" "To display the date and time of an event, you would place '%(asctime)s' in " "your format string::" msgstr "" -#: ../../howto/logging.rst:266 +#: ../../howto/logging.rst:267 msgid "" "import logging\n" "logging.basicConfig(format='%(asctime)s %(message)s')\n" "logging.warning('is when this event was logged.')" msgstr "" -#: ../../howto/logging.rst:270 +#: ../../howto/logging.rst:271 msgid "which should print something like this:" msgstr "" -#: ../../howto/logging.rst:272 +#: ../../howto/logging.rst:273 msgid "2010-12-12 11:41:42,612 is when this event was logged." msgstr "" -#: ../../howto/logging.rst:276 +#: ../../howto/logging.rst:277 msgid "" "The default format for date/time display (shown above) is like ISO8601 or :" "rfc:`3339`. If you need more control over the formatting of the date/time, " "provide a *datefmt* argument to ``basicConfig``, as in this example::" msgstr "" -#: ../../howto/logging.rst:280 +#: ../../howto/logging.rst:281 msgid "" "import logging\n" "logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:" @@ -497,25 +497,25 @@ msgid "" "logging.warning('is when this event was logged.')" msgstr "" -#: ../../howto/logging.rst:284 +#: ../../howto/logging.rst:285 msgid "which would display something like this:" msgstr "" -#: ../../howto/logging.rst:286 +#: ../../howto/logging.rst:287 msgid "12/12/2010 11:46:36 AM is when this event was logged." msgstr "" -#: ../../howto/logging.rst:290 +#: ../../howto/logging.rst:291 msgid "" "The format of the *datefmt* argument is the same as supported by :func:`time." "strftime`." msgstr "" -#: ../../howto/logging.rst:295 +#: ../../howto/logging.rst:296 msgid "Next Steps" msgstr "" -#: ../../howto/logging.rst:297 +#: ../../howto/logging.rst:298 msgid "" "That concludes the basic tutorial. It should be enough to get you up and " "running with logging. There's a lot more that the logging package offers, " @@ -524,59 +524,59 @@ msgid "" "of your favourite beverage and carry on." msgstr "" -#: ../../howto/logging.rst:303 +#: ../../howto/logging.rst:304 msgid "" "If your logging needs are simple, then use the above examples to incorporate " "logging into your own scripts, and if you run into problems or don't " -"understand something, please post a question on the comp.lang.python Usenet " -"group (available at https://groups.google.com/g/comp.lang.python) and you " +"understand something, please post a question in the Help category of the " +"`Python discussion forum `_ and you " "should receive help before too long." msgstr "" -#: ../../howto/logging.rst:309 +#: ../../howto/logging.rst:310 msgid "" "Still here? You can carry on reading the next few sections, which provide a " "slightly more advanced/in-depth tutorial than the basic one above. After " "that, you can take a look at the :ref:`logging-cookbook`." msgstr "" -#: ../../howto/logging.rst:317 +#: ../../howto/logging.rst:318 msgid "Advanced Logging Tutorial" msgstr "" -#: ../../howto/logging.rst:319 +#: ../../howto/logging.rst:320 msgid "" "The logging library takes a modular approach and offers several categories " "of components: loggers, handlers, filters, and formatters." msgstr "" -#: ../../howto/logging.rst:322 +#: ../../howto/logging.rst:323 msgid "Loggers expose the interface that application code directly uses." msgstr "" -#: ../../howto/logging.rst:323 +#: ../../howto/logging.rst:324 msgid "" "Handlers send the log records (created by loggers) to the appropriate " "destination." msgstr "" -#: ../../howto/logging.rst:325 +#: ../../howto/logging.rst:326 msgid "" "Filters provide a finer grained facility for determining which log records " "to output." msgstr "" -#: ../../howto/logging.rst:327 +#: ../../howto/logging.rst:328 msgid "Formatters specify the layout of log records in the final output." msgstr "" -#: ../../howto/logging.rst:329 +#: ../../howto/logging.rst:330 msgid "" "Log event information is passed between loggers, handlers, filters and " "formatters in a :class:`LogRecord` instance." msgstr "" -#: ../../howto/logging.rst:332 +#: ../../howto/logging.rst:333 msgid "" "Logging is performed by calling methods on instances of the :class:`Logger` " "class (hereafter called :dfn:`loggers`). Each instance has a name, and they " @@ -587,23 +587,23 @@ msgid "" "originates." msgstr "" -#: ../../howto/logging.rst:339 +#: ../../howto/logging.rst:340 msgid "" "A good convention to use when naming loggers is to use a module-level " "logger, in each module which uses logging, named as follows::" msgstr "" -#: ../../howto/logging.rst:342 +#: ../../howto/logging.rst:343 msgid "logger = logging.getLogger(__name__)" msgstr "logger = logging.getLogger(__name__)" -#: ../../howto/logging.rst:344 +#: ../../howto/logging.rst:345 msgid "" "This means that logger names track the package/module hierarchy, and it's " "intuitively obvious where events are logged just from the logger name." msgstr "" -#: ../../howto/logging.rst:347 +#: ../../howto/logging.rst:348 msgid "" "The root of the hierarchy of loggers is called the root logger. That's the " "logger used by the functions :func:`debug`, :func:`info`, :func:`warning`, :" @@ -612,7 +612,7 @@ msgid "" "root logger's name is printed as 'root' in the logged output." msgstr "" -#: ../../howto/logging.rst:353 +#: ../../howto/logging.rst:354 msgid "" "It is, of course, possible to log messages to different destinations. " "Support is included in the package for writing log messages to files, HTTP " @@ -623,7 +623,7 @@ msgid "" "built-in handler classes." msgstr "" -#: ../../howto/logging.rst:360 +#: ../../howto/logging.rst:361 msgid "" "By default, no destination is set for any logging messages. You can specify " "a destination (such as console or file) by using :func:`basicConfig` as in " @@ -635,36 +635,36 @@ msgid "" "message output." msgstr "" -#: ../../howto/logging.rst:368 +#: ../../howto/logging.rst:369 msgid "The default format set by :func:`basicConfig` for messages is:" msgstr "" -#: ../../howto/logging.rst:370 +#: ../../howto/logging.rst:371 msgid "severity:logger name:message" msgstr "severity:logger name:message" -#: ../../howto/logging.rst:374 +#: ../../howto/logging.rst:375 msgid "" "You can change this by passing a format string to :func:`basicConfig` with " "the *format* keyword argument. For all options regarding how a format string " "is constructed, see :ref:`formatter-objects`." msgstr "" -#: ../../howto/logging.rst:379 +#: ../../howto/logging.rst:380 msgid "Logging Flow" msgstr "" -#: ../../howto/logging.rst:381 +#: ../../howto/logging.rst:382 msgid "" "The flow of log event information in loggers and handlers is illustrated in " "the following diagram." msgstr "" -#: ../../howto/logging.rst:432 +#: ../../howto/logging.rst:433 msgid "Loggers" msgstr "" -#: ../../howto/logging.rst:434 +#: ../../howto/logging.rst:435 msgid "" ":class:`Logger` objects have a threefold job. First, they expose several " "methods to application code so that applications can log messages at " @@ -674,17 +674,17 @@ msgid "" "handlers." msgstr "" -#: ../../howto/logging.rst:440 +#: ../../howto/logging.rst:441 msgid "" "The most widely used methods on logger objects fall into two categories: " "configuration and message sending." msgstr "" -#: ../../howto/logging.rst:443 +#: ../../howto/logging.rst:444 msgid "These are the most common configuration methods:" msgstr "" -#: ../../howto/logging.rst:445 +#: ../../howto/logging.rst:446 msgid "" ":meth:`Logger.setLevel` specifies the lowest-severity log message a logger " "will handle, where debug is the lowest built-in severity level and critical " @@ -693,32 +693,32 @@ msgid "" "messages and will ignore DEBUG messages." msgstr "" -#: ../../howto/logging.rst:451 +#: ../../howto/logging.rst:452 msgid "" ":meth:`Logger.addHandler` and :meth:`Logger.removeHandler` add and remove " "handler objects from the logger object. Handlers are covered in more detail " "in :ref:`handler-basic`." msgstr "" -#: ../../howto/logging.rst:455 +#: ../../howto/logging.rst:456 msgid "" ":meth:`Logger.addFilter` and :meth:`Logger.removeFilter` add and remove " "filter objects from the logger object. Filters are covered in more detail " "in :ref:`filter`." msgstr "" -#: ../../howto/logging.rst:459 +#: ../../howto/logging.rst:460 msgid "" "You don't need to always call these methods on every logger you create. See " "the last two paragraphs in this section." msgstr "" -#: ../../howto/logging.rst:462 +#: ../../howto/logging.rst:463 msgid "" "With the logger object configured, the following methods create log messages:" msgstr "" -#: ../../howto/logging.rst:464 +#: ../../howto/logging.rst:465 msgid "" ":meth:`Logger.debug`, :meth:`Logger.info`, :meth:`Logger.warning`, :meth:" "`Logger.error`, and :meth:`Logger.critical` all create log records with a " @@ -731,14 +731,14 @@ msgid "" "exception information." msgstr "" -#: ../../howto/logging.rst:474 +#: ../../howto/logging.rst:475 msgid "" ":meth:`Logger.exception` creates a log message similar to :meth:`Logger." "error`. The difference is that :meth:`Logger.exception` dumps a stack trace " "along with it. Call this method only from an exception handler." msgstr "" -#: ../../howto/logging.rst:478 +#: ../../howto/logging.rst:479 msgid "" ":meth:`Logger.log` takes a log level as an explicit argument. This is a " "little more verbose for logging messages than using the log level " @@ -746,7 +746,7 @@ msgid "" "levels." msgstr "" -#: ../../howto/logging.rst:482 +#: ../../howto/logging.rst:483 msgid "" ":func:`getLogger` returns a reference to a logger instance with the " "specified name if it is provided, or ``root`` if not. The names are period-" @@ -758,7 +758,7 @@ msgid "" "descendants of ``foo``." msgstr "" -#: ../../howto/logging.rst:490 +#: ../../howto/logging.rst:491 msgid "" "Loggers have a concept of *effective level*. If a level is not explicitly " "set on a logger, the level of its parent is used instead as its effective " @@ -770,7 +770,7 @@ msgid "" "handlers." msgstr "" -#: ../../howto/logging.rst:498 +#: ../../howto/logging.rst:499 msgid "" "Child loggers propagate messages up to the handlers associated with their " "ancestor loggers. Because of this, it is unnecessary to define and configure " @@ -780,11 +780,11 @@ msgid "" "attribute of a logger to ``False``.)" msgstr "" -#: ../../howto/logging.rst:509 +#: ../../howto/logging.rst:510 msgid "Handlers" msgstr "" -#: ../../howto/logging.rst:511 +#: ../../howto/logging.rst:512 msgid "" ":class:`~logging.Handler` objects are responsible for dispatching the " "appropriate log messages (based on the log messages' severity) to the " @@ -797,14 +797,14 @@ msgid "" "of a specific severity to a specific location." msgstr "" -#: ../../howto/logging.rst:521 +#: ../../howto/logging.rst:522 msgid "" "The standard library includes quite a few handler types (see :ref:`useful-" "handlers`); the tutorials use mainly :class:`StreamHandler` and :class:" "`FileHandler` in its examples." msgstr "" -#: ../../howto/logging.rst:525 +#: ../../howto/logging.rst:526 msgid "" "There are very few methods in a handler for application developers to " "concern themselves with. The only handler methods that seem relevant for " @@ -812,7 +812,7 @@ msgid "" "not creating custom handlers) are the following configuration methods:" msgstr "" -#: ../../howto/logging.rst:530 +#: ../../howto/logging.rst:531 msgid "" "The :meth:`~Handler.setLevel` method, just as in logger objects, specifies " "the lowest severity that will be dispatched to the appropriate destination. " @@ -822,19 +822,19 @@ msgid "" "send on." msgstr "" -#: ../../howto/logging.rst:536 +#: ../../howto/logging.rst:537 msgid "" ":meth:`~Handler.setFormatter` selects a Formatter object for this handler to " "use." msgstr "" -#: ../../howto/logging.rst:539 +#: ../../howto/logging.rst:540 msgid "" ":meth:`~Handler.addFilter` and :meth:`~Handler.removeFilter` respectively " "configure and deconfigure filter objects on handlers." msgstr "" -#: ../../howto/logging.rst:542 +#: ../../howto/logging.rst:543 msgid "" "Application code should not directly instantiate and use instances of :class:" "`Handler`. Instead, the :class:`Handler` class is a base class that defines " @@ -842,11 +842,11 @@ msgid "" "behavior that child classes can use (or override)." msgstr "" -#: ../../howto/logging.rst:549 +#: ../../howto/logging.rst:550 msgid "Formatters" msgstr "" -#: ../../howto/logging.rst:551 +#: ../../howto/logging.rst:552 msgid "" "Formatter objects configure the final order, structure, and contents of the " "log message. Unlike the base :class:`logging.Handler` class, application " @@ -856,24 +856,24 @@ msgid "" "string and a style indicator." msgstr "" -#: ../../howto/logging.rst:560 +#: ../../howto/logging.rst:561 msgid "" "If there is no message format string, the default is to use the raw " "message. If there is no date format string, the default date format is:" msgstr "" -#: ../../howto/logging.rst:563 +#: ../../howto/logging.rst:564 msgid "%Y-%m-%d %H:%M:%S" msgstr "%Y-%m-%d %H:%M:%S" -#: ../../howto/logging.rst:567 +#: ../../howto/logging.rst:568 msgid "" "with the milliseconds tacked on at the end. The ``style`` is one of ``'%'``, " "``'{'``, or ``'$'``. If one of these is not specified, then ``'%'`` will be " "used." msgstr "" -#: ../../howto/logging.rst:570 +#: ../../howto/logging.rst:571 msgid "" "If the ``style`` is ``'%'``, the message format string uses ``%()s`` styled string substitution; the possible keys are documented in :" @@ -883,22 +883,22 @@ msgid "" "should conform to what is expected by :meth:`string.Template.substitute`." msgstr "" -#: ../../howto/logging.rst:577 +#: ../../howto/logging.rst:578 msgid "Added the ``style`` parameter." msgstr "新增 ``style`` 參數。" -#: ../../howto/logging.rst:580 +#: ../../howto/logging.rst:581 msgid "" "The following message format string will log the time in a human-readable " "format, the severity of the message, and the contents of the message, in " "that order::" msgstr "" -#: ../../howto/logging.rst:584 +#: ../../howto/logging.rst:585 msgid "'%(asctime)s - %(levelname)s - %(message)s'" msgstr "" -#: ../../howto/logging.rst:586 +#: ../../howto/logging.rst:587 msgid "" "Formatters use a user-configurable function to convert the creation time of " "a record to a tuple. By default, :func:`time.localtime` is used; to change " @@ -909,40 +909,40 @@ msgid "" "in the Formatter class (to ``time.gmtime`` for GMT display)." msgstr "" -#: ../../howto/logging.rst:596 +#: ../../howto/logging.rst:597 msgid "Configuring Logging" msgstr "" -#: ../../howto/logging.rst:600 +#: ../../howto/logging.rst:601 msgid "Programmers can configure logging in three ways:" msgstr "" -#: ../../howto/logging.rst:602 +#: ../../howto/logging.rst:603 msgid "" "Creating loggers, handlers, and formatters explicitly using Python code that " "calls the configuration methods listed above." msgstr "" -#: ../../howto/logging.rst:604 +#: ../../howto/logging.rst:605 msgid "" "Creating a logging config file and reading it using the :func:`fileConfig` " "function." msgstr "" -#: ../../howto/logging.rst:606 +#: ../../howto/logging.rst:607 msgid "" "Creating a dictionary of configuration information and passing it to the :" "func:`dictConfig` function." msgstr "" -#: ../../howto/logging.rst:609 +#: ../../howto/logging.rst:610 msgid "" "For the reference documentation on the last two options, see :ref:`logging-" "config-api`. The following example configures a very simple logger, a " "console handler, and a simple formatter using Python code::" msgstr "" -#: ../../howto/logging.rst:613 +#: ../../howto/logging.rst:614 msgid "" "import logging\n" "\n" @@ -972,12 +972,12 @@ msgid "" "logger.critical('critical message')" msgstr "" -#: ../../howto/logging.rst:639 +#: ../../howto/logging.rst:640 msgid "" "Running this module from the command line produces the following output:" msgstr "" -#: ../../howto/logging.rst:641 +#: ../../howto/logging.rst:642 msgid "" "$ python simple_logging_module.py\n" "2005-03-19 15:10:26,618 - simple_example - DEBUG - debug message\n" @@ -987,14 +987,14 @@ msgid "" "2005-03-19 15:10:26,773 - simple_example - CRITICAL - critical message" msgstr "" -#: ../../howto/logging.rst:650 +#: ../../howto/logging.rst:651 msgid "" "The following Python module creates a logger, handler, and formatter nearly " "identical to those in the example listed above, with the only difference " "being the names of the objects::" msgstr "" -#: ../../howto/logging.rst:654 +#: ../../howto/logging.rst:655 msgid "" "import logging\n" "import logging.config\n" @@ -1012,11 +1012,11 @@ msgid "" "logger.critical('critical message')" msgstr "" -#: ../../howto/logging.rst:669 +#: ../../howto/logging.rst:670 msgid "Here is the logging.conf file:" msgstr "" -#: ../../howto/logging.rst:671 +#: ../../howto/logging.rst:672 msgid "" "[loggers]\n" "keys=root,simpleExample\n" @@ -1047,12 +1047,12 @@ msgid "" "format=%(asctime)s - %(name)s - %(levelname)s - %(message)s" msgstr "" -#: ../../howto/logging.rst:701 +#: ../../howto/logging.rst:702 msgid "" "The output is nearly identical to that of the non-config-file-based example:" msgstr "" -#: ../../howto/logging.rst:703 +#: ../../howto/logging.rst:704 msgid "" "$ python simple_logging_config.py\n" "2005-03-19 15:38:55,977 - simpleExample - DEBUG - debug message\n" @@ -1062,14 +1062,14 @@ msgid "" "2005-03-19 15:38:56,130 - simpleExample - CRITICAL - critical message" msgstr "" -#: ../../howto/logging.rst:712 +#: ../../howto/logging.rst:713 msgid "" "You can see that the config file approach has a few advantages over the " "Python code approach, mainly separation of configuration and code and the " "ability of noncoders to easily modify the logging properties." msgstr "" -#: ../../howto/logging.rst:716 +#: ../../howto/logging.rst:717 msgid "" "The :func:`fileConfig` function takes a default parameter, " "``disable_existing_loggers``, which defaults to ``True`` for reasons of " @@ -1080,7 +1080,7 @@ msgid "" "information, and specify ``False`` for this parameter if you wish." msgstr "" -#: ../../howto/logging.rst:724 +#: ../../howto/logging.rst:725 msgid "" "The dictionary passed to :func:`dictConfig` can also specify a Boolean value " "with key ``disable_existing_loggers``, which if not specified explicitly in " @@ -1089,7 +1089,7 @@ msgid "" "want - in which case, provide the key explicitly with a value of ``False``." msgstr "" -#: ../../howto/logging.rst:734 +#: ../../howto/logging.rst:735 msgid "" "Note that the class names referenced in config files need to be either " "relative to the logging module, or absolute values which can be resolved " @@ -1100,7 +1100,7 @@ msgid "" "path)." msgstr "" -#: ../../howto/logging.rst:742 +#: ../../howto/logging.rst:743 msgid "" "In Python 3.2, a new means of configuring logging has been introduced, using " "dictionaries to hold configuration information. This provides a superset of " @@ -1115,13 +1115,13 @@ msgid "" "a socket, or use whatever approach makes sense for your application." msgstr "" -#: ../../howto/logging.rst:754 +#: ../../howto/logging.rst:755 msgid "" "Here's an example of the same configuration as above, in YAML format for the " "new dictionary-based approach:" msgstr "" -#: ../../howto/logging.rst:757 +#: ../../howto/logging.rst:758 msgid "" "version: 1\n" "formatters:\n" @@ -1143,24 +1143,24 @@ msgid "" " handlers: [console]" msgstr "" -#: ../../howto/logging.rst:778 +#: ../../howto/logging.rst:779 msgid "" "For more information about logging using a dictionary, see :ref:`logging-" "config-api`." msgstr "" -#: ../../howto/logging.rst:782 +#: ../../howto/logging.rst:783 msgid "What happens if no configuration is provided" msgstr "" -#: ../../howto/logging.rst:784 +#: ../../howto/logging.rst:785 msgid "" "If no logging configuration is provided, it is possible to have a situation " "where a logging event needs to be output, but no handlers can be found to " "output the event." msgstr "" -#: ../../howto/logging.rst:788 +#: ../../howto/logging.rst:789 msgid "" "The event is output using a 'handler of last resort', stored in :data:" "`lastResort`. This internal handler is not associated with any logger, and " @@ -1172,32 +1172,32 @@ msgid "" "severities will be output." msgstr "" -#: ../../howto/logging.rst:799 +#: ../../howto/logging.rst:800 msgid "For versions of Python prior to 3.2, the behaviour is as follows:" msgstr "" -#: ../../howto/logging.rst:801 +#: ../../howto/logging.rst:802 msgid "" "If :data:`raiseExceptions` is ``False`` (production mode), the event is " "silently dropped." msgstr "" -#: ../../howto/logging.rst:804 +#: ../../howto/logging.rst:805 msgid "" "If :data:`raiseExceptions` is ``True`` (development mode), a message 'No " "handlers could be found for logger X.Y.Z' is printed once." msgstr "" -#: ../../howto/logging.rst:807 +#: ../../howto/logging.rst:808 msgid "" "To obtain the pre-3.2 behaviour, :data:`lastResort` can be set to ``None``." msgstr "" -#: ../../howto/logging.rst:813 +#: ../../howto/logging.rst:814 msgid "Configuring Logging for a Library" msgstr "" -#: ../../howto/logging.rst:815 +#: ../../howto/logging.rst:816 msgid "" "When developing a library which uses logging, you should take care to " "document how the library uses logging - for example, the names of loggers " @@ -1208,7 +1208,7 @@ msgid "" "is regarded as the best default behaviour." msgstr "" -#: ../../howto/logging.rst:823 +#: ../../howto/logging.rst:824 msgid "" "If for some reason you *don't* want these messages printed in the absence of " "any logging configuration, you can attach a do-nothing handler to the top-" @@ -1220,7 +1220,7 @@ msgid "" "to those handlers, as normal." msgstr "" -#: ../../howto/logging.rst:832 +#: ../../howto/logging.rst:833 msgid "" "A do-nothing handler is included in the logging package: :class:`~logging." "NullHandler` (since Python 3.1). An instance of this handler could be added " @@ -1231,20 +1231,20 @@ msgid "" "etc. then the code::" msgstr "" -#: ../../howto/logging.rst:840 +#: ../../howto/logging.rst:841 msgid "" "import logging\n" "logging.getLogger('foo').addHandler(logging.NullHandler())" msgstr "" -#: ../../howto/logging.rst:843 +#: ../../howto/logging.rst:844 msgid "" "should have the desired effect. If an organisation produces a number of " "libraries, then the logger name specified can be 'orgname.foo' rather than " "just 'foo'." msgstr "" -#: ../../howto/logging.rst:847 +#: ../../howto/logging.rst:848 msgid "" "It is strongly advised that you *do not log to the root logger* in your " "library. Instead, use a logger with a unique and easily identifiable name, " @@ -1254,7 +1254,7 @@ msgid "" "library as they wish." msgstr "" -#: ../../howto/logging.rst:854 +#: ../../howto/logging.rst:855 msgid "" "It is strongly advised that you *do not add any handlers other than* :class:" "`~logging.NullHandler` *to your library's loggers*. This is because the " @@ -1265,11 +1265,11 @@ msgid "" "carry out unit tests and deliver logs which suit their requirements." msgstr "" -#: ../../howto/logging.rst:865 +#: ../../howto/logging.rst:866 msgid "Logging Levels" msgstr "" -#: ../../howto/logging.rst:867 +#: ../../howto/logging.rst:868 msgid "" "The numeric values of logging levels are given in the following table. These " "are primarily of interest if you want to define your own levels, and need " @@ -1278,39 +1278,39 @@ msgid "" "value; the predefined name is lost." msgstr "" -#: ../../howto/logging.rst:874 +#: ../../howto/logging.rst:875 msgid "Numeric value" msgstr "" -#: ../../howto/logging.rst:876 +#: ../../howto/logging.rst:877 msgid "50" msgstr "50" -#: ../../howto/logging.rst:878 +#: ../../howto/logging.rst:879 msgid "40" msgstr "40" -#: ../../howto/logging.rst:880 +#: ../../howto/logging.rst:881 msgid "30" msgstr "30" -#: ../../howto/logging.rst:882 +#: ../../howto/logging.rst:883 msgid "20" msgstr "20" -#: ../../howto/logging.rst:884 +#: ../../howto/logging.rst:885 msgid "10" msgstr "10" -#: ../../howto/logging.rst:886 +#: ../../howto/logging.rst:887 msgid "``NOTSET``" msgstr "``NOTSET``" -#: ../../howto/logging.rst:886 +#: ../../howto/logging.rst:887 msgid "0" msgstr "0" -#: ../../howto/logging.rst:889 +#: ../../howto/logging.rst:890 msgid "" "Levels can also be associated with loggers, being set either by the " "developer or through loading a saved logging configuration. When a logging " @@ -1320,14 +1320,14 @@ msgid "" "basic mechanism controlling the verbosity of logging output." msgstr "" -#: ../../howto/logging.rst:896 +#: ../../howto/logging.rst:897 msgid "" "Logging messages are encoded as instances of the :class:`~logging.LogRecord` " "class. When a logger decides to actually log an event, a :class:`~logging." "LogRecord` instance is created from the logging message." msgstr "" -#: ../../howto/logging.rst:900 +#: ../../howto/logging.rst:901 msgid "" "Logging messages are subjected to a dispatch mechanism through the use of :" "dfn:`handlers`, which are instances of subclasses of the :class:`Handler` " @@ -1344,7 +1344,7 @@ msgid "" "at which point the passing to ancestor handlers stops)." msgstr "" -#: ../../howto/logging.rst:914 +#: ../../howto/logging.rst:915 msgid "" "Just as for loggers, handlers can have levels associated with them. A " "handler's level acts as a filter in the same way as a logger's level does. " @@ -1354,11 +1354,11 @@ msgid "" "`~Handler.emit`." msgstr "" -#: ../../howto/logging.rst:923 +#: ../../howto/logging.rst:924 msgid "Custom Levels" msgstr "" -#: ../../howto/logging.rst:925 +#: ../../howto/logging.rst:926 msgid "" "Defining your own levels is possible, but should not be necessary, as the " "existing levels have been chosen on the basis of practical experience. " @@ -1371,27 +1371,27 @@ msgid "" "given numeric value might mean different things for different libraries." msgstr "" -#: ../../howto/logging.rst:938 +#: ../../howto/logging.rst:939 msgid "Useful Handlers" msgstr "" -#: ../../howto/logging.rst:940 +#: ../../howto/logging.rst:941 msgid "" "In addition to the base :class:`Handler` class, many useful subclasses are " "provided:" msgstr "" -#: ../../howto/logging.rst:943 +#: ../../howto/logging.rst:944 msgid "" ":class:`StreamHandler` instances send messages to streams (file-like " "objects)." msgstr "" -#: ../../howto/logging.rst:946 +#: ../../howto/logging.rst:947 msgid ":class:`FileHandler` instances send messages to disk files." msgstr "" -#: ../../howto/logging.rst:948 +#: ../../howto/logging.rst:949 msgid "" ":class:`~handlers.BaseRotatingHandler` is the base class for handlers that " "rotate log files at a certain point. It is not meant to be instantiated " @@ -1399,61 +1399,61 @@ msgid "" "`~handlers.TimedRotatingFileHandler`." msgstr "" -#: ../../howto/logging.rst:953 +#: ../../howto/logging.rst:954 msgid "" ":class:`~handlers.RotatingFileHandler` instances send messages to disk " "files, with support for maximum log file sizes and log file rotation." msgstr "" -#: ../../howto/logging.rst:956 +#: ../../howto/logging.rst:957 msgid "" ":class:`~handlers.TimedRotatingFileHandler` instances send messages to disk " "files, rotating the log file at certain timed intervals." msgstr "" -#: ../../howto/logging.rst:959 +#: ../../howto/logging.rst:960 msgid "" ":class:`~handlers.SocketHandler` instances send messages to TCP/IP sockets. " "Since 3.4, Unix domain sockets are also supported." msgstr "" -#: ../../howto/logging.rst:962 +#: ../../howto/logging.rst:963 msgid "" ":class:`~handlers.DatagramHandler` instances send messages to UDP sockets. " "Since 3.4, Unix domain sockets are also supported." msgstr "" -#: ../../howto/logging.rst:965 +#: ../../howto/logging.rst:966 msgid "" ":class:`~handlers.SMTPHandler` instances send messages to a designated email " "address." msgstr "" -#: ../../howto/logging.rst:968 +#: ../../howto/logging.rst:969 msgid "" ":class:`~handlers.SysLogHandler` instances send messages to a Unix syslog " "daemon, possibly on a remote machine." msgstr "" -#: ../../howto/logging.rst:971 +#: ../../howto/logging.rst:972 msgid "" ":class:`~handlers.NTEventLogHandler` instances send messages to a Windows " "NT/2000/XP event log." msgstr "" -#: ../../howto/logging.rst:974 +#: ../../howto/logging.rst:975 msgid "" ":class:`~handlers.MemoryHandler` instances send messages to a buffer in " "memory, which is flushed whenever specific criteria are met." msgstr "" -#: ../../howto/logging.rst:977 +#: ../../howto/logging.rst:978 msgid "" ":class:`~handlers.HTTPHandler` instances send messages to an HTTP server " "using either ``GET`` or ``POST`` semantics." msgstr "" -#: ../../howto/logging.rst:980 +#: ../../howto/logging.rst:981 msgid "" ":class:`~handlers.WatchedFileHandler` instances watch the file they are " "logging to. If the file changes, it is closed and reopened using the file " @@ -1461,13 +1461,13 @@ msgid "" "support the underlying mechanism used." msgstr "" -#: ../../howto/logging.rst:985 +#: ../../howto/logging.rst:986 msgid "" ":class:`~handlers.QueueHandler` instances send messages to a queue, such as " "those implemented in the :mod:`queue` or :mod:`multiprocessing` modules." msgstr "" -#: ../../howto/logging.rst:988 +#: ../../howto/logging.rst:989 msgid "" ":class:`NullHandler` instances do nothing with error messages. They are used " "by library developers who want to use logging, but want to avoid the 'No " @@ -1476,15 +1476,15 @@ msgid "" "more information." msgstr "" -#: ../../howto/logging.rst:994 +#: ../../howto/logging.rst:995 msgid "The :class:`NullHandler` class." msgstr "" -#: ../../howto/logging.rst:997 +#: ../../howto/logging.rst:998 msgid "The :class:`~handlers.QueueHandler` class." msgstr "" -#: ../../howto/logging.rst:1000 +#: ../../howto/logging.rst:1001 msgid "" "The :class:`NullHandler`, :class:`StreamHandler` and :class:`FileHandler` " "classes are defined in the core logging package. The other handlers are " @@ -1492,14 +1492,14 @@ msgid "" "module, :mod:`logging.config`, for configuration functionality.)" msgstr "" -#: ../../howto/logging.rst:1005 +#: ../../howto/logging.rst:1006 msgid "" "Logged messages are formatted for presentation through instances of the :" "class:`Formatter` class. They are initialized with a format string suitable " "for use with the % operator and a dictionary." msgstr "" -#: ../../howto/logging.rst:1009 +#: ../../howto/logging.rst:1010 msgid "" "For formatting multiple messages in a batch, instances of :class:" "`BufferingFormatter` can be used. In addition to the format string (which is " @@ -1507,7 +1507,7 @@ msgid "" "trailer format strings." msgstr "" -#: ../../howto/logging.rst:1014 +#: ../../howto/logging.rst:1015 msgid "" "When filtering based on logger level and/or handler level is not enough, " "instances of :class:`Filter` can be added to both :class:`Logger` and :class:" @@ -1517,18 +1517,18 @@ msgid "" "value, the message is not processed further." msgstr "" -#: ../../howto/logging.rst:1021 +#: ../../howto/logging.rst:1022 msgid "" "The basic :class:`Filter` functionality allows filtering by specific logger " "name. If this feature is used, messages sent to the named logger and its " "children are allowed through the filter, and all others dropped." msgstr "" -#: ../../howto/logging.rst:1029 +#: ../../howto/logging.rst:1030 msgid "Exceptions raised during logging" msgstr "" -#: ../../howto/logging.rst:1031 +#: ../../howto/logging.rst:1032 msgid "" "The logging package is designed to swallow exceptions which occur while " "logging in production. This is so that errors which occur while handling " @@ -1536,7 +1536,7 @@ msgid "" "errors - do not cause the application using logging to terminate prematurely." msgstr "" -#: ../../howto/logging.rst:1036 +#: ../../howto/logging.rst:1037 msgid "" ":class:`SystemExit` and :class:`KeyboardInterrupt` exceptions are never " "swallowed. Other exceptions which occur during the :meth:`~Handler.emit` " @@ -1544,7 +1544,7 @@ msgid "" "handleError` method." msgstr "" -#: ../../howto/logging.rst:1041 +#: ../../howto/logging.rst:1042 msgid "" "The default implementation of :meth:`~Handler.handleError` in :class:" "`Handler` checks to see if a module-level variable, :data:`raiseExceptions`, " @@ -1552,7 +1552,7 @@ msgid "" "the exception is swallowed." msgstr "" -#: ../../howto/logging.rst:1047 +#: ../../howto/logging.rst:1048 msgid "" "The default value of :data:`raiseExceptions` is ``True``. This is because " "during development, you typically want to be notified of any exceptions that " @@ -1560,11 +1560,11 @@ msgid "" "production usage." msgstr "" -#: ../../howto/logging.rst:1057 +#: ../../howto/logging.rst:1058 msgid "Using arbitrary objects as messages" msgstr "" -#: ../../howto/logging.rst:1059 +#: ../../howto/logging.rst:1060 msgid "" "In the preceding sections and examples, it has been assumed that the message " "passed when logging the event is a string. However, this is not the only " @@ -1576,11 +1576,11 @@ msgid "" "the wire." msgstr "" -#: ../../howto/logging.rst:1070 +#: ../../howto/logging.rst:1071 msgid "Optimization" msgstr "最佳化" -#: ../../howto/logging.rst:1072 +#: ../../howto/logging.rst:1073 msgid "" "Formatting of message arguments is deferred until it cannot be avoided. " "However, computing the arguments passed to the logging method can also be " @@ -1591,20 +1591,20 @@ msgid "" "code like this::" msgstr "" -#: ../../howto/logging.rst:1080 +#: ../../howto/logging.rst:1081 msgid "" "if logger.isEnabledFor(logging.DEBUG):\n" " logger.debug('Message with %s, %s', expensive_func1(),\n" " expensive_func2())" msgstr "" -#: ../../howto/logging.rst:1084 +#: ../../howto/logging.rst:1085 msgid "" "so that if the logger's threshold is set above ``DEBUG``, the calls to " "``expensive_func1`` and ``expensive_func2`` are never made." msgstr "" -#: ../../howto/logging.rst:1087 +#: ../../howto/logging.rst:1088 msgid "" "In some cases, :meth:`~Logger.isEnabledFor` can itself be more expensive " "than you'd like (e.g. for deeply nested loggers where an explicit level is " @@ -1616,7 +1616,7 @@ msgid "" "while the application is running (which is not all that common)." msgstr "" -#: ../../howto/logging.rst:1096 +#: ../../howto/logging.rst:1097 msgid "" "There are other optimizations which can be made for specific applications " "which need more precise control over what logging information is collected. " @@ -1624,94 +1624,94 @@ msgid "" "you don't need:" msgstr "" -#: ../../howto/logging.rst:1102 +#: ../../howto/logging.rst:1103 msgid "What you don't want to collect" msgstr "" -#: ../../howto/logging.rst:1102 +#: ../../howto/logging.rst:1103 msgid "How to avoid collecting it" msgstr "" -#: ../../howto/logging.rst:1104 +#: ../../howto/logging.rst:1105 msgid "Information about where calls were made from." msgstr "" -#: ../../howto/logging.rst:1104 +#: ../../howto/logging.rst:1105 msgid "" "Set ``logging._srcfile`` to ``None``. This avoids calling :func:`sys." "_getframe`, which may help to speed up your code in environments like PyPy " "(which can't speed up code that uses :func:`sys._getframe`)." msgstr "" -#: ../../howto/logging.rst:1110 +#: ../../howto/logging.rst:1111 msgid "Threading information." msgstr "" -#: ../../howto/logging.rst:1110 +#: ../../howto/logging.rst:1111 msgid "Set ``logging.logThreads`` to ``False``." msgstr "將 ``logging.logThreads`` 設為 ``False``。" -#: ../../howto/logging.rst:1112 +#: ../../howto/logging.rst:1113 msgid "Current process ID (:func:`os.getpid`)" -msgstr "當前的行程 ID (:func:`os.getpid`)" +msgstr "目前的行程 ID (:func:`os.getpid`)" -#: ../../howto/logging.rst:1112 +#: ../../howto/logging.rst:1113 msgid "Set ``logging.logProcesses`` to ``False``." msgstr "將 ``logging.logProcesses`` 設為 ``False``。" -#: ../../howto/logging.rst:1114 +#: ../../howto/logging.rst:1115 msgid "" "Current process name when using ``multiprocessing`` to manage multiple " "processes." msgstr "" -#: ../../howto/logging.rst:1114 +#: ../../howto/logging.rst:1115 msgid "Set ``logging.logMultiprocessing`` to ``False``." msgstr "將 ``logging.logMultiprocessing`` 設為 ``False``。" -#: ../../howto/logging.rst:1117 +#: ../../howto/logging.rst:1118 msgid "Current :class:`asyncio.Task` name when using ``asyncio``." msgstr "" -#: ../../howto/logging.rst:1117 +#: ../../howto/logging.rst:1118 msgid "Set ``logging.logAsyncioTasks`` to ``False``." msgstr "將 ``logging.logAsyncioTasks`` 設為 ``False``。" -#: ../../howto/logging.rst:1121 +#: ../../howto/logging.rst:1122 msgid "" "Also note that the core logging module only includes the basic handlers. If " "you don't import :mod:`logging.handlers` and :mod:`logging.config`, they " "won't take up any memory." msgstr "" -#: ../../howto/logging.rst:1128 +#: ../../howto/logging.rst:1129 msgid "Other resources" msgstr "其他資源" -#: ../../howto/logging.rst:1132 +#: ../../howto/logging.rst:1133 msgid "Module :mod:`logging`" msgstr ":mod:`logging` 模組" -#: ../../howto/logging.rst:1133 +#: ../../howto/logging.rst:1134 msgid "API reference for the logging module." msgstr "" -#: ../../howto/logging.rst:1135 +#: ../../howto/logging.rst:1136 msgid "Module :mod:`logging.config`" msgstr ":mod:`logging.config` 模組" -#: ../../howto/logging.rst:1136 +#: ../../howto/logging.rst:1137 msgid "Configuration API for the logging module." msgstr "" -#: ../../howto/logging.rst:1138 +#: ../../howto/logging.rst:1139 msgid "Module :mod:`logging.handlers`" msgstr ":mod:`logging.handlers` 模組" -#: ../../howto/logging.rst:1139 +#: ../../howto/logging.rst:1140 msgid "Useful handlers included with the logging module." msgstr "" -#: ../../howto/logging.rst:1141 +#: ../../howto/logging.rst:1142 msgid ":ref:`A logging cookbook `" msgstr "" diff --git a/howto/mro.po b/howto/mro.po index e5b77714fe..1f107b45fd 100644 --- a/howto/mro.po +++ b/howto/mro.po @@ -5,12 +5,13 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-01-22 00:13+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -527,7 +528,7 @@ msgstr "" msgid "" "A lazy programmer can obtain the MRO directly from Python 2.2, since in this " "case it coincides with the Python 2.3 linearization. It is enough to invoke " -"the .mro() method of class A:" +"the :meth:`~type.mro` method of class A:" msgstr "" #: ../../howto/mro.rst:345 @@ -614,7 +615,7 @@ msgstr "" msgid "" "We see that class G inherits from F and E, with F *before* E: therefore we " "would expect the attribute *G.remember2buy* to be inherited by *F." -"rembermer2buy* and not by *E.remember2buy*: nevertheless Python 2.2 gives" +"remember2buy* and not by *E.remember2buy*: nevertheless Python 2.2 gives" msgstr "" #: ../../howto/mro.rst:407 diff --git a/howto/perf_profiling.po b/howto/perf_profiling.po index 88ead417c7..07ffef15b4 100644 --- a/howto/perf_profiling.po +++ b/howto/perf_profiling.po @@ -5,9 +5,9 @@ # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-04-19 00:14+0000\n" "PO-Revision-Date: 2023-12-09 17:39+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -37,7 +37,7 @@ msgid "" "that aid with the analysis of the data that it produces." msgstr "" "`Linux 性能分析器 (Linux perf profiler) `_ 是一" -"個非常強大的工具,可讓你分析並獲取有關應用程式的性能資訊。``perf`` 還擁有一個" +"個非常強大的工具,可讓你分析並取得有關應用程式的性能資訊。``perf`` 還擁有一個" "非常活躍的工具生態系統,有助於分析其生成的資料。" #: ../../howto/perf_profiling.rst:17 @@ -48,7 +48,7 @@ msgid "" "and file names of Python functions in your code will not appear in the " "output of ``perf``." msgstr "" -"在 Python 應用程式中使用 ``perf`` 分析器的主要問題是 ``perf`` 僅獲取有關原生" +"在 Python 應用程式中使用 ``perf`` 分析器的主要問題是 ``perf`` 僅取得有關原生" "符號的資訊,即用 C 編寫的函式和程式的名稱。這表示程式碼中的 Python 函式名稱和" "檔案名稱不會出現在 ``perf`` 的輸出中。" @@ -115,7 +115,7 @@ msgstr "" #: ../../howto/perf_profiling.rst:55 msgid "We can run ``perf`` to sample CPU stack traces at 9999 hertz::" -msgstr "我們可以執行 ``perf`` 以 9999 赫茲採樣 CPU 堆疊追蹤 (stack trace): ::" +msgstr "我們可以執行 ``perf`` 以 9999 赫茲取樣 CPU 堆疊追蹤 (stack trace): ::" #: ../../howto/perf_profiling.rst:57 msgid "$ perf record -F 9999 -g -o perf.data python my_script.py" @@ -382,13 +382,13 @@ msgstr "如何啟用 ``perf`` 分析支援" msgid "" "``perf`` profiling support can be enabled either from the start using the " "environment variable :envvar:`PYTHONPERFSUPPORT` or the :option:`-X perf <-" -"X>` option, or dynamically using :func:`sys.activate_stack_trampoline` and :" -"func:`sys.deactivate_stack_trampoline`." +"X>` option, or dynamically using :func:`sys.activate_stack_trampoline` " +"and :func:`sys.deactivate_stack_trampoline`." msgstr "" -"要啟用 ``perf`` 分析支援,可以在一開始就使用環境變數 :envvar:" -"`PYTHONPERFSUPPORT` 或使用 :option:`-X perf <-X>` 選項,也可以使用 :func:" -"`sys.activate_stack_trampoline` 和 :func:`sys.deactivate_stack_trampoline` 來" -"動態啟用。" +"要啟用 ``perf`` 分析支援,可以在一開始就使用環境變" +"數 :envvar:`PYTHONPERFSUPPORT` 或使用 :option:`-X perf <-X>` 選項,也可以使" +"用 :func:`sys.activate_stack_trampoline` " +"和 :func:`sys.deactivate_stack_trampoline` 來動態啟用。" #: ../../howto/perf_profiling.rst:160 msgid "" @@ -403,10 +403,12 @@ msgstr "例如,使用環境變數: ::" #: ../../howto/perf_profiling.rst:165 msgid "" -"$ PYTHONPERFSUPPORT=1 python script.py\n" +"$ PYTHONPERFSUPPORT=1 perf record -F 9999 -g -o perf.data python " +"my_script.py\n" "$ perf report -g -i perf.data" msgstr "" -"$ PYTHONPERFSUPPORT=1 python script.py\n" +"$ PYTHONPERFSUPPORT=1 perf record -F 9999 -g -o perf.data python " +"my_script.py\n" "$ perf report -g -i perf.data" #: ../../howto/perf_profiling.rst:168 @@ -415,10 +417,10 @@ msgstr "例如,使用 :option:`!-X` 選項: ::" #: ../../howto/perf_profiling.rst:170 msgid "" -"$ python -X perf script.py\n" +"$ perf record -F 9999 -g -o perf.data python -X perf my_script.py\n" "$ perf report -g -i perf.data" msgstr "" -"$ python -X perf script.py\n" +"$ perf record -F 9999 -g -o perf.data python -X perf my_script.py\n" "$ perf report -g -i perf.data" #: ../../howto/perf_profiling.rst:173 @@ -449,10 +451,10 @@ msgstr "...然後: ::" #: ../../howto/perf_profiling.rst:187 msgid "" -"$ python ./example.py\n" +"$ perf record -F 9999 -g -o perf.data python ./example.py\n" "$ perf report -g -i perf.data" msgstr "" -"$ python ./example.py\n" +"$ perf record -F 9999 -g -o perf.data python ./example.py\n" "$ perf report -g -i perf.data" #: ../../howto/perf_profiling.rst:192 @@ -490,3 +492,140 @@ msgid "" msgstr "" "如果你沒有看到任何輸出,則表示你的直譯器尚未使用 frame 指標進行編譯,因此它可" "能無法在 ``perf`` 的輸出中顯示 Python 函式。" + +#: ../../howto/perf_profiling.rst:211 +msgid "How to work without frame pointers" +msgstr "" + +#: ../../howto/perf_profiling.rst:213 +msgid "" +"If you are working with a Python interpreter that has been compiled without " +"frame pointers, you can still use the ``perf`` profiler, but the overhead " +"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." +msgstr "" + +#: ../../howto/perf_profiling.rst:220 +msgid "" +"To enable this mode, you can use the environment " +"variable :envvar:`PYTHON_PERF_JIT_SUPPORT` or the :option:`-X perf_jit <-X>` " +"option, which will enable the JIT mode for the ``perf`` profiler." +msgstr "" + +#: ../../howto/perf_profiling.rst:226 +msgid "" +"Due to a bug in the ``perf`` tool, only ``perf`` versions higher than v6.8 " +"will work with the JIT mode. The fix was also backported to the v6.7.2 " +"version of the tool." +msgstr "" + +#: ../../howto/perf_profiling.rst:230 +msgid "" +"Note that when checking the version of the ``perf`` tool (which can be done " +"by running ``perf version``) you must take into account that some distros " +"add some custom version numbers including a ``-`` character. This means " +"that ``perf 6.7-3`` is not necessarily ``perf 6.7.3``." +msgstr "" + +#: ../../howto/perf_profiling.rst:235 +msgid "" +"When using the perf JIT mode, you need an extra step before you can run " +"``perf report``. You need to call the ``perf inject`` command to inject the " +"JIT information into the ``perf.data`` file.::" +msgstr "" + +#: ../../howto/perf_profiling.rst:239 +msgid "" +"$ perf record -F 9999 -g -k 1 --call-graph dwarf -o perf.data python " +"-Xperf_jit my_script.py\n" +"$ perf inject -i perf.data --jit --output perf.jit.data\n" +"$ perf report -g -i perf.jit.data" +msgstr "" +"$ perf record -F 9999 -g -k 1 --call-graph dwarf -o perf.data python " +"-Xperf_jit my_script.py\n" +"$ perf inject -i perf.data --jit --output perf.jit.data\n" +"$ perf report -g -i perf.jit.data" + +#: ../../howto/perf_profiling.rst:243 +msgid "or using the environment variable::" +msgstr "或使用環境變數: ::" + +#: ../../howto/perf_profiling.rst:245 +msgid "" +"$ PYTHON_PERF_JIT_SUPPORT=1 perf record -F 9999 -g --call-graph dwarf -o " +"perf.data python my_script.py\n" +"$ perf inject -i perf.data --jit --output perf.jit.data\n" +"$ perf report -g -i perf.jit.data" +msgstr "" +"$ PYTHON_PERF_JIT_SUPPORT=1 perf record -F 9999 -g --call-graph dwarf -o " +"perf.data python my_script.py\n" +"$ perf inject -i perf.data --jit --output perf.jit.data\n" +"$ perf report -g -i perf.jit.data" + +#: ../../howto/perf_profiling.rst:249 +msgid "" +"``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." +msgstr "" + +#: ../../howto/perf_profiling.rst:257 +msgid "" +"When using ``--call-graph dwarf``, the ``perf`` tool will take snapshots of " +"the stack of the process being profiled and save the information in the " +"``perf.data`` file. By default, the size of the stack dump is 8192 bytes, " +"but you can change the size by passing it after a comma like ``--call-graph " +"dwarf,16384``." +msgstr "" + +#: ../../howto/perf_profiling.rst:263 +msgid "" +"The size of the stack dump is important because if the size is too small " +"``perf`` will not be able to unwind the stack and the output will be " +"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." +msgstr "" + +#: ../../howto/perf_profiling.rst:269 +msgid "" +"The stack size is particularly important when profiling Python code compiled " +"with low optimization levels (like ``-O0``), as these builds tend to have " +"larger stack frames. If you are compiling Python with ``-O0`` and not seeing " +"Python functions in your profiling output, try increasing the stack dump " +"size to 65528 bytes (the maximum)::" +msgstr "" + +#: ../../howto/perf_profiling.rst:275 +msgid "" +"$ perf record -F 9999 -g -k 1 --call-graph dwarf,65528 -o perf.data python " +"-Xperf_jit my_script.py" +msgstr "" +"$ perf record -F 9999 -g -k 1 --call-graph dwarf,65528 -o perf.data python " +"-Xperf_jit my_script.py" + +#: ../../howto/perf_profiling.rst:277 +msgid "Different compilation flags can significantly impact stack sizes:" +msgstr "" + +#: ../../howto/perf_profiling.rst:279 +msgid "" +"Builds with ``-O0`` typically have much larger stack frames than those with " +"``-O1`` or higher" +msgstr "" + +#: ../../howto/perf_profiling.rst:280 +msgid "" +"Adding optimizations (``-O1``, ``-O2``, etc.) typically reduces stack size" +msgstr "" + +#: ../../howto/perf_profiling.rst:281 +msgid "" +"Frame pointers (``-fno-omit-frame-pointer``) generally provide more reliable " +"stack unwinding" +msgstr "" diff --git a/howto/pyporting.po b/howto/pyporting.po index 4184ecf0de..61899804cc 100644 --- a/howto/pyporting.po +++ b/howto/pyporting.po @@ -6,7 +6,7 @@ # jerrychen , 2016 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-05-31 00:03+0000\n" "PO-Revision-Date: 2018-05-23 14:37+0000\n" diff --git a/howto/regex.po b/howto/regex.po index ab0e03dec1..782ee533c4 100644 --- a/howto/regex.po +++ b/howto/regex.po @@ -6,9 +6,9 @@ # Kai-han Chang , 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 14:37+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -659,12 +659,12 @@ msgid "" msgstr "" #: ../../howto/regex.rst:363 ../../howto/regex.rst:417 -#: ../../howto/regex.rst:1065 +#: ../../howto/regex.rst:1069 msgid "Method/Attribute" -msgstr "" +msgstr "方法/屬性" #: ../../howto/regex.rst:363 ../../howto/regex.rst:417 -#: ../../howto/regex.rst:1065 +#: ../../howto/regex.rst:1069 msgid "Purpose" msgstr "" @@ -920,7 +920,7 @@ msgstr "" #: ../../howto/regex.rst:483 msgid "" ">>> iterator = p.finditer('12 drummers drumming, 11 ... 10 ...')\n" -">>> iterator \n" +">>> iterator\n" "\n" ">>> for match in iterator:\n" "... print(match.span())\n" @@ -930,7 +930,7 @@ msgid "" "(29, 31)" msgstr "" ">>> iterator = p.finditer('12 drummers drumming, 11 ... 10 ...')\n" -">>> iterator \n" +">>> iterator\n" "\n" ">>> for match in iterator:\n" "... print(match.span())\n" @@ -941,7 +941,7 @@ msgstr "" #: ../../howto/regex.rst:495 msgid "Module-Level Functions" -msgstr "" +msgstr "模組層級函式" #: ../../howto/regex.rst:497 msgid "" @@ -957,12 +957,12 @@ msgstr "" msgid "" ">>> print(re.match(r'From\\s+', 'Fromage amk'))\n" "None\n" -">>> re.match(r'From\\s+', 'From amk Thu May 14 19:12:10 1998') \n" +">>> re.match(r'From\\s+', 'From amk Thu May 14 19:12:10 1998')\n" "" msgstr "" ">>> print(re.match(r'From\\s+', 'Fromage amk'))\n" "None\n" -">>> re.match(r'From\\s+', 'From amk Thu May 14 19:12:10 1998') \n" +">>> re.match(r'From\\s+', 'From amk Thu May 14 19:12:10 1998')\n" "" #: ../../howto/regex.rst:509 @@ -1005,7 +1005,7 @@ msgstr "" #: ../../howto/regex.rst:538 msgid "Flag" -msgstr "" +msgstr "旗標" #: ../../howto/regex.rst:538 msgid "Meaning" @@ -1069,13 +1069,13 @@ msgid "" "letters, too. Full Unicode matching also works unless the :const:`ASCII` " "flag is used to disable non-ASCII matches. When the Unicode patterns ``[a-" "z]`` or ``[A-Z]`` are used in combination with the :const:`IGNORECASE` flag, " -"they will match the 52 ASCII letters and 4 additional non-ASCII letters: 'İ' " -"(U+0130, Latin capital letter I with dot above), 'ı' (U+0131, Latin small " -"letter dotless i), 'ſ' (U+017F, Latin small letter long s) and 'K' (U+212A, " -"Kelvin sign). ``Spam`` will match ``'Spam'``, ``'spam'``, ``'spAM'``, or " -"``'ſpam'`` (the latter is matched only in Unicode mode). This lowercasing " -"doesn't take the current locale into account; it will if you also set the :" -"const:`LOCALE` flag." +"they will match the 52 ASCII letters and 4 additional non-ASCII letters: " +"'İ' (U+0130, Latin capital letter I with dot above), 'ı' (U+0131, Latin " +"small letter dotless i), 'ſ' (U+017F, Latin small letter long s) and " +"'K' (U+212A, Kelvin sign). ``Spam`` will match ``'Spam'``, ``'spam'``, " +"``'spAM'``, or ``'ſpam'`` (the latter is matched only in Unicode mode). This " +"lowercasing doesn't take the current locale into account; it will if you " +"also set the :const:`LOCALE` flag." msgstr "" #: ../../howto/regex.rst:581 @@ -1258,12 +1258,12 @@ msgstr "" #: ../../howto/regex.rst:714 msgid "" -">>> print(re.search('^From', 'From Here to Eternity')) \n" +">>> print(re.search('^From', 'From Here to Eternity'))\n" "\n" ">>> print(re.search('^From', 'Reciting From Memory'))\n" "None" msgstr "" -">>> print(re.search('^From', 'From Here to Eternity')) \n" +">>> print(re.search('^From', 'From Here to Eternity'))\n" "\n" ">>> print(re.search('^From', 'Reciting From Memory'))\n" "None" @@ -1284,18 +1284,18 @@ msgstr "" #: ../../howto/regex.rst:725 msgid "" -">>> print(re.search('}$', '{block}')) \n" +">>> print(re.search('}$', '{block}'))\n" "\n" ">>> print(re.search('}$', '{block} '))\n" "None\n" -">>> print(re.search('}$', '{block}\\n')) \n" +">>> print(re.search('}$', '{block}\\n'))\n" "" msgstr "" -">>> print(re.search('}$', '{block}')) \n" +">>> print(re.search('}$', '{block}'))\n" "\n" ">>> print(re.search('}$', '{block} '))\n" "None\n" -">>> print(re.search('}$', '{block}\\n')) \n" +">>> print(re.search('}$', '{block}\\n'))\n" "" #: ../../howto/regex.rst:732 @@ -1825,17 +1825,21 @@ msgid "" msgstr "" #: ../../howto/regex.rst:1016 +msgid "``.*[.][^b].*$``" +msgstr "``.*[.][^b].*$``" + +#: ../../howto/regex.rst:1018 msgid "" -"``.*[.][^b].*$`` The first attempt above tries to exclude ``bat`` by " -"requiring that the first character of the extension is not a ``b``. This is " -"wrong, because the pattern also doesn't match ``foo.bar``." +"The first attempt above tries to exclude ``bat`` by requiring that the first " +"character of the extension is not a ``b``. This is wrong, because the " +"pattern also doesn't match ``foo.bar``." msgstr "" -#: ../../howto/regex.rst:1020 +#: ../../howto/regex.rst:1022 msgid "``.*[.]([^b]..|.[^a].|..[^t])$``" msgstr "``.*[.]([^b]..|.[^a].|..[^t])$``" -#: ../../howto/regex.rst:1022 +#: ../../howto/regex.rst:1024 msgid "" "The expression gets messier when you try to patch up the first solution by " "requiring one of the following cases to match: the first character of the " @@ -1846,18 +1850,18 @@ msgid "" "pattern again in an effort to fix it." msgstr "" -#: ../../howto/regex.rst:1030 +#: ../../howto/regex.rst:1032 msgid "``.*[.]([^b].?.?|.[^a]?.?|..?[^t]?)$``" msgstr "``.*[.]([^b].?.?|.[^a]?.?|..?[^t]?)$``" -#: ../../howto/regex.rst:1032 +#: ../../howto/regex.rst:1034 msgid "" "In the third attempt, the second and third letters are all made optional in " "order to allow matching extensions shorter than three characters, such as " "``sendmail.cf``." msgstr "" -#: ../../howto/regex.rst:1036 +#: ../../howto/regex.rst:1038 msgid "" "The pattern's getting really complicated now, which makes it hard to read " "and understand. Worse, if the problem changes and you want to exclude both " @@ -1865,75 +1869,79 @@ msgid "" "complicated and confusing." msgstr "" -#: ../../howto/regex.rst:1041 +#: ../../howto/regex.rst:1043 msgid "A negative lookahead cuts through all this confusion:" msgstr "" -#: ../../howto/regex.rst:1043 +#: ../../howto/regex.rst:1045 +msgid "``.*[.](?!bat$)[^.]*$``" +msgstr "``.*[.](?!bat$)[^.]*$``" + +#: ../../howto/regex.rst:1047 msgid "" -"``.*[.](?!bat$)[^.]*$`` The negative lookahead means: if the expression " -"``bat`` doesn't match at this point, try the rest of the pattern; if " -"``bat$`` does match, the whole pattern will fail. The trailing ``$`` is " -"required to ensure that something like ``sample.batch``, where the extension " -"only starts with ``bat``, will be allowed. The ``[^.]*`` makes sure that " -"the pattern works when there are multiple dots in the filename." +"The negative lookahead means: if the expression ``bat`` doesn't match at " +"this point, try the rest of the pattern; if ``bat$`` does match, the whole " +"pattern will fail. The trailing ``$`` is required to ensure that something " +"like ``sample.batch``, where the extension only starts with ``bat``, will be " +"allowed. The ``[^.]*`` makes sure that the pattern works when there are " +"multiple dots in the filename." msgstr "" -#: ../../howto/regex.rst:1050 +#: ../../howto/regex.rst:1054 msgid "" "Excluding another filename extension is now easy; simply add it as an " "alternative inside the assertion. The following pattern excludes filenames " "that end in either ``bat`` or ``exe``:" msgstr "" -#: ../../howto/regex.rst:1054 +#: ../../howto/regex.rst:1058 msgid "``.*[.](?!bat$|exe$)[^.]*$``" msgstr "``.*[.](?!bat$|exe$)[^.]*$``" -#: ../../howto/regex.rst:1058 +#: ../../howto/regex.rst:1062 msgid "Modifying Strings" msgstr "" -#: ../../howto/regex.rst:1060 +#: ../../howto/regex.rst:1064 msgid "" "Up to this point, we've simply performed searches against a static string. " "Regular expressions are also commonly used to modify strings in various " "ways, using the following pattern methods:" msgstr "" -#: ../../howto/regex.rst:1067 +#: ../../howto/regex.rst:1071 msgid "``split()``" msgstr "``split()``" -#: ../../howto/regex.rst:1067 +#: ../../howto/regex.rst:1071 msgid "Split the string into a list, splitting it wherever the RE matches" msgstr "" -#: ../../howto/regex.rst:1070 +#: ../../howto/regex.rst:1074 msgid "``sub()``" msgstr "``sub()``" -#: ../../howto/regex.rst:1070 +#: ../../howto/regex.rst:1074 msgid "" "Find all substrings where the RE matches, and replace them with a different " "string" msgstr "" -#: ../../howto/regex.rst:1073 +#: ../../howto/regex.rst:1077 msgid "``subn()``" msgstr "``subn()``" -#: ../../howto/regex.rst:1073 +#: ../../howto/regex.rst:1077 msgid "" "Does the same thing as :meth:`!sub`, but returns the new string and the " "number of replacements" msgstr "" -#: ../../howto/regex.rst:1080 +#: ../../howto/regex.rst:1084 msgid "Splitting Strings" msgstr "" -#: ../../howto/regex.rst:1082 +#: ../../howto/regex.rst:1086 msgid "" "The :meth:`~re.Pattern.split` method of a pattern splits a string apart " "wherever the RE matches, returning a list of the pieces. It's similar to " @@ -1943,7 +1951,7 @@ msgid "" "module-level :func:`re.split` function, too." msgstr "" -#: ../../howto/regex.rst:1093 +#: ../../howto/regex.rst:1097 msgid "" "Split *string* by the matches of the regular expression. If capturing " "parentheses are used in the RE, then their contents will also be returned as " @@ -1951,7 +1959,7 @@ msgid "" "splits are performed." msgstr "" -#: ../../howto/regex.rst:1098 +#: ../../howto/regex.rst:1102 msgid "" "You can limit the number of splits made, by passing a value for *maxsplit*. " "When *maxsplit* is nonzero, at most *maxsplit* splits will be made, and the " @@ -1960,7 +1968,7 @@ msgid "" "characters. ::" msgstr "" -#: ../../howto/regex.rst:1104 +#: ../../howto/regex.rst:1108 msgid "" ">>> p = re.compile(r'\\W+')\n" ">>> p.split('This is a test, short and sweet, of split().')\n" @@ -1974,7 +1982,7 @@ msgstr "" ">>> p.split('This is a test, short and sweet, of split().', 3)\n" "['This', 'is', 'a', 'test, short and sweet, of split().']" -#: ../../howto/regex.rst:1110 +#: ../../howto/regex.rst:1114 msgid "" "Sometimes you're not only interested in what the text between delimiters is, " "but also need to know what the delimiter was. If capturing parentheses are " @@ -1982,7 +1990,7 @@ msgid "" "Compare the following calls::" msgstr "" -#: ../../howto/regex.rst:1115 +#: ../../howto/regex.rst:1119 msgid "" ">>> p = re.compile(r'\\W+')\n" ">>> p2 = re.compile(r'(\\W+)')\n" @@ -1998,13 +2006,13 @@ msgstr "" ">>> p2.split('This... is a test.')\n" "['This', '... ', 'is', ' ', 'a', ' ', 'test', '.', '']" -#: ../../howto/regex.rst:1122 +#: ../../howto/regex.rst:1126 msgid "" "The module-level function :func:`re.split` adds the RE to be used as the " "first argument, but is otherwise the same. ::" msgstr "" -#: ../../howto/regex.rst:1125 +#: ../../howto/regex.rst:1129 msgid "" ">>> re.split(r'[\\W]+', 'Words, words, words.')\n" "['Words', 'words', 'words', '']\n" @@ -2020,11 +2028,11 @@ msgstr "" ">>> re.split(r'[\\W]+', 'Words, words, words.', 1)\n" "['Words', 'words, words.']" -#: ../../howto/regex.rst:1134 +#: ../../howto/regex.rst:1138 msgid "Search and Replace" msgstr "" -#: ../../howto/regex.rst:1136 +#: ../../howto/regex.rst:1140 msgid "" "Another common task is to find all the matches for a pattern, and replace " "them with a different string. The :meth:`~re.Pattern.sub` method takes a " @@ -2032,27 +2040,27 @@ msgid "" "string to be processed." msgstr "" -#: ../../howto/regex.rst:1143 +#: ../../howto/regex.rst:1147 msgid "" "Returns the string obtained by replacing the leftmost non-overlapping " "occurrences of the RE in *string* by the replacement *replacement*. If the " "pattern isn't found, *string* is returned unchanged." msgstr "" -#: ../../howto/regex.rst:1147 +#: ../../howto/regex.rst:1151 msgid "" "The optional argument *count* is the maximum number of pattern occurrences " "to be replaced; *count* must be a non-negative integer. The default value " "of 0 means to replace all occurrences." msgstr "" -#: ../../howto/regex.rst:1151 +#: ../../howto/regex.rst:1155 msgid "" "Here's a simple example of using the :meth:`~re.Pattern.sub` method. It " "replaces colour names with the word ``colour``::" msgstr "" -#: ../../howto/regex.rst:1154 +#: ../../howto/regex.rst:1158 msgid "" ">>> p = re.compile('(blue|white|red)')\n" ">>> p.sub('colour', 'blue socks and red shoes')\n" @@ -2066,14 +2074,14 @@ msgstr "" ">>> p.sub('colour', 'blue socks and red shoes', count=1)\n" "'colour socks and red shoes'" -#: ../../howto/regex.rst:1160 +#: ../../howto/regex.rst:1164 msgid "" "The :meth:`~re.Pattern.subn` method does the same work, but returns a 2-" "tuple containing the new string value and the number of replacements that " "were performed::" msgstr "" -#: ../../howto/regex.rst:1163 +#: ../../howto/regex.rst:1167 msgid "" ">>> p = re.compile('(blue|white|red)')\n" ">>> p.subn('colour', 'blue socks and red shoes')\n" @@ -2087,13 +2095,13 @@ msgstr "" ">>> p.subn('colour', 'no colours at all')\n" "('no colours at all', 0)" -#: ../../howto/regex.rst:1169 +#: ../../howto/regex.rst:1173 msgid "" "Empty matches are replaced only when they're not adjacent to a previous " "empty match. ::" msgstr "" -#: ../../howto/regex.rst:1172 +#: ../../howto/regex.rst:1176 msgid "" ">>> p = re.compile('x*')\n" ">>> p.sub('-', 'abxd')\n" @@ -2103,7 +2111,7 @@ msgstr "" ">>> p.sub('-', 'abxd')\n" "'-a-b--d-'" -#: ../../howto/regex.rst:1176 +#: ../../howto/regex.rst:1180 msgid "" "If *replacement* is a string, any backslash escapes in it are processed. " "That is, ``\\n`` is converted to a single newline character, ``\\r`` is " @@ -2114,13 +2122,13 @@ msgid "" "string." msgstr "" -#: ../../howto/regex.rst:1183 +#: ../../howto/regex.rst:1187 msgid "" "This example matches the word ``section`` followed by a string enclosed in " "``{``, ``}``, and changes ``section`` to ``subsection``::" msgstr "" -#: ../../howto/regex.rst:1186 +#: ../../howto/regex.rst:1190 msgid "" ">>> p = re.compile('section{ ( [^}]* ) }', re.VERBOSE)\n" ">>> p.sub(r'subsection{\\1}','section{First} section{second}')\n" @@ -2130,7 +2138,7 @@ msgstr "" ">>> p.sub(r'subsection{\\1}','section{First} section{second}')\n" "'subsection{First} subsection{second}'" -#: ../../howto/regex.rst:1190 +#: ../../howto/regex.rst:1194 msgid "" "There's also a syntax for referring to named groups as defined by the ``(?" "P...)`` syntax. ``\\g`` will use the substring matched by the " @@ -2142,7 +2150,7 @@ msgid "" "but use all three variations of the replacement string. ::" msgstr "" -#: ../../howto/regex.rst:1199 +#: ../../howto/regex.rst:1203 msgid "" ">>> p = re.compile('section{ (?P [^}]* ) }', re.VERBOSE)\n" ">>> p.sub(r'subsection{\\1}','section{First}')\n" @@ -2160,7 +2168,7 @@ msgstr "" ">>> p.sub(r'subsection{\\g}','section{First}')\n" "'subsection{First}'" -#: ../../howto/regex.rst:1207 +#: ../../howto/regex.rst:1211 msgid "" "*replacement* can also be a function, which gives you even more control. If " "*replacement* is a function, the function is called for every non-" @@ -2169,13 +2177,13 @@ msgid "" "this information to compute the desired replacement string and return it." msgstr "" -#: ../../howto/regex.rst:1213 +#: ../../howto/regex.rst:1217 msgid "" "In the following example, the replacement function translates decimals into " "hexadecimal::" msgstr "" -#: ../../howto/regex.rst:1216 +#: ../../howto/regex.rst:1220 msgid "" ">>> def hexrepl(match):\n" "... \"Return the hex string for a decimal number\"\n" @@ -2187,7 +2195,7 @@ msgid "" "'Call 0xffd2 for printing, 0xc000 for user code.'" msgstr "" -#: ../../howto/regex.rst:1225 +#: ../../howto/regex.rst:1229 msgid "" "When using the module-level :func:`re.sub` function, the pattern is passed " "as the first argument. The pattern may be provided as an object or as a " @@ -2197,11 +2205,11 @@ msgid "" "x'``." msgstr "" -#: ../../howto/regex.rst:1233 +#: ../../howto/regex.rst:1237 msgid "Common Problems" msgstr "" -#: ../../howto/regex.rst:1235 +#: ../../howto/regex.rst:1239 msgid "" "Regular expressions are a powerful tool for some applications, but in some " "ways their behaviour isn't intuitive and at times they don't behave the way " @@ -2209,11 +2217,11 @@ msgid "" "pitfalls." msgstr "" -#: ../../howto/regex.rst:1241 +#: ../../howto/regex.rst:1245 msgid "Use String Methods" msgstr "" -#: ../../howto/regex.rst:1243 +#: ../../howto/regex.rst:1247 msgid "" "Sometimes using the :mod:`re` module is a mistake. If you're matching a " "fixed string, or a single character class, and you're not using any :mod:" @@ -2225,7 +2233,7 @@ msgid "" "engine." msgstr "" -#: ../../howto/regex.rst:1251 +#: ../../howto/regex.rst:1255 msgid "" "One example might be replacing a single fixed string with another one; for " "example, you might replace ``word`` with ``deed``. :func:`re.sub` seems " @@ -2238,7 +2246,7 @@ msgid "" "meth:`!replace`'s abilities.)" msgstr "" -#: ../../howto/regex.rst:1260 +#: ../../howto/regex.rst:1264 msgid "" "Another common task is deleting every occurrence of a single character from " "a string or replacing it with another single character. You might do this " @@ -2247,17 +2255,17 @@ msgid "" "operation can be." msgstr "" -#: ../../howto/regex.rst:1266 +#: ../../howto/regex.rst:1270 msgid "" "In short, before turning to the :mod:`re` module, consider whether your " "problem can be solved with a faster and simpler string method." msgstr "" -#: ../../howto/regex.rst:1271 +#: ../../howto/regex.rst:1275 msgid "match() versus search()" msgstr "" -#: ../../howto/regex.rst:1273 +#: ../../howto/regex.rst:1277 msgid "" "The :func:`~re.match` function only checks if the RE matches at the " "beginning of the string while :func:`~re.search` will scan forward through " @@ -2267,7 +2275,7 @@ msgid "" "report it. ::" msgstr "" -#: ../../howto/regex.rst:1279 +#: ../../howto/regex.rst:1283 msgid "" ">>> print(re.match('super', 'superstition').span())\n" "(0, 5)\n" @@ -2279,13 +2287,13 @@ msgstr "" ">>> print(re.match('super', 'insuperable'))\n" "None" -#: ../../howto/regex.rst:1284 +#: ../../howto/regex.rst:1288 msgid "" "On the other hand, :func:`~re.search` will scan forward through the string, " "reporting the first match it finds. ::" msgstr "" -#: ../../howto/regex.rst:1287 +#: ../../howto/regex.rst:1291 msgid "" ">>> print(re.search('super', 'superstition').span())\n" "(0, 5)\n" @@ -2297,7 +2305,7 @@ msgstr "" ">>> print(re.search('super', 'insuperable').span())\n" "(2, 7)" -#: ../../howto/regex.rst:1292 +#: ../../howto/regex.rst:1296 msgid "" "Sometimes you'll be tempted to keep using :func:`re.match`, and just add ``." "*`` to the front of your RE. Resist this temptation and use :func:`re." @@ -2309,18 +2317,18 @@ msgid "" "starting character, only trying the full match if a ``'C'`` is found." msgstr "" -#: ../../howto/regex.rst:1301 +#: ../../howto/regex.rst:1305 msgid "" "Adding ``.*`` defeats this optimization, requiring scanning to the end of " "the string and then backtracking to find a match for the rest of the RE. " "Use :func:`re.search` instead." msgstr "" -#: ../../howto/regex.rst:1307 +#: ../../howto/regex.rst:1311 msgid "Greedy versus Non-Greedy" msgstr "" -#: ../../howto/regex.rst:1309 +#: ../../howto/regex.rst:1313 msgid "" "When repeating a regular expression, as in ``a*``, the resulting action is " "to consume as much of the pattern as possible. This fact often bites you " @@ -2329,7 +2337,7 @@ msgid "" "HTML tag doesn't work because of the greedy nature of ``.*``. ::" msgstr "" -#: ../../howto/regex.rst:1315 +#: ../../howto/regex.rst:1319 msgid "" ">>> s = 'Title'\n" ">>> len(s)\n" @@ -2347,7 +2355,7 @@ msgstr "" ">>> print(re.match('<.*>', s).group())\n" "Title" -#: ../../howto/regex.rst:1323 +#: ../../howto/regex.rst:1327 msgid "" "The RE matches the ``'<'`` in ``''``, and the ``.*`` consumes the rest " "of the string. There's still more left in the RE, though, and the ``>`` " @@ -2357,7 +2365,7 @@ msgid "" "``''``, which isn't what you want." msgstr "" -#: ../../howto/regex.rst:1330 +#: ../../howto/regex.rst:1334 msgid "" "In this case, the solution is to use the non-greedy quantifiers ``*?``, ``+?" "``, ``??``, or ``{m,n}?``, which match as *little* text as possible. In the " @@ -2366,7 +2374,7 @@ msgid "" "retrying the ``'>'`` at every step. This produces just the right result::" msgstr "" -#: ../../howto/regex.rst:1336 +#: ../../howto/regex.rst:1340 msgid "" ">>> print(re.match('<.*?>', s).group())\n" "" @@ -2374,7 +2382,7 @@ msgstr "" ">>> print(re.match('<.*?>', s).group())\n" "" -#: ../../howto/regex.rst:1339 +#: ../../howto/regex.rst:1343 msgid "" "(Note that parsing HTML or XML with regular expressions is painful. Quick-" "and-dirty patterns will handle common cases, but HTML and XML have special " @@ -2384,11 +2392,11 @@ msgid "" "such tasks.)" msgstr "" -#: ../../howto/regex.rst:1347 +#: ../../howto/regex.rst:1351 msgid "Using re.VERBOSE" msgstr "" -#: ../../howto/regex.rst:1349 +#: ../../howto/regex.rst:1353 msgid "" "By now you've probably noticed that regular expressions are a very compact " "notation, but they're not terribly readable. REs of moderate complexity can " @@ -2396,14 +2404,14 @@ msgid "" "making them difficult to read and understand." msgstr "" -#: ../../howto/regex.rst:1354 +#: ../../howto/regex.rst:1358 msgid "" "For such REs, specifying the :const:`re.VERBOSE` flag when compiling the " "regular expression can be helpful, because it allows you to format the " "regular expression more clearly." msgstr "" -#: ../../howto/regex.rst:1358 +#: ../../howto/regex.rst:1362 msgid "" "The ``re.VERBOSE`` flag has several effects. Whitespace in the regular " "expression that *isn't* inside a character class is ignored. This means " @@ -2414,7 +2422,7 @@ msgid "" "quoted strings, this enables REs to be formatted more neatly::" msgstr "" -#: ../../howto/regex.rst:1366 +#: ../../howto/regex.rst:1370 msgid "" "pat = re.compile(r\"\"\"\n" " \\s* # Skip leading whitespace\n" @@ -2426,19 +2434,19 @@ msgid "" "\"\"\", re.VERBOSE)" msgstr "" -#: ../../howto/regex.rst:1375 +#: ../../howto/regex.rst:1379 msgid "This is far more readable than::" msgstr "" -#: ../../howto/regex.rst:1377 +#: ../../howto/regex.rst:1381 msgid "pat = re.compile(r\"\\s*(?P
[^:]+)\\s*:(?P.*?)\\s*$\")" msgstr "pat = re.compile(r\"\\s*(?P
[^:]+)\\s*:(?P.*?)\\s*$\")" -#: ../../howto/regex.rst:1381 +#: ../../howto/regex.rst:1385 msgid "Feedback" msgstr "" -#: ../../howto/regex.rst:1383 +#: ../../howto/regex.rst:1387 msgid "" "Regular expressions are a complicated topic. Did this document help you " "understand them? Were there parts that were unclear, or Problems you " @@ -2446,7 +2454,7 @@ msgid "" "improvements to the author." msgstr "" -#: ../../howto/regex.rst:1388 +#: ../../howto/regex.rst:1392 msgid "" "The most complete book on regular expressions is almost certainly Jeffrey " "Friedl's Mastering Regular Expressions, published by O'Reilly. " diff --git a/howto/sockets.po b/howto/sockets.po index 982fa34fd1..0d6717fa74 100644 --- a/howto/sockets.po +++ b/howto/sockets.po @@ -50,7 +50,7 @@ msgstr "" #: ../../howto/sockets.rst:20 msgid "Sockets" -msgstr "" +msgstr "Sockets" #: ../../howto/sockets.rst:22 msgid "" @@ -335,7 +335,7 @@ msgid "" "request, then reads a reply. That's it. The socket is discarded. This means " "that a client can detect the end of the reply by receiving 0 bytes." msgstr "" -"像 HTTP 這樣的協議只使用一個 socket 進行一次傳輸,用戶端發送一個請求,然後讀" +"像 HTTP 這樣的協定只使用一個 socket 進行一次傳輸,用戶端發送一個請求,然後讀" "取一個回覆。就這樣,然後這個 socket 就會被銷毀。這表示者用戶端可以通過接收" "「零位元組」來檢測回覆的結束。" @@ -441,7 +441,7 @@ msgid "" "of a following message. You'll need to put that aside and hold onto it, " "until it's needed." msgstr "" -"需要注意的一個複雜情況是,如果你的通訊協議允許連續發送多個訊息(沒有任何回" +"需要注意的一個複雜情況是,如果你的通訊協定允許連續發送多個訊息(沒有任何回" "應),並且你傳遞給 ``recv`` 函式一個任意的區塊大小,最後有可能讀取到下一條訊" "息的開頭。你需要將其放在一旁並保留下來,直到需要使用的時候。" @@ -594,7 +594,7 @@ msgid "" "the thread, your whole process is likely to be screwed up." msgstr "" "使用阻塞式 socket 最糟糕的地方可能是在另一端突然強制關閉(未執行 ``close``)" -"的情況下會發生什麼?你的 socket 很可能會處於阻塞狀態。TCP 是一種可靠的協議," +"的情況下會發生什麼?你的 socket 很可能會處於阻塞狀態。TCP 是一種可靠的協定," "它在放棄連線之前會等待很長很長的時間。如果你正在使用執行緒,整個執行緒基本上" "已經無法使用。在這方面,你無法做太多事情。只要你不做一些愚蠢的事情,比如在執" "行阻塞式讀取時持有一個鎖,那麼執行緒並不會消耗太多資源。*不要*\\ 試圖終止執行" diff --git a/howto/sorting.po b/howto/sorting.po index cf6833970c..dcdc529f4e 100644 --- a/howto/sorting.po +++ b/howto/sorting.po @@ -5,11 +5,11 @@ # Ching-Lung Chuang, 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" -"PO-Revision-Date: 2023-08-12 15:09+0800\n" -"Last-Translator: Adrian Liaw \n" +"PO-Revision-Date: 2024-12-20 19:16+0800\n" +"Last-Translator: Li-Hung Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -17,6 +17,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Poedit 3.4.2\n" #: ../../howto/sorting.rst:4 msgid "Sorting Techniques" @@ -127,6 +128,8 @@ msgid "" ">>> sorted(\"This is a test string from Andrew\".split(), key=str.casefold)\n" "['a', 'Andrew', 'from', 'is', 'string', 'test', 'This']" msgstr "" +">>> sorted(\"This is a test string from Andrew\".split(), key=str.casefold)\n" +"['a', 'Andrew', 'from', 'is', 'string', 'test', 'This']" #: ../../howto/sorting.rst:61 msgid "" @@ -156,6 +159,13 @@ msgid "" ">>> sorted(student_tuples, key=lambda student: student[2]) # sort by age\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" msgstr "" +">>> student_tuples = [\n" +"... ('john', 'A', 15),\n" +"... ('jane', 'B', 12),\n" +"... ('dave', 'B', 10),\n" +"... ]\n" +">>> sorted(student_tuples, key=lambda student: student[2]) # 依照年齡排序\n" +"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" #: ../../howto/sorting.rst:79 msgid "" @@ -181,6 +191,22 @@ msgid "" "age\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" msgstr "" +">>> class Student:\n" +"... def __init__(self, name, grade, age):\n" +"... self.name = name\n" +"... self.grade = grade\n" +"... self.age = age\n" +"... def __repr__(self):\n" +"... return repr((self.name, self.grade, self.age))\n" +"\n" +">>> student_objects = [\n" +"... Student('john', 'A', 15),\n" +"... Student('jane', 'B', 12),\n" +"... Student('dave', 'B', 10),\n" +"... ]\n" +">>> sorted(student_objects, key=lambda student: student.age) # 依照年齡排" +"序\n" +"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" #: ../../howto/sorting.rst:99 msgid "" @@ -188,10 +214,12 @@ msgid "" "or they can be instances of :class:`~dataclasses.dataclass` or a :term:" "`named tuple`." msgstr "" +"具有命名屬性的物件可以如上方的方式使用一個常規的類別建立,或是他們可以是 :" +"class:`~dataclasses.dataclass` 的實例或是一個 :term:`named tuple`。" #: ../../howto/sorting.rst:104 msgid "Operator Module Functions and Partial Function Evaluation" -msgstr "" +msgstr "Operator 模組函式以及部份函式 (partial function) 評估" #: ../../howto/sorting.rst:106 msgid "" @@ -255,6 +283,9 @@ msgid "" "`_ of a multi-argument function making " "it suitable for use as a key-function." msgstr "" +"模組 :mod:`functools` 提供了另一個製作鍵函式的好用工具。:func:`~functools." +"partial` 函式可以減少多引數函式的\\ `引數數目 `_,使其更適合作為鍵函式使用。" #: ../../howto/sorting.rst:139 msgid "" @@ -357,6 +388,10 @@ msgid "" "primary key, descending\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" msgstr "" +">>> s = sorted(student_objects, key=attrgetter('age')) # 依照次要鍵排序\n" +">>> sorted(s, key=attrgetter('grade'), reverse=True) # 現在依照主要鍵降" +"冪排序\n" +"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" #: ../../howto/sorting.rst:193 msgid "" @@ -430,6 +465,11 @@ msgid "" ">>> [student for grade, i, student in decorated] # undecorate\n" "[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]" msgstr "" +">>> decorated = [(student.grade, i, student) for i, student in " +"enumerate(student_objects)]\n" +">>> decorated.sort()\n" +">>> [student for grade, i, student in decorated] # 移除裝飾\n" +"[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]" #: ../../howto/sorting.rst:231 msgid "" @@ -526,7 +566,7 @@ msgstr "" #: ../../howto/sorting.rst:273 msgid "sorted(words, key=cmp_to_key(strcoll)) # locale-aware sort order" -msgstr "" +msgstr "sorted(words, key=cmp_to_key(strcoll)) # 理解語系的排序順序" #: ../../howto/sorting.rst:276 msgid "Odds and Ends" @@ -599,6 +639,10 @@ msgid "" "six comparison methods be implemented. The :func:`~functools.total_ordering` " "decorator is provided to make that task easier." msgstr "" +"然而,請注意,當 :meth:`~object.__lt__` 沒有被實作時,``<`` 可以回退 (fall " +"back) 使用 :meth:`~object.__gt__`\\ (有關技術上的細節資訊請看 :func:`object." +"__lt__` )。為了避免意外發生,:pep:`8` 建議所有六種的比較函式都需要被實作。裝" +"飾器 :func:`~functools.total_ordering` 被提供用來讓任務更為簡單。" #: ../../howto/sorting.rst:314 msgid "" @@ -624,13 +668,15 @@ msgstr "" #: ../../howto/sorting.rst:327 msgid "Partial Sorts" -msgstr "" +msgstr "部份排序" #: ../../howto/sorting.rst:329 msgid "" "Some applications require only some of the data to be ordered. The standard " "library provides several tools that do less work than a full sort:" msgstr "" +"有些應用程式只需要排序部份的資料。基礎函式庫提供相較做完整排序更為輕鬆的多項" +"工具:" #: ../../howto/sorting.rst:332 msgid "" @@ -638,6 +684,8 @@ msgid "" "respectively. These functions make a single pass over the input data and " "require almost no auxiliary memory." msgstr "" +":func:`min` 以及 :func:`max` 會分別回傳最小值及最大值。這些函式會將輸入資料進" +"行一次傳遞且幾乎無須輔助記憶體。" #: ../../howto/sorting.rst:336 msgid "" @@ -647,6 +695,9 @@ msgid "" "that are small relative to the number of inputs, these functions make far " "fewer comparisons than a full sort." msgstr "" +":func:`heapq.nsmallest` 以及 :func:`heapq.nlargest` 會分別回傳 *n* 個最小值及" +"最大值。這些函式會將資料進行一次傳遞且一次只會保留 *n* 個元素在記憶體中。對於" +"相對於輸入數量較小的 *n* 個值,這些函式進行的比較比完整排序要少得多。" #: ../../howto/sorting.rst:342 msgid "" @@ -655,3 +706,6 @@ msgid "" "position ``0``. These functions are suitable for implementing priority " "queues which are commonly used for task scheduling." msgstr "" +":func:`heapq.heappush` 和 :func:`heapq.heappop` 會建立並維持一個部份排序的資" +"料排列,將最小的元素保持在位置 ``0``。這些函式適合用來實作常用於任務排程的優" +"先佇列。" diff --git a/howto/timerfd.po b/howto/timerfd.po new file mode 100644 index 0000000000..31cd12792d --- /dev/null +++ b/howto/timerfd.po @@ -0,0 +1,488 @@ +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# Translators: +# GitHub Copilot, 2025 +# +msgid "" +msgstr "" +"Project-Id-Version: Python 3.13\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"PO-Revision-Date: 2024-12-19 10:00+0000\n" +"Last-Translator: GitHub Copilot\n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" +"Language: zh_TW\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../../howto/timerfd.rst:5 +msgid "timer file descriptor HOWTO" +msgstr "計時器檔案描述器 (timerfd) 指南" + +#: ../../howto/timerfd.rst:0 +msgid "Release" +msgstr "發佈版本" + +#: ../../howto/timerfd.rst:7 +msgid "1.13" +msgstr "1.13" + +#: ../../howto/timerfd.rst:9 +msgid "" +"This HOWTO discusses Python's support for the linux timer file descriptor." +msgstr "此篇指南探討 Python 對 Linux 計時器檔案描述器的支援。" + +#: ../../howto/timerfd.rst:13 +msgid "Examples" +msgstr "範例" + +#: ../../howto/timerfd.rst:15 +msgid "" +"The following example shows how to use a timer file descriptor to execute a " +"function twice a second:" +msgstr "以下範例顯示如何使用計時器檔案描述器來每秒執行函式兩次:" + +#: ../../howto/timerfd.rst:18 +msgid "" +"# Practical scripts should use really use a non-blocking timer,\n" +"# we use a blocking timer here for simplicity.\n" +"import os, time\n" +"\n" +"# Create the timer file descriptor\n" +"fd = os.timerfd_create(time.CLOCK_REALTIME)\n" +"\n" +"# Start the timer in 1 second, with an interval of half a second\n" +"os.timerfd_settime(fd, initial=1, interval=0.5)\n" +"\n" +"try:\n" +" # Process timer events four times.\n" +" for _ in range(4):\n" +" # read() will block until the timer expires\n" +" _ = os.read(fd, 8)\n" +" print(\"Timer expired\")\n" +"finally:\n" +" # Remember to close the timer file descriptor!\n" +" os.close(fd)" +msgstr "" +"# 實際腳本應該使用非阻塞計時器,\n" +"# 在這裡為了簡單起見我們使用阻塞計時器。\n" +"import os, time\n" +"\n" +"# 建立計時器檔案描述器\n" +"fd = os.timerfd_create(time.CLOCK_REALTIME)\n" +"\n" +"# 在 1 秒後開始計時器,間隔為半秒\n" +"os.timerfd_settime(fd, initial=1, interval=0.5)\n" +"\n" +"try:\n" +" # 處理計時器事件四次。\n" +" for _ in range(4):\n" +" # read() 會阻塞直到計時器到期\n" +" _ = os.read(fd, 8)\n" +" print(\"Timer expired\")\n" +"finally:\n" +" # 記得關閉計時器檔案描述器!\n" +" os.close(fd)" + +#: ../../howto/timerfd.rst:40 +msgid "" +"To avoid the precision loss caused by the :class:`float` type, timer file " +"descriptors allow specifying initial expiration and interval in integer " +"nanoseconds with ``_ns`` variants of the functions." +msgstr "" +"為了避免由 :class:`float` 型別造成的精度損失,計時器檔案描述器允許使用函式的 " +"``_ns`` 變體以整數奈秒為單位指定初始到期時間和間隔。" + +#: ../../howto/timerfd.rst:44 +msgid "" +"This example shows how :func:`~select.epoll` can be used with timer file " +"descriptors to wait until the file descriptor is ready for reading:" +msgstr "" +"此範例展示如何將 :func:`~select.epoll` 與計時器檔案描述器一起使用," +"用於等待檔案描述器直到它準備好讀取:" + +#: ../../howto/timerfd.rst:47 +msgid "" +"import os, time, select, socket, sys\n" +"\n" +"# Create an epoll object\n" +"ep = select.epoll()\n" +"\n" +"# In this example, use loopback address to send \"stop\" command to the " +"server.\n" +"#\n" +"# $ telnet 127.0.0.1 1234\n" +"# Trying 127.0.0.1...\n" +"# Connected to 127.0.0.1.\n" +"# Escape character is '^]'.\n" +"# stop\n" +"# Connection closed by foreign host.\n" +"#\n" +"sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n" +"sock.bind((\"127.0.0.1\", 1234))\n" +"sock.setblocking(False)\n" +"sock.listen(1)\n" +"ep.register(sock, select.EPOLLIN)\n" +"\n" +"# Create timer file descriptors in non-blocking mode.\n" +"num = 3\n" +"fds = []\n" +"for _ in range(num):\n" +" fd = os.timerfd_create(time.CLOCK_REALTIME, flags=os.TFD_NONBLOCK)\n" +" fds.append(fd)\n" +" # Register the timer file descriptor for read events\n" +" ep.register(fd, select.EPOLLIN)\n" +"\n" +"# Start the timer with os.timerfd_settime_ns() in nanoseconds.\n" +"# Timer 1 fires every 0.25 seconds; timer 2 every 0.5 seconds; etc\n" +"for i, fd in enumerate(fds, start=1):\n" +" one_sec_in_nsec = 10**9\n" +" i = i * one_sec_in_nsec\n" +" os.timerfd_settime_ns(fd, initial=i//4, interval=i//4)\n" +"\n" +"timeout = 3\n" +"try:\n" +" conn = None\n" +" is_active = True\n" +" while is_active:\n" +" # Wait for the timer to expire for 3 seconds.\n" +" # epoll.poll() returns a list of (fd, event) pairs.\n" +" # fd is a file descriptor.\n" +" # sock and conn[=returned value of socket.accept()] are socket " +"objects, not file descriptors.\n" +" # So use sock.fileno() and conn.fileno() to get the file " +"descriptors.\n" +" events = ep.poll(timeout)\n" +"\n" +" # If more than one timer file descriptors are ready for reading at " +"once,\n" +" # epoll.poll() returns a list of (fd, event) pairs.\n" +" #\n" +" # In this example settings,\n" +" # 1st timer fires every 0.25 seconds in 0.25 seconds. (0.25, 0.5, " +"0.75, 1.0, ...)\n" +" # 2nd timer every 0.5 seconds in 0.5 seconds. (0.5, 1.0, 1.5, " +"2.0, ...)\n" +" # 3rd timer every 0.75 seconds in 0.75 seconds. (0.75, 1.5, 2.25, " +"3.0, ...)\n" +" #\n" +" # In 0.25 seconds, only 1st timer fires.\n" +" # In 0.5 seconds, 1st timer and 2nd timer fires at once.\n" +" # In 0.75 seconds, 1st timer and 3rd timer fires at once.\n" +" # In 1.5 seconds, 1st timer, 2nd timer and 3rd timer fires at " +"once.\n" +" #\n" +" # If a timer file descriptor is signaled more than once since\n" +" # the last os.read() call, os.read() returns the number of signaled\n" +" # as host order of class bytes.\n" +" print(f\"Signaled events={events}\")\n" +" for fd, event in events:\n" +" if event & select.EPOLLIN:\n" +" if fd == sock.fileno():\n" +" # Check if there is a connection request.\n" +" print(f\"Accepting connection {fd}\")\n" +" conn, addr = sock.accept()\n" +" conn.setblocking(False)\n" +" print(f\"Accepted connection {conn} from {addr}\")\n" +" ep.register(conn, select.EPOLLIN)\n" +" elif conn and fd == conn.fileno():\n" +" # Check if there is data to read.\n" +" print(f\"Reading data {fd}\")\n" +" data = conn.recv(1024)\n" +" if data:\n" +" # You should catch UnicodeDecodeError exception for " +"safety.\n" +" cmd = data.decode()\n" +" if cmd.startswith(\"stop\"):\n" +" print(f\"Stopping server\")\n" +" is_active = False\n" +" else:\n" +" print(f\"Unknown command: {cmd}\")\n" +" else:\n" +" # No more data, close connection\n" +" print(f\"Closing connection {fd}\")\n" +" ep.unregister(conn)\n" +" conn.close()\n" +" conn = None\n" +" elif fd in fds:\n" +" print(f\"Reading timer {fd}\")\n" +" count = int.from_bytes(os.read(fd, 8), byteorder=sys." +"byteorder)\n" +" print(f\"Timer {fds.index(fd) + 1} expired {count} " +"times\")\n" +" else:\n" +" print(f\"Unknown file descriptor {fd}\")\n" +"finally:\n" +" for fd in fds:\n" +" ep.unregister(fd)\n" +" os.close(fd)\n" +" ep.close()" +msgstr "" +"import os, time, select, socket, sys\n" +"\n" +"# 建立 epoll 物件\n" +"ep = select.epoll()\n" +"\n" +"# 在此範例中,使用回送位址 (loopback address) 向伺服器發送 \"stop\" 命令。\n" +"#\n" +"# $ telnet 127.0.0.1 1234\n" +"# Trying 127.0.0.1...\n" +"# Connected to 127.0.0.1.\n" +"# Escape character is '^]'.\n" +"# stop\n" +"# Connection closed by foreign host.\n" +"#\n" +"sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n" +"sock.bind((\"127.0.0.1\", 1234))\n" +"sock.setblocking(False)\n" +"sock.listen(1)\n" +"ep.register(sock, select.EPOLLIN)\n" +"\n" +"# 以非阻塞模式建立計時器檔案描述器。\n" +"num = 3\n" +"fds = []\n" +"for _ in range(num):\n" +" fd = os.timerfd_create(time.CLOCK_REALTIME, flags=os.TFD_NONBLOCK)\n" +" fds.append(fd)\n" +" # 為讀取事件註冊計時器檔案描述器\n" +" ep.register(fd, select.EPOLLIN)\n" +"\n" +"# 使用 os.timerfd_settime_ns() 以奈秒為單位啟動計時器。\n" +"# 計時器 1 每 0.25 秒觸發一次;計時器 2 每 0.5 秒觸發一次;以此類推\n" +"for i, fd in enumerate(fds, start=1):\n" +" one_sec_in_nsec = 10**9\n" +" i = i * one_sec_in_nsec\n" +" os.timerfd_settime_ns(fd, initial=i//4, interval=i//4)\n" +"\n" +"timeout = 3\n" +"try:\n" +" conn = None\n" +" is_active = True\n" +" while is_active:\n" +" # 等待計時器在 3 秒內到期。\n" +" # epoll.poll() 回傳一個 (fd, event) 配對的串列。\n" +" # fd 是檔案描述器。\n" +" # sock 和 conn[=socket.accept() 的回傳值] 是 socket 物件,不是檔案描述器。\n" +" # 所以要使用 sock.fileno() 和 conn.fileno() 來取得檔案描述器。\n" +" events = ep.poll(timeout)\n" +"\n" +" # 如果同時有多個計時器檔案描述器準備好讀取,\n" +" # epoll.poll() 會回傳一個 (fd, event) 配對的串列。\n" +" #\n" +" # 在此範例設定中,\n" +" # 第 1 個計時器在 0.25 秒內每 0.25 秒觸發一次。(0.25, 0.5, 0.75, 1.0, ...)\n" +" # 第 2 個計時器在 0.5 秒內每 0.5 秒觸發一次。(0.5, 1.0, 1.5, 2.0, ...)\n" +" # 第 3 個計時器在 0.75 秒內每 0.75 秒觸發一次。(0.75, 1.5, 2.25, 3.0, ...)\n" +" #\n" +" # 在 0.25 秒時,只有第 1 個計時器觸發。\n" +" # 在 0.5 秒時,第 1 個計時器和第 2 個計時器同時觸發。\n" +" # 在 0.75 秒時,第 1 個計時器和第 3 個計時器同時觸發。\n" +" # 在 1.5 秒時,第 1、2、3 個計時器同時觸發。\n" +" #\n" +" # 如果計時器檔案描述器自上次 os.read() 呼叫以來被觸發多次,\n" +" # os.read() 會以主機類別位元組順序回傳被觸發次數。\n" +" print(f\"Signaled events={events}\")\n" +" for fd, event in events:\n" +" if event & select.EPOLLIN:\n" +" if fd == sock.fileno():\n" +" # 檢查是否有連線請求。\n" +" print(f\"Accepting connection {fd}\")\n" +" conn, addr = sock.accept()\n" +" conn.setblocking(False)\n" +" print(f\"Accepted connection {conn} from {addr}\")\n" +" ep.register(conn, select.EPOLLIN)\n" +" elif conn and fd == conn.fileno():\n" +" # 檢查是否有資料要讀取。\n" +" print(f\"Reading data {fd}\")\n" +" data = conn.recv(1024)\n" +" if data:\n" +" # 為了安全起見,你應該捕獲 UnicodeDecodeError 例外。\n" +" cmd = data.decode()\n" +" if cmd.startswith(\"stop\"):\n" +" print(f\"Stopping server\")\n" +" is_active = False\n" +" else:\n" +" print(f\"Unknown command: {cmd}\")\n" +" else:\n" +" # 沒有更多資料,關閉連線\n" +" print(f\"Closing connection {fd}\")\n" +" ep.unregister(conn)\n" +" conn.close()\n" +" conn = None\n" +" elif fd in fds:\n" +" print(f\"Reading timer {fd}\")\n" +" count = int.from_bytes(os.read(fd, 8), byteorder=sys." +"byteorder)\n" +" print(f\"Timer {fds.index(fd) + 1} expired {count} " +"times\")\n" +" else:\n" +" print(f\"Unknown file descriptor {fd}\")\n" +"finally:\n" +" for fd in fds:\n" +" ep.unregister(fd)\n" +" os.close(fd)\n" +" ep.close()" + +#: ../../howto/timerfd.rst:153 +msgid "" +"This example shows how :func:`~select.select` can be used with timer file " +"descriptors to wait until the file descriptor is ready for reading:" +msgstr "" +"此範例展示如何將 :func:`~select.select` 與計時器檔案描述器一起使用," +"用於等待檔案描述器直到它準備好讀取:" + +#: ../../howto/timerfd.rst:156 +msgid "" +"import os, time, select, socket, sys\n" +"\n" +"# In this example, use loopback address to send \"stop\" command to the " +"server.\n" +"#\n" +"# $ telnet 127.0.0.1 1234\n" +"# Trying 127.0.0.1...\n" +"# Connected to 127.0.0.1.\n" +"# Escape character is '^]'.\n" +"# stop\n" +"# Connection closed by foreign host.\n" +"#\n" +"sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n" +"sock.bind((\"127.0.0.1\", 1234))\n" +"sock.setblocking(False)\n" +"sock.listen(1)\n" +"\n" +"# Create timer file descriptors in non-blocking mode.\n" +"num = 3\n" +"fds = [os.timerfd_create(time.CLOCK_REALTIME, flags=os.TFD_NONBLOCK)\n" +" for _ in range(num)]\n" +"select_fds = fds + [sock]\n" +"\n" +"# Start the timers with os.timerfd_settime() in seconds.\n" +"# Timer 1 fires every 0.25 seconds; timer 2 every 0.5 seconds; etc\n" +"for i, fd in enumerate(fds, start=1):\n" +" os.timerfd_settime(fd, initial=i/4, interval=i/4)\n" +"\n" +"timeout = 3\n" +"try:\n" +" conn = None\n" +" is_active = True\n" +" while is_active:\n" +" # Wait for the timer to expire for 3 seconds.\n" +" # select.select() returns a list of file descriptors or objects.\n" +" rfd, wfd, xfd = select.select(select_fds, select_fds, select_fds, " +"timeout)\n" +" for fd in rfd:\n" +" if fd == sock:\n" +" # Check if there is a connection request.\n" +" print(f\"Accepting connection {fd}\")\n" +" conn, addr = sock.accept()\n" +" conn.setblocking(False)\n" +" print(f\"Accepted connection {conn} from {addr}\")\n" +" select_fds.append(conn)\n" +" elif conn and fd == conn:\n" +" # Check if there is data to read.\n" +" print(f\"Reading data {fd}\")\n" +" data = conn.recv(1024)\n" +" if data:\n" +" # You should catch UnicodeDecodeError exception for " +"safety.\n" +" cmd = data.decode()\n" +" if cmd.startswith(\"stop\"):\n" +" print(f\"Stopping server\")\n" +" is_active = False\n" +" else:\n" +" print(f\"Unknown command: {cmd}\")\n" +" else:\n" +" # No more data, close connection\n" +" print(f\"Closing connection {fd}\")\n" +" select_fds.remove(conn)\n" +" conn.close()\n" +" conn = None\n" +" elif fd in fds:\n" +" print(f\"Reading timer {fd}\")\n" +" count = int.from_bytes(os.read(fd, 8), byteorder=sys." +"byteorder)\n" +" print(f\"Timer {fds.index(fd) + 1} expired {count} times\")\n" +" else:\n" +" print(f\"Unknown file descriptor {fd}\")\n" +"finally:\n" +" for fd in fds:\n" +" os.close(fd)\n" +" sock.close()\n" +" sock = None" +msgstr "" +"import os, time, select, socket, sys\n" +"\n" +"# 在此範例中,使用回送位址向伺服器發送 \"stop\" 命令。\n" +"#\n" +"# $ telnet 127.0.0.1 1234\n" +"# Trying 127.0.0.1...\n" +"# Connected to 127.0.0.1.\n" +"# Escape character is '^]'.\n" +"# stop\n" +"# Connection closed by foreign host.\n" +"#\n" +"sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n" +"sock.bind((\"127.0.0.1\", 1234))\n" +"sock.setblocking(False)\n" +"sock.listen(1)\n" +"\n" +"# 以非阻塞模式建立計時器檔案描述器。\n" +"num = 3\n" +"fds = [os.timerfd_create(time.CLOCK_REALTIME, flags=os.TFD_NONBLOCK)\n" +" for _ in range(num)]\n" +"select_fds = fds + [sock]\n" +"\n" +"# 使用 os.timerfd_settime() 以秒為單位啟動計時器。\n" +"# 計時器 1 每 0.25 秒觸發一次;計時器 2 每 0.5 秒觸發一次;以此類推\n" +"for i, fd in enumerate(fds, start=1):\n" +" os.timerfd_settime(fd, initial=i/4, interval=i/4)\n" +"\n" +"timeout = 3\n" +"try:\n" +" conn = None\n" +" is_active = True\n" +" while is_active:\n" +" # 等待計時器在 3 秒內到期。\n" +" # select.select() 回傳檔案描述器或物件的串列。\n" +" rfd, wfd, xfd = select.select(select_fds, select_fds, select_fds, " +"timeout)\n" +" for fd in rfd:\n" +" if fd == sock:\n" +" # 檢查是否有連線請求。\n" +" print(f\"Accepting connection {fd}\")\n" +" conn, addr = sock.accept()\n" +" conn.setblocking(False)\n" +" print(f\"Accepted connection {conn} from {addr}\")\n" +" select_fds.append(conn)\n" +" elif conn and fd == conn:\n" +" # 檢查是否有資料要讀取。\n" +" print(f\"Reading data {fd}\")\n" +" data = conn.recv(1024)\n" +" if data:\n" +" # 為了安全起見,你應該捕獲 UnicodeDecodeError 例外。\n" +" cmd = data.decode()\n" +" if cmd.startswith(\"stop\"):\n" +" print(f\"Stopping server\")\n" +" is_active = False\n" +" else:\n" +" print(f\"Unknown command: {cmd}\")\n" +" else:\n" +" # 沒有更多資料,關閉連線\n" +" print(f\"Closing connection {fd}\")\n" +" select_fds.remove(conn)\n" +" conn.close()\n" +" conn = None\n" +" elif fd in fds:\n" +" print(f\"Reading timer {fd}\")\n" +" count = int.from_bytes(os.read(fd, 8), byteorder=sys." +"byteorder)\n" +" print(f\"Timer {fds.index(fd) + 1} expired {count} times\")\n" +" else:\n" +" print(f\"Unknown file descriptor {fd}\")\n" +"finally:\n" +" for fd in fds:\n" +" os.close(fd)\n" +" sock.close()\n" +" sock = None" diff --git a/howto/unicode.po b/howto/unicode.po index eaeca2e421..66eab41171 100644 --- a/howto/unicode.po +++ b/howto/unicode.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-02-19 00:13+0000\n" "PO-Revision-Date: 2018-05-23 14:37+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -79,10 +79,10 @@ msgstr "" msgid "" "The Unicode standard describes how characters are represented by **code " "points**. A code point value is an integer in the range 0 to 0x10FFFF " -"(about 1.1 million values, the `actual number assigned `_ 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)." +"(about 1.1 million values, the `actual number assigned `_ 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)." msgstr "" #: ../../howto/unicode.rst:50 @@ -301,8 +301,8 @@ msgstr "" #: ../../howto/unicode.rst:173 msgid "" -"Another `good introductory article `_ was " "written by Joel Spolsky. If this introduction didn't make things clear to " "you, you should try reading this alternate article before continuing." @@ -406,7 +406,7 @@ msgstr "" #: ../../howto/unicode.rst:236 msgid "" -">>> b'\\x80abc'.decode(\"utf-8\", \"strict\") \n" +">>> b'\\x80abc'.decode(\"utf-8\", \"strict\")\n" "Traceback (most recent call last):\n" " ...\n" "UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0:\n" @@ -418,7 +418,7 @@ msgid "" ">>> b'\\x80abc'.decode(\"utf-8\", \"ignore\")\n" "'abc'" msgstr "" -">>> b'\\x80abc'.decode(\"utf-8\", \"strict\") \n" +">>> b'\\x80abc'.decode(\"utf-8\", \"strict\")\n" "Traceback (most recent call last):\n" " ...\n" "UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0:\n" @@ -473,10 +473,10 @@ msgstr "" #: ../../howto/unicode.rst:272 msgid "" -"The *errors* parameter is the same as the parameter of the :meth:`~bytes." -"decode` method but supports a few more possible handlers. As well as " -"``'strict'``, ``'ignore'``, and ``'replace'`` (which in this case inserts a " -"question mark instead of the unencodable character), there is also " +"The *errors* parameter is the same as the parameter of " +"the :meth:`~bytes.decode` method but supports a few more possible handlers. " +"As well as ``'strict'``, ``'ignore'``, and ``'replace'`` (which in this case " +"inserts a question mark instead of the unencodable character), there is also " "``'xmlcharrefreplace'`` (inserts an XML character reference), " "``backslashreplace`` (inserts a ``\\uNNNN`` escape sequence) and " "``namereplace`` (inserts a ``\\N{...}`` escape sequence)." @@ -491,7 +491,7 @@ msgid "" ">>> u = chr(40960) + 'abcd' + chr(1972)\n" ">>> u.encode('utf-8')\n" "b'\\xea\\x80\\x80abcd\\xde\\xb4'\n" -">>> u.encode('ascii') \n" +">>> u.encode('ascii')\n" "Traceback (most recent call last):\n" " ...\n" "UnicodeEncodeError: 'ascii' codec can't encode character '\\ua000' in\n" @@ -510,7 +510,7 @@ msgstr "" ">>> u = chr(40960) + 'abcd' + chr(1972)\n" ">>> u.encode('utf-8')\n" "b'\\xea\\x80\\x80abcd\\xde\\xb4'\n" -">>> u.encode('ascii') \n" +">>> u.encode('ascii')\n" "Traceback (most recent call last):\n" " ...\n" "UnicodeEncodeError: 'ascii' codec can't encode character '\\ua000' in\n" @@ -674,9 +674,9 @@ msgid "" "subcategories. To take the codes from the above output, ``'Ll'`` means " "'Letter, lowercase', ``'No'`` means \"Number, other\", ``'Mn'`` is \"Mark, " "nonspacing\", and ``'So'`` is \"Symbol, other\". See `the General Category " -"Values section of the Unicode Character Database documentation `_ for a list of category " -"codes." +"Values section of the Unicode Character Database documentation `_ for a list of " +"category codes." msgstr "" #: ../../howto/unicode.rst:402 @@ -714,12 +714,12 @@ msgstr "" #: ../../howto/unicode.rst:425 msgid "" -"A second tool is the :mod:`unicodedata` module's :func:`~unicodedata." -"normalize` function that converts strings to one of several normal forms, " -"where letters followed by a combining character are replaced with single " -"characters. :func:`~unicodedata.normalize` can be used to perform string " -"comparisons that won't falsely report inequality if two strings use " -"combining characters differently:" +"A second tool is the :mod:`unicodedata` " +"module's :func:`~unicodedata.normalize` function that converts strings to " +"one of several normal forms, where letters followed by a combining character " +"are replaced with single characters. :func:`~unicodedata.normalize` can be " +"used to perform string comparisons that won't falsely report inequality if " +"two strings use combining characters differently:" msgstr "" #: ../../howto/unicode.rst:434 @@ -863,8 +863,9 @@ msgstr "" #: ../../howto/unicode.rst:520 msgid "" -"`Processing Text Files in Python 3 `_, by Nick Coghlan." +"`Processing Text Files in Python 3 `_, " +"by Nick Coghlan." msgstr "" #: ../../howto/unicode.rst:521 @@ -875,8 +876,8 @@ msgstr "" #: ../../howto/unicode.rst:523 msgid "" -"The :class:`str` type is described in the Python library reference at :ref:" -"`textseq`." +"The :class:`str` type is described in the Python library reference " +"at :ref:`textseq`." msgstr "" #: ../../howto/unicode.rst:526 @@ -947,8 +948,8 @@ msgid "" "object that assumes the file's contents are in a specified encoding and " "accepts Unicode parameters for methods such as :meth:`~io.TextIOBase.read` " "and :meth:`~io.TextIOBase.write`. This works through :func:`open`\\'s " -"*encoding* and *errors* parameters which are interpreted just like those in :" -"meth:`str.encode` and :meth:`bytes.decode`." +"*encoding* and *errors* parameters which are interpreted just like those " +"in :meth:`str.encode` and :meth:`bytes.decode`." msgstr "" #: ../../howto/unicode.rst:574 @@ -1217,8 +1218,8 @@ msgstr "" #: ../../howto/unicode.rst:737 msgid "" -"One section of `Mastering Python 3 Input/Output `_, a PyCon 2010 talk by David " +"One section of `Mastering Python 3 Input/Output `_, a PyCon 2010 talk by David " "Beazley, discusses text processing and binary data handling." msgstr "" diff --git a/howto/urllib2.po b/howto/urllib2.po index a625f8a466..c712f8230a 100644 --- a/howto/urllib2.po +++ b/howto/urllib2.po @@ -5,9 +5,9 @@ # Phate , 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2022-06-27 09:36+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -63,7 +63,7 @@ msgid "" "These are provided by objects called handlers and openers." msgstr "" "**urllib.request** 是一個用來從 URLs (Uniform Resource Locators) 取得資料的" -"Python模組。它提供一個了非常簡單的介面能接受多種不同的協議,*urlopen* 函式。" +"Python模組。它提供一個了非常簡單的介面能接受多種不同的協定,*urlopen* 函式。" "也提供了較複雜的介面用於處理一些常見的狀況,例如:基本的 authentication、" "cookies、proxies 等等,這些都可以由 handler 或 opener 物件操作。" @@ -88,7 +88,7 @@ msgid "" "is supplementary to them." msgstr "" "一般情形下 *urlopen* 是非常容易使用的,但當你遇到錯誤或者較複雜的情況下,你可" -"能需要對超文本協議 HyperText Transfer Protocol 有一定的了解。最完整且具參考價" +"能需要對超文本協定 (HyperText Transfer Protocol) 有一定的了解。最完整且具參考價" "值的是 :rfc:`2616`,不過它是一份技術文件並不容易閱讀,以下的教學會提供足夠的 " "HTTP 知識來幫助你使用 *urllib*。這份教學並非要取代 :mod:`urllib.request` 這份" "文件,你還是會需要它。" @@ -274,7 +274,7 @@ msgid "" ">>> data['location'] = 'Northampton'\n" ">>> data['language'] = 'Python'\n" ">>> url_values = urllib.parse.urlencode(data)\n" -">>> print(url_values) # The order may differ from below. \n" +">>> print(url_values) # The order may differ from below.\n" "name=Somebody+Here&language=Python&location=Northampton\n" ">>> url = 'http://www.example.com/example.cgi'\n" ">>> full_url = url + '?' + url_values\n" @@ -287,7 +287,7 @@ msgstr "" ">>> data['location'] = 'Northampton'\n" ">>> data['language'] = 'Python'\n" ">>> url_values = urllib.parse.urlencode(data)\n" -">>> print(url_values) # The order may differ from below. \n" +">>> print(url_values) # The order may differ from below.\n" "name=Somebody+Here&language=Python&location=Northampton\n" ">>> url = 'http://www.example.com/example.cgi'\n" ">>> full_url = url + '?' + url_values\n" @@ -405,14 +405,14 @@ msgid "" ">>> req = urllib.request.Request('http://www.pretend_server.org')\n" ">>> try: urllib.request.urlopen(req)\n" "... except urllib.error.URLError as e:\n" -"... print(e.reason) \n" +"... print(e.reason)\n" "...\n" "(4, 'getaddrinfo failed')" msgstr "" ">>> req = urllib.request.Request('http://www.pretend_server.org')\n" ">>> try: urllib.request.urlopen(req)\n" "... except urllib.error.URLError as e:\n" -"... print(e.reason) \n" +"... print(e.reason)\n" "...\n" "(4, 'getaddrinfo failed')" @@ -457,82 +457,37 @@ msgstr "" #: ../../howto/urllib2.rst:247 msgid "" ":attr:`http.server.BaseHTTPRequestHandler.responses` is a useful dictionary " -"of response codes in that shows all the response codes used by :rfc:`2616`. " -"The dictionary is reproduced here for convenience ::" +"of response codes that shows all the response codes used by :rfc:`2616`. An " +"excerpt from the dictionary is shown below ::" msgstr "" #: ../../howto/urllib2.rst:251 msgid "" -"# Table mapping response codes to messages; entries have the\n" -"# form {code: (shortmessage, longmessage)}.\n" "responses = {\n" -" 100: ('Continue', 'Request received, please continue'),\n" -" 101: ('Switching Protocols',\n" -" 'Switching to new protocol; obey Upgrade header'),\n" -"\n" -" 200: ('OK', 'Request fulfilled, document follows'),\n" -" 201: ('Created', 'Document created, URL follows'),\n" -" 202: ('Accepted',\n" -" 'Request accepted, processing continues off-line'),\n" -" 203: ('Non-Authoritative Information', 'Request fulfilled from cache'),\n" -" 204: ('No Content', 'Request fulfilled, nothing follows'),\n" -" 205: ('Reset Content', 'Clear input form for further input.'),\n" -" 206: ('Partial Content', 'Partial content follows.'),\n" -"\n" -" 300: ('Multiple Choices',\n" -" 'Object has several resources -- see URI list'),\n" -" 301: ('Moved Permanently', 'Object moved permanently -- see URI list'),\n" -" 302: ('Found', 'Object moved temporarily -- see URI list'),\n" -" 303: ('See Other', 'Object moved -- see Method and URL list'),\n" -" 304: ('Not Modified',\n" -" 'Document has not changed since given time'),\n" -" 305: ('Use Proxy',\n" -" 'You must use proxy specified in Location to access this '\n" -" 'resource.'),\n" -" 307: ('Temporary Redirect',\n" -" 'Object moved temporarily -- see URI list'),\n" -"\n" -" 400: ('Bad Request',\n" -" 'Bad request syntax or unsupported method'),\n" -" 401: ('Unauthorized',\n" -" 'No permission -- see authorization schemes'),\n" -" 402: ('Payment Required',\n" -" 'No payment -- see charging schemes'),\n" -" 403: ('Forbidden',\n" -" 'Request forbidden -- authorization will not help'),\n" -" 404: ('Not Found', 'Nothing matches the given URI'),\n" -" 405: ('Method Not Allowed',\n" -" 'Specified method is invalid for this server.'),\n" -" 406: ('Not Acceptable', 'URI not available in preferred format.'),\n" -" 407: ('Proxy Authentication Required', 'You must authenticate with '\n" -" 'this proxy before proceeding.'),\n" -" 408: ('Request Timeout', 'Request timed out; try again later.'),\n" -" 409: ('Conflict', 'Request conflict.'),\n" -" 410: ('Gone',\n" -" 'URI no longer exists and has been permanently removed.'),\n" -" 411: ('Length Required', 'Client must specify Content-Length.'),\n" -" 412: ('Precondition Failed', 'Precondition in headers is false.'),\n" -" 413: ('Request Entity Too Large', 'Entity is too large.'),\n" -" 414: ('Request-URI Too Long', 'URI is too long.'),\n" -" 415: ('Unsupported Media Type', 'Entity body in unsupported format.'),\n" -" 416: ('Requested Range Not Satisfiable',\n" -" 'Cannot satisfy request range.'),\n" -" 417: ('Expectation Failed',\n" -" 'Expect condition could not be satisfied.'),\n" -"\n" -" 500: ('Internal Server Error', 'Server got itself in trouble'),\n" -" 501: ('Not Implemented',\n" -" 'Server does not support this operation'),\n" -" 502: ('Bad Gateway', 'Invalid responses from another server/proxy.'),\n" -" 503: ('Service Unavailable',\n" -" 'The server cannot process the request due to a high load'),\n" -" 504: ('Gateway Timeout',\n" -" 'The gateway server did not receive a timely response'),\n" -" 505: ('HTTP Version Not Supported', 'Cannot fulfill request.'),\n" +" ...\n" +" : ('OK', 'Request fulfilled, document follows'),\n" +" ...\n" +" : ('Forbidden',\n" +" 'Request forbidden -- authorization will " +"'\n" +" 'not help'),\n" +" : ('Not Found',\n" +" 'Nothing matches the given URI'),\n" +" ...\n" +" : (\"I'm a Teapot\",\n" +" 'Server refuses to brew coffee because " +"'\n" +" 'it is a teapot'),\n" +" ...\n" +" : ('Service Unavailable',\n" +" 'The server cannot process the " +"'\n" +" 'request due to a high load'),\n" +" ...\n" " }" msgstr "" -#: ../../howto/urllib2.rst:319 +#: ../../howto/urllib2.rst:271 msgid "" "When an error is raised the server responds by returning an HTTP error code " "*and* an error page. You can use the :exc:`~urllib.error.HTTPError` instance " @@ -541,14 +496,14 @@ msgid "" "``urllib.response`` module::" msgstr "" -#: ../../howto/urllib2.rst:324 +#: ../../howto/urllib2.rst:276 msgid "" ">>> req = urllib.request.Request('http://www.python.org/fish.html')\n" ">>> try:\n" "... urllib.request.urlopen(req)\n" "... except urllib.error.HTTPError as e:\n" "... print(e.code)\n" -"... print(e.read()) \n" +"... print(e.read())\n" "...\n" "404\n" "b'Page Not Found\\n\n" " ..." -#: ../../howto/urllib2.rst:339 +#: ../../howto/urllib2.rst:291 msgid "Wrapping it Up" msgstr "" -#: ../../howto/urllib2.rst:341 +#: ../../howto/urllib2.rst:293 msgid "" "So if you want to be prepared for :exc:`~urllib.error.HTTPError` *or* :exc:" "`~urllib.error.URLError` there are two basic approaches. I prefer the second " "approach." msgstr "" -#: ../../howto/urllib2.rst:345 +#: ../../howto/urllib2.rst:297 msgid "Number 1" msgstr "" -#: ../../howto/urllib2.rst:350 +#: ../../howto/urllib2.rst:302 msgid "" "from urllib.request import Request, urlopen\n" "from urllib.error import URLError, HTTPError\n" @@ -605,17 +560,17 @@ msgid "" " # everything is fine" msgstr "" -#: ../../howto/urllib2.rst:367 +#: ../../howto/urllib2.rst:319 msgid "" "The ``except HTTPError`` *must* come first, otherwise ``except URLError`` " "will *also* catch an :exc:`~urllib.error.HTTPError`." msgstr "" -#: ../../howto/urllib2.rst:371 +#: ../../howto/urllib2.rst:323 msgid "Number 2" msgstr "" -#: ../../howto/urllib2.rst:375 +#: ../../howto/urllib2.rst:327 msgid "" "from urllib.request import Request, urlopen\n" "from urllib.error import URLError\n" @@ -633,18 +588,18 @@ msgid "" " # everything is fine" msgstr "" -#: ../../howto/urllib2.rst:392 +#: ../../howto/urllib2.rst:344 msgid "info and geturl" msgstr "" -#: ../../howto/urllib2.rst:394 +#: ../../howto/urllib2.rst:346 msgid "" "The response returned by urlopen (or the :exc:`~urllib.error.HTTPError` " "instance) has two useful methods :meth:`!info` and :meth:`!geturl` and is " "defined in the module :mod:`urllib.response`." msgstr "" -#: ../../howto/urllib2.rst:398 +#: ../../howto/urllib2.rst:350 msgid "" "**geturl** - this returns the real URL of the page fetched. This is useful " "because ``urlopen`` (or the opener object used) may have followed a " @@ -652,14 +607,14 @@ msgid "" "requested." msgstr "" -#: ../../howto/urllib2.rst:402 +#: ../../howto/urllib2.rst:354 msgid "" "**info** - this returns a dictionary-like object that describes the page " "fetched, particularly the headers sent by the server. It is currently an :" "class:`http.client.HTTPMessage` instance." msgstr "" -#: ../../howto/urllib2.rst:406 +#: ../../howto/urllib2.rst:358 msgid "" "Typical headers include 'Content-length', 'Content-type', and so on. See the " "`Quick Reference to HTTP Headers `_ for a " @@ -667,11 +622,11 @@ msgid "" "use." msgstr "" -#: ../../howto/urllib2.rst:413 +#: ../../howto/urllib2.rst:365 msgid "Openers and Handlers" msgstr "" -#: ../../howto/urllib2.rst:415 +#: ../../howto/urllib2.rst:367 msgid "" "When you fetch a URL you use an opener (an instance of the perhaps " "confusingly named :class:`urllib.request.OpenerDirector`). Normally we have " @@ -682,20 +637,20 @@ msgid "" "HTTP redirections or HTTP cookies." msgstr "" -#: ../../howto/urllib2.rst:423 +#: ../../howto/urllib2.rst:375 msgid "" "You will want to create openers if you want to fetch URLs with specific " "handlers installed, for example to get an opener that handles cookies, or to " "get an opener that does not handle redirections." msgstr "" -#: ../../howto/urllib2.rst:427 +#: ../../howto/urllib2.rst:379 msgid "" "To create an opener, instantiate an ``OpenerDirector``, and then call ``." "add_handler(some_handler_instance)`` repeatedly." msgstr "" -#: ../../howto/urllib2.rst:430 +#: ../../howto/urllib2.rst:382 msgid "" "Alternatively, you can use ``build_opener``, which is a convenience function " "for creating opener objects with a single function call. ``build_opener`` " @@ -703,31 +658,31 @@ msgid "" "or override the default handlers." msgstr "" -#: ../../howto/urllib2.rst:435 +#: ../../howto/urllib2.rst:387 msgid "" "Other sorts of handlers you might want to can handle proxies, " "authentication, and other common but slightly specialised situations." msgstr "" -#: ../../howto/urllib2.rst:438 +#: ../../howto/urllib2.rst:390 msgid "" "``install_opener`` can be used to make an ``opener`` object the (global) " "default opener. This means that calls to ``urlopen`` will use the opener you " "have installed." msgstr "" -#: ../../howto/urllib2.rst:442 +#: ../../howto/urllib2.rst:394 msgid "" "Opener objects have an ``open`` method, which can be called directly to " "fetch urls in the same way as the ``urlopen`` function: there's no need to " "call ``install_opener``, except as a convenience." msgstr "" -#: ../../howto/urllib2.rst:448 +#: ../../howto/urllib2.rst:400 msgid "Basic Authentication" msgstr "" -#: ../../howto/urllib2.rst:450 +#: ../../howto/urllib2.rst:402 msgid "" "To illustrate creating and installing a handler we will use the " "``HTTPBasicAuthHandler``. For a more detailed discussion of this subject -- " @@ -736,7 +691,7 @@ msgid "" "www.voidspace.org.uk/python/articles/authentication.shtml>`__." msgstr "" -#: ../../howto/urllib2.rst:456 +#: ../../howto/urllib2.rst:408 msgid "" "When authentication is required, the server sends a header (as well as the " "401 error code) requesting authentication. This specifies the " @@ -744,15 +699,15 @@ msgid "" "Authenticate: SCHEME realm=\"REALM\"``." msgstr "" -#: ../../howto/urllib2.rst:461 +#: ../../howto/urllib2.rst:413 msgid "e.g." msgstr "例如" -#: ../../howto/urllib2.rst:463 +#: ../../howto/urllib2.rst:415 msgid "WWW-Authenticate: Basic realm=\"cPanel Users\"" msgstr "WWW-Authenticate: Basic realm=\"cPanel Users\"" -#: ../../howto/urllib2.rst:468 +#: ../../howto/urllib2.rst:420 msgid "" "The client should then retry the request with the appropriate name and " "password for the realm included as a header in the request. This is 'basic " @@ -760,7 +715,7 @@ msgid "" "of ``HTTPBasicAuthHandler`` and an opener to use this handler." msgstr "" -#: ../../howto/urllib2.rst:473 +#: ../../howto/urllib2.rst:425 msgid "" "The ``HTTPBasicAuthHandler`` uses an object called a password manager to " "handle the mapping of URLs and realms to passwords and usernames. If you " @@ -773,13 +728,13 @@ msgid "" "by providing ``None`` as the realm argument to the ``add_password`` method." msgstr "" -#: ../../howto/urllib2.rst:483 +#: ../../howto/urllib2.rst:435 msgid "" "The top-level URL is the first URL that requires authentication. URLs " "\"deeper\" than the URL you pass to .add_password() will also match. ::" msgstr "" -#: ../../howto/urllib2.rst:486 +#: ../../howto/urllib2.rst:438 msgid "" "# create a password manager\n" "password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()\n" @@ -802,7 +757,7 @@ msgid "" "urllib.request.install_opener(opener)" msgstr "" -#: ../../howto/urllib2.rst:508 +#: ../../howto/urllib2.rst:460 msgid "" "In the above example we only supplied our ``HTTPBasicAuthHandler`` to " "``build_opener``. By default openers have the handlers for normal situations " @@ -812,7 +767,7 @@ msgid "" "``FileHandler``, ``DataHandler``, ``HTTPErrorProcessor``." msgstr "" -#: ../../howto/urllib2.rst:515 +#: ../../howto/urllib2.rst:467 msgid "" "``top_level_url`` is in fact *either* a full URL (including the 'http:' " "scheme component and the hostname and optionally the port number) e.g. " @@ -823,11 +778,11 @@ msgid "" "example ``\"joe:password@example.com\"`` is not correct." msgstr "" -#: ../../howto/urllib2.rst:525 +#: ../../howto/urllib2.rst:477 msgid "Proxies" msgstr "" -#: ../../howto/urllib2.rst:527 +#: ../../howto/urllib2.rst:479 msgid "" "**urllib** will auto-detect your proxy settings and use those. This is " "through the ``ProxyHandler``, which is part of the normal handler chain when " @@ -837,7 +792,7 @@ msgid "" "similar steps to setting up a `Basic Authentication`_ handler: ::" msgstr "" -#: ../../howto/urllib2.rst:534 +#: ../../howto/urllib2.rst:486 msgid "" ">>> proxy_support = urllib.request.ProxyHandler({})\n" ">>> opener = urllib.request.build_opener(proxy_support)\n" @@ -847,30 +802,30 @@ msgstr "" ">>> opener = urllib.request.build_opener(proxy_support)\n" ">>> urllib.request.install_opener(opener)" -#: ../../howto/urllib2.rst:540 +#: ../../howto/urllib2.rst:492 msgid "" "Currently ``urllib.request`` *does not* support fetching of ``https`` " "locations through a proxy. However, this can be enabled by extending urllib." "request as shown in the recipe [#]_." msgstr "" -#: ../../howto/urllib2.rst:546 +#: ../../howto/urllib2.rst:498 msgid "" "``HTTP_PROXY`` will be ignored if a variable ``REQUEST_METHOD`` is set; see " "the documentation on :func:`~urllib.request.getproxies`." msgstr "" -#: ../../howto/urllib2.rst:551 +#: ../../howto/urllib2.rst:503 msgid "Sockets and Layers" msgstr "" -#: ../../howto/urllib2.rst:553 +#: ../../howto/urllib2.rst:505 msgid "" "The Python support for fetching resources from the web is layered. urllib " "uses the :mod:`http.client` library, which in turn uses the socket library." msgstr "" -#: ../../howto/urllib2.rst:556 +#: ../../howto/urllib2.rst:508 msgid "" "As of Python 2.3 you can specify how long a socket should wait for a " "response before timing out. This can be useful in applications which have to " @@ -880,7 +835,7 @@ msgid "" "sockets using ::" msgstr "" -#: ../../howto/urllib2.rst:562 +#: ../../howto/urllib2.rst:514 msgid "" "import socket\n" "import urllib.request\n" @@ -895,38 +850,38 @@ msgid "" "response = urllib.request.urlopen(req)" msgstr "" -#: ../../howto/urllib2.rst:579 +#: ../../howto/urllib2.rst:531 msgid "Footnotes" -msgstr "註解" +msgstr "註腳" -#: ../../howto/urllib2.rst:581 +#: ../../howto/urllib2.rst:533 msgid "This document was reviewed and revised by John Lee." msgstr "" -#: ../../howto/urllib2.rst:583 +#: ../../howto/urllib2.rst:535 msgid "Google for example." msgstr "" -#: ../../howto/urllib2.rst:584 +#: ../../howto/urllib2.rst:536 msgid "" "Browser sniffing is a very bad practice for website design - building sites " "using web standards is much more sensible. Unfortunately a lot of sites " "still send different versions to different browsers." msgstr "" -#: ../../howto/urllib2.rst:587 +#: ../../howto/urllib2.rst:539 msgid "" "The user agent for MSIE 6 is *'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT " "5.1; SV1; .NET CLR 1.1.4322)'*" msgstr "" -#: ../../howto/urllib2.rst:589 +#: ../../howto/urllib2.rst:541 msgid "" "For details of more HTTP request headers, see `Quick Reference to HTTP " "Headers`_." msgstr "" -#: ../../howto/urllib2.rst:591 +#: ../../howto/urllib2.rst:543 msgid "" "In my case I have to use a proxy to access the internet at work. If you " "attempt to fetch *localhost* URLs through this proxy it blocks them. IE is " @@ -934,19 +889,9 @@ msgid "" "with a localhost server, I have to prevent urllib from using the proxy." msgstr "" -#: ../../howto/urllib2.rst:596 +#: ../../howto/urllib2.rst:548 msgid "" "urllib opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe `_." msgstr "" - -#~ msgid "" -#~ "There is a French translation of an earlier revision of this HOWTO, " -#~ "available at `urllib2 - Le Manuel manquant `_." -#~ msgstr "" -#~ "這份指南出自於早期版本的法文翻譯 `urllib2 - Le Manuel manquant `_。" diff --git a/includes/wasm-notavail.po b/includes/wasm-notavail.po deleted file mode 100644 index e08d6b73d8..0000000000 --- a/includes/wasm-notavail.po +++ /dev/null @@ -1,29 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation -# This file is distributed under the same license as the Python package. -# FIRST AUTHOR , YEAR. -# -msgid "" -msgstr "" -"Project-Id-Version: Python 3.12\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-02-13 00:17+0000\n" -"PO-Revision-Date: 2022-10-16 07:40+0800\n" -"Last-Translator: \n" -"Language-Team: \n" -"Language: zh_TW\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 3.1.1\n" - -#: ../../includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not Emscripten, not WASI." -msgstr "" - -#: ../../includes/wasm-notavail.rst:5 -msgid "" -"This module does not work or is not available on WebAssembly platforms " -"``wasm32-emscripten`` and ``wasm32-wasi``. See :ref:`wasm-availability` for " -"more information." -msgstr "" diff --git a/installing/index.po b/installing/index.po index 322ff93627..eab5a62179 100644 --- a/installing/index.po +++ b/installing/index.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -8,7 +7,7 @@ # Steven Hsu , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2022-06-27 09:37+0800\n" @@ -217,6 +216,8 @@ msgid "" "python -m pip install SomePackage==1.0.4 # specific version\n" "python -m pip install \"SomePackage>=1.0.4\" # minimum version" msgstr "" +"python -m pip install SomePackage==1.0.4 # 明確版本\n" +"python -m pip install \"SomePackage>=1.0.4\" # 最小版本" #: ../../installing/index.rst:103 msgid "" @@ -341,6 +342,10 @@ msgid "" "python3 -m pip install SomePackage # default Python 3\n" "python3.4 -m pip install SomePackage # specifically Python 3.4" msgstr "" +"python2 -m pip install SomePackage # 預設 Python 2\n" +"python2.7 -m pip install SomePackage # 指定 Python 2.7\n" +"python3 -m pip install SomePackage # 預設 Python 3\n" +"python3.4 -m pip install SomePackage # 指定 Python 3.4" #: ../../installing/index.rst:176 msgid "Appropriately versioned ``pip`` commands may also be available." @@ -361,6 +366,10 @@ msgid "" "py -3 -m pip install SomePackage # default Python 3\n" "py -3.4 -m pip install SomePackage # specifically Python 3.4" msgstr "" +"py -2 -m pip install SomePackage # 預設 Python 2\n" +"py -2.7 -m pip install SomePackage # 指定 Python 2.7\n" +"py -3 -m pip install SomePackage # 預設 Python 3\n" +"py -3.4 -m pip install SomePackage # 指定 Python 3.4" #: ../../installing/index.rst:195 msgid "Common installation issues" diff --git a/library/2to3.po b/library/2to3.po deleted file mode 100644 index 407aa22b5b..0000000000 --- a/library/2to3.po +++ /dev/null @@ -1,706 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation -# This file is distributed under the same license as the Python package. -# -# Translators: -# jerrychen , 2016 -msgid "" -msgstr "" -"Project-Id-Version: Python 3.12\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" -"PO-Revision-Date: 2018-05-23 14:37+0000\n" -"Last-Translator: Adrian Liaw \n" -"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" -"tw)\n" -"Language: zh_TW\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=1; plural=0;\n" - -#: ../../library/2to3.rst:4 -msgid "2to3 --- Automated Python 2 to 3 code translation" -msgstr "2to3 --- 自動將 Python 2的程式碼轉成 Python 3" - -#: ../../library/2to3.rst:8 -msgid "" -"2to3 is a Python program that reads Python 2.x source code and applies a " -"series of *fixers* to transform it into valid Python 3.x code. The standard " -"library contains a rich set of fixers that will handle almost all code. " -"2to3 supporting library :mod:`lib2to3` is, however, a flexible and generic " -"library, so it is possible to write your own fixers for 2to3." -msgstr "" - -#: ../../library/2to3.rst:14 -msgid "" -"The ``lib2to3`` module was marked pending for deprecation in Python 3.9 " -"(raising :exc:`PendingDeprecationWarning` on import) and fully deprecated in " -"Python 3.11 (raising :exc:`DeprecationWarning`). The ``2to3`` tool is part " -"of that. It will be removed in Python 3.13." -msgstr "" - -#: ../../library/2to3.rst:23 -msgid "Using 2to3" -msgstr "使用 2to3" - -#: ../../library/2to3.rst:25 -msgid "" -"2to3 will usually be installed with the Python interpreter as a script. It " -"is also located in the :file:`Tools/scripts` directory of the Python root." -msgstr "" - -#: ../../library/2to3.rst:28 -msgid "" -"2to3's basic arguments are a list of files or directories to transform. The " -"directories are recursively traversed for Python sources." -msgstr "" - -#: ../../library/2to3.rst:31 -msgid "Here is a sample Python 2.x source file, :file:`example.py`::" -msgstr "這邊有簡單的 Python 2的原始檔案 :file:`example.py`::" - -#: ../../library/2to3.rst:33 -msgid "" -"def greet(name):\n" -" print \"Hello, {0}!\".format(name)\n" -"print \"What's your name?\"\n" -"name = raw_input()\n" -"greet(name)" -msgstr "" - -#: ../../library/2to3.rst:39 -msgid "It can be converted to Python 3.x code via 2to3 on the command line:" -msgstr "" - -#: ../../library/2to3.rst:41 -msgid "$ 2to3 example.py" -msgstr "$ 2to3 example.py" - -#: ../../library/2to3.rst:45 -msgid "" -"A diff against the original source file is printed. 2to3 can also write the " -"needed modifications right back to the source file. (A backup of the " -"original file is made unless :option:`!-n` is also given.) Writing the " -"changes back is enabled with the :option:`!-w` flag:" -msgstr "" - -#: ../../library/2to3.rst:50 -msgid "$ 2to3 -w example.py" -msgstr "$ 2to3 -w example.py" - -#: ../../library/2to3.rst:54 -msgid "After transformation, :file:`example.py` looks like this::" -msgstr "" - -#: ../../library/2to3.rst:56 -msgid "" -"def greet(name):\n" -" print(\"Hello, {0}!\".format(name))\n" -"print(\"What's your name?\")\n" -"name = input()\n" -"greet(name)" -msgstr "" - -#: ../../library/2to3.rst:62 -msgid "" -"Comments and exact indentation are preserved throughout the translation " -"process." -msgstr "" - -#: ../../library/2to3.rst:64 -msgid "" -"By default, 2to3 runs a set of :ref:`predefined fixers <2to3-fixers>`. The :" -"option:`!-l` flag lists all available fixers. An explicit set of fixers to " -"run can be given with :option:`!-f`. Likewise the :option:`!-x` explicitly " -"disables a fixer. The following example runs only the ``imports`` and " -"``has_key`` fixers:" -msgstr "" - -#: ../../library/2to3.rst:69 -msgid "$ 2to3 -f imports -f has_key example.py" -msgstr "$ 2to3 -f imports -f has_key example.py" - -#: ../../library/2to3.rst:73 -msgid "This command runs every fixer except the ``apply`` fixer:" -msgstr "" - -#: ../../library/2to3.rst:75 -msgid "$ 2to3 -x apply example.py" -msgstr "$ 2to3 -x apply example.py" - -#: ../../library/2to3.rst:79 -msgid "" -"Some fixers are *explicit*, meaning they aren't run by default and must be " -"listed on the command line to be run. Here, in addition to the default " -"fixers, the ``idioms`` fixer is run:" -msgstr "" - -#: ../../library/2to3.rst:83 -msgid "$ 2to3 -f all -f idioms example.py" -msgstr "$ 2to3 -f all -f idioms example.py" - -#: ../../library/2to3.rst:87 -msgid "Notice how passing ``all`` enables all default fixers." -msgstr "" - -#: ../../library/2to3.rst:89 -msgid "" -"Sometimes 2to3 will find a place in your source code that needs to be " -"changed, but 2to3 cannot fix automatically. In this case, 2to3 will print a " -"warning beneath the diff for a file. You should address the warning in " -"order to have compliant 3.x code." -msgstr "" - -#: ../../library/2to3.rst:94 -msgid "" -"2to3 can also refactor doctests. To enable this mode, use the :option:`!-d` " -"flag. Note that *only* doctests will be refactored. This also doesn't " -"require the module to be valid Python. For example, doctest like examples " -"in a reST document could also be refactored with this option." -msgstr "" - -#: ../../library/2to3.rst:99 -msgid "" -"The :option:`!-v` option enables output of more information on the " -"translation process." -msgstr "" - -#: ../../library/2to3.rst:102 -msgid "" -"Since some print statements can be parsed as function calls or statements, " -"2to3 cannot always read files containing the print function. When 2to3 " -"detects the presence of the ``from __future__ import print_function`` " -"compiler directive, it modifies its internal grammar to interpret :func:" -"`print` as a function. This change can also be enabled manually with the :" -"option:`!-p` flag. Use :option:`!-p` to run fixers on code that already has " -"had its print statements converted. Also :option:`!-e` can be used to make :" -"func:`exec` a function." -msgstr "" - -#: ../../library/2to3.rst:110 -msgid "" -"The :option:`!-o` or :option:`!--output-dir` option allows specification of " -"an alternate directory for processed output files to be written to. The :" -"option:`!-n` flag is required when using this as backup files do not make " -"sense when not overwriting the input files." -msgstr "" - -#: ../../library/2to3.rst:115 -msgid "The :option:`!-o` option was added." -msgstr "新增 :option:`!-o` 選項。" - -#: ../../library/2to3.rst:118 -msgid "" -"The :option:`!-W` or :option:`!--write-unchanged-files` flag tells 2to3 to " -"always write output files even if no changes were required to the file. " -"This is most useful with :option:`!-o` so that an entire Python source tree " -"is copied with translation from one directory to another. This option " -"implies the :option:`!-w` flag as it would not make sense otherwise." -msgstr "" - -#: ../../library/2to3.rst:124 -msgid "The :option:`!-W` flag was added." -msgstr "" - -#: ../../library/2to3.rst:127 -msgid "" -"The :option:`!--add-suffix` option specifies a string to append to all " -"output filenames. The :option:`!-n` flag is required when specifying this " -"as backups are not necessary when writing to different filenames. Example:" -msgstr "" - -#: ../../library/2to3.rst:131 -msgid "$ 2to3 -n -W --add-suffix=3 example.py" -msgstr "$ 2to3 -n -W --add-suffix=3 example.py" - -#: ../../library/2to3.rst:135 -msgid "Will cause a converted file named ``example.py3`` to be written." -msgstr "" - -#: ../../library/2to3.rst:137 -msgid "The :option:`!--add-suffix` option was added." -msgstr "" - -#: ../../library/2to3.rst:140 -msgid "To translate an entire project from one directory tree to another use:" -msgstr "" - -#: ../../library/2to3.rst:142 -msgid "$ 2to3 --output-dir=python3-version/mycode -W -n python2-version/mycode" -msgstr "" -"$ 2to3 --output-dir=python3-version/mycode -W -n python2-version/mycode" - -#: ../../library/2to3.rst:150 -msgid "Fixers" -msgstr "" - -#: ../../library/2to3.rst:152 -msgid "" -"Each step of transforming code is encapsulated in a fixer. The command " -"``2to3 -l`` lists them. As :ref:`documented above <2to3-using>`, each can " -"be turned on and off individually. They are described here in more detail." -msgstr "" - -#: ../../library/2to3.rst:159 -msgid "" -"Removes usage of :func:`apply`. For example ``apply(function, *args, " -"**kwargs)`` is converted to ``function(*args, **kwargs)``." -msgstr "" - -#: ../../library/2to3.rst:164 -msgid "Replaces deprecated :mod:`unittest` method names with the correct ones." -msgstr "" - -#: ../../library/2to3.rst:167 ../../library/2to3.rst:356 -msgid "From" -msgstr "從" - -#: ../../library/2to3.rst:167 ../../library/2to3.rst:356 -msgid "To" -msgstr "到" - -#: ../../library/2to3.rst:169 -msgid "``failUnlessEqual(a, b)``" -msgstr "``failUnlessEqual(a, b)``" - -#: ../../library/2to3.rst:169 ../../library/2to3.rst:171 -msgid ":meth:`assertEqual(a, b) `" -msgstr ":meth:`assertEqual(a, b) `" - -#: ../../library/2to3.rst:171 -msgid "``assertEquals(a, b)``" -msgstr "``assertEquals(a, b)``" - -#: ../../library/2to3.rst:173 -msgid "``failIfEqual(a, b)``" -msgstr "``failIfEqual(a, b)``" - -#: ../../library/2to3.rst:173 ../../library/2to3.rst:175 -msgid ":meth:`assertNotEqual(a, b) `" -msgstr ":meth:`assertNotEqual(a, b) `" - -#: ../../library/2to3.rst:175 -msgid "``assertNotEquals(a, b)``" -msgstr "``assertNotEquals(a, b)``" - -#: ../../library/2to3.rst:177 -msgid "``failUnless(a)``" -msgstr "``failUnless(a)``" - -#: ../../library/2to3.rst:177 ../../library/2to3.rst:179 -msgid ":meth:`assertTrue(a) `" -msgstr ":meth:`assertTrue(a) `" - -#: ../../library/2to3.rst:179 -msgid "``assert_(a)``" -msgstr "``assert_(a)``" - -#: ../../library/2to3.rst:181 -msgid "``failIf(a)``" -msgstr "``failIf(a)``" - -#: ../../library/2to3.rst:181 -msgid ":meth:`assertFalse(a) `" -msgstr ":meth:`assertFalse(a) `" - -#: ../../library/2to3.rst:183 -msgid "``failUnlessRaises(exc, cal)``" -msgstr "``failUnlessRaises(exc, cal)``" - -#: ../../library/2to3.rst:183 -msgid ":meth:`assertRaises(exc, cal) `" -msgstr ":meth:`assertRaises(exc, cal) `" - -#: ../../library/2to3.rst:185 -msgid "``failUnlessAlmostEqual(a, b)``" -msgstr "``failUnlessAlmostEqual(a, b)``" - -#: ../../library/2to3.rst:185 ../../library/2to3.rst:187 -msgid ":meth:`assertAlmostEqual(a, b) `" -msgstr ":meth:`assertAlmostEqual(a, b) `" - -#: ../../library/2to3.rst:187 -msgid "``assertAlmostEquals(a, b)``" -msgstr "``assertAlmostEquals(a, b)``" - -#: ../../library/2to3.rst:189 -msgid "``failIfAlmostEqual(a, b)``" -msgstr "``failIfAlmostEqual(a, b)``" - -#: ../../library/2to3.rst:189 ../../library/2to3.rst:191 -msgid "" -":meth:`assertNotAlmostEqual(a, b) `" -msgstr "" - -#: ../../library/2to3.rst:191 -msgid "``assertNotAlmostEquals(a, b)``" -msgstr "``assertNotAlmostEquals(a, b)``" - -#: ../../library/2to3.rst:197 -msgid "Converts :class:`basestring` to :class:`str`." -msgstr "" - -#: ../../library/2to3.rst:201 -msgid "" -"Converts :class:`buffer` to :class:`memoryview`. This fixer is optional " -"because the :class:`memoryview` API is similar but not exactly the same as " -"that of :class:`buffer`." -msgstr "" - -#: ../../library/2to3.rst:207 -msgid "" -"Fixes dictionary iteration methods. :meth:`dict.iteritems` is converted to :" -"meth:`dict.items`, :meth:`dict.iterkeys` to :meth:`dict.keys`, and :meth:" -"`dict.itervalues` to :meth:`dict.values`. Similarly, :meth:`dict." -"viewitems`, :meth:`dict.viewkeys` and :meth:`dict.viewvalues` are converted " -"respectively to :meth:`dict.items`, :meth:`dict.keys` and :meth:`dict." -"values`. It also wraps existing usages of :meth:`dict.items`, :meth:`dict." -"keys`, and :meth:`dict.values` in a call to :class:`list`." -msgstr "" - -#: ../../library/2to3.rst:217 -msgid "Converts ``except X, T`` to ``except X as T``." -msgstr "" - -#: ../../library/2to3.rst:221 -msgid "Converts the ``exec`` statement to the :func:`exec` function." -msgstr "" - -#: ../../library/2to3.rst:225 -msgid "" -"Removes usage of :func:`execfile`. The argument to :func:`execfile` is " -"wrapped in calls to :func:`open`, :func:`compile`, and :func:`exec`." -msgstr "" - -#: ../../library/2to3.rst:230 -msgid "" -"Changes assignment of :attr:`sys.exitfunc` to use of the :mod:`atexit` " -"module." -msgstr "" - -#: ../../library/2to3.rst:235 -msgid "Wraps :func:`filter` usage in a :class:`list` call." -msgstr "" - -#: ../../library/2to3.rst:239 -msgid "" -"Fixes function attributes that have been renamed. For example, " -"``my_function.func_closure`` is converted to ``my_function.__closure__``." -msgstr "" - -#: ../../library/2to3.rst:244 -msgid "Removes ``from __future__ import new_feature`` statements." -msgstr "" - -#: ../../library/2to3.rst:248 -msgid "Renames :func:`os.getcwdu` to :func:`os.getcwd`." -msgstr "" - -#: ../../library/2to3.rst:252 -msgid "Changes ``dict.has_key(key)`` to ``key in dict``." -msgstr "" - -#: ../../library/2to3.rst:256 -msgid "" -"This optional fixer performs several transformations that make Python code " -"more idiomatic. Type comparisons like ``type(x) is SomeClass`` and " -"``type(x) == SomeClass`` are converted to ``isinstance(x, SomeClass)``. " -"``while 1`` becomes ``while True``. This fixer also tries to make use of :" -"func:`sorted` in appropriate places. For example, this block ::" -msgstr "" - -#: ../../library/2to3.rst:262 -msgid "" -"L = list(some_iterable)\n" -"L.sort()" -msgstr "" -"L = list(some_iterable)\n" -"L.sort()" - -#: ../../library/2to3.rst:265 -msgid "is changed to ::" -msgstr "" - -#: ../../library/2to3.rst:267 -msgid "L = sorted(some_iterable)" -msgstr "L = sorted(some_iterable)" - -#: ../../library/2to3.rst:271 -msgid "Detects sibling imports and converts them to relative imports." -msgstr "" - -#: ../../library/2to3.rst:275 -msgid "Handles module renames in the standard library." -msgstr "" - -#: ../../library/2to3.rst:279 -msgid "" -"Handles other modules renames in the standard library. It is separate from " -"the :2to3fixer:`imports` fixer only because of technical limitations." -msgstr "" - -#: ../../library/2to3.rst:284 -msgid "Converts ``input(prompt)`` to ``eval(input(prompt))``." -msgstr "" - -#: ../../library/2to3.rst:288 -msgid "Converts :func:`intern` to :func:`sys.intern`." -msgstr "" - -#: ../../library/2to3.rst:292 -msgid "" -"Fixes duplicate types in the second argument of :func:`isinstance`. For " -"example, ``isinstance(x, (int, int))`` is converted to ``isinstance(x, " -"int)`` and ``isinstance(x, (int, float, int))`` is converted to " -"``isinstance(x, (int, float))``." -msgstr "" - -#: ../../library/2to3.rst:299 -msgid "" -"Removes imports of :func:`itertools.ifilter`, :func:`itertools.izip`, and :" -"func:`itertools.imap`. Imports of :func:`itertools.ifilterfalse` are also " -"changed to :func:`itertools.filterfalse`." -msgstr "" - -#: ../../library/2to3.rst:305 -msgid "" -"Changes usage of :func:`itertools.ifilter`, :func:`itertools.izip`, and :" -"func:`itertools.imap` to their built-in equivalents. :func:`itertools." -"ifilterfalse` is changed to :func:`itertools.filterfalse`." -msgstr "" - -#: ../../library/2to3.rst:311 -msgid "Renames :class:`long` to :class:`int`." -msgstr "" - -#: ../../library/2to3.rst:315 -msgid "" -"Wraps :func:`map` in a :class:`list` call. It also changes ``map(None, x)`` " -"to ``list(x)``. Using ``from future_builtins import map`` disables this " -"fixer." -msgstr "" - -#: ../../library/2to3.rst:321 -msgid "" -"Converts the old metaclass syntax (``__metaclass__ = Meta`` in the class " -"body) to the new (``class X(metaclass=Meta)``)." -msgstr "" - -#: ../../library/2to3.rst:326 -msgid "" -"Fixes old method attribute names. For example, ``meth.im_func`` is " -"converted to ``meth.__func__``." -msgstr "" - -#: ../../library/2to3.rst:331 -msgid "Converts the old not-equal syntax, ``<>``, to ``!=``." -msgstr "" - -#: ../../library/2to3.rst:335 -msgid "" -"Converts the use of iterator's :meth:`~iterator.next` methods to the :func:" -"`next` function. It also renames :meth:`next` methods to :meth:`~iterator." -"__next__`." -msgstr "" - -#: ../../library/2to3.rst:341 -msgid "" -"Renames definitions of methods called :meth:`__nonzero__` to :meth:`~object." -"__bool__`." -msgstr "" - -#: ../../library/2to3.rst:346 -msgid "Converts octal literals into the new syntax." -msgstr "" - -#: ../../library/2to3.rst:350 -msgid "" -"Converts calls to various functions in the :mod:`operator` module to other, " -"but equivalent, function calls. When needed, the appropriate ``import`` " -"statements are added, e.g. ``import collections.abc``. The following " -"mapping are made:" -msgstr "" - -#: ../../library/2to3.rst:358 -msgid "``operator.isCallable(obj)``" -msgstr "``operator.isCallable(obj)``" - -#: ../../library/2to3.rst:358 -msgid "``callable(obj)``" -msgstr "``callable(obj)``" - -#: ../../library/2to3.rst:359 -msgid "``operator.sequenceIncludes(obj)``" -msgstr "``operator.sequenceIncludes(obj)``" - -#: ../../library/2to3.rst:359 -msgid "``operator.contains(obj)``" -msgstr "``operator.contains(obj)``" - -#: ../../library/2to3.rst:360 -msgid "``operator.isSequenceType(obj)``" -msgstr "``operator.isSequenceType(obj)``" - -#: ../../library/2to3.rst:360 -msgid "``isinstance(obj, collections.abc.Sequence)``" -msgstr "``isinstance(obj, collections.abc.Sequence)``" - -#: ../../library/2to3.rst:361 -msgid "``operator.isMappingType(obj)``" -msgstr "``operator.isMappingType(obj)``" - -#: ../../library/2to3.rst:361 -msgid "``isinstance(obj, collections.abc.Mapping)``" -msgstr "``isinstance(obj, collections.abc.Mapping)``" - -#: ../../library/2to3.rst:362 -msgid "``operator.isNumberType(obj)``" -msgstr "``operator.isNumberType(obj)``" - -#: ../../library/2to3.rst:362 -msgid "``isinstance(obj, numbers.Number)``" -msgstr "``isinstance(obj, numbers.Number)``" - -#: ../../library/2to3.rst:363 -msgid "``operator.repeat(obj, n)``" -msgstr "``operator.repeat(obj, n)``" - -#: ../../library/2to3.rst:363 -msgid "``operator.mul(obj, n)``" -msgstr "``operator.mul(obj, n)``" - -#: ../../library/2to3.rst:364 -msgid "``operator.irepeat(obj, n)``" -msgstr "``operator.irepeat(obj, n)``" - -#: ../../library/2to3.rst:364 -msgid "``operator.imul(obj, n)``" -msgstr "``operator.imul(obj, n)``" - -#: ../../library/2to3.rst:369 -msgid "" -"Add extra parenthesis where they are required in list comprehensions. For " -"example, ``[x for x in 1, 2]`` becomes ``[x for x in (1, 2)]``." -msgstr "" - -#: ../../library/2to3.rst:374 -msgid "Converts the ``print`` statement to the :func:`print` function." -msgstr "" - -#: ../../library/2to3.rst:378 -msgid "" -"Converts ``raise E, V`` to ``raise E(V)``, and ``raise E, V, T`` to ``raise " -"E(V).with_traceback(T)``. If ``E`` is a tuple, the translation will be " -"incorrect because substituting tuples for exceptions has been removed in 3.0." -msgstr "" - -#: ../../library/2to3.rst:384 -msgid "Converts :func:`raw_input` to :func:`input`." -msgstr "" - -#: ../../library/2to3.rst:388 -msgid "Handles the move of :func:`reduce` to :func:`functools.reduce`." -msgstr "" - -#: ../../library/2to3.rst:392 -msgid "Converts :func:`reload` to :func:`importlib.reload`." -msgstr "" - -#: ../../library/2to3.rst:396 -msgid "Changes :data:`sys.maxint` to :data:`sys.maxsize`." -msgstr "" - -#: ../../library/2to3.rst:400 -msgid "Replaces backtick repr with the :func:`repr` function." -msgstr "" - -#: ../../library/2to3.rst:404 -msgid "" -"Replaces use of the :class:`set` constructor with set literals. This fixer " -"is optional." -msgstr "" - -#: ../../library/2to3.rst:409 -msgid "Renames :exc:`StandardError` to :exc:`Exception`." -msgstr "" - -#: ../../library/2to3.rst:413 -msgid "" -"Changes the deprecated :data:`sys.exc_value`, :data:`sys.exc_type`, :data:" -"`sys.exc_traceback` to use :func:`sys.exc_info`." -msgstr "" - -#: ../../library/2to3.rst:418 -msgid "Fixes the API change in generator's :meth:`throw` method." -msgstr "" - -#: ../../library/2to3.rst:422 -msgid "" -"Removes implicit tuple parameter unpacking. This fixer inserts temporary " -"variables." -msgstr "" - -#: ../../library/2to3.rst:427 -msgid "" -"Fixes code broken from the removal of some members in the :mod:`types` " -"module." -msgstr "" - -#: ../../library/2to3.rst:432 -msgid "Renames :class:`unicode` to :class:`str`." -msgstr "" - -#: ../../library/2to3.rst:436 -msgid "" -"Handles the rename of :mod:`urllib` and :mod:`urllib2` to the :mod:`urllib` " -"package." -msgstr "" - -#: ../../library/2to3.rst:441 -msgid "" -"Removes excess whitespace from comma separated items. This fixer is " -"optional." -msgstr "" - -#: ../../library/2to3.rst:446 -msgid "" -"Renames :func:`xrange` to :func:`range` and wraps existing :func:`range` " -"calls with :class:`list`." -msgstr "" - -#: ../../library/2to3.rst:451 -msgid "Changes ``for x in file.xreadlines()`` to ``for x in file``." -msgstr "" - -#: ../../library/2to3.rst:455 -msgid "" -"Wraps :func:`zip` usage in a :class:`list` call. This is disabled when " -"``from future_builtins import zip`` appears." -msgstr "" - -#: ../../library/2to3.rst:460 -msgid ":mod:`lib2to3` --- 2to3's library" -msgstr "" - -#: ../../library/2to3.rst:469 -msgid "**Source code:** :source:`Lib/lib2to3/`" -msgstr "**原始碼:**\\ :source:`Lib/lib2to3/`" - -#: ../../library/2to3.rst:473 -msgid "" -"Python 3.9 switched to a PEG parser (see :pep:`617`) while lib2to3 is using " -"a less flexible LL(1) parser. Python 3.10 includes new language syntax that " -"is not parsable by lib2to3's LL(1) parser (see :pep:`634`). The ``lib2to3`` " -"module was marked pending for deprecation in Python 3.9 (raising :exc:" -"`PendingDeprecationWarning` on import) and fully deprecated in Python 3.11 " -"(raising :exc:`DeprecationWarning`). It will be removed from the standard " -"library in Python 3.13. Consider third-party alternatives such as `LibCST`_ " -"or `parso`_." -msgstr "" - -#: ../../library/2to3.rst:485 -msgid "" -"The :mod:`lib2to3` API should be considered unstable and may change " -"drastically in the future." -msgstr "" diff --git a/library/__future__.po b/library/__future__.po index 5e55c54fc2..a1267b3397 100644 --- a/library/__future__.po +++ b/library/__future__.po @@ -5,7 +5,7 @@ # Matt Wang , 2023-2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2024-02-06 02:12+0000\n" @@ -306,7 +306,7 @@ msgid "" "compiler_flag` attribute on :class:`_Feature` instances." msgstr "" "*CompilerFlag* 是(位元欄位 (bitfield))旗標,應在第四個引數中傳遞給內建函" -"式 :func:`compile` 以在動態編譯的程式碼中啟用該功能。此旗標存儲在 :class:" +"式 :func:`compile` 以在動態編譯的程式碼中啟用該功能。此旗標儲存在 :class:" "`_Feature` 實例上的 :attr:`_Feature.compiler_flag` 屬性中。" #: ../../library/__future__.rst:117 diff --git a/library/__main__.po b/library/__main__.po index 6bf15fc1e9..ff81f21bf6 100644 --- a/library/__main__.po +++ b/library/__main__.po @@ -4,7 +4,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2023-12-21 14:49+0800\n" diff --git a/library/_thread.po b/library/_thread.po index e2b4e567be..1f52f9ef12 100644 --- a/library/_thread.po +++ b/library/_thread.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-10-12 00:13+0000\n" "PO-Revision-Date: 2015-12-09 17:51+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -157,7 +156,7 @@ msgid "" "identifiers may be recycled when a thread exits and another thread is " "created." msgstr "" -"回傳當前執行緒的「執行緒識別字」。這是一個非零的整數。它的值沒有直接的含義;" +"回傳目前執行緒的「執行緒識別字」。這是一個非零的整數。它的值沒有直接的含義;" "它被用作一個 magic cookie,例如用於索引特定於執行緒的資料的字典。當執行緒退出" "並建立另一個執行緒時,執行緒識別字可能會被重複使用。" @@ -168,19 +167,19 @@ msgid "" "identify this particular thread system-wide (until the thread terminates, " "after which the value may be recycled by the OS)." msgstr "" -"回傳由核心 (kernel) 分配的當前執行緒的原生整數執行緒 ID。這是一個非負整數。它" +"回傳由核心 (kernel) 分配的目前執行緒的原生整數執行緒 ID。這是一個非負整數。它" "的值可用於在整個系統中唯一標識此特定執行緒(直到執行緒終止後,該值可能被操作" "系統重新使用)。" -#: ../../library/_thread.rst:123 -msgid "" -":ref:`Availability `: Windows, FreeBSD, Linux, macOS, OpenBSD, " -"NetBSD, AIX, DragonFlyBSD." -msgstr "" -":ref:`適用 `:Windows、FreeBSD、Linux、macOS、OpenBSD、NetBSD、" -"AIX、DragonFlyBSD。" +#: ../../library/_thread.rst:123 ../../library/_thread.rst:148 +msgid "Availability" +msgstr "可用性" + +#: ../../library/_thread.rst:127 +msgid "Added support for GNU/kFreeBSD." +msgstr "新增了對 GNU/kFreeBSD 的支援。" -#: ../../library/_thread.rst:130 +#: ../../library/_thread.rst:133 msgid "" "Return the thread stack size used when creating new threads. The optional " "*size* argument specifies the stack size to be used for subsequently created " @@ -205,18 +204,14 @@ msgstr "" "`ValueError` 錯誤,並且堆疊大小不會被修改。目前,32 KiB 是保證解譯器本身具有" "足夠堆疊空間所支持的最小堆疊大小值。請注意,某些平台對於堆疊大小的值可能有特" "定的限制,例如要求最小堆疊大小 > 32 KiB,或要求按系統記憶體頁面大小的倍數進行" -"分配。應參考平台文檔以獲取更多訊息(4 KiB 頁面是比較普遍的;在缺乏更具體訊息" +"分配。應參考平台文件以取得更多訊息(4 KiB 頁面是比較普遍的;在缺乏更具體訊息" "的情況下,建議使用 4096 的倍數作為堆疊大小)。" -#: ../../library/_thread.rst:145 -msgid ":ref:`Availability `: Windows, pthreads." -msgstr ":ref:`適用 `:Windows, pthreads。" - -#: ../../library/_thread.rst:147 +#: ../../library/_thread.rst:150 msgid "Unix platforms with POSIX threads support." msgstr "Unix 平台上支援 POSIX 執行緒。" -#: ../../library/_thread.rst:152 +#: ../../library/_thread.rst:155 msgid "" "The maximum value allowed for the *timeout* parameter of :meth:`Lock.acquire " "`. Specifying a timeout greater than this value will " @@ -225,21 +220,21 @@ msgstr "" ":meth:`Lock.acquire ` 的 *timeout* 參數所允許的最大" "值。指定超過此值的 timeout 將引發 :exc:`OverflowError` 錯誤。" -#: ../../library/_thread.rst:159 +#: ../../library/_thread.rst:162 msgid "Lock objects have the following methods:" msgstr "鎖物件具有以下方法:" -#: ../../library/_thread.rst:164 +#: ../../library/_thread.rst:167 msgid "" "Without any optional argument, this method acquires the lock " "unconditionally, if necessary waiting until it is released by another thread " "(only one thread at a time can acquire a lock --- that's their reason for " "existence)." msgstr "" -"沒有任何可選引數時,此方法無條件地獲取鎖,必要時會等待直到被另一個執行緒釋放" -"(一次只能有一個執行緒獲取鎖 --- 這正是鎖存在的原因)。" +"沒有任何可選引數時,此方法無條件地取得鎖,必要時會等待直到被另一個執行緒釋放" +"(一次只能有一個執行緒取得鎖 --- 這正是鎖存在的原因)。" -#: ../../library/_thread.rst:168 +#: ../../library/_thread.rst:171 msgid "" "If the *blocking* argument is present, the action depends on its value: if " "it is false, the lock is only acquired if it can be acquired immediately " @@ -247,9 +242,9 @@ msgid "" "as above." msgstr "" "如果存在 *blocking* 引數,則根據其值執行操作:如果為 False,只有在可以立即獲" -"取鎖而無需等待的情況下才獲取鎖,而如果為 True,則像上面一樣無條件地獲取鎖。" +"取鎖而無需等待的情況下才取得鎖,而如果為 True,則像上面一樣無條件地取得鎖。" -#: ../../library/_thread.rst:173 +#: ../../library/_thread.rst:176 msgid "" "If the floating-point *timeout* argument is present and positive, it " "specifies the maximum wait time in seconds before returning. A negative " @@ -260,40 +255,40 @@ msgstr "" "(以秒為單位)。如果 *timeout* 引數為負值,則表示等待時間會無限期地等待。如" "果 *blocking* 為 False,則你無法指定 *timeout*。" -#: ../../library/_thread.rst:178 +#: ../../library/_thread.rst:181 msgid "" "The return value is ``True`` if the lock is acquired successfully, ``False`` " "if not." -msgstr "如果成功獲取鎖,回傳值為 ``True``,否則為 ``False``。" +msgstr "如果成功取得鎖,回傳值為 ``True``,否則為 ``False``。" -#: ../../library/_thread.rst:181 +#: ../../library/_thread.rst:184 msgid "The *timeout* parameter is new." msgstr "新增的 *timeout* 參數。" -#: ../../library/_thread.rst:184 +#: ../../library/_thread.rst:187 msgid "Lock acquires can now be interrupted by signals on POSIX." -msgstr "現在獲取鎖的操作可以被 POSIX 訊號中斷。" +msgstr "現在取得鎖的操作可以被 POSIX 訊號中斷。" -#: ../../library/_thread.rst:190 +#: ../../library/_thread.rst:193 msgid "" "Releases the lock. The lock must have been acquired earlier, but not " "necessarily by the same thread." -msgstr "釋放鎖。鎖必須先前被獲取,但不一定是由同一個執行緒獲取的。" +msgstr "釋放鎖。鎖必須先前被取得,但不一定是由同一個執行緒取得的。" -#: ../../library/_thread.rst:196 +#: ../../library/_thread.rst:199 msgid "" "Return the status of the lock: ``True`` if it has been acquired by some " "thread, ``False`` if not." msgstr "" -"回傳鎖的狀態:如果鎖已被某個執行緒獲取,則回傳 ``True``,否則回傳 ``False``。" +"回傳鎖的狀態:如果鎖已被某個執行緒取得,則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/_thread.rst:199 +#: ../../library/_thread.rst:202 msgid "" "In addition to these methods, lock objects can also be used via the :keyword:" "`with` statement, e.g.::" msgstr "除了這些方法之外,鎖物件還可以透過 :keyword:`with` 語句來使用,例如:" -#: ../../library/_thread.rst:202 +#: ../../library/_thread.rst:205 msgid "" "import _thread\n" "\n" @@ -302,39 +297,44 @@ msgid "" "with a_lock:\n" " print(\"a_lock is locked while this executes\")" msgstr "" +"import _thread\n" +"\n" +"a_lock = _thread.allocate_lock()\n" +"\n" +"with a_lock:\n" +" print(\"a_lock 在執行這裡時被鎖定\")" -#: ../../library/_thread.rst:209 +#: ../../library/_thread.rst:212 msgid "**Caveats:**" msgstr "**注意事項:**" -#: ../../library/_thread.rst:213 +#: ../../library/_thread.rst:216 msgid "" -"Threads interact strangely with interrupts: the :exc:`KeyboardInterrupt` " -"exception will be received by an arbitrary thread. (When the :mod:`signal` " -"module is available, interrupts always go to the main thread.)" -msgstr "" -"執行緒與中斷的互動可能會有奇怪的情況:任何一個執行緒都有可能收到 :exc:" -"`KeyboardInterrupt` 例外。(當 :mod:`signal` 模組可用時,中斷總是會進入主執行" -"緒。)" +"Interrupts always go to the main thread (the :exc:`KeyboardInterrupt` " +"exception will be received by that thread.)" +msgstr "中斷總會跳到主執行緒(該執行緒將接收 :exc:`KeyboardInterrupt` 例外。)" -#: ../../library/_thread.rst:217 +#: ../../library/_thread.rst:219 msgid "" "Calling :func:`sys.exit` or raising the :exc:`SystemExit` exception is " "equivalent to calling :func:`_thread.exit`." msgstr "" -"呼叫 :func:`sys.exit` 函數或引發 :exc:`SystemExit` 例外等同於呼叫 :func:" +"呼叫 :func:`sys.exit` 函式或引發 :exc:`SystemExit` 例外等同於呼叫 :func:" "`_thread.exit` 函式。" -#: ../../library/_thread.rst:220 +#: ../../library/_thread.rst:222 msgid "" -"It is not possible to interrupt the :meth:`~threading.Lock.acquire` method " -"on a lock --- the :exc:`KeyboardInterrupt` exception will happen after the " -"lock has been acquired." +"It is platform-dependent whether the :meth:`~threading.Lock.acquire` method " +"on a lock can be interrupted (so that the :exc:`KeyboardInterrupt` 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." msgstr "" -"無法在鎖的 :meth:`~threading.Lock.acquire` 方法上中斷執行, :exc:" -"`KeyboardInterrupt` 例外會在鎖被獲取後發生。" +"鎖的 :meth:`~threading.Lock.acquire` 方法是否可以中斷(如此一來 :exc:" +"`KeyboardInterrupt` 例外會立即發生,而不是僅在取得鎖或操作逾時後)是取決於平" +"台的。在 POSIX 上可以中斷,但在 Windows 上則不行。" -#: ../../library/_thread.rst:224 +#: ../../library/_thread.rst:228 msgid "" "When the main thread exits, it is system defined whether the other threads " "survive. On most systems, they are killed without executing :keyword:" @@ -344,15 +344,6 @@ msgstr "" "終止,而不會執行 :keyword:`try` ... :keyword:`finally` 子句或執行物件的解構函" "式。" -#: ../../library/_thread.rst:229 -msgid "" -"When the main thread exits, it does not do any of its usual cleanup (except " -"that :keyword:`try` ... :keyword:`finally` clauses are honored), and the " -"standard I/O files are not flushed." -msgstr "" -"當主執行緒退出時,它不會執行任何通常的清理操作(除非有 :keyword:`try` ... :" -"keyword:`finally` 子句),並且標準 I/O 檔案不會被刷新。" - #: ../../library/_thread.rst:7 msgid "light-weight processes" msgstr "light-weight processes(輕量級行程)" @@ -381,10 +372,10 @@ msgstr "threads(執行緒)" msgid "POSIX" msgstr "POSIX" -#: ../../library/_thread.rst:211 +#: ../../library/_thread.rst:214 msgid "module" msgstr "module(模組)" -#: ../../library/_thread.rst:211 +#: ../../library/_thread.rst:214 msgid "signal" msgstr "signal(訊號)" diff --git a/library/abc.po b/library/abc.po index a28e811d5a..9a2d736b8d 100644 --- a/library/abc.po +++ b/library/abc.po @@ -7,9 +7,9 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2025-02-27 00:15+0000\n" "PO-Revision-Date: 2022-11-16 03:29+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -33,8 +33,9 @@ msgstr "**原始碼:**\\ :source:`Lib/abc.py`" msgid "" "This module provides the infrastructure for defining :term:`abstract base " "classes ` (ABCs) in Python, as outlined in :pep:`3119`; " -"see the PEP for why this was added to Python. (See also :pep:`3141` and the :" -"mod:`numbers` module regarding a type hierarchy for numbers based on ABCs.)" +"see the PEP for why this was added to Python. (See also :pep:`3141` and " +"the :mod:`numbers` module regarding a type hierarchy for numbers based on " +"ABCs.)" msgstr "" "如同在 :pep:`3119` 中所述,該模組提供了在 Python 中定義\\ :term:`抽象基底類" "別 ` (ABC) 的基礎元件;若想瞭解為什麼需要在 Python 中增" @@ -44,10 +45,10 @@ msgstr "" #: ../../library/abc.rst:20 msgid "" "The :mod:`collections` module has some concrete classes that derive from " -"ABCs; these can, of course, be further derived. In addition, the :mod:" -"`collections.abc` submodule has some ABCs that can be used to test whether a " -"class or instance provides a particular interface, for example, if it is :" -"term:`hashable` or if it is a :term:`mapping`." +"ABCs; these can, of course, be further derived. In addition, " +"the :mod:`collections.abc` submodule has some ABCs that can be used to test " +"whether a class or instance provides a particular interface, for example, if " +"it is :term:`hashable` or if it is a :term:`mapping`." msgstr "" ":mod:`collections` 模組中有一些衍生自 ABC 的具體類別;當然這些類別還可以進一" "步衍生出其他類別。此外,:mod:`collections.abc` 子模組中有一些 ABC 可被用於測" @@ -68,9 +69,9 @@ msgid "" "an abstract base class can be created by simply deriving from :class:`!ABC` " "avoiding sometimes confusing metaclass usage, for example::" msgstr "" -"一個使用 :class:`ABCMeta` 作為元類別的工具類別。抽象基底類別可以透過自 :" -"class:`!ABC` 衍生而建立,這就避免了在某些情況下會令人混淆的元類別用法,用法如" -"以下範例: ::" +"一個使用 :class:`ABCMeta` 作為元類別的工具類別。抽象基底類別可以透過" +"自 :class:`!ABC` 衍生而建立,這就避免了在某些情況下會令人混淆的元類別用法,用" +"法如以下範例: ::" #: ../../library/abc.rst:36 msgid "" @@ -125,10 +126,10 @@ msgid "" msgstr "" "使用該元類別以建立一個 ABC。一個 ABC 可以像 mix-in 類別一樣直接被子類別繼承。" "你也可以將不相關的具體類別(甚至是內建類別)和 ABC 註冊為「虛擬子類別 " -"(virtual subclass)」 —— 這些類別以及它們的子類別會被內建函式 :func:" -"`issubclass` 識別為已註冊 ABC 的子類別,但是該 ABC 不會出現在其 MRO(Method " -"Resolution Order,方法解析順序)中,由該 ABC 所定義的方法實作也不可呼叫(即使" -"透過 :func:`super` 呼叫也不行)。[#]_" +"(virtual subclass)」 —— 這些類別以及它們的子類別會被內建函" +"式 :func:`issubclass` 識別為已註冊 ABC 的子類別,但是該 ABC 不會出現在其 MRO" +"(Method Resolution Order,方法解析順序)中,由該 ABC 所定義的方法實作也不可" +"呼叫(即使透過 :func:`super` 呼叫也不行)。[#]_" #: ../../library/abc.rst:68 msgid "" @@ -169,8 +170,8 @@ msgstr "回傳已註冊的子類別,使其能夠作為類別裝飾器。" #: ../../library/abc.rst:88 msgid "" -"To detect calls to :meth:`!register`, you can use the :func:" -"`get_cache_token` function." +"To detect calls to :meth:`!register`, you can use " +"the :func:`get_cache_token` function." msgstr "" "你可以使用 :func:`get_cache_token` 函式來檢測對 :meth:`!register` 的呼叫。" @@ -187,13 +188,13 @@ msgid "" "Check whether *subclass* is considered a subclass of this ABC. This means " "that you can customize the behavior of :func:`issubclass` further without " "the need to call :meth:`register` on every class you want to consider a " -"subclass of the ABC. (This class method is called from the :meth:`~class." -"__subclasscheck__` method of the ABC.)" +"subclass of the ABC. (This class method is called from " +"the :meth:`~type.__subclasscheck__` method of the ABC.)" msgstr "" -"檢查 *subclass* 是否該被認為是該 ABC 的子類別,也就是說你可以直接自訂 :func:" -"`issubclass` 的行為,而不用對於那些你希望定義為該 ABC 的子類別的類別都個別呼" -"叫 :meth:`register` 方法。(這個類別方法是在 ABC 的 :meth:`~class." -"__subclasscheck__` 方法中呼叫。)" +"檢查 *subclass* 是否該被認為是該 ABC 的子類別,也就是說你可以直接自" +"訂 :func:`issubclass` 的行為,而不用對於那些你希望定義為該 ABC 的子類別的類別" +"都個別呼叫 :meth:`register` 方法。(這個類別方法是在 ABC " +"的 :meth:`~type.__subclasscheck__` 方法中呼叫。)" #: ../../library/abc.rst:104 msgid "" @@ -205,8 +206,8 @@ msgid "" msgstr "" "此方法必須回傳 ``True``、``False`` 或是 :data:`NotImplemented`。如果回傳 " "``True``,*subclass* 就會被認為是這個 ABC 的子類別。如果回傳 ``False``," -"*subclass* 就會被判定並非該 ABC 的子類別,即便正常情況應如此。如果回傳 :data:" -"`!NotImplemented`,子類別檢查會按照正常機制繼續執行。" +"*subclass* 就會被判定並非該 ABC 的子類別,即便正常情況應如此。如果回" +"傳 :data:`!NotImplemented`,子類別檢查會按照正常機制繼續執行。" #: ../../library/abc.rst:114 msgid "" @@ -271,39 +272,40 @@ msgstr "" #: ../../library/abc.rst:143 msgid "" -"The ABC ``MyIterable`` defines the standard iterable method, :meth:" -"`~iterator.__iter__`, as an abstract method. The implementation given here " -"can still be called from subclasses. The :meth:`!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 ABC ``MyIterable`` defines the standard iterable " +"method, :meth:`~object.__iter__`, as an abstract method. The implementation " +"given here can still be called from subclasses. The :meth:`!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." msgstr "" -"ABC ``MyIterable`` 定義了作為抽象方法的一個標準疊代方法 :meth:`~iterator." -"__iter__`。這裡給定的實作仍可在子類別中被呼叫。:meth:`!get_iterator` 方法也" -"是 ``MyIterable`` 抽象基底類別的一部分,但它不必被非抽象衍生類別覆寫。" +"ABC ``MyIterable`` 定義了作為抽象方法的一個標準疊代方" +"法 :meth:`~object.__iter__`。這裡給定的實作仍可在子類別中被呼叫。:meth:`!" +"get_iterator` 方法也是 ``MyIterable`` 抽象基底類別的一部分,但它不必被非抽象" +"衍生類別覆寫。" #: ../../library/abc.rst:149 msgid "" "The :meth:`__subclasshook__` class method defined here says that any class " -"that has an :meth:`~iterator.__iter__` method in its :attr:`~object." -"__dict__` (or in that of one of its base classes, accessed via the :attr:" -"`~class.__mro__` list) is considered a ``MyIterable`` too." +"that has an :meth:`~object.__iter__` method in its :attr:`~object.__dict__` " +"(or in that of one of its base classes, accessed via " +"the :attr:`~type.__mro__` list) is considered a ``MyIterable`` too." msgstr "" -"這裡定義的 :meth:`__subclasshook__` 類別方法說明任何在其 :attr:`~object." -"__dict__` (或在其透過 :attr:`~class.__mro__` 列表訪問的基底類別) 中具有 :" -"meth:`~iterator.__iter__` 方法的類別也都會被視為 ``MyIterable``。" +"這裡定義的 :meth:`__subclasshook__` 類別方法說明任何在" +"其 :attr:`~object.__dict__` (或在其透過 :attr:`~type.__mro__` 列表存取的基底" +"類別) 中具有 :meth:`~object.__iter__` 方法的類別也都會被視為 ``MyIterable``。" #: ../../library/abc.rst:154 msgid "" "Finally, the last line makes ``Foo`` a virtual subclass of ``MyIterable``, " -"even though it does not define an :meth:`~iterator.__iter__` method (it uses " +"even though it does not define an :meth:`~object.__iter__` method (it uses " "the old-style iterable protocol, defined in terms of :meth:`~object.__len__` " "and :meth:`~object.__getitem__`). Note that this will not make " "``get_iterator`` available as a method of ``Foo``, so it is provided " "separately." msgstr "" -"最後,即使 ``Foo`` 沒有定義 :meth:`~iterator.__iter__` 方法(它使用了以 :" -"meth:`~object.__len__` 和 :meth:`~object.__getitem__` 所定義的舊式可疊代物件" -"協定),最末一行使其成為 ``MyIterable`` 的一個虛擬子類別。請注意這不會使 " +"最後,即使 ``Foo`` 沒有定義 :meth:`~object.__iter__` 方法(它使用了" +"以 :meth:`~object.__len__` 和 :meth:`~object.__getitem__` 所定義的舊式可疊代" +"物件協定),最末一行使其成為 ``MyIterable`` 的一個虛擬子類別。請注意這不會使 " "``get_iterator`` 成為 ``Foo`` 的一個可用方法,所以它是需要被另外提供的。" #: ../../library/abc.rst:163 @@ -423,8 +425,8 @@ msgid "" msgstr "" "為了能正確地與 ABC 機制實作相互操作,描述器必須使用 :attr:`!" "__isabstractmethod__` 將自身標識為抽象的。一般來說,如果被用於組成描述器的任" -"一方法是抽象的,則此屬性應當為 ``True``。 例如,Python 的內建 :class:" -"`property` 所做的就等價於: ::" +"一方法是抽象的,則此屬性應當為 ``True``。 例如,Python 的內" +"建 :class:`property` 所做的就等價於: ::" #: ../../library/abc.rst:223 msgid "" @@ -536,13 +538,15 @@ msgstr "" #: ../../library/abc.rst:285 msgid "" -"It is now possible to use :class:`property`, :meth:`property.getter`, :meth:" -"`property.setter` and :meth:`property.deleter` with :func:`abstractmethod`, " -"making this decorator redundant." +"It is now possible to " +"use :class:`property`, :meth:`property.getter`, :meth:`property.setter` " +"and :meth:`property.deleter` with :func:`abstractmethod`, making this " +"decorator redundant." msgstr "" -"現在可以讓 :class:`property`、:meth:`property.getter`、:meth:`property." -"setter` 和 :meth:`property.deleter` 配合 :func:`abstractmethod` 使用,使得此" -"裝飾器變得冗餘。" +"現在可以" +"讓 :class:`property`、:meth:`property.getter`、:meth:`property.setter` " +"和 :meth:`property.deleter` 配合 :func:`abstractmethod` 使用,使得此裝飾器變" +"得冗餘。" #: ../../library/abc.rst:290 msgid "" @@ -627,7 +631,7 @@ msgstr ":mod:`!abc` 模組也提供了這些函式:" #: ../../library/abc.rst:330 msgid "Returns the current abstract base class cache token." -msgstr "回傳當前 ABC 快取令牌 (cache token)。" +msgstr "回傳目前 ABC 快取令牌 (cache token)。" #: ../../library/abc.rst:332 msgid "" @@ -636,8 +640,8 @@ msgid "" "The token changes with every call to :meth:`ABCMeta.register` on any ABC." msgstr "" "此令牌是一個(支援相等性測試的)不透明物件 (opaque object),用於為虛擬子類別" -"標識抽象基底類別快取的當前版本。此令牌會在任何 ABC 上每次呼叫 :meth:`ABCMeta." -"register` 時發生更改。" +"標識抽象基底類別快取的目前版本。此令牌會在任何 ABC 上每次呼" +"叫 :meth:`ABCMeta.register` 時發生更改。" #: ../../library/abc.rst:340 msgid "" @@ -666,7 +670,7 @@ msgstr "" #: ../../library/abc.rst:357 msgid "Footnotes" -msgstr "註解" +msgstr "註腳" #: ../../library/abc.rst:358 msgid "" diff --git a/library/aifc.po b/library/aifc.po index c7c6c1d8af..2cfcb0d41f 100644 --- a/library/aifc.po +++ b/library/aifc.po @@ -1,286 +1,39 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # -# Translators: +#, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-07-20 00:03+0000\n" -"PO-Revision-Date: 2022-05-22 01:57+0800\n" -"Last-Translator: Adrian Liaw \n" +"POT-Creation-Date: 2024-11-18 00:15+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Poedit 3.0.1\n" #: ../../library/aifc.rst:2 -msgid ":mod:`aifc` --- Read and write AIFF and AIFC files" -msgstr ":mod:`aifc` --- 讀寫 AIFF 與 AIFC 檔案" +msgid ":mod:`!aifc` --- Read and write AIFF and AIFC files" +msgstr ":mod:`!aifc` --- 讀寫 AIFF 與 AIFC 檔案" -#: ../../library/aifc.rst:8 -msgid "**Source code:** :source:`Lib/aifc.py`" -msgstr "**原始碼:**\\ :source:`Lib/aifc.py`" - -#: ../../library/aifc.rst:16 -msgid "" -"The :mod:`aifc` module is deprecated (see :pep:`PEP 594 <594#aifc>` for " -"details)." -msgstr "" -":mod:`aifc` 模組 (module) 即將被棄用(詳見 :pep:`PEP 594 <594#aifc>`\\ )。" - -#: ../../library/aifc.rst:22 -msgid "" -"This module provides support for reading and writing AIFF and AIFF-C files. " -"AIFF is Audio Interchange File Format, a format for storing digital audio " -"samples in a file. AIFF-C is a newer version of the format that includes " -"the ability to compress the audio data." -msgstr "" - -#: ../../library/aifc.rst:27 -msgid "" -"Audio files have a number of parameters that describe the audio data. The " -"sampling rate or frame rate is the number of times per second the sound is " -"sampled. The number of channels indicate if the audio is mono, stereo, or " -"quadro. Each frame consists of one sample per channel. The sample size is " -"the size in bytes of each sample. Thus a frame consists of ``nchannels * " -"samplesize`` bytes, and a second's worth of audio consists of ``nchannels * " -"samplesize * framerate`` bytes." -msgstr "" - -#: ../../library/aifc.rst:35 -msgid "" -"For example, CD quality audio has a sample size of two bytes (16 bits), uses " -"two channels (stereo) and has a frame rate of 44,100 frames/second. This " -"gives a frame size of 4 bytes (2\\*2), and a second's worth occupies " -"2\\*2\\*44100 bytes (176,400 bytes)." -msgstr "" - -#: ../../library/aifc.rst:40 -msgid "Module :mod:`aifc` defines the following function:" -msgstr ":mod:`aifc` 模組定義了以下函式:" - -#: ../../library/aifc.rst:45 -msgid "" -"Open an AIFF or AIFF-C file and return an object instance with methods that " -"are described below. The argument *file* is either a string naming a file " -"or a :term:`file object`. *mode* must be ``'r'`` or ``'rb'`` when the file " -"must be opened for reading, or ``'w'`` or ``'wb'`` when the file must be " -"opened for writing. If omitted, ``file.mode`` is used if it exists, " -"otherwise ``'rb'`` is used. When used for writing, the file object should " -"be seekable, unless you know ahead of time how many samples you are going to " -"write in total and use :meth:`writeframesraw` and :meth:`setnframes`. The :" -"func:`.open` function may be used in a :keyword:`with` statement. When the :" -"keyword:`!with` block completes, the :meth:`~aifc.close` method is called." -msgstr "" - -#: ../../library/aifc.rst:56 -msgid "Support for the :keyword:`with` statement was added." -msgstr "" - -#: ../../library/aifc.rst:59 -msgid "" -"Objects returned by :func:`.open` when a file is opened for reading have the " -"following methods:" -msgstr "" - -#: ../../library/aifc.rst:65 -msgid "Return the number of audio channels (1 for mono, 2 for stereo)." -msgstr "" - -#: ../../library/aifc.rst:70 -msgid "Return the size in bytes of individual samples." -msgstr "" - -#: ../../library/aifc.rst:75 -msgid "Return the sampling rate (number of audio frames per second)." -msgstr "" - -#: ../../library/aifc.rst:80 -msgid "Return the number of audio frames in the file." -msgstr "" - -#: ../../library/aifc.rst:85 -msgid "" -"Return a bytes array of length 4 describing the type of compression used in " -"the audio file. For AIFF files, the returned value is ``b'NONE'``." -msgstr "" - -#: ../../library/aifc.rst:92 -msgid "" -"Return a bytes array convertible to a human-readable description of the type " -"of compression used in the audio file. For AIFF files, the returned value " -"is ``b'not compressed'``." -msgstr "" - -#: ../../library/aifc.rst:99 -msgid "" -"Returns a :func:`~collections.namedtuple` ``(nchannels, sampwidth, " -"framerate, nframes, comptype, compname)``, equivalent to output of the :meth:" -"`get\\*` methods." -msgstr "" - -#: ../../library/aifc.rst:106 -msgid "" -"Return a list of markers in the audio file. A marker consists of a tuple of " -"three elements. The first is the mark ID (an integer), the second is the " -"mark position in frames from the beginning of the data (an integer), the " -"third is the name of the mark (a string)." -msgstr "" - -#: ../../library/aifc.rst:114 -msgid "" -"Return the tuple as described in :meth:`getmarkers` for the mark with the " -"given *id*." -msgstr "" - -#: ../../library/aifc.rst:120 -msgid "" -"Read and return the next *nframes* frames from the audio file. The returned " -"data is a string containing for each frame the uncompressed samples of all " -"channels." -msgstr "" - -#: ../../library/aifc.rst:127 -msgid "" -"Rewind the read pointer. The next :meth:`readframes` will start from the " -"beginning." -msgstr "" - -#: ../../library/aifc.rst:133 -msgid "Seek to the specified frame number." -msgstr "" - -#: ../../library/aifc.rst:138 -msgid "Return the current frame number." -msgstr "" - -#: ../../library/aifc.rst:143 -msgid "" -"Close the AIFF file. After calling this method, the object can no longer be " -"used." -msgstr "" - -#: ../../library/aifc.rst:146 -msgid "" -"Objects returned by :func:`.open` when a file is opened for writing have all " -"the above methods, except for :meth:`readframes` and :meth:`setpos`. In " -"addition the following methods exist. The :meth:`get\\*` methods can only " -"be called after the corresponding :meth:`set\\*` methods have been called. " -"Before the first :meth:`writeframes` or :meth:`writeframesraw`, all " -"parameters except for the number of frames must be filled in." -msgstr "" - -#: ../../library/aifc.rst:156 -msgid "" -"Create an AIFF file. The default is that an AIFF-C file is created, unless " -"the name of the file ends in ``'.aiff'`` in which case the default is an " -"AIFF file." -msgstr "" - -#: ../../library/aifc.rst:162 -msgid "" -"Create an AIFF-C file. The default is that an AIFF-C file is created, " -"unless the name of the file ends in ``'.aiff'`` in which case the default is " -"an AIFF file." -msgstr "" - -#: ../../library/aifc.rst:169 -msgid "Specify the number of channels in the audio file." -msgstr "" - -#: ../../library/aifc.rst:174 -msgid "Specify the size in bytes of audio samples." -msgstr "" - -#: ../../library/aifc.rst:179 -msgid "Specify the sampling frequency in frames per second." -msgstr "" - -#: ../../library/aifc.rst:184 -msgid "" -"Specify the number of frames that are to be written to the audio file. If " -"this parameter is not set, or not set correctly, the file needs to support " -"seeking." -msgstr "" - -#: ../../library/aifc.rst:195 -msgid "" -"Specify the compression type. If not specified, the audio data will not be " -"compressed. In AIFF files, compression is not possible. The name parameter " -"should be a human-readable description of the compression type as a bytes " -"array, the type parameter should be a bytes array of length 4. Currently " -"the following compression types are supported: ``b'NONE'``, ``b'ULAW'``, " -"``b'ALAW'``, ``b'G722'``." -msgstr "" - -#: ../../library/aifc.rst:205 -msgid "" -"Set all the above parameters at once. The argument is a tuple consisting of " -"the various parameters. This means that it is possible to use the result of " -"a :meth:`getparams` call as argument to :meth:`setparams`." -msgstr "" - -#: ../../library/aifc.rst:212 -msgid "" -"Add a mark with the given id (larger than 0), and the given name at the " -"given position. This method can be called at any time before :meth:`close`." -msgstr "" - -#: ../../library/aifc.rst:219 -msgid "" -"Return the current write position in the output file. Useful in combination " -"with :meth:`setmark`." -msgstr "" - -#: ../../library/aifc.rst:225 -msgid "" -"Write data to the output file. This method can only be called after the " -"audio file parameters have been set." -msgstr "" - -#: ../../library/aifc.rst:228 ../../library/aifc.rst:237 -msgid "Any :term:`bytes-like object` is now accepted." -msgstr "" - -#: ../../library/aifc.rst:234 +#: ../../library/aifc.rst:10 msgid "" -"Like :meth:`writeframes`, except that the header of the audio file is not " -"updated." +"This module is no longer part of the Python standard library. It was :ref:" +"`removed in Python 3.13 ` after being deprecated in " +"Python 3.11. The removal was decided in :pep:`594`." msgstr "" +"這個模組已不再是 Python 標準函式庫的一部分。它在 Python 3.11 中被棄用,並\\ :" +"ref:`已在 Python 3.13 中被移除 `。它的移除是在 :pep:" +"`594` 中決定的。" -#: ../../library/aifc.rst:244 +#: ../../library/aifc.rst:14 msgid "" -"Close the AIFF file. The header of the file is updated to reflect the " -"actual size of the audio data. After calling this method, the object can no " -"longer be used." +"The last version of Python that provided the :mod:`!aifc` module was `Python " +"3.12 `_." msgstr "" - -#: ../../library/aifc.rst:10 -msgid "Audio Interchange File Format" -msgstr "Audio Interchange File Format(音訊交換檔案格式)" - -#: ../../library/aifc.rst:10 -msgid "AIFF" -msgstr "AIFF" - -#: ../../library/aifc.rst:10 -msgid "AIFF-C" -msgstr "AIFF-C" - -#: ../../library/aifc.rst:190 -msgid "u-LAW" -msgstr "u-LAW" - -#: ../../library/aifc.rst:190 -msgid "A-LAW" -msgstr "A-LAW" - -#: ../../library/aifc.rst:190 -msgid "G.722" -msgstr "G.722" +"最後提供 :mod:`!aifc` 模組的 Python 版本是 `Python 3.12 `_。" diff --git a/library/allos.po b/library/allos.po index cad1734fed..59c9cddfde 100644 --- a/library/allos.po +++ b/library/allos.po @@ -5,7 +5,7 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2022-02-15 17:54+0800\n" diff --git a/library/archiving.po b/library/archiving.po index d54de5aacc..c42e38f29a 100644 --- a/library/archiving.po +++ b/library/archiving.po @@ -6,7 +6,7 @@ # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2023-02-18 14:22+0800\n" diff --git a/library/argparse.po b/library/argparse.po index e6458432b6..7c9a382be0 100644 --- a/library/argparse.po +++ b/library/argparse.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-07-20 00:19+0000\n" "PO-Revision-Date: 2018-05-23 14:38+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -20,572 +19,245 @@ msgstr "" #: ../../library/argparse.rst:2 msgid "" -":mod:`!argparse` --- Parser for command-line options, arguments and sub-" -"commands" -msgstr "" +":mod:`!argparse` --- Parser for command-line options, arguments and " +"subcommands" +msgstr ":mod:`!argparse` --- 命令列選項、引數和子命令的剖析器" #: ../../library/argparse.rst:12 msgid "**Source code:** :source:`Lib/argparse.py`" msgstr "**原始碼:**\\ :source:`Lib/argparse.py`" +#: ../../library/argparse.rst:16 +msgid "" +"While :mod:`argparse` is the default recommended standard library module for " +"implementing basic command line applications, authors with more exacting " +"requirements for exactly how their command line applications behave may find " +"it doesn't provide the necessary level of control. Refer to :ref:`choosing-" +"an-argument-parser` for alternatives to consider when ``argparse`` doesn't " +"support behaviors that the application requires (such as entirely disabling " +"support for interspersed options and positional arguments, or accepting " +"option parameter values that start with ``-`` even when they correspond to " +"another defined option)." +msgstr "" + #: ../../library/argparse.rst:-1 msgid "Tutorial" msgstr "教學" -#: ../../library/argparse.rst:18 +#: ../../library/argparse.rst:30 msgid "" "This page contains the API reference information. For a more gentle " "introduction to Python command-line parsing, have a look at the :ref:" "`argparse tutorial `." msgstr "" -#: ../../library/argparse.rst:22 +#: ../../library/argparse.rst:34 msgid "" -"The :mod:`argparse` module makes it easy to write user-friendly command-line " -"interfaces. The program defines what arguments it requires, and :mod:" -"`argparse` will figure out how to parse those out of :data:`sys.argv`. The :" -"mod:`argparse` module also automatically generates help and usage messages. " -"The module will also issue errors when users give the program invalid " -"arguments." +"The :mod:`!argparse` module makes it easy to write user-friendly command-" +"line interfaces. The program defines what arguments it requires, and :mod:`!" +"argparse` will figure out how to parse those out of :data:`sys.argv`. The :" +"mod:`!argparse` module also automatically generates help and usage " +"messages. The module will also issue errors when users give the program " +"invalid arguments." msgstr "" -#: ../../library/argparse.rst:30 -msgid "Core Functionality" -msgstr "" - -#: ../../library/argparse.rst:32 +#: ../../library/argparse.rst:40 msgid "" -"The :mod:`argparse` module's support for command-line interfaces is built " +"The :mod:`!argparse` module's support for command-line interfaces is built " "around an instance of :class:`argparse.ArgumentParser`. It is a container " "for argument specifications and has options that apply to the parser as " "whole::" msgstr "" -#: ../../library/argparse.rst:36 +#: ../../library/argparse.rst:44 msgid "" "parser = argparse.ArgumentParser(\n" " prog='ProgramName',\n" " description='What the program does',\n" " epilog='Text at the bottom of help')" msgstr "" +"parser = argparse.ArgumentParser(\n" +" prog='ProgramName',\n" +" description='What the program does',\n" +" epilog='Text at the bottom of help')" -#: ../../library/argparse.rst:41 +#: ../../library/argparse.rst:49 msgid "" "The :meth:`ArgumentParser.add_argument` method attaches individual argument " "specifications to the parser. It supports positional arguments, options " "that accept values, and on/off flags::" msgstr "" -#: ../../library/argparse.rst:45 +#: ../../library/argparse.rst:53 msgid "" "parser.add_argument('filename') # positional argument\n" "parser.add_argument('-c', '--count') # option that takes a value\n" "parser.add_argument('-v', '--verbose',\n" " action='store_true') # on/off flag" msgstr "" +"parser.add_argument('filename') # 位置引數\n" +"parser.add_argument('-c', '--count') # 接收一個值的選項\n" +"parser.add_argument('-v', '--verbose',\n" +" action='store_true') # 開關旗標" -#: ../../library/argparse.rst:50 +#: ../../library/argparse.rst:58 msgid "" "The :meth:`ArgumentParser.parse_args` method runs the parser and places the " "extracted data in a :class:`argparse.Namespace` object::" msgstr "" -#: ../../library/argparse.rst:53 -msgid "" -"args = parser.parse_args()\n" -"print(args.filename, args.count, args.verbose)" -msgstr "" - -#: ../../library/argparse.rst:58 -msgid "Quick Links for add_argument()" -msgstr "" - -#: ../../library/argparse.rst:61 -msgid "Name" -msgstr "名稱" - #: ../../library/argparse.rst:61 -msgid "Description" -msgstr "描述" - -#: ../../library/argparse.rst:61 -msgid "Values" -msgstr "數值" - -#: ../../library/argparse.rst:63 -msgid "action_" -msgstr "action_" - -#: ../../library/argparse.rst:63 -msgid "Specify how an argument should be handled" -msgstr "" - -#: ../../library/argparse.rst:63 -msgid "" -"``'store'``, ``'store_const'``, ``'store_true'``, ``'append'``, " -"``'append_const'``, ``'count'``, ``'help'``, ``'version'``" -msgstr "" -"``'store'``, ``'store_const'``, ``'store_true'``, ``'append'``, " -"``'append_const'``, ``'count'``, ``'help'``, ``'version'``" - -#: ../../library/argparse.rst:64 -msgid "choices_" -msgstr "choices_" - -#: ../../library/argparse.rst:64 -msgid "Limit values to a specific set of choices" -msgstr "" - -#: ../../library/argparse.rst:64 -msgid "" -"``['foo', 'bar']``, ``range(1, 10)``, or :class:`~collections.abc.Container` " -"instance" -msgstr "" - -#: ../../library/argparse.rst:65 -msgid "const_" -msgstr "const_" - -#: ../../library/argparse.rst:65 -msgid "Store a constant value" -msgstr "" - -#: ../../library/argparse.rst:66 -msgid "default_" -msgstr "default_" - -#: ../../library/argparse.rst:66 -msgid "Default value used when an argument is not provided" -msgstr "" - -#: ../../library/argparse.rst:66 -msgid "Defaults to ``None``" -msgstr "" - -#: ../../library/argparse.rst:67 -msgid "dest_" -msgstr "dest_" - -#: ../../library/argparse.rst:67 -msgid "Specify the attribute name used in the result namespace" -msgstr "" - -#: ../../library/argparse.rst:68 -msgid "help_" -msgstr "help_" - -#: ../../library/argparse.rst:68 -msgid "Help message for an argument" -msgstr "" - -#: ../../library/argparse.rst:69 -msgid "metavar_" -msgstr "metavar_" - -#: ../../library/argparse.rst:69 -msgid "Alternate display name for the argument as shown in help" -msgstr "" - -#: ../../library/argparse.rst:70 -msgid "nargs_" -msgstr "nargs_" - -#: ../../library/argparse.rst:70 -msgid "Number of times the argument can be used" -msgstr "" - -#: ../../library/argparse.rst:70 -msgid ":class:`int`, ``'?'``, ``'*'``, or ``'+'``" -msgstr ":class:`int`, ``'?'``, ``'*'``, or ``'+'``" - -#: ../../library/argparse.rst:71 -msgid "required_" -msgstr "required_" - -#: ../../library/argparse.rst:71 -msgid "Indicate whether an argument is required or optional" -msgstr "" - -#: ../../library/argparse.rst:71 -msgid "``True`` or ``False``" -msgstr "``True`` 或 ``False``" - -#: ../../library/argparse.rst:72 -msgid ":ref:`type `" -msgstr "" - -#: ../../library/argparse.rst:72 -msgid "Automatically convert an argument to the given type" -msgstr "" - -#: ../../library/argparse.rst:72 -msgid "" -":class:`int`, :class:`float`, ``argparse.FileType('w')``, or callable " -"function" -msgstr "" -":class:`int`、:class:`float`、``argparse.FileType('w')`` 或可呼叫的函式" - -#: ../../library/argparse.rst:77 -msgid "Example" -msgstr "範例" - -#: ../../library/argparse.rst:79 -msgid "" -"The following code is a Python program that takes a list of integers and " -"produces either the sum or the max::" -msgstr "" - -#: ../../library/argparse.rst:82 msgid "" -"import argparse\n" -"\n" -"parser = argparse.ArgumentParser(description='Process some integers.')\n" -"parser.add_argument('integers', metavar='N', type=int, nargs='+',\n" -" help='an integer for the accumulator')\n" -"parser.add_argument('--sum', dest='accumulate', action='store_const',\n" -" const=sum, default=max,\n" -" help='sum the integers (default: find the max)')\n" -"\n" "args = parser.parse_args()\n" -"print(args.accumulate(args.integers))" +"print(args.filename, args.count, args.verbose)" msgstr "" -"import argparse\n" -"\n" -"parser = argparse.ArgumentParser(description='Process some integers.')\n" -"parser.add_argument('integers', metavar='N', type=int, nargs='+',\n" -" help='an integer for the accumulator')\n" -"parser.add_argument('--sum', dest='accumulate', action='store_const',\n" -" const=sum, default=max,\n" -" help='sum the integers (default: find the max)')\n" -"\n" "args = parser.parse_args()\n" -"print(args.accumulate(args.integers))" - -#: ../../library/argparse.rst:94 -msgid "" -"Assuming the above Python code is saved into a file called ``prog.py``, it " -"can be run at the command line and it provides useful help messages:" -msgstr "" - -#: ../../library/argparse.rst:97 -msgid "" -"$ python prog.py -h\n" -"usage: prog.py [-h] [--sum] N [N ...]\n" -"\n" -"Process some integers.\n" -"\n" -"positional arguments:\n" -" N an integer for the accumulator\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --sum sum the integers (default: find the max)" -msgstr "" -"$ python prog.py -h\n" -"usage: prog.py [-h] [--sum] N [N ...]\n" -"\n" -"Process some integers.\n" -"\n" -"positional arguments:\n" -" N an integer for the accumulator\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --sum sum the integers (default: find the max)" - -#: ../../library/argparse.rst:111 -msgid "" -"When run with the appropriate arguments, it prints either the sum or the max " -"of the command-line integers:" -msgstr "" - -#: ../../library/argparse.rst:114 -msgid "" -"$ python prog.py 1 2 3 4\n" -"4\n" -"\n" -"$ python prog.py 1 2 3 4 --sum\n" -"10" -msgstr "" -"$ python prog.py 1 2 3 4\n" -"4\n" -"\n" -"$ python prog.py 1 2 3 4 --sum\n" -"10" - -#: ../../library/argparse.rst:122 -msgid "If invalid arguments are passed in, an error will be displayed:" -msgstr "" - -#: ../../library/argparse.rst:124 -msgid "" -"$ python prog.py a b c\n" -"usage: prog.py [-h] [--sum] N [N ...]\n" -"prog.py: error: argument N: invalid int value: 'a'" -msgstr "" -"$ python prog.py a b c\n" -"usage: prog.py [-h] [--sum] N [N ...]\n" -"prog.py: error: argument N: invalid int value: 'a'" - -#: ../../library/argparse.rst:130 -msgid "The following sections walk you through this example." -msgstr "" - -#: ../../library/argparse.rst:134 -msgid "Creating a parser" -msgstr "建立一個剖析器" - -#: ../../library/argparse.rst:136 -msgid "" -"The first step in using the :mod:`argparse` is creating an :class:" -"`ArgumentParser` object::" -msgstr "" - -#: ../../library/argparse.rst:139 -msgid "" -">>> parser = argparse.ArgumentParser(description='Process some integers.')" -msgstr "" -">>> parser = argparse.ArgumentParser(description='Process some integers.')" - -#: ../../library/argparse.rst:141 -msgid "" -"The :class:`ArgumentParser` object will hold all the information necessary " -"to parse the command line into Python data types." -msgstr "" - -#: ../../library/argparse.rst:146 -msgid "Adding arguments" -msgstr "增加引數" - -#: ../../library/argparse.rst:148 -msgid "" -"Filling an :class:`ArgumentParser` with information about program arguments " -"is done by making calls to the :meth:`~ArgumentParser.add_argument` method. " -"Generally, these calls tell the :class:`ArgumentParser` how to take the " -"strings on the command line and turn them into objects. This information is " -"stored and used when :meth:`~ArgumentParser.parse_args` is called. For " -"example::" -msgstr "" - -#: ../../library/argparse.rst:154 -msgid "" -">>> parser.add_argument('integers', metavar='N', type=int, nargs='+',\n" -"... help='an integer for the accumulator')\n" -">>> parser.add_argument('--sum', dest='accumulate', action='store_const',\n" -"... const=sum, default=max,\n" -"... help='sum the integers (default: find the max)')" -msgstr "" -">>> parser.add_argument('integers', metavar='N', type=int, nargs='+',\n" -"... help='an integer for the accumulator')\n" -">>> parser.add_argument('--sum', dest='accumulate', action='store_const',\n" -"... const=sum, default=max,\n" -"... help='sum the integers (default: find the max)')" - -#: ../../library/argparse.rst:160 -msgid "" -"Later, calling :meth:`~ArgumentParser.parse_args` will return an object with " -"two attributes, ``integers`` and ``accumulate``. The ``integers`` attribute " -"will be a list of one or more integers, and the ``accumulate`` attribute " -"will be either the :func:`sum` function, if ``--sum`` was specified at the " -"command line, or the :func:`max` function if it was not." -msgstr "" - -#: ../../library/argparse.rst:168 -msgid "Parsing arguments" -msgstr "剖析引數" - -#: ../../library/argparse.rst:170 -msgid "" -":class:`ArgumentParser` parses arguments through the :meth:`~ArgumentParser." -"parse_args` method. This will inspect the command line, convert each " -"argument to the appropriate type and then invoke the appropriate action. In " -"most cases, this means a simple :class:`Namespace` object will be built up " -"from attributes parsed out of the command line::" -msgstr "" - -#: ../../library/argparse.rst:176 -msgid "" -">>> parser.parse_args(['--sum', '7', '-1', '42'])\n" -"Namespace(accumulate=, integers=[7, -1, 42])" -msgstr "" -">>> parser.parse_args(['--sum', '7', '-1', '42'])\n" -"Namespace(accumulate=, integers=[7, -1, 42])" +"print(args.filename, args.count, args.verbose)" -#: ../../library/argparse.rst:179 +#: ../../library/argparse.rst:65 msgid "" -"In a script, :meth:`~ArgumentParser.parse_args` will typically be called " -"with no arguments, and the :class:`ArgumentParser` will automatically " -"determine the command-line arguments from :data:`sys.argv`." +"If you're looking for a guide about how to upgrade :mod:`optparse` code to :" +"mod:`!argparse`, see :ref:`Upgrading Optparse Code `." msgstr "" -#: ../../library/argparse.rst:185 +#: ../../library/argparse.rst:69 msgid "ArgumentParser objects" msgstr "ArgumentParser 物件" -#: ../../library/argparse.rst:194 +#: ../../library/argparse.rst:78 msgid "" "Create a new :class:`ArgumentParser` object. All parameters should be passed " "as keyword arguments. Each parameter has its own more detailed description " "below, but in short they are:" msgstr "" -#: ../../library/argparse.rst:198 +#: ../../library/argparse.rst:82 msgid "" "prog_ - The name of the program (default: ``os.path.basename(sys.argv[0])``)" -msgstr "" +msgstr "prog_ - 程式的名稱(預設值:``os.path.basename(sys.argv[0])``)" -#: ../../library/argparse.rst:201 +#: ../../library/argparse.rst:85 msgid "" "usage_ - The string describing the program usage (default: generated from " "arguments added to parser)" -msgstr "" +msgstr "usage_ - 描述程式用法的字串(預設值:從新增到剖析器的引數產生)" -#: ../../library/argparse.rst:204 +#: ../../library/argparse.rst:88 msgid "" "description_ - Text to display before the argument help (by default, no text)" -msgstr "" +msgstr "description_ - 引數說明之前要顯示的文字(預設值:無文字)" -#: ../../library/argparse.rst:207 +#: ../../library/argparse.rst:91 msgid "epilog_ - Text to display after the argument help (by default, no text)" -msgstr "" +msgstr "epilog_ - 引數說明之後要顯示的文字(預設值:無文字)" -#: ../../library/argparse.rst:209 +#: ../../library/argparse.rst:93 msgid "" "parents_ - A list of :class:`ArgumentParser` objects whose arguments should " "also be included" -msgstr "" +msgstr "parents_ - 一個 :class:`ArgumentParser` 物件的串列,其引數也應該被包含" -#: ../../library/argparse.rst:212 +#: ../../library/argparse.rst:96 msgid "formatter_class_ - A class for customizing the help output" -msgstr "" +msgstr "formatter_class_ - 用於自訂說明輸出的類別" -#: ../../library/argparse.rst:214 +#: ../../library/argparse.rst:98 msgid "" "prefix_chars_ - The set of characters that prefix optional arguments " "(default: '-')" -msgstr "" +msgstr "prefix_chars_ - 前綴可選引數的字元集合(預設值:'-')" -#: ../../library/argparse.rst:217 +#: ../../library/argparse.rst:101 msgid "" "fromfile_prefix_chars_ - The set of characters that prefix files from which " "additional arguments should be read (default: ``None``)" msgstr "" -#: ../../library/argparse.rst:220 +#: ../../library/argparse.rst:104 msgid "" "argument_default_ - The global default value for arguments (default: " "``None``)" msgstr "" -#: ../../library/argparse.rst:223 +#: ../../library/argparse.rst:107 msgid "" "conflict_handler_ - The strategy for resolving conflicting optionals " "(usually unnecessary)" msgstr "" -#: ../../library/argparse.rst:226 +#: ../../library/argparse.rst:110 msgid "" "add_help_ - Add a ``-h/--help`` option to the parser (default: ``True``)" msgstr "" -#: ../../library/argparse.rst:228 +#: ../../library/argparse.rst:112 msgid "" "allow_abbrev_ - Allows long options to be abbreviated if the abbreviation is " "unambiguous. (default: ``True``)" msgstr "" -#: ../../library/argparse.rst:231 +#: ../../library/argparse.rst:115 msgid "" -"exit_on_error_ - Determines whether or not ArgumentParser exits with error " -"info when an error occurs. (default: ``True``)" +"exit_on_error_ - Determines whether or not :class:`!ArgumentParser` exits " +"with error info when an error occurs. (default: ``True``)" msgstr "" -#: ../../library/argparse.rst:234 +#: ../../library/argparse.rst:118 msgid "*allow_abbrev* parameter was added." msgstr "新增 *allow_abbrev* 參數。" -#: ../../library/argparse.rst:237 +#: ../../library/argparse.rst:121 msgid "" "In previous versions, *allow_abbrev* also disabled grouping of short flags " "such as ``-vv`` to mean ``-v -v``." msgstr "" -#: ../../library/argparse.rst:241 +#: ../../library/argparse.rst:125 msgid "*exit_on_error* parameter was added." msgstr "新增 *exit_on_error* 參數。" -#: ../../library/argparse.rst:244 ../../library/argparse.rst:780 +#: ../../library/argparse.rst:128 ../../library/argparse.rst:616 msgid "The following sections describe how each of these are used." msgstr "" -#: ../../library/argparse.rst:250 +#: ../../library/argparse.rst:134 msgid "prog" -msgstr "" +msgstr "prog" -#: ../../library/argparse.rst:252 +#: ../../library/argparse.rst:137 msgid "" -"By default, :class:`ArgumentParser` objects use ``sys.argv[0]`` to determine " -"how to display the name of the program in help messages. This default is " -"almost always desirable because it will make the help messages match how the " -"program was invoked on the command line. For example, consider a file named " -"``myprogram.py`` with the following code::" +"By default, :class:`ArgumentParser` calculates the name of the program to " +"display in help messages depending on the way the Python interpreter was run:" msgstr "" -#: ../../library/argparse.rst:258 ../../library/argparse.rst:678 +#: ../../library/argparse.rst:140 msgid "" -"import argparse\n" -"parser = argparse.ArgumentParser()\n" -"parser.add_argument('--foo', help='foo help')\n" -"args = parser.parse_args()" +"The :func:`base name ` of ``sys.argv[0]`` if a file was " +"passed as argument." msgstr "" -"import argparse\n" -"parser = argparse.ArgumentParser()\n" -"parser.add_argument('--foo', help='foo help')\n" -"args = parser.parse_args()" -#: ../../library/argparse.rst:263 +#: ../../library/argparse.rst:142 msgid "" -"The help for this program will display ``myprogram.py`` as the program name " -"(regardless of where the program was invoked from):" +"The Python interpreter name followed by ``sys.argv[0]`` if a directory or a " +"zipfile was passed as argument." msgstr "" -#: ../../library/argparse.rst:266 +#: ../../library/argparse.rst:144 msgid "" -"$ python myprogram.py --help\n" -"usage: myprogram.py [-h] [--foo FOO]\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo FOO foo help\n" -"$ cd ..\n" -"$ python subdir/myprogram.py --help\n" -"usage: myprogram.py [-h] [--foo FOO]\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo FOO foo help" +"The Python interpreter name followed by ``-m`` followed by the module or " +"package name if the :option:`-m` option was used." msgstr "" -"$ python myprogram.py --help\n" -"usage: myprogram.py [-h] [--foo FOO]\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo FOO foo help\n" -"$ cd ..\n" -"$ python subdir/myprogram.py --help\n" -"usage: myprogram.py [-h] [--foo FOO]\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo FOO foo help" -#: ../../library/argparse.rst:282 +#: ../../library/argparse.rst:147 msgid "" -"To change this default behavior, another value can be supplied using the " -"``prog=`` argument to :class:`ArgumentParser`::" +"This default is almost always desirable because it will make the help " +"messages match the string that was used to invoke the program on the command " +"line. However, to change this default behavior, another value can be " +"supplied using the ``prog=`` argument to :class:`ArgumentParser`::" msgstr "" -#: ../../library/argparse.rst:285 +#: ../../library/argparse.rst:152 msgid "" ">>> parser = argparse.ArgumentParser(prog='myprogram')\n" ">>> parser.print_help()\n" @@ -601,14 +273,14 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../library/argparse.rst:292 +#: ../../library/argparse.rst:159 msgid "" "Note that the program name, whether determined from ``sys.argv[0]`` or from " "the ``prog=`` argument, is available to help messages using the ``%(prog)s`` " "format specifier." msgstr "" -#: ../../library/argparse.rst:298 +#: ../../library/argparse.rst:165 msgid "" ">>> parser = argparse.ArgumentParser(prog='myprogram')\n" ">>> parser.add_argument('--foo', help='foo of the %(prog)s program')\n" @@ -628,50 +300,18 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo FOO foo of the myprogram program" -#: ../../library/argparse.rst:309 +#: ../../library/argparse.rst:176 msgid "usage" -msgstr "" +msgstr "usage" -#: ../../library/argparse.rst:311 +#: ../../library/argparse.rst:178 msgid "" "By default, :class:`ArgumentParser` calculates the usage message from the " -"arguments it contains::" -msgstr "" - -#: ../../library/argparse.rst:314 -msgid "" -">>> parser = argparse.ArgumentParser(prog='PROG')\n" -">>> parser.add_argument('--foo', nargs='?', help='foo help')\n" -">>> parser.add_argument('bar', nargs='+', help='bar help')\n" -">>> parser.print_help()\n" -"usage: PROG [-h] [--foo [FOO]] bar [bar ...]\n" -"\n" -"positional arguments:\n" -" bar bar help\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo [FOO] foo help" -msgstr "" -">>> parser = argparse.ArgumentParser(prog='PROG')\n" -">>> parser.add_argument('--foo', nargs='?', help='foo help')\n" -">>> parser.add_argument('bar', nargs='+', help='bar help')\n" -">>> parser.print_help()\n" -"usage: PROG [-h] [--foo [FOO]] bar [bar ...]\n" -"\n" -"positional arguments:\n" -" bar bar help\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo [FOO] foo help" - -#: ../../library/argparse.rst:327 -msgid "" -"The default message can be overridden with the ``usage=`` keyword argument::" +"arguments it contains. The default message can be overridden with the " +"``usage=`` keyword argument::" msgstr "" -#: ../../library/argparse.rst:329 +#: ../../library/argparse.rst:182 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', usage='%(prog)s " "[options]')\n" @@ -701,63 +341,43 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo [FOO] foo help" -#: ../../library/argparse.rst:342 +#: ../../library/argparse.rst:195 msgid "" "The ``%(prog)s`` format specifier is available to fill in the program name " "in your usage messages." msgstr "" -#: ../../library/argparse.rst:349 +#: ../../library/argparse.rst:202 msgid "description" -msgstr "描述" +msgstr "description" -#: ../../library/argparse.rst:351 +#: ../../library/argparse.rst:204 msgid "" "Most calls to the :class:`ArgumentParser` 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::" +"messages for the various arguments." msgstr "" -#: ../../library/argparse.rst:357 -msgid "" -">>> parser = argparse.ArgumentParser(description='A foo that bars')\n" -">>> parser.print_help()\n" -"usage: argparse.py [-h]\n" -"\n" -"A foo that bars\n" -"\n" -"options:\n" -" -h, --help show this help message and exit" -msgstr "" -">>> parser = argparse.ArgumentParser(description='A foo that bars')\n" -">>> parser.print_help()\n" -"usage: argparse.py [-h]\n" -"\n" -"A foo that bars\n" -"\n" -"options:\n" -" -h, --help show this help message and exit" - -#: ../../library/argparse.rst:366 +#: ../../library/argparse.rst:210 msgid "" "By default, the description will be line-wrapped so that it fits within the " "given space. To change this behavior, see the formatter_class_ argument." msgstr "" -#: ../../library/argparse.rst:371 +#: ../../library/argparse.rst:215 msgid "epilog" -msgstr "" +msgstr "epilog" -#: ../../library/argparse.rst:373 +#: ../../library/argparse.rst:217 msgid "" "Some programs like to display additional description of the program after " "the description of the arguments. Such text can be specified using the " "``epilog=`` argument to :class:`ArgumentParser`::" msgstr "" -#: ../../library/argparse.rst:377 +#: ../../library/argparse.rst:221 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... description='A foo that bars',\n" @@ -785,18 +405,18 @@ msgstr "" "\n" "And that's how you'd foo a bar" -#: ../../library/argparse.rst:390 +#: ../../library/argparse.rst:234 msgid "" "As with the description_ argument, the ``epilog=`` text is by default line-" "wrapped, but this behavior can be adjusted with the formatter_class_ " "argument to :class:`ArgumentParser`." msgstr "" -#: ../../library/argparse.rst:396 +#: ../../library/argparse.rst:240 msgid "parents" -msgstr "" +msgstr "parents" -#: ../../library/argparse.rst:398 +#: ../../library/argparse.rst:242 msgid "" "Sometimes, several parsers share a common set of arguments. Rather than " "repeating the definitions of these arguments, a single parser with all the " @@ -807,7 +427,7 @@ msgid "" "object being constructed::" msgstr "" -#: ../../library/argparse.rst:405 +#: ../../library/argparse.rst:249 msgid "" ">>> parent_parser = argparse.ArgumentParser(add_help=False)\n" ">>> parent_parser.add_argument('--parent', type=int)\n" @@ -835,32 +455,32 @@ msgstr "" ">>> bar_parser.parse_args(['--bar', 'YYY'])\n" "Namespace(bar='YYY', parent=None)" -#: ../../library/argparse.rst:418 +#: ../../library/argparse.rst:262 msgid "" "Note that most parent parsers will specify ``add_help=False``. Otherwise, " "the :class:`ArgumentParser` will see two ``-h/--help`` options (one in the " "parent and one in the child) and raise an error." msgstr "" -#: ../../library/argparse.rst:423 +#: ../../library/argparse.rst:267 msgid "" "You must fully initialize the parsers before passing them via ``parents=``. " "If you change the parent parsers after the child parser, those changes will " "not be reflected in the child." msgstr "" -#: ../../library/argparse.rst:431 +#: ../../library/argparse.rst:275 msgid "formatter_class" msgstr "formatter_class" -#: ../../library/argparse.rst:433 +#: ../../library/argparse.rst:277 msgid "" ":class:`ArgumentParser` objects allow the help formatting to be customized " "by specifying an alternate formatting class. Currently, there are four such " "classes:" msgstr "" -#: ../../library/argparse.rst:442 +#: ../../library/argparse.rst:286 msgid "" ":class:`RawDescriptionHelpFormatter` and :class:`RawTextHelpFormatter` give " "more control over how textual descriptions are displayed. By default, :class:" @@ -868,7 +488,7 @@ msgid "" "command-line help messages::" msgstr "" -#: ../../library/argparse.rst:447 +#: ../../library/argparse.rst:291 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -892,14 +512,14 @@ msgid "" "will be wrapped across a couple lines" msgstr "" -#: ../../library/argparse.rst:467 +#: ../../library/argparse.rst:311 msgid "" "Passing :class:`RawDescriptionHelpFormatter` as ``formatter_class=`` " "indicates that description_ and epilog_ are already correctly formatted and " "should not be line-wrapped::" msgstr "" -#: ../../library/argparse.rst:471 +#: ../../library/argparse.rst:315 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -923,22 +543,43 @@ msgid "" "options:\n" " -h, --help show this help message and exit" msgstr "" +">>> parser = argparse.ArgumentParser(\n" +"... prog='PROG',\n" +"... formatter_class=argparse.RawDescriptionHelpFormatter,\n" +"... description=textwrap.dedent('''\\\n" +"... Please do not mess up this text!\n" +"... --------------------------------\n" +"... I have indented it\n" +"... exactly the way\n" +"... I want it\n" +"... '''))\n" +">>> parser.print_help()\n" +"usage: PROG [-h]\n" +"\n" +"Please do not mess up this text!\n" +"--------------------------------\n" +" I have indented it\n" +" exactly the way\n" +" I want it\n" +"\n" +"options:\n" +" -h, --help show this help message and exit" -#: ../../library/argparse.rst:493 +#: ../../library/argparse.rst:337 msgid "" ":class:`RawTextHelpFormatter` maintains whitespace for all sorts of help " -"text, including argument descriptions. However, multiple new lines are " +"text, including argument descriptions. However, multiple newlines are " "replaced with one. If you wish to preserve multiple blank lines, add spaces " "between the newlines." msgstr "" -#: ../../library/argparse.rst:498 +#: ../../library/argparse.rst:342 msgid "" ":class:`ArgumentDefaultsHelpFormatter` automatically adds information about " "default values to each of the argument help messages::" msgstr "" -#: ../../library/argparse.rst:501 +#: ../../library/argparse.rst:345 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -970,14 +611,14 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo FOO FOO! (default: 42)" -#: ../../library/argparse.rst:516 +#: ../../library/argparse.rst:360 msgid "" ":class:`MetavarTypeHelpFormatter` uses the name of the type_ argument for " "each argument as the display name for its values (rather than using the " "dest_ as the regular formatter does)::" msgstr "" -#: ../../library/argparse.rst:520 +#: ../../library/argparse.rst:364 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -1009,19 +650,19 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo int" -#: ../../library/argparse.rst:537 +#: ../../library/argparse.rst:381 msgid "prefix_chars" msgstr "prefix_chars" -#: ../../library/argparse.rst:539 +#: ../../library/argparse.rst:383 msgid "" "Most command-line options will use ``-`` as the prefix, e.g. ``-f/--foo``. " "Parsers that need to support different or additional prefix characters, e.g. " "for options like ``+f`` or ``/foo``, may specify them using the " -"``prefix_chars=`` argument to the ArgumentParser constructor::" +"``prefix_chars=`` argument to the :class:`ArgumentParser` constructor::" msgstr "" -#: ../../library/argparse.rst:545 +#: ../../library/argparse.rst:389 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='-+')\n" ">>> parser.add_argument('+f')\n" @@ -1035,18 +676,18 @@ msgstr "" ">>> parser.parse_args('+f X ++bar Y'.split())\n" "Namespace(bar='Y', f='X')" -#: ../../library/argparse.rst:551 +#: ../../library/argparse.rst:395 msgid "" "The ``prefix_chars=`` argument defaults to ``'-'``. Supplying a set of " "characters that does not include ``-`` will cause ``-f/--foo`` options to be " "disallowed." msgstr "" -#: ../../library/argparse.rst:557 +#: ../../library/argparse.rst:401 msgid "fromfile_prefix_chars" msgstr "fromfile_prefix_chars" -#: ../../library/argparse.rst:559 +#: ../../library/argparse.rst:403 msgid "" "Sometimes, when dealing with a particularly long argument list, it may make " "sense to keep the list of arguments in a file rather than typing it out at " @@ -1056,7 +697,7 @@ msgid "" "by the arguments they contain. For example::" msgstr "" -#: ../../library/argparse.rst:566 +#: ../../library/argparse.rst:410 msgid "" ">>> with open('args.txt', 'w', encoding=sys.getfilesystemencoding()) as fp:\n" "... fp.write('-f\\nbar')\n" @@ -1074,9 +715,9 @@ msgstr "" ">>> parser.parse_args(['-f', 'foo', '@args.txt'])\n" "Namespace(f='bar')" -#: ../../library/argparse.rst:574 +#: ../../library/argparse.rst:418 msgid "" -"Arguments read from a file must by default be one per line (but see also :" +"Arguments read from a file must be one per line by default (but see also :" "meth:`~ArgumentParser.convert_arg_line_to_args`) and are treated as if they " "were in the same place as the original file referencing argument on the " "command line. So in the example above, the expression ``['-f', 'foo', " @@ -1084,32 +725,39 @@ msgid "" "f', 'bar']``." msgstr "" -#: ../../library/argparse.rst:580 +#: ../../library/argparse.rst:426 +msgid "" +"Empty lines are treated as empty strings (``''``), which are allowed as " +"values but not as arguments. Empty lines that are read as arguments will " +"result in an \"unrecognized arguments\" error." +msgstr "" + +#: ../../library/argparse.rst:430 msgid "" ":class:`ArgumentParser` uses :term:`filesystem encoding and error handler` " "to read the file containing arguments." msgstr "" -#: ../../library/argparse.rst:583 +#: ../../library/argparse.rst:433 msgid "" "The ``fromfile_prefix_chars=`` argument defaults to ``None``, meaning that " "arguments will never be treated as file references." msgstr "" -#: ../../library/argparse.rst:586 +#: ../../library/argparse.rst:436 msgid "" ":class:`ArgumentParser` changed encoding and errors to read arguments files " "from default (e.g. :func:`locale.getpreferredencoding(False) ` and ``\"strict\"``) to :term:`filesystem encoding and " -"error handler`. Arguments file should be encoded in UTF-8 instead of ANSI " -"Codepage on Windows." +"getpreferredencoding>` and ``\"strict\"``) to the :term:`filesystem encoding " +"and error handler`. Arguments file should be encoded in UTF-8 instead of " +"ANSI Codepage on Windows." msgstr "" -#: ../../library/argparse.rst:594 +#: ../../library/argparse.rst:444 msgid "argument_default" msgstr "argument_default" -#: ../../library/argparse.rst:596 +#: ../../library/argparse.rst:446 msgid "" "Generally, argument defaults are specified either by passing a default to :" "meth:`~ArgumentParser.add_argument` or by calling the :meth:`~ArgumentParser." @@ -1121,7 +769,7 @@ msgid "" "supply ``argument_default=SUPPRESS``::" msgstr "" -#: ../../library/argparse.rst:605 +#: ../../library/argparse.rst:455 msgid "" ">>> parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS)\n" ">>> parser.add_argument('--foo')\n" @@ -1139,22 +787,22 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace()" -#: ../../library/argparse.rst:616 +#: ../../library/argparse.rst:466 msgid "allow_abbrev" msgstr "allow_abbrev" -#: ../../library/argparse.rst:618 +#: ../../library/argparse.rst:468 msgid "" "Normally, when you pass an argument list to the :meth:`~ArgumentParser." "parse_args` method of an :class:`ArgumentParser`, it :ref:`recognizes " "abbreviations ` of long options." msgstr "" -#: ../../library/argparse.rst:622 +#: ../../library/argparse.rst:472 msgid "This feature can be disabled by setting ``allow_abbrev`` to ``False``::" msgstr "" -#: ../../library/argparse.rst:624 +#: ../../library/argparse.rst:474 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', allow_abbrev=False)\n" ">>> parser.add_argument('--foobar', action='store_true')\n" @@ -1170,11 +818,11 @@ msgstr "" "usage: PROG [-h] [--foobar] [--foonley]\n" "PROG: error: unrecognized arguments: --foon" -#: ../../library/argparse.rst:635 +#: ../../library/argparse.rst:485 msgid "conflict_handler" msgstr "conflict_handler" -#: ../../library/argparse.rst:637 +#: ../../library/argparse.rst:487 msgid "" ":class:`ArgumentParser` objects do not allow two actions with the same " "option string. By default, :class:`ArgumentParser` objects raise an " @@ -1182,7 +830,7 @@ msgid "" "that is already in use::" msgstr "" -#: ../../library/argparse.rst:642 +#: ../../library/argparse.rst:492 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-f', '--foo', help='old foo help')\n" @@ -1198,7 +846,7 @@ msgstr "" " ..\n" "ArgumentError: argument --foo: conflicting option string(s): --foo" -#: ../../library/argparse.rst:649 +#: ../../library/argparse.rst:499 msgid "" "Sometimes (e.g. when using parents_) it may be useful to simply override any " "older arguments with the same option string. To get this behavior, the " @@ -1206,7 +854,7 @@ msgid "" "of :class:`ArgumentParser`::" msgstr "" -#: ../../library/argparse.rst:654 +#: ../../library/argparse.rst:504 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', " "conflict_handler='resolve')\n" @@ -1232,7 +880,7 @@ msgstr "" " -f FOO old foo help\n" " --foo FOO new foo help" -#: ../../library/argparse.rst:665 +#: ../../library/argparse.rst:515 msgid "" "Note that :class:`ArgumentParser` objects only remove an action if all of " "its option strings are overridden. So, in the example above, the old ``-f/--" @@ -1240,47 +888,25 @@ msgid "" "option string was overridden." msgstr "" -#: ../../library/argparse.rst:672 +#: ../../library/argparse.rst:522 msgid "add_help" msgstr "add_help" -#: ../../library/argparse.rst:674 -msgid "" -"By default, ArgumentParser objects add an option which simply displays the " -"parser's help message. For example, consider a file named ``myprogram.py`` " -"containing the following code::" -msgstr "" - -#: ../../library/argparse.rst:683 -msgid "" -"If ``-h`` or ``--help`` is supplied at the command line, the ArgumentParser " -"help will be printed:" -msgstr "" - -#: ../../library/argparse.rst:686 +#: ../../library/argparse.rst:524 msgid "" -"$ python myprogram.py --help\n" -"usage: myprogram.py [-h] [--foo FOO]\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo FOO foo help" +"By default, :class:`ArgumentParser` objects add an option which simply " +"displays the parser's help message. If ``-h`` or ``--help`` is supplied at " +"the command line, the :class:`!ArgumentParser` help will be printed." msgstr "" -"$ python myprogram.py --help\n" -"usage: myprogram.py [-h] [--foo FOO]\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo FOO foo help" -#: ../../library/argparse.rst:695 +#: ../../library/argparse.rst:528 msgid "" "Occasionally, it may be useful to disable the addition of this help option. " "This can be achieved by passing ``False`` as the ``add_help=`` argument to :" "class:`ArgumentParser`::" msgstr "" -#: ../../library/argparse.rst:699 +#: ../../library/argparse.rst:532 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> parser.add_argument('--foo', help='foo help')\n" @@ -1298,7 +924,7 @@ msgstr "" "options:\n" " --foo FOO foo help" -#: ../../library/argparse.rst:707 +#: ../../library/argparse.rst:540 msgid "" "The help option is typically ``-h/--help``. The exception to this is if the " "``prefix_chars=`` is specified and does not include ``-``, in which case ``-" @@ -1306,7 +932,7 @@ msgid "" "in ``prefix_chars`` is used to prefix the help options::" msgstr "" -#: ../../library/argparse.rst:713 +#: ../../library/argparse.rst:546 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='+/')\n" ">>> parser.print_help()\n" @@ -1322,24 +948,24 @@ msgstr "" "options:\n" " +h, ++help show this help message and exit" -#: ../../library/argparse.rst:722 +#: ../../library/argparse.rst:555 msgid "exit_on_error" msgstr "exit_on_error" -#: ../../library/argparse.rst:724 +#: ../../library/argparse.rst:557 msgid "" "Normally, when you pass an invalid argument list to the :meth:" "`~ArgumentParser.parse_args` method of an :class:`ArgumentParser`, it will " -"exit with error info." +"print a *message* to :data:`sys.stderr` and exit with a status code of 2." msgstr "" -#: ../../library/argparse.rst:727 +#: ../../library/argparse.rst:561 msgid "" "If the user would like to catch errors manually, the feature can be enabled " "by setting ``exit_on_error`` to ``False``::" msgstr "" -#: ../../library/argparse.rst:730 +#: ../../library/argparse.rst:564 msgid "" ">>> parser = argparse.ArgumentParser(exit_on_error=False)\n" ">>> parser.add_argument('--integers', type=int)\n" @@ -1365,77 +991,81 @@ msgstr "" "...\n" "Catching an argumentError" -#: ../../library/argparse.rst:744 +#: ../../library/argparse.rst:578 msgid "The add_argument() method" -msgstr "" +msgstr "add_argument() 方法" -#: ../../library/argparse.rst:750 +#: ../../library/argparse.rst:584 msgid "" "Define how a single command-line argument should be parsed. Each parameter " "has its own more detailed description below, but in short they are:" msgstr "" -#: ../../library/argparse.rst:753 +#: ../../library/argparse.rst:587 msgid "" -"`name or flags`_ - Either a name or a list of option strings, e.g. ``foo`` " -"or ``-f, --foo``." +"`name or flags`_ - Either a name or a list of option strings, e.g. ``'foo'`` " +"or ``'-f', '--foo'``." msgstr "" -#: ../../library/argparse.rst:756 +#: ../../library/argparse.rst:590 msgid "" "action_ - The basic type of action to be taken when this argument is " "encountered at the command line." msgstr "" -#: ../../library/argparse.rst:759 +#: ../../library/argparse.rst:593 msgid "nargs_ - The number of command-line arguments that should be consumed." msgstr "" -#: ../../library/argparse.rst:761 +#: ../../library/argparse.rst:595 msgid "" "const_ - A constant value required by some action_ and nargs_ selections." msgstr "" -#: ../../library/argparse.rst:763 +#: ../../library/argparse.rst:597 msgid "" "default_ - The value produced if the argument is absent from the command " "line and if it is absent from the namespace object." msgstr "" -#: ../../library/argparse.rst:766 +#: ../../library/argparse.rst:600 msgid "" "type_ - The type to which the command-line argument should be converted." msgstr "" -#: ../../library/argparse.rst:768 +#: ../../library/argparse.rst:602 msgid "choices_ - A sequence of the allowable values for the argument." msgstr "" -#: ../../library/argparse.rst:770 +#: ../../library/argparse.rst:604 msgid "" "required_ - Whether or not the command-line option may be omitted (optionals " "only)." msgstr "" -#: ../../library/argparse.rst:773 +#: ../../library/argparse.rst:607 msgid "help_ - A brief description of what the argument does." msgstr "" -#: ../../library/argparse.rst:775 +#: ../../library/argparse.rst:609 msgid "metavar_ - A name for the argument in usage messages." msgstr "" -#: ../../library/argparse.rst:777 +#: ../../library/argparse.rst:611 msgid "" "dest_ - The name of the attribute to be added to the object returned by :" "meth:`parse_args`." msgstr "" -#: ../../library/argparse.rst:786 -msgid "name or flags" +#: ../../library/argparse.rst:614 +msgid "deprecated_ - Whether or not use of the argument is deprecated." msgstr "" -#: ../../library/argparse.rst:788 +#: ../../library/argparse.rst:622 +msgid "name or flags" +msgstr "name or flags" + +#: ../../library/argparse.rst:624 msgid "" "The :meth:`~ArgumentParser.add_argument` method must know whether an " "optional argument, like ``-f`` or ``--foo``, or a positional argument, like " @@ -1444,30 +1074,30 @@ msgid "" "or a simple argument name." msgstr "" -#: ../../library/argparse.rst:794 +#: ../../library/argparse.rst:630 msgid "For example, an optional argument could be created like::" msgstr "" -#: ../../library/argparse.rst:796 +#: ../../library/argparse.rst:632 msgid ">>> parser.add_argument('-f', '--foo')" msgstr ">>> parser.add_argument('-f', '--foo')" -#: ../../library/argparse.rst:798 +#: ../../library/argparse.rst:634 msgid "while a positional argument could be created like::" msgstr "" -#: ../../library/argparse.rst:800 +#: ../../library/argparse.rst:636 msgid ">>> parser.add_argument('bar')" msgstr ">>> parser.add_argument('bar')" -#: ../../library/argparse.rst:802 +#: ../../library/argparse.rst:638 msgid "" "When :meth:`~ArgumentParser.parse_args` is called, optional arguments will " "be identified by the ``-`` prefix, and the remaining arguments will be " "assumed to be positional::" msgstr "" -#: ../../library/argparse.rst:806 +#: ../../library/argparse.rst:642 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-f', '--foo')\n" @@ -1491,11 +1121,11 @@ msgstr "" "usage: PROG [-h] [-f FOO] bar\n" "PROG: error: the following arguments are required: bar" -#: ../../library/argparse.rst:821 +#: ../../library/argparse.rst:657 msgid "action" -msgstr "" +msgstr "action" -#: ../../library/argparse.rst:823 +#: ../../library/argparse.rst:659 msgid "" ":class:`ArgumentParser` objects associate command-line arguments with " "actions. These actions can do just about anything with the command-line " @@ -1505,25 +1135,13 @@ msgid "" "be handled. The supplied actions are:" msgstr "" -#: ../../library/argparse.rst:829 +#: ../../library/argparse.rst:665 msgid "" "``'store'`` - This just stores the argument's value. This is the default " -"action. For example::" +"action." msgstr "" -#: ../../library/argparse.rst:832 -msgid "" -">>> parser = argparse.ArgumentParser()\n" -">>> parser.add_argument('--foo')\n" -">>> parser.parse_args('--foo 1'.split())\n" -"Namespace(foo='1')" -msgstr "" -">>> parser = argparse.ArgumentParser()\n" -">>> parser.add_argument('--foo')\n" -">>> parser.parse_args('--foo 1'.split())\n" -"Namespace(foo='1')" - -#: ../../library/argparse.rst:837 +#: ../../library/argparse.rst:668 msgid "" "``'store_const'`` - This stores the value specified by the const_ keyword " "argument; note that the const_ keyword argument defaults to ``None``. The " @@ -1531,7 +1149,7 @@ msgid "" "specify some sort of flag. For example::" msgstr "" -#: ../../library/argparse.rst:842 +#: ../../library/argparse.rst:673 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_const', const=42)\n" @@ -1543,15 +1161,15 @@ msgstr "" ">>> parser.parse_args(['--foo'])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:847 +#: ../../library/argparse.rst:678 msgid "" "``'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. For example::" +"``True`` respectively::" msgstr "" -#: ../../library/argparse.rst:852 +#: ../../library/argparse.rst:683 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_true')\n" @@ -1567,7 +1185,7 @@ msgstr "" ">>> parser.parse_args('--foo --bar'.split())\n" "Namespace(foo=True, bar=False, baz=True)" -#: ../../library/argparse.rst:859 +#: ../../library/argparse.rst:690 msgid "" "``'append'`` - This stores a list, and appends each argument value to the " "list. It is useful to allow an option to be specified multiple times. If the " @@ -1576,7 +1194,7 @@ msgid "" "after those default values. Example usage::" msgstr "" -#: ../../library/argparse.rst:865 +#: ../../library/argparse.rst:696 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='append')\n" @@ -1588,7 +1206,7 @@ msgstr "" ">>> parser.parse_args('--foo 1 --foo 2'.split())\n" "Namespace(foo=['1', '2'])" -#: ../../library/argparse.rst:870 +#: ../../library/argparse.rst:701 msgid "" "``'append_const'`` - This stores a list, and appends the value specified by " "the const_ keyword argument to the list; note that the const_ keyword " @@ -1597,7 +1215,7 @@ msgid "" "example::" msgstr "" -#: ../../library/argparse.rst:876 +#: ../../library/argparse.rst:707 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--str', dest='types', action='append_const', " @@ -1608,20 +1226,45 @@ msgid "" "Namespace(types=[, ])" msgstr "" ">>> parser = argparse.ArgumentParser()\n" -">>> parser.add_argument('--str', dest='types', action='append_const', " -"const=str)\n" -">>> parser.add_argument('--int', dest='types', action='append_const', " -"const=int)\n" -">>> parser.parse_args('--str --int'.split())\n" -"Namespace(types=[, ])" +">>> parser.add_argument('--str', dest='types', action='append_const', " +"const=str)\n" +">>> parser.add_argument('--int', dest='types', action='append_const', " +"const=int)\n" +">>> parser.parse_args('--str --int'.split())\n" +"Namespace(types=[, ])" + +#: ../../library/argparse.rst:713 +msgid "" +"``'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 " +"nargs_ keyword argument value ``'+'`` or ``'*'``. Note that when nargs_ is " +"``None`` (the default) or ``'?'``, each character of the argument string " +"will be appended to the list. Example usage::" +msgstr "" + +#: ../../library/argparse.rst:721 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument(\"--foo\", action=\"extend\", nargs=\"+\", " +"type=str)\n" +">>> parser.parse_args([\"--foo\", \"f1\", \"--foo\", \"f2\", \"f3\", " +"\"f4\"])\n" +"Namespace(foo=['f1', 'f2', 'f3', 'f4'])" +msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument(\"--foo\", action=\"extend\", nargs=\"+\", " +"type=str)\n" +">>> parser.parse_args([\"--foo\", \"f1\", \"--foo\", \"f2\", \"f3\", " +"\"f4\"])\n" +"Namespace(foo=['f1', 'f2', 'f3', 'f4'])" -#: ../../library/argparse.rst:882 +#: ../../library/argparse.rst:728 msgid "" "``'count'`` - This counts the number of times a keyword argument occurs. For " "example, this is useful for increasing verbosity levels::" msgstr "" -#: ../../library/argparse.rst:885 +#: ../../library/argparse.rst:731 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--verbose', '-v', action='count', default=0)\n" @@ -1629,11 +1272,11 @@ msgid "" "Namespace(verbose=3)" msgstr "" -#: ../../library/argparse.rst:890 +#: ../../library/argparse.rst:736 msgid "Note, the *default* will be ``None`` unless explicitly set to *0*." msgstr "" -#: ../../library/argparse.rst:892 +#: ../../library/argparse.rst:738 msgid "" "``'help'`` - This prints a complete help message for all the options in the " "current parser and then exits. By default a help action is automatically " @@ -1641,14 +1284,14 @@ msgid "" "output is created." msgstr "" -#: ../../library/argparse.rst:897 +#: ../../library/argparse.rst:743 msgid "" "``'version'`` - This expects a ``version=`` keyword argument in the :meth:" "`~ArgumentParser.add_argument` call, and prints version information and " "exits when invoked::" msgstr "" -#: ../../library/argparse.rst:901 +#: ../../library/argparse.rst:747 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" @@ -1664,62 +1307,33 @@ msgstr "" ">>> parser.parse_args(['--version'])\n" "PROG 2.0" -#: ../../library/argparse.rst:907 -msgid "" -"``'extend'`` - This stores a list, and extends each argument value to the " -"list. Example usage::" -msgstr "" - -#: ../../library/argparse.rst:911 -msgid "" -">>> parser = argparse.ArgumentParser()\n" -">>> parser.add_argument(\"--foo\", action=\"extend\", nargs=\"+\", " -"type=str)\n" -">>> parser.parse_args([\"--foo\", \"f1\", \"--foo\", \"f2\", \"f3\", " -"\"f4\"])\n" -"Namespace(foo=['f1', 'f2', 'f3', 'f4'])" -msgstr "" -">>> parser = argparse.ArgumentParser()\n" -">>> parser.add_argument(\"--foo\", action=\"extend\", nargs=\"+\", " -"type=str)\n" -">>> parser.parse_args([\"--foo\", \"f1\", \"--foo\", \"f2\", \"f3\", " -"\"f4\"])\n" -"Namespace(foo=['f1', 'f2', 'f3', 'f4'])" - -#: ../../library/argparse.rst:918 -msgid "" -"You may also specify an arbitrary action by passing an Action 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``::" -msgstr "" - -#: ../../library/argparse.rst:923 +#: ../../library/argparse.rst:753 msgid "" -">>> import argparse\n" -">>> parser = argparse.ArgumentParser()\n" -">>> parser.add_argument('--foo', action=argparse.BooleanOptionalAction)\n" -">>> parser.parse_args(['--no-foo'])\n" -"Namespace(foo=False)" +"You may also specify an arbitrary action by passing an :class:`Action` " +"subclass (e.g. :class:`BooleanOptionalAction`) or other object that " +"implements the same interface. Only actions that consume command-line " +"arguments (e.g. ``'store'``, ``'append'``, ``'extend'``, or custom actions " +"with non-zero ``nargs``) can be used with positional arguments." msgstr "" -">>> import argparse\n" -">>> parser = argparse.ArgumentParser()\n" -">>> parser.add_argument('--foo', action=argparse.BooleanOptionalAction)\n" -">>> parser.parse_args(['--no-foo'])\n" -"Namespace(foo=False)" +"你也可以傳遞一個 :class:`Action` 子類別(例如 :class:" +"`BooleanOptionalAction`)或實作相同介面的其他物件。只有會消耗命令列引數的 " +"action(例如 ``'store'``、``'append'``、``'extend'`` 或 ``nargs`` 不為零的自" +"定義 action)可以被用於位置引數。" -#: ../../library/argparse.rst:931 +#: ../../library/argparse.rst:759 msgid "" "The recommended way to create a custom action is to extend :class:`Action`, " -"overriding the ``__call__`` method and optionally the ``__init__`` and " -"``format_usage`` methods." +"overriding the :meth:`!__call__` method and optionally the :meth:`!__init__` " +"and :meth:`!format_usage` methods. You can also register custom actions " +"using the :meth:`~ArgumentParser.register` method and reference them by " +"their registered name." msgstr "" -#: ../../library/argparse.rst:935 +#: ../../library/argparse.rst:764 msgid "An example of a custom action::" msgstr "" -#: ../../library/argparse.rst:937 +#: ../../library/argparse.rst:766 msgid "" ">>> class FooAction(argparse.Action):\n" "... def __init__(self, option_strings, dest, nargs=None, **kwargs):\n" @@ -1740,29 +1354,30 @@ msgid "" "Namespace(bar='1', foo='2')" msgstr "" -#: ../../library/argparse.rst:955 +#: ../../library/argparse.rst:784 msgid "For more details, see :class:`Action`." -msgstr "" +msgstr "更多詳情請見 :class:`Action`。" -#: ../../library/argparse.rst:961 +#: ../../library/argparse.rst:790 msgid "nargs" -msgstr "" +msgstr "nargs" -#: ../../library/argparse.rst:963 +#: ../../library/argparse.rst:792 msgid "" -"ArgumentParser 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 :" -"ref:`specifying-ambiguous-arguments`. The supported values are:" +":class:`ArgumentParser` 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 :ref:`specifying-ambiguous-arguments`. The supported values " +"are:" msgstr "" -#: ../../library/argparse.rst:968 +#: ../../library/argparse.rst:797 msgid "" "``N`` (an integer). ``N`` arguments from the command line will be gathered " "together into a list. For example::" msgstr "" -#: ../../library/argparse.rst:971 +#: ../../library/argparse.rst:800 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs=2)\n" @@ -1776,13 +1391,13 @@ msgstr "" ">>> parser.parse_args('c --foo a b'.split())\n" "Namespace(bar=['c'], foo=['a', 'b'])" -#: ../../library/argparse.rst:977 +#: ../../library/argparse.rst:806 msgid "" "Note that ``nargs=1`` produces a list of one item. This is different from " "the default, in which the item is produced by itself." msgstr "" -#: ../../library/argparse.rst:982 +#: ../../library/argparse.rst:811 msgid "" "``'?'``. One argument will be consumed from the command line if possible, " "and produced as a single item. If no command-line argument is present, the " @@ -1792,7 +1407,7 @@ msgid "" "produced. Some examples to illustrate this::" msgstr "" -#: ../../library/argparse.rst:989 +#: ../../library/argparse.rst:818 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs='?', const='c', default='d')\n" @@ -1814,13 +1429,13 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(bar='d', foo='d')" -#: ../../library/argparse.rst:999 +#: ../../library/argparse.rst:828 msgid "" "One of the more common uses of ``nargs='?'`` is to allow optional input and " "output files::" msgstr "" -#: ../../library/argparse.rst:1002 +#: ../../library/argparse.rst:831 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('infile', nargs='?', type=argparse.FileType('r'),\n" @@ -1846,7 +1461,7 @@ msgstr "" "Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>,\n" " outfile=<_io.TextIOWrapper name='' encoding='UTF-8'>)" -#: ../../library/argparse.rst:1016 +#: ../../library/argparse.rst:845 msgid "" "``'*'``. All command-line arguments present are gathered into a list. Note " "that it generally doesn't make much sense to have more than one positional " @@ -1854,7 +1469,7 @@ msgid "" "``nargs='*'`` is possible. For example::" msgstr "" -#: ../../library/argparse.rst:1021 +#: ../../library/argparse.rst:850 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs='*')\n" @@ -1870,14 +1485,14 @@ msgstr "" ">>> parser.parse_args('a b --foo x y --bar 1 2'.split())\n" "Namespace(bar=['1', '2'], baz=['a', 'b'], foo=['x', 'y'])" -#: ../../library/argparse.rst:1030 +#: ../../library/argparse.rst:859 msgid "" -"``'+'``. Just like ``'*'``, all command-line args present are gathered into " -"a list. Additionally, an error message will be generated if there wasn't at " -"least one command-line argument present. For example::" +"``'+'``. Just like ``'*'``, all command-line arguments present are gathered " +"into a list. Additionally, an error message will be generated if there " +"wasn't at least one command-line argument present. For example::" msgstr "" -#: ../../library/argparse.rst:1034 +#: ../../library/argparse.rst:863 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('foo', nargs='+')\n" @@ -1895,19 +1510,20 @@ msgstr "" "usage: PROG [-h] foo [foo ...]\n" "PROG: error: the following arguments are required: foo" -#: ../../library/argparse.rst:1042 +#: ../../library/argparse.rst:871 msgid "" "If the ``nargs`` keyword argument is not provided, the number of arguments " "consumed is determined by the action_. Generally this means a single " "command-line argument will be consumed and a single item (not a list) will " -"be produced." +"be produced. Actions that do not consume command-line arguments (e.g. " +"``'store_const'``) set ``nargs=0``." msgstr "" -#: ../../library/argparse.rst:1050 +#: ../../library/argparse.rst:881 msgid "const" -msgstr "" +msgstr "const" -#: ../../library/argparse.rst:1052 +#: ../../library/argparse.rst:883 msgid "" "The ``const`` argument of :meth:`~ArgumentParser.add_argument` is used to " "hold constant values that are not read from the command line but are " @@ -1915,7 +1531,7 @@ msgid "" "common uses of it are:" msgstr "" -#: ../../library/argparse.rst:1056 +#: ../../library/argparse.rst:887 msgid "" "When :meth:`~ArgumentParser.add_argument` is called with " "``action='store_const'`` or ``action='append_const'``. These actions add " @@ -1925,7 +1541,7 @@ msgid "" "receive a default value of ``None``." msgstr "" -#: ../../library/argparse.rst:1064 +#: ../../library/argparse.rst:895 msgid "" "When :meth:`~ArgumentParser.add_argument` is called with option strings " "(like ``-f`` or ``--foo``) and ``nargs='?'``. This creates an optional " @@ -1935,17 +1551,17 @@ msgid "" "to be ``None`` instead. See the nargs_ description for examples." msgstr "" -#: ../../library/argparse.rst:1071 +#: ../../library/argparse.rst:902 msgid "" "``const=None`` by default, including when ``action='append_const'`` or " "``action='store_const'``." msgstr "" -#: ../../library/argparse.rst:1078 +#: ../../library/argparse.rst:909 msgid "default" -msgstr "" +msgstr "default" -#: ../../library/argparse.rst:1080 +#: ../../library/argparse.rst:911 msgid "" "All optional arguments and some positional arguments may be omitted at the " "command line. The ``default`` keyword argument of :meth:`~ArgumentParser." @@ -1955,7 +1571,7 @@ msgid "" "command line::" msgstr "" -#: ../../library/argparse.rst:1087 +#: ../../library/argparse.rst:918 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=42)\n" @@ -1971,13 +1587,13 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:1094 +#: ../../library/argparse.rst:925 msgid "" "If the target namespace already has an attribute set, the action *default* " -"will not over write it::" +"will not overwrite it::" msgstr "" -#: ../../library/argparse.rst:1097 +#: ../../library/argparse.rst:928 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=42)\n" @@ -1989,7 +1605,7 @@ msgstr "" ">>> parser.parse_args([], namespace=argparse.Namespace(foo=101))\n" "Namespace(foo=101)" -#: ../../library/argparse.rst:1102 +#: ../../library/argparse.rst:933 msgid "" "If the ``default`` value is a string, the parser parses the value as if it " "were a command-line argument. In particular, the parser applies any type_ " @@ -1997,7 +1613,7 @@ msgid "" "`Namespace` return value. Otherwise, the parser uses the value as is::" msgstr "" -#: ../../library/argparse.rst:1107 +#: ../../library/argparse.rst:938 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--length', default='10', type=int)\n" @@ -2011,13 +1627,13 @@ msgstr "" ">>> parser.parse_args()\n" "Namespace(length=10, width=10.5)" -#: ../../library/argparse.rst:1113 +#: ../../library/argparse.rst:944 msgid "" "For positional arguments with nargs_ equal to ``?`` or ``*``, the " "``default`` value is used when no command-line argument was present::" msgstr "" -#: ../../library/argparse.rst:1116 +#: ../../library/argparse.rst:947 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('foo', nargs='?', default=42)\n" @@ -2033,13 +1649,20 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:1124 +#: ../../library/argparse.rst:954 +msgid "" +"For required_ arguments, the ``default`` value is ignored. For example, this " +"applies to positional arguments with nargs_ values other than ``?`` or " +"``*``, or optional arguments marked as ``required=True``." +msgstr "" + +#: ../../library/argparse.rst:958 msgid "" "Providing ``default=argparse.SUPPRESS`` causes no attribute to be added if " "the command-line argument was not present::" msgstr "" -#: ../../library/argparse.rst:1127 +#: ../../library/argparse.rst:961 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=argparse.SUPPRESS)\n" @@ -2055,11 +1678,11 @@ msgstr "" ">>> parser.parse_args(['--foo', '1'])\n" "Namespace(foo='1')" -#: ../../library/argparse.rst:1138 +#: ../../library/argparse.rst:972 msgid "type" -msgstr "" +msgstr "type" -#: ../../library/argparse.rst:1140 +#: ../../library/argparse.rst:974 msgid "" "By default, the parser reads command-line arguments in as simple strings. " "However, quite often the command-line string should instead be interpreted " @@ -2068,25 +1691,26 @@ msgid "" "checking and type conversions to be performed." msgstr "" -#: ../../library/argparse.rst:1146 +#: ../../library/argparse.rst:980 msgid "" "If the type_ keyword is used with the default_ keyword, the type converter " "is only applied if the default is a string." msgstr "" -#: ../../library/argparse.rst:1149 +#: ../../library/argparse.rst:983 msgid "" -"The argument to ``type`` can be any callable that accepts a single string. " -"If the function raises :exc:`ArgumentTypeError`, :exc:`TypeError`, or :exc:" +"The argument to ``type`` can be a callable that accepts a single string or " +"the name of a registered type (see :meth:`~ArgumentParser.register`) If the " +"function raises :exc:`ArgumentTypeError`, :exc:`TypeError`, or :exc:" "`ValueError`, the exception is caught and a nicely formatted error message " -"is displayed. No other exception types are handled." +"is displayed. Other exception types are not handled." msgstr "" -#: ../../library/argparse.rst:1154 +#: ../../library/argparse.rst:989 msgid "Common built-in types and functions can be used as type converters:" msgstr "" -#: ../../library/argparse.rst:1156 +#: ../../library/argparse.rst:991 msgid "" "import argparse\n" "import pathlib\n" @@ -2096,7 +1720,6 @@ msgid "" "parser.add_argument('distance', type=float)\n" "parser.add_argument('street', type=ascii)\n" "parser.add_argument('code_point', type=ord)\n" -"parser.add_argument('source_file', type=open)\n" "parser.add_argument('dest_file', type=argparse.FileType('w', " "encoding='latin-1'))\n" "parser.add_argument('datapath', type=pathlib.Path)" @@ -2109,16 +1732,15 @@ msgstr "" "parser.add_argument('distance', type=float)\n" "parser.add_argument('street', type=ascii)\n" "parser.add_argument('code_point', type=ord)\n" -"parser.add_argument('source_file', type=open)\n" "parser.add_argument('dest_file', type=argparse.FileType('w', " "encoding='latin-1'))\n" "parser.add_argument('datapath', type=pathlib.Path)" -#: ../../library/argparse.rst:1170 +#: ../../library/argparse.rst:1004 msgid "User defined functions can be used as well:" msgstr "" -#: ../../library/argparse.rst:1172 +#: ../../library/argparse.rst:1006 msgid "" ">>> def hyphenated(string):\n" "... return '-'.join([word[:4] for word in string.casefold().split()])\n" @@ -2136,14 +1758,14 @@ msgstr "" ">>> parser.parse_args(['\"The Tale of Two Cities\"'])\n" "Namespace(short_title='\"the-tale-of-two-citi')" -#: ../../library/argparse.rst:1182 +#: ../../library/argparse.rst:1016 msgid "" "The :func:`bool` function is not recommended as a type converter. All it " "does is convert empty strings to ``False`` and non-empty strings to " "``True``. This is usually not what is desired." msgstr "" -#: ../../library/argparse.rst:1186 +#: ../../library/argparse.rst:1020 msgid "" "In general, the ``type`` keyword is a convenience that should only be used " "for simple conversions that can only raise one of the three supported " @@ -2151,7 +1773,7 @@ msgid "" "management should be done downstream after the arguments are parsed." msgstr "" -#: ../../library/argparse.rst:1191 +#: ../../library/argparse.rst:1025 msgid "" "For example, JSON or YAML conversions have complex error cases that require " "better reporting than can be given by the ``type`` keyword. A :exc:`~json." @@ -2159,26 +1781,27 @@ msgid "" "exception would not be handled at all." msgstr "" -#: ../../library/argparse.rst:1196 +#: ../../library/argparse.rst:1030 msgid "" "Even :class:`~argparse.FileType` has its limitations for use with the " -"``type`` keyword. If one argument uses *FileType* 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 :keyword:`with`-statement to manage the files." +"``type`` keyword. If one argument uses :class:`~argparse.FileType` 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 :keyword:`with`-statement to manage the " +"files." msgstr "" -#: ../../library/argparse.rst:1202 +#: ../../library/argparse.rst:1037 msgid "" "For type checkers that simply check against a fixed set of values, consider " "using the choices_ keyword instead." msgstr "" -#: ../../library/argparse.rst:1209 +#: ../../library/argparse.rst:1044 msgid "choices" -msgstr "" +msgstr "choices" -#: ../../library/argparse.rst:1211 +#: ../../library/argparse.rst:1046 msgid "" "Some command-line arguments should be selected from a restricted set of " "values. These can be handled by passing a sequence object as the *choices* " @@ -2187,7 +1810,7 @@ msgid "" "be displayed if the argument was not one of the acceptable values::" msgstr "" -#: ../../library/argparse.rst:1217 +#: ../../library/argparse.rst:1052 msgid "" ">>> parser = argparse.ArgumentParser(prog='game.py')\n" ">>> parser.add_argument('move', choices=['rock', 'paper', 'scissors'])\n" @@ -2207,44 +1830,26 @@ msgstr "" "game.py: error: argument move: invalid choice: 'fire' (choose from 'rock',\n" "'paper', 'scissors')" -#: ../../library/argparse.rst:1226 +#: ../../library/argparse.rst:1061 msgid "" "Note that inclusion in the *choices* sequence is checked after any type_ " "conversions have been performed, so the type of the objects in the *choices* " -"sequence should match the type_ specified::" -msgstr "" - -#: ../../library/argparse.rst:1230 -msgid "" -">>> parser = argparse.ArgumentParser(prog='doors.py')\n" -">>> parser.add_argument('door', type=int, choices=range(1, 4))\n" -">>> print(parser.parse_args(['3']))\n" -"Namespace(door=3)\n" -">>> parser.parse_args(['4'])\n" -"usage: doors.py [-h] {1,2,3}\n" -"doors.py: error: argument door: invalid choice: 4 (choose from 1, 2, 3)" +"sequence should match the type_ specified." msgstr "" -">>> parser = argparse.ArgumentParser(prog='doors.py')\n" -">>> parser.add_argument('door', type=int, choices=range(1, 4))\n" -">>> print(parser.parse_args(['3']))\n" -"Namespace(door=3)\n" -">>> parser.parse_args(['4'])\n" -"usage: doors.py [-h] {1,2,3}\n" -"doors.py: error: argument door: invalid choice: 4 (choose from 1, 2, 3)" -#: ../../library/argparse.rst:1238 +#: ../../library/argparse.rst:1065 msgid "" "Any sequence can be passed as the *choices* value, so :class:`list` " "objects, :class:`tuple` objects, and custom sequences are all supported." msgstr "" -#: ../../library/argparse.rst:1241 +#: ../../library/argparse.rst:1068 msgid "" "Use of :class:`enum.Enum` is not recommended because it is difficult to " "control its appearance in usage, help, and error messages." msgstr "" -#: ../../library/argparse.rst:1244 +#: ../../library/argparse.rst:1071 msgid "" "Formatted choices override the default *metavar* which is normally derived " "from *dest*. This is usually what you want because the user never sees the " @@ -2252,19 +1857,19 @@ msgid "" "are many choices), just specify an explicit metavar_." msgstr "" -#: ../../library/argparse.rst:1253 +#: ../../library/argparse.rst:1080 msgid "required" -msgstr "" +msgstr "required" -#: ../../library/argparse.rst:1255 +#: ../../library/argparse.rst:1082 msgid "" -"In general, the :mod:`argparse` module assumes that flags like ``-f`` and " +"In general, the :mod:`!argparse` module assumes that flags like ``-f`` and " "``--bar`` indicate *optional* arguments, which can always be omitted at the " "command line. To make an option *required*, ``True`` can be specified for " "the ``required=`` keyword argument to :meth:`~ArgumentParser.add_argument`::" msgstr "" -#: ../../library/argparse.rst:1260 +#: ../../library/argparse.rst:1087 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', required=True)\n" @@ -2282,64 +1887,32 @@ msgstr "" "usage: [-h] --foo FOO\n" ": error: the following arguments are required: --foo" -#: ../../library/argparse.rst:1268 +#: ../../library/argparse.rst:1095 msgid "" "As the example shows, if an option is marked as ``required``, :meth:" "`~ArgumentParser.parse_args` will report an error if that option is not " "present at the command line." msgstr "" -#: ../../library/argparse.rst:1274 +#: ../../library/argparse.rst:1101 msgid "" "Required options are generally considered bad form because users expect " "*options* to be *optional*, and thus they should be avoided when possible." msgstr "" -#: ../../library/argparse.rst:1281 +#: ../../library/argparse.rst:1108 msgid "help" -msgstr "幫助" +msgstr "help" -#: ../../library/argparse.rst:1283 +#: ../../library/argparse.rst:1110 msgid "" "The ``help`` value is a string containing a brief description of the " "argument. When a user requests help (usually by using ``-h`` or ``--help`` " "at the command line), these ``help`` descriptions will be displayed with " -"each argument::" -msgstr "" - -#: ../../library/argparse.rst:1288 -msgid "" -">>> parser = argparse.ArgumentParser(prog='frobble')\n" -">>> parser.add_argument('--foo', action='store_true',\n" -"... help='foo the bars before frobbling')\n" -">>> parser.add_argument('bar', nargs='+',\n" -"... help='one of the bars to be frobbled')\n" -">>> parser.parse_args(['-h'])\n" -"usage: frobble [-h] [--foo] bar [bar ...]\n" -"\n" -"positional arguments:\n" -" bar one of the bars to be frobbled\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo foo the bars before frobbling" +"each argument." msgstr "" -">>> parser = argparse.ArgumentParser(prog='frobble')\n" -">>> parser.add_argument('--foo', action='store_true',\n" -"... help='foo the bars before frobbling')\n" -">>> parser.add_argument('bar', nargs='+',\n" -"... help='one of the bars to be frobbled')\n" -">>> parser.parse_args(['-h'])\n" -"usage: frobble [-h] [--foo] bar [bar ...]\n" -"\n" -"positional arguments:\n" -" bar one of the bars to be frobbled\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo foo the bars before frobbling" -#: ../../library/argparse.rst:1303 +#: ../../library/argparse.rst:1115 msgid "" "The ``help`` strings can include various format specifiers to avoid " "repetition of things like the program name or the argument default_. The " @@ -2348,7 +1921,7 @@ msgid "" "``%(type)s``, etc.::" msgstr "" -#: ../../library/argparse.rst:1308 +#: ../../library/argparse.rst:1120 msgid "" ">>> parser = argparse.ArgumentParser(prog='frobble')\n" ">>> parser.add_argument('bar', nargs='?', type=int, default=42,\n" @@ -2374,19 +1947,19 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../library/argparse.rst:1320 +#: ../../library/argparse.rst:1132 msgid "" "As the help string supports %-formatting, if you want a literal ``%`` to " "appear in the help string, you must escape it as ``%%``." msgstr "" -#: ../../library/argparse.rst:1323 +#: ../../library/argparse.rst:1135 msgid "" -":mod:`argparse` supports silencing the help entry for certain options, by " +":mod:`!argparse` supports silencing the help entry for certain options, by " "setting the ``help`` value to ``argparse.SUPPRESS``::" msgstr "" -#: ../../library/argparse.rst:1326 +#: ../../library/argparse.rst:1138 msgid "" ">>> parser = argparse.ArgumentParser(prog='frobble')\n" ">>> parser.add_argument('--foo', help=argparse.SUPPRESS)\n" @@ -2404,23 +1977,23 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../library/argparse.rst:1338 +#: ../../library/argparse.rst:1150 msgid "metavar" -msgstr "" +msgstr "metavar" -#: ../../library/argparse.rst:1340 +#: ../../library/argparse.rst:1152 msgid "" "When :class:`ArgumentParser` generates help messages, it needs some way to " -"refer to each expected argument. By default, ArgumentParser objects use the " -"dest_ value as the \"name\" of each object. By default, for positional " -"argument actions, the dest_ value is used directly, and for optional " -"argument actions, the dest_ 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::" +"refer to each expected argument. By default, :class:`!ArgumentParser` " +"objects use the dest_ value as the \"name\" of each object. By default, for " +"positional argument actions, the dest_ value is used directly, and for " +"optional argument actions, the dest_ 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::" msgstr "" -#: ../../library/argparse.rst:1349 +#: ../../library/argparse.rst:1161 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -2452,11 +2025,11 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo FOO" -#: ../../library/argparse.rst:1364 +#: ../../library/argparse.rst:1176 msgid "An alternative name can be specified with ``metavar``::" msgstr "" -#: ../../library/argparse.rst:1366 +#: ../../library/argparse.rst:1178 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', metavar='YYY')\n" @@ -2488,21 +2061,21 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo YYY" -#: ../../library/argparse.rst:1381 +#: ../../library/argparse.rst:1193 msgid "" "Note that ``metavar`` only changes the *displayed* name - the name of the " "attribute on the :meth:`~ArgumentParser.parse_args` object is still " "determined by the dest_ value." msgstr "" -#: ../../library/argparse.rst:1385 +#: ../../library/argparse.rst:1197 msgid "" "Different values of ``nargs`` may cause the metavar to be used multiple " "times. Providing a tuple to ``metavar`` specifies a different display for " "each of the arguments::" msgstr "" -#: ../../library/argparse.rst:1389 +#: ../../library/argparse.rst:1201 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x', nargs=2)\n" @@ -2526,11 +2099,11 @@ msgstr "" " -x X X\n" " --foo bar baz" -#: ../../library/argparse.rst:1404 +#: ../../library/argparse.rst:1216 msgid "dest" -msgstr "" +msgstr "dest" -#: ../../library/argparse.rst:1406 +#: ../../library/argparse.rst:1218 msgid "" "Most :class:`ArgumentParser` actions add some value as an attribute of the " "object returned by :meth:`~ArgumentParser.parse_args`. The name of this " @@ -2540,7 +2113,7 @@ msgid "" "add_argument`::" msgstr "" -#: ../../library/argparse.rst:1413 +#: ../../library/argparse.rst:1225 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('bar')\n" @@ -2552,7 +2125,7 @@ msgstr "" ">>> parser.parse_args(['XXX'])\n" "Namespace(bar='XXX')" -#: ../../library/argparse.rst:1418 +#: ../../library/argparse.rst:1230 msgid "" "For optional argument actions, the value of ``dest`` is normally inferred " "from the option strings. :class:`ArgumentParser` generates the value of " @@ -2564,7 +2137,7 @@ msgid "" "below illustrate this behavior::" msgstr "" -#: ../../library/argparse.rst:1427 +#: ../../library/argparse.rst:1239 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('-f', '--foo-bar', '--foo')\n" @@ -2582,11 +2155,11 @@ msgstr "" ">>> parser.parse_args('--foo 1 -y 2'.split())\n" "Namespace(foo_bar='1', x='2')" -#: ../../library/argparse.rst:1435 +#: ../../library/argparse.rst:1247 msgid "``dest`` allows a custom attribute name to be provided::" msgstr "" -#: ../../library/argparse.rst:1437 +#: ../../library/argparse.rst:1249 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', dest='bar')\n" @@ -2598,120 +2171,181 @@ msgstr "" ">>> parser.parse_args('--foo XXX'.split())\n" "Namespace(bar='XXX')" -#: ../../library/argparse.rst:1443 -msgid "Action classes" +#: ../../library/argparse.rst:1258 +msgid "deprecated" +msgstr "deprecated" + +#: ../../library/argparse.rst:1260 +msgid "" +"During a project's lifetime, some arguments may need to be removed from the " +"command line. Before removing them, you should inform your users that the " +"arguments are deprecated and will be removed. The ``deprecated`` keyword " +"argument of :meth:`~ArgumentParser.add_argument`, 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 :data:`sys.stderr` when the argument is used::" msgstr "" -#: ../../library/argparse.rst:1445 +#: ../../library/argparse.rst:1270 +msgid "" +">>> import argparse\n" +">>> parser = argparse.ArgumentParser(prog='snake.py')\n" +">>> parser.add_argument('--legs', default=0, type=int, deprecated=True)\n" +">>> parser.parse_args([])\n" +"Namespace(legs=0)\n" +">>> parser.parse_args(['--legs', '4'])\n" +"snake.py: warning: option '--legs' is deprecated\n" +"Namespace(legs=4)" +msgstr "" +">>> import argparse\n" +">>> parser = argparse.ArgumentParser(prog='snake.py')\n" +">>> parser.add_argument('--legs', default=0, type=int, deprecated=True)\n" +">>> parser.parse_args([])\n" +"Namespace(legs=0)\n" +">>> parser.parse_args(['--legs', '4'])\n" +"snake.py: warning: option '--legs' is deprecated\n" +"Namespace(legs=4)" + +#: ../../library/argparse.rst:1283 +msgid "Action classes" +msgstr "Action 類別" + +#: ../../library/argparse.rst:1285 msgid "" -"Action classes implement the Action API, a callable which returns a callable " -"which processes arguments from the command-line. Any object which follows " -"this API may be passed as the ``action`` parameter to :meth:`~ArgumentParser." -"add_argument`." +":class:`!Action` classes implement the Action API, a callable which returns " +"a callable which processes arguments from the command-line. Any object which " +"follows this API may be passed as the ``action`` parameter to :meth:" +"`~ArgumentParser.add_argument`." msgstr "" -#: ../../library/argparse.rst:1454 +#: ../../library/argparse.rst:1294 msgid "" -"Action objects are used by an ArgumentParser 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 :meth:`ArgumentParser.add_argument` except for " -"the ``action`` itself." +":class:`!Action` objects are used by an :class:`ArgumentParser` to represent " +"the information needed to parse a single argument from one or more strings " +"from the command line. The :class:`!Action` class must accept the two " +"positional arguments plus any keyword arguments passed to :meth:" +"`ArgumentParser.add_argument` except for the ``action`` itself." msgstr "" -#: ../../library/argparse.rst:1460 +#: ../../library/argparse.rst:1300 msgid "" -"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__``." +"Instances of :class:`!Action` (or return value of any callable to the " +"``action`` parameter) should have attributes :attr:`!dest`, :attr:`!" +"option_strings`, :attr:`!default`, :attr:`!type`, :attr:`!required`, :attr:`!" +"help`, etc. defined. The easiest way to ensure these attributes are defined " +"is to call :meth:`!Action.__init__`." msgstr "" -#: ../../library/argparse.rst:1465 +#: ../../library/argparse.rst:1308 msgid "" -"Action instances should be callable, so subclasses must override the " -"``__call__`` method, which should accept four parameters:" +":class:`!Action` instances should be callable, so subclasses must override " +"the :meth:`!__call__` method, which should accept four parameters:" msgstr "" -#: ../../library/argparse.rst:1468 -msgid "``parser`` - The ArgumentParser object which contains this action." +#: ../../library/argparse.rst:1311 +msgid "" +"*parser* - The :class:`ArgumentParser` object which contains this action." msgstr "" -#: ../../library/argparse.rst:1470 +#: ../../library/argparse.rst:1313 msgid "" -"``namespace`` - The :class:`Namespace` object that will be returned by :meth:" +"*namespace* - The :class:`Namespace` object that will be returned by :meth:" "`~ArgumentParser.parse_args`. Most actions add an attribute to this object " "using :func:`setattr`." msgstr "" -#: ../../library/argparse.rst:1474 +#: ../../library/argparse.rst:1317 msgid "" -"``values`` - The associated command-line arguments, with any type " -"conversions applied. Type conversions are specified with the type_ keyword " -"argument to :meth:`~ArgumentParser.add_argument`." +"*values* - The associated command-line arguments, with any type conversions " +"applied. Type conversions are specified with the type_ keyword argument to :" +"meth:`~ArgumentParser.add_argument`." msgstr "" -#: ../../library/argparse.rst:1478 +#: ../../library/argparse.rst:1321 msgid "" -"``option_string`` - The option string that was used to invoke this action. " -"The ``option_string`` argument is optional, and will be absent if the action " -"is associated with a positional argument." +"*option_string* - The option string that was used to invoke this action. The " +"``option_string`` argument is optional, and will be absent if the action is " +"associated with a positional argument." msgstr "" -#: ../../library/argparse.rst:1482 +#: ../../library/argparse.rst:1325 msgid "" -"The ``__call__`` method may perform arbitrary actions, but will typically " -"set attributes on the ``namespace`` based on ``dest`` and ``values``." +"The :meth:`!__call__` method may perform arbitrary actions, but will " +"typically set attributes on the ``namespace`` based on ``dest`` and " +"``values``." msgstr "" -#: ../../library/argparse.rst:1485 +#: ../../library/argparse.rst:1330 msgid "" -"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." +":class:`!Action` subclasses can define a :meth:`!format_usage` method that " +"takes no argument and return a string which will be used when printing the " +"usage of the program. If such method is not provided, a sensible default " +"will be used." msgstr "" -#: ../../library/argparse.rst:1490 -msgid "The parse_args() method" +#: ../../library/argparse.rst:1336 +msgid "" +"A subclass of :class:`Action` for handling boolean flags with positive and " +"negative options. Adding a single argument such as ``--foo`` automatically " +"creates both ``--foo`` and ``--no-foo`` options, storing ``True`` and " +"``False`` respectively::" +msgstr "" + +#: ../../library/argparse.rst:1341 +msgid "" +">>> import argparse\n" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', action=argparse.BooleanOptionalAction)\n" +">>> parser.parse_args(['--no-foo'])\n" +"Namespace(foo=False)" msgstr "" +">>> import argparse\n" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', action=argparse.BooleanOptionalAction)\n" +">>> parser.parse_args(['--no-foo'])\n" +"Namespace(foo=False)" + +#: ../../library/argparse.rst:1351 +msgid "The parse_args() method" +msgstr "parse_args() 方法" -#: ../../library/argparse.rst:1494 +#: ../../library/argparse.rst:1355 msgid "" "Convert argument strings to objects and assign them as attributes of the " "namespace. Return the populated namespace." msgstr "" -#: ../../library/argparse.rst:1497 +#: ../../library/argparse.rst:1358 msgid "" "Previous calls to :meth:`add_argument` determine exactly what objects are " -"created and how they are assigned. See the documentation for :meth:" -"`add_argument` for details." +"created and how they are assigned. See the documentation for :meth:`!" +"add_argument` for details." msgstr "" -#: ../../library/argparse.rst:1501 +#: ../../library/argparse.rst:1362 msgid "" "args_ - List of strings to parse. The default is taken from :data:`sys." "argv`." msgstr "" -#: ../../library/argparse.rst:1504 +#: ../../library/argparse.rst:1365 msgid "" "namespace_ - An object to take the attributes. The default is a new empty :" "class:`Namespace` object." msgstr "" -#: ../../library/argparse.rst:1509 +#: ../../library/argparse.rst:1370 msgid "Option value syntax" msgstr "" -#: ../../library/argparse.rst:1511 +#: ../../library/argparse.rst:1372 msgid "" "The :meth:`~ArgumentParser.parse_args` method supports several ways of " "specifying the value of an option (if it takes one). In the simplest case, " "the option and its value are passed as two separate arguments::" msgstr "" -#: ../../library/argparse.rst:1515 +#: ../../library/argparse.rst:1376 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x')\n" @@ -2729,14 +2363,14 @@ msgstr "" ">>> parser.parse_args(['--foo', 'FOO'])\n" "Namespace(foo='FOO', x=None)" -#: ../../library/argparse.rst:1523 +#: ../../library/argparse.rst:1384 msgid "" "For long options (options with names longer than a single character), the " "option and value can also be passed as a single command-line argument, using " "``=`` to separate them::" msgstr "" -#: ../../library/argparse.rst:1527 +#: ../../library/argparse.rst:1388 msgid "" ">>> parser.parse_args(['--foo=FOO'])\n" "Namespace(foo='FOO', x=None)" @@ -2744,13 +2378,13 @@ msgstr "" ">>> parser.parse_args(['--foo=FOO'])\n" "Namespace(foo='FOO', x=None)" -#: ../../library/argparse.rst:1530 +#: ../../library/argparse.rst:1391 msgid "" "For short options (options only one character long), the option and its " "value can be concatenated::" msgstr "" -#: ../../library/argparse.rst:1533 +#: ../../library/argparse.rst:1394 msgid "" ">>> parser.parse_args(['-xX'])\n" "Namespace(foo=None, x='X')" @@ -2758,13 +2392,13 @@ msgstr "" ">>> parser.parse_args(['-xX'])\n" "Namespace(foo=None, x='X')" -#: ../../library/argparse.rst:1536 +#: ../../library/argparse.rst:1397 msgid "" "Several short options can be joined together, using only a single ``-`` " "prefix, as long as only the last option (or none of them) requires a value::" msgstr "" -#: ../../library/argparse.rst:1539 +#: ../../library/argparse.rst:1400 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x', action='store_true')\n" @@ -2780,11 +2414,11 @@ msgstr "" ">>> parser.parse_args(['-xyzZ'])\n" "Namespace(x=True, y=True, z='Z')" -#: ../../library/argparse.rst:1548 +#: ../../library/argparse.rst:1409 msgid "Invalid arguments" -msgstr "" +msgstr "無效引數" -#: ../../library/argparse.rst:1550 +#: ../../library/argparse.rst:1411 msgid "" "While parsing the command line, :meth:`~ArgumentParser.parse_args` checks " "for a variety of errors, including ambiguous options, invalid types, invalid " @@ -2792,7 +2426,7 @@ msgid "" "an error, it exits and prints the error along with a usage message::" msgstr "" -#: ../../library/argparse.rst:1555 +#: ../../library/argparse.rst:1416 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('--foo', type=int)\n" @@ -2813,12 +2447,30 @@ msgid "" "usage: PROG [-h] [--foo FOO] [bar]\n" "PROG: error: extra arguments found: badger" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('--foo', type=int)\n" +">>> parser.add_argument('bar', nargs='?')\n" +"\n" +">>> # 無效型別\n" +">>> parser.parse_args(['--foo', 'spam'])\n" +"usage: PROG [-h] [--foo FOO] [bar]\n" +"PROG: error: argument --foo: invalid int value: 'spam'\n" +"\n" +">>> # 無效選項\n" +">>> parser.parse_args(['--bar'])\n" +"usage: PROG [-h] [--foo FOO] [bar]\n" +"PROG: error: no such option: --bar\n" +"\n" +">>> # 錯誤引數數量\n" +">>> parser.parse_args(['spam', 'badger'])\n" +"usage: PROG [-h] [--foo FOO] [bar]\n" +"PROG: error: extra arguments found: badger" -#: ../../library/argparse.rst:1576 +#: ../../library/argparse.rst:1437 msgid "Arguments containing ``-``" -msgstr "" +msgstr "包含 ``-`` 的引數" -#: ../../library/argparse.rst:1578 +#: ../../library/argparse.rst:1439 msgid "" "The :meth:`~ArgumentParser.parse_args` method attempts to give errors " "whenever the user has clearly made a mistake, but some situations are " @@ -2830,7 +2482,7 @@ msgid "" "negative numbers::" msgstr "" -#: ../../library/argparse.rst:1586 +#: ../../library/argparse.rst:1447 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x')\n" @@ -2863,7 +2515,7 @@ msgid "" "PROG: error: argument -1: expected one argument" msgstr "" -#: ../../library/argparse.rst:1616 +#: ../../library/argparse.rst:1477 msgid "" "If you have positional arguments that must begin with ``-`` and don't look " "like negative numbers, you can insert the pseudo-argument ``'--'`` which " @@ -2871,7 +2523,7 @@ msgid "" "positional argument::" msgstr "" -#: ../../library/argparse.rst:1621 +#: ../../library/argparse.rst:1482 msgid "" ">>> parser.parse_args(['--', '-f'])\n" "Namespace(foo='-f', one=None)" @@ -2879,24 +2531,24 @@ msgstr "" ">>> parser.parse_args(['--', '-f'])\n" "Namespace(foo='-f', one=None)" -#: ../../library/argparse.rst:1624 +#: ../../library/argparse.rst:1485 msgid "" "See also :ref:`the argparse howto on ambiguous arguments ` for more details." msgstr "" -#: ../../library/argparse.rst:1630 +#: ../../library/argparse.rst:1491 msgid "Argument abbreviations (prefix matching)" -msgstr "" +msgstr "引數縮寫 (前綴匹配)" -#: ../../library/argparse.rst:1632 +#: ../../library/argparse.rst:1493 msgid "" "The :meth:`~ArgumentParser.parse_args` method :ref:`by default " "` allows long options to be abbreviated to a prefix, if the " "abbreviation is unambiguous (the prefix matches a unique option)::" msgstr "" -#: ../../library/argparse.rst:1636 +#: ../../library/argparse.rst:1497 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-bacon')\n" @@ -2920,25 +2572,25 @@ msgstr "" "usage: PROG [-h] [-bacon BACON] [-badger BADGER]\n" "PROG: error: ambiguous option: -ba could match -badger, -bacon" -#: ../../library/argparse.rst:1647 +#: ../../library/argparse.rst:1508 msgid "" "An error is produced for arguments that could produce more than one options. " "This feature can be disabled by setting :ref:`allow_abbrev` to ``False``." msgstr "" -#: ../../library/argparse.rst:1653 +#: ../../library/argparse.rst:1514 msgid "Beyond ``sys.argv``" msgstr "" -#: ../../library/argparse.rst:1655 +#: ../../library/argparse.rst:1516 msgid "" -"Sometimes it may be useful to have an ArgumentParser parse arguments other " -"than those of :data:`sys.argv`. This can be accomplished by passing a list " -"of strings to :meth:`~ArgumentParser.parse_args`. This is useful for " -"testing at the interactive prompt::" +"Sometimes it may be useful to have an :class:`ArgumentParser` parse " +"arguments other than those of :data:`sys.argv`. This can be accomplished by " +"passing a list of strings to :meth:`~ArgumentParser.parse_args`. This is " +"useful for testing at the interactive prompt::" msgstr "" -#: ../../library/argparse.rst:1660 +#: ../../library/argparse.rst:1521 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument(\n" @@ -2964,24 +2616,24 @@ msgstr "" ">>> parser.parse_args(['1', '2', '3', '4', '--sum'])\n" "Namespace(accumulate=, integers=[1, 2, 3, 4])" -#: ../../library/argparse.rst:1675 +#: ../../library/argparse.rst:1536 msgid "The Namespace object" -msgstr "" +msgstr "命名空間物件" -#: ../../library/argparse.rst:1679 +#: ../../library/argparse.rst:1540 msgid "" "Simple class used by default by :meth:`~ArgumentParser.parse_args` to create " "an object holding attributes and return it." msgstr "" -#: ../../library/argparse.rst:1682 +#: ../../library/argparse.rst:1543 msgid "" "This class is deliberately simple, just an :class:`object` subclass with a " "readable string representation. If you prefer to have dict-like view of the " "attributes, you can use the standard Python idiom, :func:`vars`::" msgstr "" -#: ../../library/argparse.rst:1686 +#: ../../library/argparse.rst:1547 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -2995,14 +2647,14 @@ msgstr "" ">>> vars(args)\n" "{'foo': 'BAR'}" -#: ../../library/argparse.rst:1692 +#: ../../library/argparse.rst:1553 msgid "" "It may also be useful to have an :class:`ArgumentParser` assign attributes " "to an already existing object, rather than a new :class:`Namespace` object. " "This can be achieved by specifying the ``namespace=`` keyword argument::" msgstr "" -#: ../../library/argparse.rst:1696 +#: ../../library/argparse.rst:1557 msgid "" ">>> class C:\n" "... pass\n" @@ -3024,98 +2676,97 @@ msgstr "" ">>> c.foo\n" "'BAR'" -#: ../../library/argparse.rst:1708 +#: ../../library/argparse.rst:1569 msgid "Other utilities" msgstr "" -#: ../../library/argparse.rst:1711 +#: ../../library/argparse.rst:1572 msgid "Sub-commands" -msgstr "" +msgstr "子命令" -#: ../../library/argparse.rst:1718 +#: ../../library/argparse.rst:1579 msgid "" -"Many programs split up their functionality into a number of sub-commands, " -"for example, the ``svn`` program can invoke sub-commands 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. :class:`ArgumentParser` supports the creation of such sub-" -"commands with the :meth:`add_subparsers` method. The :meth:`add_subparsers` " -"method is normally called with no arguments and returns a special action " -"object. This object has a single method, :meth:`~_SubParsersAction." -"add_parser`, which takes a command name and any :class:`ArgumentParser` " -"constructor arguments, and returns an :class:`ArgumentParser` object that " -"can be modified as usual." -msgstr "" - -#: ../../library/argparse.rst:1730 -msgid "Description of parameters:" +"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. :class:" +"`ArgumentParser` supports the creation of such subcommands with the :meth:`!" +"add_subparsers` method. The :meth:`!add_subparsers` method is normally " +"called with no arguments and returns a special action object. This object " +"has a single method, :meth:`~_SubParsersAction.add_parser`, which takes a " +"command name and any :class:`!ArgumentParser` constructor arguments, and " +"returns an :class:`!ArgumentParser` object that can be modified as usual." msgstr "" -#: ../../library/argparse.rst:1732 +#: ../../library/argparse.rst:1591 +msgid "Description of parameters:" +msgstr "參數的解釋:" + +#: ../../library/argparse.rst:1593 msgid "" -"title - title for the sub-parser group in help output; by default " +"*title* - title for the sub-parser group in help output; by default " "\"subcommands\" if description is provided, otherwise uses title for " "positional arguments" msgstr "" -#: ../../library/argparse.rst:1736 +#: ../../library/argparse.rst:1597 msgid "" -"description - description for the sub-parser group in help output, by " +"*description* - description for the sub-parser group in help output, by " "default ``None``" msgstr "" -#: ../../library/argparse.rst:1739 +#: ../../library/argparse.rst:1600 msgid "" -"prog - usage information that will be displayed with sub-command help, by " +"*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" msgstr "" -#: ../../library/argparse.rst:1743 +#: ../../library/argparse.rst:1604 msgid "" -"parser_class - class which will be used to create sub-parser instances, by " -"default the class of the current parser (e.g. ArgumentParser)" +"*parser_class* - class which will be used to create sub-parser instances, by " +"default the class of the current parser (e.g. :class:`ArgumentParser`)" msgstr "" -#: ../../library/argparse.rst:1746 +#: ../../library/argparse.rst:1607 msgid "" "action_ - the basic type of action to be taken when this argument is " "encountered at the command line" msgstr "" -#: ../../library/argparse.rst:1749 +#: ../../library/argparse.rst:1610 msgid "" "dest_ - name of the attribute under which sub-command name will be stored; " "by default ``None`` and no value is stored" msgstr "" -#: ../../library/argparse.rst:1752 +#: ../../library/argparse.rst:1613 msgid "" "required_ - Whether or not a subcommand must be provided, by default " "``False`` (added in 3.7)" msgstr "" -#: ../../library/argparse.rst:1755 +#: ../../library/argparse.rst:1616 msgid "help_ - help for sub-parser group in help output, by default ``None``" msgstr "" -#: ../../library/argparse.rst:1757 +#: ../../library/argparse.rst:1618 msgid "" -"metavar_ - string presenting available sub-commands in help; by default it " -"is ``None`` and presents sub-commands in form {cmd1, cmd2, ..}" +"metavar_ - string presenting available subcommands in help; by default it is " +"``None`` and presents subcommands in form {cmd1, cmd2, ..}" msgstr "" -#: ../../library/argparse.rst:1760 +#: ../../library/argparse.rst:1621 msgid "Some example usage::" msgstr "一些使用範例: ::" -#: ../../library/argparse.rst:1762 +#: ../../library/argparse.rst:1623 msgid "" ">>> # create the top-level parser\n" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('--foo', action='store_true', help='foo help')\n" -">>> subparsers = parser.add_subparsers(help='sub-command help')\n" +">>> subparsers = parser.add_subparsers(help='subcommand help')\n" ">>>\n" ">>> # create the parser for the \"a\" command\n" ">>> parser_a = subparsers.add_parser('a', help='a help')\n" @@ -3123,7 +2774,8 @@ msgid "" ">>>\n" ">>> # create the parser for the \"b\" command\n" ">>> parser_b = subparsers.add_parser('b', help='b help')\n" -">>> parser_b.add_argument('--baz', choices='XYZ', help='baz help')\n" +">>> parser_b.add_argument('--baz', choices=('X', 'Y', 'Z'), help='baz " +"help')\n" ">>>\n" ">>> # parse some argument lists\n" ">>> parser.parse_args(['a', '12'])\n" @@ -3132,7 +2784,7 @@ msgid "" "Namespace(baz='Z', foo=True)" msgstr "" -#: ../../library/argparse.rst:1781 +#: ../../library/argparse.rst:1642 msgid "" "Note that the object returned by :meth:`parse_args` will only contain " "attributes for the main parser and the subparser that was selected by the " @@ -3142,7 +2794,7 @@ msgid "" "``baz`` attributes are present." msgstr "" -#: ../../library/argparse.rst:1788 +#: ../../library/argparse.rst:1649 msgid "" "Similarly, when a help message is requested from a subparser, only the help " "for that particular parser will be printed. The help message will not " @@ -3151,13 +2803,13 @@ msgid "" "to :meth:`~_SubParsersAction.add_parser` as above.)" msgstr "" -#: ../../library/argparse.rst:1796 +#: ../../library/argparse.rst:1657 msgid "" ">>> parser.parse_args(['--help'])\n" "usage: PROG [-h] [--foo] {a,b} ...\n" "\n" "positional arguments:\n" -" {a,b} sub-command help\n" +" {a,b} subcommand help\n" " a a help\n" " b b help\n" "\n" @@ -3185,7 +2837,7 @@ msgstr "" "usage: PROG [-h] [--foo] {a,b} ...\n" "\n" "positional arguments:\n" -" {a,b} sub-command help\n" +" {a,b} subcommand help\n" " a a help\n" " b b help\n" "\n" @@ -3209,14 +2861,14 @@ msgstr "" " -h, --help show this help message and exit\n" " --baz {X,Y,Z} baz help" -#: ../../library/argparse.rst:1824 +#: ../../library/argparse.rst:1685 msgid "" "The :meth:`add_subparsers` method also supports ``title`` and " "``description`` keyword arguments. When either is present, the subparser's " "commands will appear in their own group in the help output. For example::" msgstr "" -#: ../../library/argparse.rst:1828 +#: ../../library/argparse.rst:1689 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers(title='subcommands',\n" @@ -3252,14 +2904,15 @@ msgstr "" "\n" " {foo,bar} additional help" -#: ../../library/argparse.rst:1845 +#: ../../library/argparse.rst:1706 msgid "" -"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``::" +"Furthermore, :meth:`~_SubParsersAction.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``::" msgstr "" -#: ../../library/argparse.rst:1849 +#: ../../library/argparse.rst:1711 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers()\n" @@ -3275,17 +2928,23 @@ msgstr "" ">>> parser.parse_args(['co', 'bar'])\n" "Namespace(foo='bar')" -#: ../../library/argparse.rst:1856 +#: ../../library/argparse.rst:1718 +msgid "" +":meth:`~_SubParsersAction.add_parser` supports also an additional " +"*deprecated* argument, which allows to deprecate the subparser." +msgstr "" + +#: ../../library/argparse.rst:1732 msgid "" -"One particularly effective way of handling sub-commands is to combine the " -"use of the :meth:`add_subparsers` method with calls to :meth:`set_defaults` " -"so that each subparser knows which Python function it should execute. For " +"One particularly effective way of handling subcommands is to combine the use " +"of the :meth:`add_subparsers` method with calls to :meth:`set_defaults` so " +"that each subparser knows which Python function it should execute. For " "example::" msgstr "" -#: ../../library/argparse.rst:1861 +#: ../../library/argparse.rst:1737 msgid "" -">>> # sub-command functions\n" +">>> # subcommand functions\n" ">>> def foo(args):\n" "... print(args.x * args.y)\n" "...\n" @@ -3318,7 +2977,7 @@ msgid "" "((XYZYX))" msgstr "" -#: ../../library/argparse.rst:1893 +#: ../../library/argparse.rst:1769 msgid "" "This way, you can let :meth:`parse_args` do the job of calling the " "appropriate function after argument parsing is complete. Associating " @@ -3328,7 +2987,7 @@ msgid "" "argument to the :meth:`add_subparsers` call will work::" msgstr "" -#: ../../library/argparse.rst:1900 +#: ../../library/argparse.rst:1776 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers(dest='subparser_name')\n" @@ -3348,15 +3007,15 @@ msgstr "" ">>> parser.parse_args(['2', 'frobble'])\n" "Namespace(subparser_name='2', y='frobble')" -#: ../../library/argparse.rst:1909 -msgid "New *required* keyword argument." +#: ../../library/argparse.rst:1785 +msgid "New *required* keyword-only parameter." msgstr "" -#: ../../library/argparse.rst:1914 +#: ../../library/argparse.rst:1790 msgid "FileType objects" msgstr "FileType 物件" -#: ../../library/argparse.rst:1918 +#: ../../library/argparse.rst:1794 msgid "" "The :class:`FileType` factory creates objects that can be passed to the type " "argument of :meth:`ArgumentParser.add_argument`. Arguments that have :class:" @@ -3365,7 +3024,7 @@ msgid "" "the :func:`open` function for more details)::" msgstr "" -#: ../../library/argparse.rst:1924 +#: ../../library/argparse.rst:1800 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--raw', type=argparse.FileType('wb', 0))\n" @@ -3383,14 +3042,14 @@ msgstr "" "Namespace(out=<_io.TextIOWrapper name='file.txt' mode='w' encoding='UTF-8'>, " "raw=<_io.FileIO name='raw.dat' mode='wb'>)" -#: ../../library/argparse.rst:1930 +#: ../../library/argparse.rst:1806 msgid "" "FileType objects understand the pseudo-argument ``'-'`` and automatically " "convert this into :data:`sys.stdin` for readable :class:`FileType` objects " "and :data:`sys.stdout` for writable :class:`FileType` objects::" msgstr "" -#: ../../library/argparse.rst:1934 +#: ../../library/argparse.rst:1810 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('infile', type=argparse.FileType('r'))\n" @@ -3402,24 +3061,24 @@ msgstr "" ">>> parser.parse_args(['-'])\n" "Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>)" -#: ../../library/argparse.rst:1939 +#: ../../library/argparse.rst:1815 msgid "Added the *encodings* and *errors* parameters." msgstr "" -#: ../../library/argparse.rst:1944 +#: ../../library/argparse.rst:1820 msgid "Argument groups" msgstr "" -#: ../../library/argparse.rst:1948 +#: ../../library/argparse.rst:1825 msgid "" "By default, :class:`ArgumentParser` 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 :meth:`add_argument_group` " +"appropriate groups can be created using the :meth:`!add_argument_group` " "method::" msgstr "" -#: ../../library/argparse.rst:1954 +#: ../../library/argparse.rst:1831 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> group = parser.add_argument_group('group')\n" @@ -3443,18 +3102,18 @@ msgstr "" " bar bar help\n" " --foo FOO foo help" -#: ../../library/argparse.rst:1965 +#: ../../library/argparse.rst:1842 msgid "" "The :meth:`add_argument_group` method returns an argument group object which " "has an :meth:`~ArgumentParser.add_argument` method just like a regular :" "class:`ArgumentParser`. 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 :meth:`add_argument_group` method " +"separate group for help messages. The :meth:`!add_argument_group` method " "accepts *title* and *description* arguments which can be used to customize " "this display::" msgstr "" -#: ../../library/argparse.rst:1973 +#: ../../library/argparse.rst:1850 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> group1 = parser.add_argument_group('group1', 'group1 description')\n" @@ -3492,13 +3151,22 @@ msgstr "" "\n" " --bar BAR bar help" -#: ../../library/argparse.rst:1991 +#: ../../library/argparse.rst:1868 +msgid "" +"The optional, keyword-only parameters argument_default_ and " +"conflict_handler_ allow for finer-grained control of the behavior of the " +"argument group. These parameters have the same meaning as in the :class:" +"`ArgumentParser` constructor, but apply specifically to the argument group " +"rather than the entire parser." +msgstr "" + +#: ../../library/argparse.rst:1873 msgid "" "Note that any arguments not in your user-defined groups will end up back in " "the usual \"positional arguments\" and \"optional arguments\" sections." msgstr "" -#: ../../library/argparse.rst:1994 +#: ../../library/argparse.rst:1876 msgid "" "Calling :meth:`add_argument_group` on an argument group is deprecated. This " "feature was never supported and does not always work correctly. The function " @@ -3506,18 +3174,18 @@ msgid "" "future." msgstr "" -#: ../../library/argparse.rst:2002 +#: ../../library/argparse.rst:1884 msgid "Mutual exclusion" msgstr "" -#: ../../library/argparse.rst:2006 +#: ../../library/argparse.rst:1888 msgid "" -"Create a mutually exclusive group. :mod:`argparse` will make sure that only " +"Create a mutually exclusive group. :mod:`!argparse` will make sure that only " "one of the arguments in the mutually exclusive group was present on the " "command line::" msgstr "" -#: ../../library/argparse.rst:2010 +#: ../../library/argparse.rst:1892 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_mutually_exclusive_group()\n" @@ -3543,14 +3211,14 @@ msgstr "" "usage: PROG [-h] [--foo | --bar]\n" "PROG: error: argument --bar: not allowed with argument --foo" -#: ../../library/argparse.rst:2022 +#: ../../library/argparse.rst:1904 msgid "" "The :meth:`add_mutually_exclusive_group` method also accepts a *required* " "argument, to indicate that at least one of the mutually exclusive arguments " "is required::" msgstr "" -#: ../../library/argparse.rst:2026 +#: ../../library/argparse.rst:1908 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_mutually_exclusive_group(required=True)\n" @@ -3568,7 +3236,7 @@ msgstr "" "usage: PROG [-h] (--foo | --bar)\n" "PROG: error: one of the arguments --foo --bar is required" -#: ../../library/argparse.rst:2034 +#: ../../library/argparse.rst:1916 msgid "" "Note that currently mutually exclusive argument groups do not support the " "*title* and *description* arguments of :meth:`~ArgumentParser." @@ -3576,7 +3244,7 @@ msgid "" "argument group that has a title and description. For example::" msgstr "" -#: ../../library/argparse.rst:2040 +#: ../../library/argparse.rst:1922 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_argument_group('Group title', 'Group description')\n" @@ -3612,7 +3280,7 @@ msgstr "" " --foo FOO foo help\n" " --bar BAR bar help" -#: ../../library/argparse.rst:2057 +#: ../../library/argparse.rst:1939 msgid "" "Calling :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group` " "on a mutually exclusive group is deprecated. These features were never " @@ -3620,11 +3288,11 @@ msgid "" "by accident through inheritance and will be removed in the future." msgstr "" -#: ../../library/argparse.rst:2065 +#: ../../library/argparse.rst:1947 msgid "Parser defaults" msgstr "" -#: ../../library/argparse.rst:2069 +#: ../../library/argparse.rst:1951 msgid "" "Most of the time, the attributes of the object returned by :meth:" "`parse_args` will be fully determined by inspecting the command-line " @@ -3633,7 +3301,7 @@ msgid "" "command line to be added::" msgstr "" -#: ../../library/argparse.rst:2075 +#: ../../library/argparse.rst:1957 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('foo', type=int)\n" @@ -3647,12 +3315,12 @@ msgstr "" ">>> parser.parse_args(['736'])\n" "Namespace(bar=42, baz='badger', foo=736)" -#: ../../library/argparse.rst:2081 +#: ../../library/argparse.rst:1963 msgid "" "Note that parser-level defaults always override argument-level defaults::" msgstr "" -#: ../../library/argparse.rst:2083 +#: ../../library/argparse.rst:1965 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default='bar')\n" @@ -3666,20 +3334,20 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo='spam')" -#: ../../library/argparse.rst:2089 +#: ../../library/argparse.rst:1971 msgid "" "Parser-level defaults can be particularly useful when working with multiple " "parsers. See the :meth:`~ArgumentParser.add_subparsers` method for an " "example of this type." msgstr "" -#: ../../library/argparse.rst:2095 +#: ../../library/argparse.rst:1977 msgid "" "Get the default value for a namespace attribute, as set by either :meth:" "`~ArgumentParser.add_argument` or by :meth:`~ArgumentParser.set_defaults`::" msgstr "" -#: ../../library/argparse.rst:2099 +#: ../../library/argparse.rst:1981 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default='badger')\n" @@ -3691,65 +3359,70 @@ msgstr "" ">>> parser.get_default('foo')\n" "'badger'" -#: ../../library/argparse.rst:2106 +#: ../../library/argparse.rst:1988 msgid "Printing help" -msgstr "" +msgstr "印出幫助訊息" -#: ../../library/argparse.rst:2108 +#: ../../library/argparse.rst:1990 msgid "" "In most typical applications, :meth:`~ArgumentParser.parse_args` will take " "care of formatting and printing any usage or error messages. However, " "several formatting methods are available:" msgstr "" -#: ../../library/argparse.rst:2114 +#: ../../library/argparse.rst:1996 msgid "" "Print a brief description of how the :class:`ArgumentParser` should be " "invoked on the command line. If *file* is ``None``, :data:`sys.stdout` is " "assumed." msgstr "" -#: ../../library/argparse.rst:2120 +#: ../../library/argparse.rst:2002 msgid "" "Print a help message, including the program usage and information about the " "arguments registered with the :class:`ArgumentParser`. If *file* is " "``None``, :data:`sys.stdout` is assumed." msgstr "" -#: ../../library/argparse.rst:2124 +#: ../../library/argparse.rst:2006 msgid "" "There are also variants of these methods that simply return a string instead " "of printing it:" msgstr "" -#: ../../library/argparse.rst:2129 +#: ../../library/argparse.rst:2011 msgid "" "Return a string containing a brief description of how the :class:" "`ArgumentParser` should be invoked on the command line." msgstr "" -#: ../../library/argparse.rst:2134 +#: ../../library/argparse.rst:2016 msgid "" "Return a string containing a help message, including the program usage and " "information about the arguments registered with the :class:`ArgumentParser`." msgstr "" -#: ../../library/argparse.rst:2139 +#: ../../library/argparse.rst:2021 msgid "Partial parsing" msgstr "" -#: ../../library/argparse.rst:2143 +#: ../../library/argparse.rst:2025 +msgid "" +"Sometimes a script only needs to handle a specific set of command-line " +"arguments, leaving any unrecognized arguments for another script or program. " +"In these cases, the :meth:`~ArgumentParser.parse_known_args` method can be " +"useful." +msgstr "" + +#: ../../library/argparse.rst:2030 msgid "" -"Sometimes a script may only parse a few of the command-line arguments, " -"passing the remaining arguments on to another script or program. In these " -"cases, the :meth:`~ArgumentParser.parse_known_args` method can be useful. " -"It works much like :meth:`~ArgumentParser.parse_args` except that it does " -"not produce an error when extra arguments are present. Instead, it returns " -"a two item tuple containing the populated namespace and the list of " -"remaining argument strings." +"This method works similarly to :meth:`~ArgumentParser.parse_args`, but it " +"does not raise an error for extra, unrecognized arguments. Instead, it " +"parses the known arguments and returns a two item tuple that contains the " +"populated namespace and the list of any unrecognized arguments." msgstr "" -#: ../../library/argparse.rst:2152 +#: ../../library/argparse.rst:2037 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_true')\n" @@ -3763,7 +3436,7 @@ msgstr "" ">>> parser.parse_known_args(['--foo', '--badger', 'BAR', 'spam'])\n" "(Namespace(bar='BAR', foo=True), ['--badger', 'spam'])" -#: ../../library/argparse.rst:2159 +#: ../../library/argparse.rst:2044 msgid "" ":ref:`Prefix matching ` rules apply to :meth:" "`~ArgumentParser.parse_known_args`. The parser may consume an option even if " @@ -3771,11 +3444,11 @@ msgid "" "remaining arguments list." msgstr "" -#: ../../library/argparse.rst:2166 +#: ../../library/argparse.rst:2051 msgid "Customizing file parsing" msgstr "" -#: ../../library/argparse.rst:2170 +#: ../../library/argparse.rst:2055 msgid "" "Arguments that are read from a file (see the *fromfile_prefix_chars* keyword " "argument to the :class:`ArgumentParser` constructor) are read one argument " @@ -3783,20 +3456,20 @@ msgid "" "reading." msgstr "" -#: ../../library/argparse.rst:2175 +#: ../../library/argparse.rst:2060 msgid "" "This method takes a single argument *arg_line* which is a string read from " "the argument file. It returns a list of arguments parsed from this string. " "The method is called once per line read from the argument file, in order." msgstr "" -#: ../../library/argparse.rst:2179 +#: ../../library/argparse.rst:2064 msgid "" "A useful override of this method is one that treats each space-separated " "word as an argument. The following example demonstrates how to do this::" msgstr "" -#: ../../library/argparse.rst:2182 +#: ../../library/argparse.rst:2067 msgid "" "class MyArgumentParser(argparse.ArgumentParser):\n" " def convert_arg_line_to_args(self, arg_line):\n" @@ -3806,18 +3479,18 @@ msgstr "" " def convert_arg_line_to_args(self, arg_line):\n" " return arg_line.split()" -#: ../../library/argparse.rst:2188 +#: ../../library/argparse.rst:2073 msgid "Exiting methods" msgstr "" -#: ../../library/argparse.rst:2192 +#: ../../library/argparse.rst:2077 msgid "" "This method terminates the program, exiting with the specified *status* and, " -"if given, it prints a *message* before that. The user can override this " -"method to handle these steps differently::" +"if given, it prints a *message* to :data:`sys.stderr` before that. The user " +"can override this method to handle these steps differently::" msgstr "" -#: ../../library/argparse.rst:2196 +#: ../../library/argparse.rst:2081 msgid "" "class ErrorCatchingArgumentParser(argparse.ArgumentParser):\n" " def exit(self, status=0, message=None):\n" @@ -3831,17 +3504,17 @@ msgstr "" " raise Exception(f'Exiting because of an error: {message}')\n" " exit(status)" -#: ../../library/argparse.rst:2204 +#: ../../library/argparse.rst:2089 msgid "" -"This method prints a usage message including the *message* to the standard " -"error and terminates the program with a status code of 2." +"This method prints a usage message, including the *message*, to :data:`sys." +"stderr` and terminates the program with a status code of 2." msgstr "" -#: ../../library/argparse.rst:2209 +#: ../../library/argparse.rst:2094 msgid "Intermixed parsing" msgstr "" -#: ../../library/argparse.rst:2214 +#: ../../library/argparse.rst:2099 msgid "" "A number of Unix commands allow the user to intermix optional arguments with " "positional arguments. The :meth:`~ArgumentParser.parse_intermixed_args` " @@ -3849,15 +3522,15 @@ msgid "" "parsing style." msgstr "" -#: ../../library/argparse.rst:2219 +#: ../../library/argparse.rst:2104 msgid "" -"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." +"These parsers do not support all the :mod:`!argparse` features, and will " +"raise exceptions if unsupported features are used. In particular, " +"subparsers, and mutually exclusive groups that include both optionals and " +"positionals are not supported." msgstr "" -#: ../../library/argparse.rst:2224 +#: ../../library/argparse.rst:2109 msgid "" "The following example shows the difference between :meth:`~ArgumentParser." "parse_known_args` and :meth:`~ArgumentParser.parse_intermixed_args`: the " @@ -3865,7 +3538,7 @@ msgid "" "collects all the positionals into ``rest``. ::" msgstr "" -#: ../../library/argparse.rst:2230 +#: ../../library/argparse.rst:2115 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -3885,7 +3558,7 @@ msgstr "" ">>> parser.parse_intermixed_args('doit 1 --foo bar 2 3'.split())\n" "Namespace(cmd='doit', foo='bar', rest=[1, 2, 3])" -#: ../../library/argparse.rst:2239 +#: ../../library/argparse.rst:2124 msgid "" ":meth:`~ArgumentParser.parse_known_intermixed_args` returns a two item tuple " "containing the populated namespace and the list of remaining argument " @@ -3893,143 +3566,83 @@ msgid "" "there are any remaining unparsed argument strings." msgstr "" -#: ../../library/argparse.rst:2249 -msgid "Upgrading optparse code" -msgstr "" - -#: ../../library/argparse.rst:2251 -msgid "" -"Originally, the :mod:`argparse` module had attempted to maintain " -"compatibility with :mod:`optparse`. However, :mod:`optparse` was difficult " -"to extend transparently, particularly with the changes required to support " -"the new ``nargs=`` specifiers and better usage messages. When most " -"everything in :mod:`optparse` had either been copy-pasted over or monkey-" -"patched, it no longer seemed practical to try to maintain the backwards " -"compatibility." -msgstr "" - -#: ../../library/argparse.rst:2258 -msgid "" -"The :mod:`argparse` module improves on the standard library :mod:`optparse` " -"module in a number of ways including:" -msgstr "" - -#: ../../library/argparse.rst:2261 -msgid "Handling positional arguments." -msgstr "" - -#: ../../library/argparse.rst:2262 -msgid "Supporting sub-commands." -msgstr "" - -#: ../../library/argparse.rst:2263 -msgid "Allowing alternative option prefixes like ``+`` and ``/``." -msgstr "" - -#: ../../library/argparse.rst:2264 -msgid "Handling zero-or-more and one-or-more style arguments." -msgstr "" - -#: ../../library/argparse.rst:2265 -msgid "Producing more informative usage messages." -msgstr "" - -#: ../../library/argparse.rst:2266 -msgid "Providing a much simpler interface for custom ``type`` and ``action``." -msgstr "" - -#: ../../library/argparse.rst:2268 -msgid "A partial upgrade path from :mod:`optparse` to :mod:`argparse`:" -msgstr "" - -#: ../../library/argparse.rst:2270 -msgid "" -"Replace all :meth:`optparse.OptionParser.add_option` calls with :meth:" -"`ArgumentParser.add_argument` calls." -msgstr "" - -#: ../../library/argparse.rst:2273 -msgid "" -"Replace ``(options, args) = parser.parse_args()`` with ``args = parser." -"parse_args()`` and add additional :meth:`ArgumentParser.add_argument` calls " -"for the positional arguments. Keep in mind that what was previously called " -"``options``, now in the :mod:`argparse` context is called ``args``." -msgstr "" - -#: ../../library/argparse.rst:2278 -msgid "" -"Replace :meth:`optparse.OptionParser.disable_interspersed_args` by using :" -"meth:`~ArgumentParser.parse_intermixed_args` instead of :meth:" -"`~ArgumentParser.parse_args`." -msgstr "" - -#: ../../library/argparse.rst:2282 -msgid "" -"Replace callback actions and the ``callback_*`` keyword arguments with " -"``type`` or ``action`` arguments." +#: ../../library/argparse.rst:2133 +msgid "Registering custom types or actions" msgstr "" -#: ../../library/argparse.rst:2285 +#: ../../library/argparse.rst:2137 msgid "" -"Replace string names for ``type`` keyword arguments with the corresponding " -"type objects (e.g. int, float, complex, etc)." +"Sometimes it's desirable to use a custom string in error messages to provide " +"more user-friendly output. In these cases, :meth:`!register` can be used to " +"register custom actions or types with a parser and allow you to reference " +"the type by their registered name instead of their callable name." msgstr "" -#: ../../library/argparse.rst:2288 +#: ../../library/argparse.rst:2142 msgid "" -"Replace :class:`optparse.Values` with :class:`Namespace` and :exc:`optparse." -"OptionError` and :exc:`optparse.OptionValueError` with :exc:`ArgumentError`." +"The :meth:`!register` method accepts three arguments - a *registry_name*, " +"specifying the internal registry where the object will be stored (e.g., " +"``action``, ``type``), *value*, which is the key under which the object will " +"be registered, and object, the callable to be registered." msgstr "" -#: ../../library/argparse.rst:2292 +#: ../../library/argparse.rst:2147 msgid "" -"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``." +"The following example shows how to register a custom type with a parser::" msgstr "" -#: ../../library/argparse.rst:2296 +#: ../../library/argparse.rst:2149 msgid "" -"Replace the OptionParser constructor ``version`` argument with a call to " -"``parser.add_argument('--version', action='version', version='')``." +">>> import argparse\n" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.register('type', 'hexadecimal integer', lambda s: int(s, 16))\n" +">>> parser.add_argument('--foo', type='hexadecimal integer')\n" +"_StoreAction(option_strings=['--foo'], dest='foo', nargs=None, const=None, " +"default=None, type='hexadecimal integer', choices=None, required=False, " +"help=None, metavar=None, deprecated=False)\n" +">>> parser.parse_args(['--foo', '0xFA'])\n" +"Namespace(foo=250)\n" +">>> parser.parse_args(['--foo', '1.2'])\n" +"usage: PROG [-h] [--foo FOO]\n" +"PROG: error: argument --foo: invalid 'hexadecimal integer' value: '1.2'" msgstr "" -#: ../../library/argparse.rst:2300 +#: ../../library/argparse.rst:2161 msgid "Exceptions" -msgstr "" +msgstr "例外" -#: ../../library/argparse.rst:2304 +#: ../../library/argparse.rst:2165 msgid "An error from creating or using an argument (optional or positional)." msgstr "" -#: ../../library/argparse.rst:2306 +#: ../../library/argparse.rst:2167 msgid "" "The string value of this exception is the message, augmented with " "information about the argument that caused it." msgstr "" -#: ../../library/argparse.rst:2311 +#: ../../library/argparse.rst:2172 msgid "" "Raised when something goes wrong converting a command line string to a type." msgstr "" -#: ../../library/argparse.rst:980 +#: ../../library/argparse.rst:2176 +msgid "Guides and Tutorials" +msgstr "" + +#: ../../library/argparse.rst:809 msgid "? (question mark)" msgstr "? (問號)" -#: ../../library/argparse.rst:980 ../../library/argparse.rst:1014 -#: ../../library/argparse.rst:1028 +#: ../../library/argparse.rst:809 ../../library/argparse.rst:843 +#: ../../library/argparse.rst:857 msgid "in argparse module" msgstr "於 argparse 模組中" -#: ../../library/argparse.rst:1014 +#: ../../library/argparse.rst:843 msgid "* (asterisk)" msgstr "* (星號)" -#: ../../library/argparse.rst:1028 +#: ../../library/argparse.rst:857 msgid "+ (plus)" msgstr "+ (加號)" - -#~ msgid "type_" -#~ msgstr "type_" diff --git a/library/array.po b/library/array.po index 9fb7774db1..c9aa3ec262 100644 --- a/library/array.po +++ b/library/array.po @@ -8,9 +8,9 @@ # Benson Chen , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2021-11-23 18:40+0800\n" "Last-Translator: Benson Chen \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -69,10 +69,10 @@ msgid "signed char" msgstr "signed char" #: ../../library/array.rst:21 ../../library/array.rst:23 -#: ../../library/array.rst:27 ../../library/array.rst:29 -#: ../../library/array.rst:31 ../../library/array.rst:33 -#: ../../library/array.rst:35 ../../library/array.rst:37 -#: ../../library/array.rst:39 ../../library/array.rst:41 +#: ../../library/array.rst:29 ../../library/array.rst:31 +#: ../../library/array.rst:33 ../../library/array.rst:35 +#: ../../library/array.rst:37 ../../library/array.rst:39 +#: ../../library/array.rst:41 ../../library/array.rst:43 msgid "int" msgstr "int" @@ -96,13 +96,13 @@ msgstr "``'u'``" msgid "wchar_t" msgstr "wchar_t" -#: ../../library/array.rst:25 +#: ../../library/array.rst:25 ../../library/array.rst:27 msgid "Unicode character" msgstr "Unicode character" -#: ../../library/array.rst:25 ../../library/array.rst:27 -#: ../../library/array.rst:29 ../../library/array.rst:31 -#: ../../library/array.rst:33 +#: ../../library/array.rst:25 ../../library/array.rst:29 +#: ../../library/array.rst:31 ../../library/array.rst:33 +#: ../../library/array.rst:35 msgid "2" msgstr "2" @@ -111,114 +111,126 @@ msgid "\\(1)" msgstr "\\(1)" #: ../../library/array.rst:27 +msgid "``'w'``" +msgstr "``'w'``" + +#: ../../library/array.rst:27 +msgid "Py_UCS4" +msgstr "Py_UCS4" + +#: ../../library/array.rst:27 ../../library/array.rst:37 +#: ../../library/array.rst:39 ../../library/array.rst:45 +msgid "4" +msgstr "4" + +#: ../../library/array.rst:29 msgid "``'h'``" msgstr "``'h'``" -#: ../../library/array.rst:27 +#: ../../library/array.rst:29 msgid "signed short" msgstr "signed short" -#: ../../library/array.rst:29 +#: ../../library/array.rst:31 msgid "``'H'``" msgstr "``'H'``" -#: ../../library/array.rst:29 +#: ../../library/array.rst:31 msgid "unsigned short" msgstr "unsigned short" -#: ../../library/array.rst:31 +#: ../../library/array.rst:33 msgid "``'i'``" msgstr "``'i'``" -#: ../../library/array.rst:31 +#: ../../library/array.rst:33 msgid "signed int" msgstr "signed int" -#: ../../library/array.rst:33 +#: ../../library/array.rst:35 msgid "``'I'``" msgstr "``'I'``" -#: ../../library/array.rst:33 +#: ../../library/array.rst:35 msgid "unsigned int" msgstr "unsigned int" -#: ../../library/array.rst:35 +#: ../../library/array.rst:37 msgid "``'l'``" msgstr "``'l'``" -#: ../../library/array.rst:35 +#: ../../library/array.rst:37 msgid "signed long" msgstr "signed long" -#: ../../library/array.rst:35 ../../library/array.rst:37 -#: ../../library/array.rst:43 -msgid "4" -msgstr "4" - -#: ../../library/array.rst:37 +#: ../../library/array.rst:39 msgid "``'L'``" msgstr "``'L'``" -#: ../../library/array.rst:37 +#: ../../library/array.rst:39 msgid "unsigned long" msgstr "unsigned long" -#: ../../library/array.rst:39 +#: ../../library/array.rst:41 msgid "``'q'``" msgstr "``'q'``" -#: ../../library/array.rst:39 +#: ../../library/array.rst:41 msgid "signed long long" msgstr "signed long long" -#: ../../library/array.rst:39 ../../library/array.rst:41 -#: ../../library/array.rst:45 +#: ../../library/array.rst:41 ../../library/array.rst:43 +#: ../../library/array.rst:47 msgid "8" msgstr "8" -#: ../../library/array.rst:41 +#: ../../library/array.rst:43 msgid "``'Q'``" msgstr "``'Q'``" -#: ../../library/array.rst:41 +#: ../../library/array.rst:43 msgid "unsigned long long" msgstr "unsigned long long" -#: ../../library/array.rst:43 +#: ../../library/array.rst:45 msgid "``'f'``" msgstr "``'f'``" -#: ../../library/array.rst:43 ../../library/array.rst:45 +#: ../../library/array.rst:45 ../../library/array.rst:47 msgid "float" msgstr "float" -#: ../../library/array.rst:45 +#: ../../library/array.rst:47 msgid "``'d'``" msgstr "``'d'``" -#: ../../library/array.rst:45 +#: ../../library/array.rst:47 msgid "double" msgstr "double" -#: ../../library/array.rst:48 +#: ../../library/array.rst:50 msgid "Notes:" msgstr "註解:" -#: ../../library/array.rst:51 +#: ../../library/array.rst:53 msgid "It can be 16 bits or 32 bits depending on the platform." msgstr "根據平台的不同,它有可能是 16 位元或者 32 位元。" -#: ../../library/array.rst:53 +#: ../../library/array.rst:55 msgid "" "``array('u')`` now uses :c:type:`wchar_t` as C type instead of deprecated " "``Py_UNICODE``. This change doesn't affect its behavior because " "``Py_UNICODE`` is alias of :c:type:`wchar_t` since Python 3.3." msgstr "" "目前 ``array('u')`` 使用 :c:type:`wchar_t` 取代已棄用的 ``Py_UNICODE`` 作為 " -"C type。這個異動並沒有影響到它的作用,因爲自從 Python 3.3 開始 " +"C type。這個異動並沒有影響到它的作用,因為自從 Python 3.3 開始 " "``Py_UNICODE`` 即為 :c:type:`wchar_t` 的別名。" -#: ../../library/array.rst:61 +#: ../../library/array.rst:60 +msgid "Please migrate to ``'w'`` typecode." +msgstr "" + +#: ../../library/array.rst:64 msgid "" "The actual representation of values is determined by the machine " "architecture (strictly speaking, by the C implementation). The actual size " @@ -227,30 +239,30 @@ msgstr "" "實際上數值的表示方法是被機器的架構所決定(更精準地說,被 C 的實作方法決定)。" "實際的大小可以透過 :attr:`array.itemsize` 屬性存取。" -#: ../../library/array.rst:65 +#: ../../library/array.rst:68 msgid "The module defines the following item:" msgstr "這個模組定義了以下項目:" -#: ../../library/array.rst:70 +#: ../../library/array.rst:73 msgid "A string with all available type codes." msgstr "一個包含所有可用的 type codes 的字串。" -#: ../../library/array.rst:73 +#: ../../library/array.rst:76 msgid "The module defines the following type:" msgstr "這個模組定義了下方的型別:" -#: ../../library/array.rst:78 +#: ../../library/array.rst:81 msgid "" "A new array whose items are restricted by *typecode*, and initialized from " -"the optional *initializer* value, which must be a :class:`bytes` or :class:" -"`bytearray` object, a Unicode string, or iterable over elements of the " -"appropriate type." +"the optional *initializer* value, which must be a :class:`bytes` " +"or :class:`bytearray` object, a Unicode string, or iterable over elements of " +"the appropriate type." msgstr "" "一個新的陣列中的元素被 *typecode* 限制,並由選用的 *initializer* 參數初始化," "*initializer* 必須是一個 :class:`bytes` 或 :class:`bytearray` 物件、一個 " "Unicode 字串或包含適當型別元素的可疊代物件 (iterable)。" -#: ../../library/array.rst:83 +#: ../../library/array.rst:86 msgid "" "If given a :class:`bytes` or :class:`bytearray` object, the initializer is " "passed to the new array's :meth:`frombytes` method; if given a Unicode " @@ -263,7 +275,7 @@ msgstr "" "方法;其他情況時, 一個 initializer 的可疊代物件將被傳入 :meth:`extend` 方法" "之中來將初始項目新增至陣列。" -#: ../../library/array.rst:90 +#: ../../library/array.rst:93 msgid "" "Array objects support the ordinary sequence operations of indexing, slicing, " "concatenation, and multiplication. When using slice assignment, the " @@ -278,7 +290,7 @@ msgstr "" "了緩衝區介面,可以在任何支援 :term:`bytes-like objects ` " "的地方使用。" -#: ../../library/array.rst:96 +#: ../../library/array.rst:99 msgid "" "Raises an :ref:`auditing event ` ``array.__new__`` with arguments " "``typecode``, ``initializer``." @@ -286,19 +298,19 @@ msgstr "" "引發\\ :ref:`稽核事件 (auditing event) ` ``array.__new__`` 並附帶引" "數 ``typecode``、``initializer``。" -#: ../../library/array.rst:101 +#: ../../library/array.rst:104 msgid "The typecode character used to create the array." msgstr "typecode 字元被用在建立陣列時。" -#: ../../library/array.rst:106 +#: ../../library/array.rst:109 msgid "The length in bytes of one array item in the internal representation." msgstr "陣列當中的一個元素在內部需要的位元組長度。" -#: ../../library/array.rst:111 +#: ../../library/array.rst:114 msgid "Append a new item with value *x* to the end of the array." msgstr "新增一個元素 *x* 到陣列的最尾端。" -#: ../../library/array.rst:116 +#: ../../library/array.rst:119 msgid "" "Return a tuple ``(address, length)`` giving the current memory address and " "the length in elements of the buffer used to hold array's contents. The " @@ -309,13 +321,13 @@ msgid "" "as long as the array exists and no length-changing operations are applied to " "it." msgstr "" -"回傳一個 tuple ``(address, length)`` 表示當前的記憶體位置和陣列儲存元素的緩衝" +"回傳一個 tuple ``(address, length)`` 表示目前的記憶體位置和陣列儲存元素的緩衝" "區記憶體長度。緩衝區的長度單位是位元組,並可以用 ``array.buffer_info()[1] * " "array.itemsize`` 計算得到。這偶爾會在底層操作需要記憶體位置的輸出輸入時很有" "用,例如 :c:func:`!ioctl` 指令。只要陣列存在且沒有使用任何更改長度的操作時," "回傳的數值就有效。" -#: ../../library/array.rst:126 +#: ../../library/array.rst:129 msgid "" "When using array objects from code written in C or C++ (the only way to " "effectively make use of this information), it makes more sense to use the " @@ -327,98 +339,100 @@ msgstr "" "適當的做法是使用陣列物件支援的緩衝區介面。這個方法維護了向後兼容性,並應該在" "新的程式碼中避免。關於緩衝區介面的文件在\\ :ref:`bufferobjects`。" -#: ../../library/array.rst:135 +#: ../../library/array.rst:138 msgid "" "\"Byteswap\" all items of the array. This is only supported for values " -"which are 1, 2, 4, or 8 bytes in size; for other types of values, :exc:" -"`RuntimeError` is raised. It is useful when reading data from a file " -"written on a machine with a different byte order." +"which are 1, 2, 4, or 8 bytes in size; for other types of " +"values, :exc:`RuntimeError` is raised. It is useful when reading data from " +"a file written on a machine with a different byte order." msgstr "" "\"Byteswap\" 所有陣列中的物件。這只有支援物件長度為 1、2、4 或 8 位元組的陣" "列,其他型別的值會導致 :exc:`RuntimeError`。這在從機器讀取位元順序不同的檔案" "時很有用。" -#: ../../library/array.rst:143 +#: ../../library/array.rst:146 msgid "Return the number of occurrences of *x* in the array." msgstr "回傳 *x* 在陣列中出現了幾次。" -#: ../../library/array.rst:148 +#: ../../library/array.rst:151 msgid "" "Append items from *iterable* to the end of the array. If *iterable* is " -"another array, it must have *exactly* the same type code; if not, :exc:" -"`TypeError` will be raised. If *iterable* is not an array, it must be " -"iterable and its elements must be the right type to be appended to the array." +"another array, it must have *exactly* the same type code; if " +"not, :exc:`TypeError` will be raised. If *iterable* is not an array, it " +"must be iterable and its elements must be the right type to be appended to " +"the array." msgstr "" "從 *iterable* 中新增元素到陣列的尾端,如果 *iterable* 是另一個陣列,它必須有" "完全相同的 type code,如果不同會導致 :exc:`TypeError`。如果 *iterable* 不是一" "個陣列,它必須可以被疊代 (iterable) 且其中的元素必須是可以被加入陣列中的正確" "型別。" -#: ../../library/array.rst:156 +#: ../../library/array.rst:159 msgid "" "Appends items from the :term:`bytes-like object`, interpreting its content " -"as an array of machine values (as if it had been read from a file using the :" -"meth:`fromfile` method)." +"as an array of machine values (as if it had been read from a file using " +"the :meth:`fromfile` method)." msgstr "" "從 :term:`bytes-like object` 中新增元素。讀取時會將其內容當作一個機器數值組成" "的陣列(就像從檔案中使用 :meth:`fromfile` 方法讀出的資料)。" -#: ../../library/array.rst:160 +#: ../../library/array.rst:163 msgid ":meth:`!fromstring` is renamed to :meth:`frombytes` for clarity." msgstr "將 :meth:`!fromstring` 更名為 :meth:`frombytes`,使其更加清晰易懂。" -#: ../../library/array.rst:166 +#: ../../library/array.rst:169 msgid "" "Read *n* items (as machine values) from the :term:`file object` *f* and " -"append them to the end of the array. If less than *n* items are available, :" -"exc:`EOFError` is raised, but the items that were available are still " -"inserted into the array." +"append them to the end of the array. If less than *n* items are " +"available, :exc:`EOFError` is raised, but the items that were available are " +"still inserted into the array." msgstr "" "從 :term:`file object` *f* 讀取 *n* 個元素(作為機器數值),接著將這些元素加" "入陣列的最尾端。如果只有少於 *n* 個有效的元素會導致 :exc:`EOFError`,但有效的" "元素仍然會被加入陣列中。" -#: ../../library/array.rst:174 +#: ../../library/array.rst:177 msgid "" -"Append items from the list. This is equivalent to ``for x in list: a." -"append(x)`` except that if there is a type error, the array is unchanged." +"Append items from the list. This is equivalent to ``for x in list: " +"a.append(x)`` except that if there is a type error, the array is unchanged." msgstr "" "從 list 中新增元素。這等價於 ``for x in list: a.append(x)``,除了有型別錯誤產" "生時,陣列會保持原狀不會被更改。" -#: ../../library/array.rst:180 +#: ../../library/array.rst:183 msgid "" "Extends this array with data from the given Unicode string. The array must " -"have type code ``'u'``; otherwise a :exc:`ValueError` is raised. Use ``array." -"frombytes(unicodestring.encode(enc))`` to append Unicode data to an array of " -"some other type." +"have type code ``'u'`` or ``'w'``; otherwise a :exc:`ValueError` is raised. " +"Use ``array.frombytes(unicodestring.encode(enc))`` to append Unicode data to " +"an array of some other type." msgstr "" -"用給定的 Unicode 字串擴展這個陣列。陣列的 type code 必須是 ``u``;其他的型別" -"會導致 :exc:`ValueError` 被引發。使用 ``array.frombytes(unicodestring." -"encode(enc))`` 來新增 Unicode 資料到一個其他型別的陣列。" +"用給定的 Unicode 字串擴展這個陣列。陣列的 type code 必須是 ``u`` 或 ``'w'``;" +"其他的型別會導致 :exc:`ValueError` 被引發。使用 " +"``array.frombytes(unicodestring.encode(enc))`` 來新增 Unicode 資料到一個其他" +"型別的陣列。" -#: ../../library/array.rst:188 +#: ../../library/array.rst:191 msgid "" "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 :exc:" -"`ValueError` if *x* is not found." +"specified to search for *x* within a subsection of the array. " +"Raise :exc:`ValueError` if *x* is not found." msgstr "" "回傳 *i* 的最小數值,使得 *i* 成為陣列之中第一次出現 *x* 的索引。選擇性的引" "數 *start* 及 *stop* 則可以被用來在指定的陣列空間中搜尋 *x*。如果 *x* 不存在" "將導致 :exc:`ValueError`。" -#: ../../library/array.rst:193 +#: ../../library/array.rst:196 msgid "Added optional *start* and *stop* parameters." msgstr "新增選擇性的參數 *start* 及 *stop*。" -#: ../../library/array.rst:199 +#: ../../library/array.rst:202 msgid "" "Insert a new item with value *x* in the array before position *i*. Negative " "values are treated as being relative to the end of the array." msgstr "在位置 *i* 之前插入一個元素 *x*。負數的索引值會從陣列尾端開始數。" -#: ../../library/array.rst:205 +#: ../../library/array.rst:208 msgid "" "Removes the item with the index *i* from the array and returns it. The " "optional argument defaults to ``-1``, so that by default the last item is " @@ -427,15 +441,20 @@ msgstr "" "移除並回傳陣列索引值 *i* 的元素。選擇性的引數 *i* 預設為 ``-1``,所以預設會刪" "除並回傳最後一個元素。" -#: ../../library/array.rst:212 +#: ../../library/array.rst:215 msgid "Remove the first occurrence of *x* from the array." msgstr "從陣列中刪除第一個出現的 *x*。" -#: ../../library/array.rst:217 +#: ../../library/array.rst:220 +#, fuzzy +msgid "Remove all elements from the array." +msgstr "從陣列中刪除第一個出現的 *x*。" + +#: ../../library/array.rst:227 msgid "Reverse the order of the items in the array." msgstr "反轉陣列中元素的順序。" -#: ../../library/array.rst:222 +#: ../../library/array.rst:232 msgid "" "Convert the array to an array of machine values and return the bytes " "representation (the same sequence of bytes that would be written to a file " @@ -444,49 +463,54 @@ msgstr "" "將陣列轉為另一個機器數值組成的陣列並回傳它的位元組表示(跟用 :meth:`tofile` " "方法寫入檔案時的位元序列相同)。" -#: ../../library/array.rst:226 +#: ../../library/array.rst:236 msgid ":meth:`!tostring` is renamed to :meth:`tobytes` for clarity." msgstr "為了明確性,過去的 :meth:`!tostring` 已更名為 :meth:`tobytes`。" -#: ../../library/array.rst:232 +#: ../../library/array.rst:242 msgid "Write all items (as machine values) to the :term:`file object` *f*." msgstr "將所有元素(作為機器數值)寫入 :term:`file object` *f*。" -#: ../../library/array.rst:237 +#: ../../library/array.rst:247 msgid "Convert the array to an ordinary list with the same items." msgstr "不更改元素,將陣列轉為一般的 list。" -#: ../../library/array.rst:242 +#: ../../library/array.rst:252 +#, fuzzy msgid "" -"Convert the array to a Unicode string. The array must have a type ``'u'``; " -"otherwise a :exc:`ValueError` is raised. Use ``array.tobytes().decode(enc)`` " -"to obtain a Unicode string from an array of some other type." +"Convert the array to a Unicode string. The array must have a type ``'u'`` " +"or ``'w'``; otherwise a :exc:`ValueError` is raised. Use " +"``array.tobytes().decode(enc)`` to obtain a Unicode string from an array of " +"some other type." msgstr "" -"將陣列轉為一個 Unicode 字串。陣列的型別必須為 ``u``。其他型別的陣列會導致 :" -"exc:`ValueError` 錯誤。請使用 ``array.tobytes().decode(enc)`` 來為其他型別的" -"陣列轉為 Unicode 字串。" +"將陣列轉為一個 Unicode 字串。陣列的型別必須為 ``u``。其他型別的陣列會導" +"致 :exc:`ValueError` 錯誤。請使用 ``array.tobytes().decode(enc)`` 來為其他型" +"別的陣列轉為 Unicode 字串。" -#: ../../library/array.rst:247 +#: ../../library/array.rst:257 +#, fuzzy msgid "" "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'``, 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 :func:" -"`eval`, so long as the :class:`~array.array` 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::" +"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 :func:`eval`, so long as the :class:`~array.array` 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::" msgstr "" "陣列物件的字串表示形式為 ``array(typecode, initializer)``。若為空陣列則參數 " "*initializer* 被省略,若 *typecode* 是 ``'u'`` 將被表示為 Unicode 字串,其他" "情況則被表示為由數字組成的 list。只要 :class:`~array.array` class(類別)透" -"過 ``from array import array`` 的方式引入,便能確保該字串表示能透過 :func:" -"`eval` 轉換回一個擁有相同型別及數值的陣列。範例: ::" +"過 ``from array import array`` 的方式引入,便能確保該字串表示能透" +"過 :func:`eval` 轉換回一個擁有相同型別及數值的陣列。範例: ::" -#: ../../library/array.rst:259 +#: ../../library/array.rst:269 +#, fuzzy msgid "" "array('l')\n" -"array('u', 'hello \\u2641')\n" +"array('w', 'hello \\u2641')\n" "array('l', [1, 2, 3, 4, 5])\n" "array('d', [1.0, 2.0, 3.14, -inf, nan])" msgstr "" @@ -495,31 +519,19 @@ msgstr "" "array('l', [1, 2, 3, 4, 5])\n" "array('d', [1.0, 2.0, 3.14, -inf, nan])" -#: ../../library/array.rst:267 +#: ../../library/array.rst:277 msgid "Module :mod:`struct`" msgstr ":mod:`struct` 模組" -#: ../../library/array.rst:268 +#: ../../library/array.rst:278 msgid "Packing and unpacking of heterogeneous binary data." msgstr "將包含不同資料類型的二進位資料包裝與解開包裝。" -#: ../../library/array.rst:270 -msgid "Module :mod:`xdrlib`" -msgstr ":mod:`xdrlib` 模組" - -#: ../../library/array.rst:271 -msgid "" -"Packing and unpacking of External Data Representation (XDR) data as used in " -"some remote procedure call systems." -msgstr "" -"將 External Data Representation (XDR) 的資料包裝與解開包裝,這用在一些遠端操" -"作的系統 (remote procedure call systems)。" - -#: ../../library/array.rst:274 +#: ../../library/array.rst:280 msgid "`NumPy `_" msgstr "`NumPy `_" -#: ../../library/array.rst:275 +#: ../../library/array.rst:281 msgid "The NumPy package defines another array type." msgstr "NumPy 套件定義了另一個陣列型別" diff --git a/library/ast.po b/library/ast.po index c58533b4e9..5d46b5bc4c 100644 --- a/library/ast.po +++ b/library/ast.po @@ -4,9 +4,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-18 00:04+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 14:38+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -34,7 +34,7 @@ msgid "" msgstr "" ":mod:`ast` 模組可以幫助 Python 應用程式處理 Python 抽象語法文法 (abstract " "syntax grammar) 樹狀資料結構。抽象語法本身可能會隨著每個 Python 版本發布而改" -"變;此模組有助於以程式化的方式來得知當前文法的面貌。" +"變;此模組有助於以程式化的方式來得知目前文法的面貌。" #: ../../library/ast.rst:23 msgid "" @@ -224,9 +224,9 @@ msgid "" "\n" " type_ignore = TypeIgnore(int lineno, string tag)\n" "\n" -" type_param = TypeVar(identifier name, expr? bound)\n" -" | ParamSpec(identifier name)\n" -" | TypeVarTuple(identifier name)\n" +" type_param = TypeVar(identifier name, expr? bound, expr? default_value)\n" +" | ParamSpec(identifier name, expr? default_value)\n" +" | TypeVarTuple(identifier name, expr? default_value)\n" " attributes (int lineno, int col_offset, int end_lineno, int " "end_col_offset)\n" "}\n" @@ -265,9 +265,9 @@ msgstr "" #: ../../library/ast.rst:64 msgid "" -"Each concrete class has an attribute :attr:`_fields` which gives the names " +"Each concrete class has an attribute :attr:`!_fields` which gives the names " "of all child nodes." -msgstr "每個具體類別都有一個屬性 :attr:`_fields`,它會給出所有子節點的名稱。" +msgstr "每個具體類別都有一個屬性 :attr:`!_fields`,它會給出所有子節點的名稱。" #: ../../library/ast.rst:67 msgid "" @@ -290,8 +290,26 @@ msgstr "" "可以有零個或多個值(用星號標記),則這些值將表示為 Python 串列。使用 :func:" "`compile` 編譯 AST 時,所有可能的屬性都必須存在並且具有有效值。" +#: ../../library/ast.rst:79 +msgid "" +"The :attr:`!_field_types` attribute on each concrete class is a dictionary " +"mapping field names (as also listed in :attr:`_fields`) to their types." +msgstr "" +"每個具體類別上的 :attr:`!_field_types` 屬性是將欄位名稱(也在 :attr:" +"`_fields` 中列出)對映到其型別的字典。" + #: ../../library/ast.rst:82 msgid "" +">>> ast.TypeVar._field_types\n" +"{'name': , 'bound': ast.expr | None, 'default_value': ast.expr " +"| None}" +msgstr "" +">>> ast.TypeVar._field_types\n" +"{'name': , 'bound': ast.expr | None, 'default_value': ast.expr " +"| None}" + +#: ../../library/ast.rst:94 +msgid "" "Instances of :class:`ast.expr` and :class:`ast.stmt` subclasses have :attr:" "`lineno`, :attr:`col_offset`, :attr:`end_lineno`, and :attr:`end_col_offset` " "attributes. The :attr:`lineno` and :attr:`end_lineno` are the first and " @@ -308,7 +326,7 @@ msgstr "" "`end_col_offset` 是生成節點的第一個和最後一個標記對應的 UTF-8 位元組偏移量。" "會記錄 UTF-8 偏移量是因為剖析器 (parser) 內部使用 UTF-8。" -#: ../../library/ast.rst:91 +#: ../../library/ast.rst:103 msgid "" "Note that the end positions are not required by the compiler and are " "therefore optional. The end offset is *after* the last symbol, for example " @@ -317,14 +335,14 @@ msgid "" msgstr "" "請注意,編譯器並不需要結束位置,因此其為可選的。結束偏移量在最後一個符號\\ *" "之後*,例如可以使用 ``source_line[node.col_offset : node.end_col_offset]`` 來" -"獲取單列運算式節點 (expression node) 的原始片段。" +"取得單列運算式節點 (expression node) 的原始片段。" -#: ../../library/ast.rst:96 +#: ../../library/ast.rst:108 msgid "" "The constructor of a class :class:`ast.T` parses its arguments as follows:" msgstr ":class:`ast.T` 類別的建構函式按以下方式剖析其引數:" -#: ../../library/ast.rst:98 +#: ../../library/ast.rst:110 msgid "" "If there are positional arguments, there must be as many as there are items " "in :attr:`T._fields`; they will be assigned as attributes of these names." @@ -332,44 +350,20 @@ msgstr "" "如果有位置引數,則必須與 :attr:`T._fields` 中的項目一樣多;它們將被賦値為這些" "名稱的屬性。" -#: ../../library/ast.rst:100 +#: ../../library/ast.rst:112 msgid "" "If there are keyword arguments, they will set the attributes of the same " "names to the given values." msgstr "如果有關鍵字引數,它們會將相同名稱的屬性設定為給定值。" -#: ../../library/ast.rst:103 +#: ../../library/ast.rst:115 msgid "" "For example, to create and populate an :class:`ast.UnaryOp` node, you could " "use ::" msgstr "" "例如,要建立並填充 (populate) :class:`ast.UnaryOp` 節點,你可以使用: ::" -#: ../../library/ast.rst:106 -msgid "" -"node = ast.UnaryOp()\n" -"node.op = ast.USub()\n" -"node.operand = ast.Constant()\n" -"node.operand.value = 5\n" -"node.operand.lineno = 0\n" -"node.operand.col_offset = 0\n" -"node.lineno = 0\n" -"node.col_offset = 0" -msgstr "" -"node = ast.UnaryOp()\n" -"node.op = ast.USub()\n" -"node.operand = ast.Constant()\n" -"node.operand.value = 5\n" -"node.operand.lineno = 0\n" -"node.operand.col_offset = 0\n" -"node.lineno = 0\n" -"node.col_offset = 0" - -#: ../../library/ast.rst:115 -msgid "or the more compact ::" -msgstr "或更簡潔的: ::" - -#: ../../library/ast.rst:117 +#: ../../library/ast.rst:118 msgid "" "node = ast.UnaryOp(ast.USub(), ast.Constant(5, lineno=0, col_offset=0),\n" " lineno=0, col_offset=0)" @@ -377,17 +371,32 @@ msgstr "" "node = ast.UnaryOp(ast.USub(), ast.Constant(5, lineno=0, col_offset=0),\n" " lineno=0, col_offset=0)" -#: ../../library/ast.rst:122 +#: ../../library/ast.rst:121 +msgid "" +"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 :class:`!ast.expr_context` is omitted, it " +"defaults to :class:`Load() `. If any other field is omitted, a :" +"exc:`DeprecationWarning` is raised and the AST node will not have this " +"field. In Python 3.15, this condition will raise an error." +msgstr "" +"如果建構函式中省略了文法中可選的欄位,則它預設為 ``None``。如果省略串列欄位," +"則預設為空串列。如果省略 :class:`!ast.expr_context` 型別的欄位,則預設為 :" +"class:`Load() `。如果省略任何其他欄位,則會引發 :exc:" +"`DeprecationWarning`,且 AST 節點將沒有此欄位。在 Python 3.15 中,這種情況會" +"引發錯誤。" + +#: ../../library/ast.rst:130 msgid "Class :class:`ast.Constant` is now used for all constants." msgstr ":class:`ast.Constant` 類別現在用於所有常數。" -#: ../../library/ast.rst:126 +#: ../../library/ast.rst:134 msgid "" "Simple indices are represented by their value, extended slices are " "represented as tuples." msgstr "以它們的值表示簡單索引,擴充切片 (slice) 則以元組 (tuple) 表示。" -#: ../../library/ast.rst:131 +#: ../../library/ast.rst:139 msgid "" "Old classes :class:`!ast.Num`, :class:`!ast.Str`, :class:`!ast.Bytes`, :" "class:`!ast.NameConstant` and :class:`!ast.Ellipsis` are still available, " @@ -398,7 +407,7 @@ msgstr "" "ast.NameConstant` 和 :class:`!ast.Ellipsis` 仍然可用,但它們將在未來的 " "Python 釋出版本中移除。與此同時,實例化它們將回傳不同類別的實例。" -#: ../../library/ast.rst:138 +#: ../../library/ast.rst:146 msgid "" "Old classes :class:`!ast.Index` and :class:`!ast.ExtSlice` are still " "available, but they will be removed in future Python releases. In the " @@ -407,7 +416,19 @@ msgstr "" "舊的類別 :class:`!ast.Index` 和 :class:`!ast.ExtSlice` 仍然可用,但它們將在未" "來的 Python 版本中刪除。同時,實例化它們會回傳不同類別的實例。" -#: ../../library/ast.rst:144 +#: ../../library/ast.rst:153 +msgid "" +"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." +msgstr "" +"先前版本的 Python 允許建立缺少必填欄位的 AST 節點。同樣地,AST 節點建構函式允" +"許將任意關鍵字引數設為 AST 節點的屬性,即使它們與 AST 節點的任何欄位都不匹" +"配。此行為已被棄用,並將在 Python 3.15 中刪除。" + +#: ../../library/ast.rst:160 msgid "" "The descriptions of the specific node classes displayed here were initially " "adapted from the fantastic `Green Tree Snakes `__ 專案和所有貢獻者那裡改編而來" "的。" -#: ../../library/ast.rst:153 +#: ../../library/ast.rst:169 msgid "Root nodes" msgstr "根節點" -#: ../../library/ast.rst:157 +#: ../../library/ast.rst:173 msgid "" "A Python module, as with :ref:`file input `. Node type generated " "by :func:`ast.parse` in the default ``\"exec\"`` *mode*." @@ -429,19 +450,19 @@ msgstr "" "一個 Python 模組,與\\ :ref:`檔案輸入 ` 一樣。由 :func:`ast." "parse` 在預設的 ``\"exec\"`` *mode* 下生成的節點型別。" -#: ../../library/ast.rst:160 -msgid "*body* is a :class:`list` of the module's :ref:`ast-statements`." -msgstr "*body* 是模組的\\ :ref:`ast-statements` 的一個 :class:`list`。" +#: ../../library/ast.rst:176 +msgid "``body`` is a :class:`list` of the module's :ref:`ast-statements`." +msgstr "``body`` 是模組的\\ :ref:`ast-statements` 的一個 :class:`list`。" -#: ../../library/ast.rst:162 +#: ../../library/ast.rst:178 msgid "" -"*type_ignores* is a :class:`list` of the module's type ignore comments; see :" -"func:`ast.parse` for more details." +"``type_ignores`` is a :class:`list` of the module's type ignore comments; " +"see :func:`ast.parse` for more details." msgstr "" -"*type_ignores* 是模組的忽略型別註解的 :class:`list`;有關更多詳細資訊,請參" +"``type_ignores`` 是模組的忽略型別註解的 :class:`list`;有關更多詳細資訊,請參" "閱 :func:`ast.parse`。" -#: ../../library/ast.rst:165 +#: ../../library/ast.rst:181 msgid "" ">>> print(ast.dump(ast.parse('x = 1'), indent=4))\n" "Module(\n" @@ -449,8 +470,7 @@ msgid "" " Assign(\n" " targets=[\n" " Name(id='x', ctx=Store())],\n" -" value=Constant(value=1))],\n" -" type_ignores=[])" +" value=Constant(value=1))])" msgstr "" ">>> print(ast.dump(ast.parse('x = 1'), indent=4))\n" "Module(\n" @@ -458,10 +478,9 @@ msgstr "" " Assign(\n" " targets=[\n" " Name(id='x', ctx=Store())],\n" -" value=Constant(value=1))],\n" -" type_ignores=[])" +" value=Constant(value=1))])" -#: ../../library/ast.rst:179 +#: ../../library/ast.rst:194 msgid "" "A single Python :ref:`expression input `. Node type " "generated by :func:`ast.parse` when *mode* is ``\"eval\"``." @@ -469,14 +488,14 @@ msgstr "" "單個 Python :ref:`運算式輸入 `。當 *mode* 是 ``\"eval\"`` " "時節點型別由 :func:`ast.parse` 生成。" -#: ../../library/ast.rst:182 +#: ../../library/ast.rst:197 msgid "" -"*body* is a single node, one of the :ref:`expression types `." msgstr "" -"*body* 是單個節點,是\\ :ref:`運算式型別 `\\ 的其中之一。" +"``body`` 是單個節點,是\\ :ref:`運算式型別 `\\ 的其中之一。" -#: ../../library/ast.rst:185 ../../library/ast.rst:255 +#: ../../library/ast.rst:200 ../../library/ast.rst:270 msgid "" ">>> print(ast.dump(ast.parse('123', mode='eval'), indent=4))\n" "Expression(\n" @@ -486,7 +505,7 @@ msgstr "" "Expression(\n" " body=Constant(value=123))" -#: ../../library/ast.rst:194 +#: ../../library/ast.rst:209 msgid "" "A single :ref:`interactive input `, like in :ref:`tut-interac`. " "Node type generated by :func:`ast.parse` when *mode* is ``\"single\"``." @@ -494,13 +513,13 @@ msgstr "" "單個\\ :ref:`互動式輸入 `,和\\ :ref:`tut-interac`\\ 中所述的相" "似。當 *mode* 是 ``\"single\"`` 時節點型別由 :func:`ast.parse` 生成。" -#: ../../library/ast.rst:197 -msgid "*body* is a :class:`list` of :ref:`statement nodes `." +#: ../../library/ast.rst:212 +msgid "``body`` is a :class:`list` of :ref:`statement nodes `." msgstr "" -"*body* 是\\ :ref:`陳述式節點 (statement nodes) ` 的 :class:" +"``body`` 是\\ :ref:`陳述式節點 (statement nodes) ` 的 :class:" "`list`。" -#: ../../library/ast.rst:199 +#: ../../library/ast.rst:214 msgid "" ">>> print(ast.dump(ast.parse('x = 1; y = 2', mode='single'), indent=4))\n" "Interactive(\n" @@ -526,7 +545,7 @@ msgstr "" " Name(id='y', ctx=Store())],\n" " value=Constant(value=2))])" -#: ../../library/ast.rst:216 +#: ../../library/ast.rst:231 msgid "" "A representation of an old-style type comments for functions, as Python " "versions prior to 3.5 didn't support :pep:`484` annotations. Node type " @@ -535,11 +554,11 @@ msgstr "" "函式的舊式型別註解的表示法,因為 3.5 之前的 Python 版本不支援 :pep:`484` 註" "釋。當 *mode* 是 ``\"func_type\"`` 時節點型別由 :func:`ast.parse` 生成。" -#: ../../library/ast.rst:220 +#: ../../library/ast.rst:235 msgid "Such type comments would look like this::" msgstr "這種型別的註解看起來像這樣: ::" -#: ../../library/ast.rst:222 +#: ../../library/ast.rst:237 msgid "" "def sum_two_number(a, b):\n" " # type: (int, int) -> int\n" @@ -549,17 +568,17 @@ msgstr "" " # type: (int, int) -> int\n" " return a + b" -#: ../../library/ast.rst:226 +#: ../../library/ast.rst:241 msgid "" -"*argtypes* is a :class:`list` of :ref:`expression nodes `." +"``argtypes`` is a :class:`list` of :ref:`expression nodes `." msgstr "" -"*argtypes* 是\\ :ref:`運算式節點 `\\ 的 :class:`list`。" +"``argtypes`` 是\\ :ref:`運算式節點 `\\ 的 :class:`list`。" -#: ../../library/ast.rst:228 -msgid "*returns* is a single :ref:`expression node `." -msgstr "*returns* 是單個\\ :ref:`運算式節點 `。" +#: ../../library/ast.rst:243 +msgid "``returns`` is a single :ref:`expression node `." +msgstr "``returns`` 是單個\\ :ref:`運算式節點 `。" -#: ../../library/ast.rst:230 +#: ../../library/ast.rst:245 msgid "" ">>> print(ast.dump(ast.parse('(int, str) -> List[int]', mode='func_type'), " "indent=4))\n" @@ -583,23 +602,24 @@ msgstr "" " slice=Name(id='int', ctx=Load()),\n" " ctx=Load()))" -#: ../../library/ast.rst:246 +#: ../../library/ast.rst:261 msgid "Literals" msgstr "文本 (Literals)" -#: ../../library/ast.rst:250 +#: ../../library/ast.rst:265 msgid "" "A constant value. The ``value`` attribute of the ``Constant`` literal " "contains the Python object it represents. The values represented can be " -"simple types such as a number, string or ``None``, but also immutable " -"container types (tuples and frozensets) if all of their elements are " -"constant." +"instances of :class:`str`, :class:`bytes`, :class:`int`, :class:`float`, :" +"class:`complex`, and :class:`bool`, and the constants :data:`None` and :data:" +"`Ellipsis`." msgstr "" "一個常數值。``Constant`` 文本的 ``value`` 屬性包含它所代表的 Python 物件。表" -"示的值可以是簡單型別,例如數字、字串或 ``None``,但如果它們的所有元素都是常" -"數,也可以是不可變的 (immutable) 容器型別(元組和凍結集合 (frozensets))。" +"示的值可以是 :class:`str`、:class:`bytes`、:class:`int`、:class:`float`、:" +"class:`complex` 和 :class:`bool` 的實例,以及常數 :data:`None` 和 :" +"data:`Ellipsis`。" -#: ../../library/ast.rst:264 +#: ../../library/ast.rst:279 msgid "" "Node representing a single formatting field in an f-string. If the string " "contains a single formatting field and nothing else the node can be isolated " @@ -609,33 +629,33 @@ msgstr "" "沒有其他內容,則可以隔離 (isolate) 該節點,否則它將出現在 :class:`JoinedStr` " "中。" -#: ../../library/ast.rst:268 +#: ../../library/ast.rst:283 msgid "" "``value`` is any expression node (such as a literal, a variable, or a " "function call)." msgstr "``value`` 為任何運算式節點(例如文字、變數或函式呼叫)。" -#: ../../library/ast.rst:270 +#: ../../library/ast.rst:285 msgid "``conversion`` is an integer:" msgstr "``conversion`` 是一個整數:" -#: ../../library/ast.rst:272 +#: ../../library/ast.rst:287 msgid "-1: no formatting" msgstr "-1: 無格式化" -#: ../../library/ast.rst:273 +#: ../../library/ast.rst:288 msgid "115: ``!s`` string formatting" msgstr "115: ``!s`` 字串格式化" -#: ../../library/ast.rst:274 +#: ../../library/ast.rst:289 msgid "114: ``!r`` repr formatting" msgstr "114:``!r`` 重複格式化化" -#: ../../library/ast.rst:275 +#: ../../library/ast.rst:290 msgid "97: ``!a`` ascii formatting" msgstr "97: ``!a`` ascii 格式化" -#: ../../library/ast.rst:277 +#: ../../library/ast.rst:292 msgid "" "``format_spec`` is a :class:`JoinedStr` node representing the formatting of " "the value, or ``None`` if no format was specified. Both ``conversion`` and " @@ -644,14 +664,14 @@ msgstr "" "``format_spec`` 是一個 :class:`JoinedStr` 節點,表示值的格式,若未指定格式則" "為 ``None``。``conversion`` 和 ``format_spec`` 可以同時設定。" -#: ../../library/ast.rst:284 +#: ../../library/ast.rst:299 msgid "" "An f-string, comprising a series of :class:`FormattedValue` and :class:" "`Constant` nodes." msgstr "" "一個 f 字串,包含一系列 :class:`FormattedValue` 和 :class:`Constant` 節點。" -#: ../../library/ast.rst:287 +#: ../../library/ast.rst:302 msgid "" ">>> print(ast.dump(ast.parse('f\"sin({a}) is {sin(a):.3}\"', mode='eval'), " "indent=4))\n" @@ -667,8 +687,7 @@ msgid "" " value=Call(\n" " func=Name(id='sin', ctx=Load()),\n" " args=[\n" -" Name(id='a', ctx=Load())],\n" -" keywords=[]),\n" +" Name(id='a', ctx=Load())]),\n" " conversion=-1,\n" " format_spec=JoinedStr(\n" " values=[\n" @@ -688,14 +707,13 @@ msgstr "" " value=Call(\n" " func=Name(id='sin', ctx=Load()),\n" " args=[\n" -" Name(id='a', ctx=Load())],\n" -" keywords=[]),\n" +" Name(id='a', ctx=Load())]),\n" " conversion=-1,\n" " format_spec=JoinedStr(\n" " values=[\n" " Constant(value='.3')]))]))" -#: ../../library/ast.rst:313 +#: ../../library/ast.rst:327 msgid "" "A list or tuple. ``elts`` holds a list of nodes representing the elements. " "``ctx`` is :class:`Store` if the container is an assignment target (i.e. " @@ -704,7 +722,7 @@ msgstr "" "串列或元組。``elts`` 保存表示元素的節點串列。如果容器是賦值目標(即 ``(x," "y)=something`` ),則 ``ctx`` 是 :class:`Store`,否則是 :class:`Load`。" -#: ../../library/ast.rst:317 +#: ../../library/ast.rst:331 msgid "" ">>> print(ast.dump(ast.parse('[1, 2, 3]', mode='eval'), indent=4))\n" "Expression(\n" @@ -740,11 +758,11 @@ msgstr "" " Constant(value=3)],\n" " ctx=Load()))" -#: ../../library/ast.rst:339 +#: ../../library/ast.rst:353 msgid "A set. ``elts`` holds a list of nodes representing the set's elements." msgstr "一個集合。``elts`` 保存表示集合之元素的節點串列。" -#: ../../library/ast.rst:341 +#: ../../library/ast.rst:355 msgid "" ">>> print(ast.dump(ast.parse('{1, 2, 3}', mode='eval'), indent=4))\n" "Expression(\n" @@ -762,7 +780,7 @@ msgstr "" " Constant(value=2),\n" " Constant(value=3)]))" -#: ../../library/ast.rst:354 +#: ../../library/ast.rst:368 msgid "" "A dictionary. ``keys`` and ``values`` hold lists of nodes representing the " "keys and the values respectively, in matching order (what would be returned " @@ -772,7 +790,7 @@ msgstr "" "節點串列(為呼叫 :code:`dictionary.keys()` 和 :code:`dictionary.values()` 時" "將回傳的內容)。" -#: ../../library/ast.rst:358 +#: ../../library/ast.rst:372 msgid "" "When doing dictionary unpacking using dictionary literals the expression to " "be expanded goes in the ``values`` list, with a ``None`` at the " @@ -781,7 +799,7 @@ msgstr "" "當使用字典文本進行字典解包 (unpack) 時,要擴充的運算式位於 ``values`` 串列" "中,在 ``keys`` 中的相應位置有一個 ``None``。" -#: ../../library/ast.rst:362 +#: ../../library/ast.rst:376 msgid "" ">>> print(ast.dump(ast.parse('{\"a\":1, **d}', mode='eval'), indent=4))\n" "Expression(\n" @@ -803,17 +821,17 @@ msgstr "" " Constant(value=1),\n" " Name(id='d', ctx=Load())]))" -#: ../../library/ast.rst:376 +#: ../../library/ast.rst:390 msgid "Variables" msgstr "變數" -#: ../../library/ast.rst:380 +#: ../../library/ast.rst:394 msgid "" "A variable name. ``id`` holds the name as a string, and ``ctx`` is one of " "the following types." msgstr "一個變數名稱。``id`` 將名稱以字串形式保存,且 ``ctx`` 是以下型別之一。" -#: ../../library/ast.rst:388 +#: ../../library/ast.rst:402 msgid "" "Variable references can be used to load the value of a variable, to assign a " "new value to it, or to delete it. Variable references are given a context to " @@ -822,14 +840,13 @@ msgstr "" "變數參照可用於載入變數的值、為其分配新值或刪除它。變數參照被賦予情境 " "(context) 來區分這些情況。" -#: ../../library/ast.rst:392 +#: ../../library/ast.rst:406 msgid "" ">>> print(ast.dump(ast.parse('a'), indent=4))\n" "Module(\n" " body=[\n" " Expr(\n" -" value=Name(id='a', ctx=Load()))],\n" -" type_ignores=[])\n" +" value=Name(id='a', ctx=Load()))])\n" "\n" ">>> print(ast.dump(ast.parse('a = 1'), indent=4))\n" "Module(\n" @@ -837,23 +854,20 @@ msgid "" " Assign(\n" " targets=[\n" " Name(id='a', ctx=Store())],\n" -" value=Constant(value=1))],\n" -" type_ignores=[])\n" +" value=Constant(value=1))])\n" "\n" ">>> print(ast.dump(ast.parse('del a'), indent=4))\n" "Module(\n" " body=[\n" " Delete(\n" " targets=[\n" -" Name(id='a', ctx=Del())])],\n" -" type_ignores=[])" +" Name(id='a', ctx=Del())])])" msgstr "" ">>> print(ast.dump(ast.parse('a'), indent=4))\n" "Module(\n" " body=[\n" " Expr(\n" -" value=Name(id='a', ctx=Load()))],\n" -" type_ignores=[])\n" +" value=Name(id='a', ctx=Load()))])\n" "\n" ">>> print(ast.dump(ast.parse('a = 1'), indent=4))\n" "Module(\n" @@ -861,18 +875,16 @@ msgstr "" " Assign(\n" " targets=[\n" " Name(id='a', ctx=Store())],\n" -" value=Constant(value=1))],\n" -" type_ignores=[])\n" +" value=Constant(value=1))])\n" "\n" ">>> print(ast.dump(ast.parse('del a'), indent=4))\n" "Module(\n" " body=[\n" " Delete(\n" " targets=[\n" -" Name(id='a', ctx=Del())])],\n" -" type_ignores=[])" +" Name(id='a', ctx=Del())])])" -#: ../../library/ast.rst:421 +#: ../../library/ast.rst:432 msgid "" "A ``*var`` variable reference. ``value`` holds the variable, typically a :" "class:`Name` node. This type must be used when building a :class:`Call` node " @@ -881,7 +893,7 @@ msgstr "" "一個 ``*var`` 變數參照。``value`` 保存變數,通常是一個 :class:`Name` 節點。在" "使用 ``*args`` 建置 :class:`Call` 節點時必須使用此型別。" -#: ../../library/ast.rst:425 +#: ../../library/ast.rst:436 msgid "" ">>> print(ast.dump(ast.parse('a, *b = it'), indent=4))\n" "Module(\n" @@ -895,8 +907,7 @@ msgid "" " value=Name(id='b', ctx=Store()),\n" " ctx=Store())],\n" " ctx=Store())],\n" -" value=Name(id='it', ctx=Load()))],\n" -" type_ignores=[])" +" value=Name(id='it', ctx=Load()))])" msgstr "" ">>> print(ast.dump(ast.parse('a, *b = it'), indent=4))\n" "Module(\n" @@ -910,14 +921,13 @@ msgstr "" " value=Name(id='b', ctx=Store()),\n" " ctx=Store())],\n" " ctx=Store())],\n" -" value=Name(id='it', ctx=Load()))],\n" -" type_ignores=[])" +" value=Name(id='it', ctx=Load()))])" -#: ../../library/ast.rst:446 +#: ../../library/ast.rst:456 msgid "Expressions" msgstr "運算式" -#: ../../library/ast.rst:450 +#: ../../library/ast.rst:460 msgid "" "When an expression, such as a function call, appears as a statement by " "itself with its return value not used or stored, it is wrapped in this " @@ -930,7 +940,7 @@ msgstr "" "`Constant`、:class:`Name`、:class:`Lambda`、:class:`Yield` 或 :class:" "`YieldFrom`" -#: ../../library/ast.rst:455 +#: ../../library/ast.rst:465 msgid "" ">>> print(ast.dump(ast.parse('-a'), indent=4))\n" "Module(\n" @@ -938,8 +948,7 @@ msgid "" " Expr(\n" " value=UnaryOp(\n" " op=USub(),\n" -" operand=Name(id='a', ctx=Load())))],\n" -" type_ignores=[])" +" operand=Name(id='a', ctx=Load())))])" msgstr "" ">>> print(ast.dump(ast.parse('-a'), indent=4))\n" "Module(\n" @@ -947,17 +956,16 @@ msgstr "" " Expr(\n" " value=UnaryOp(\n" " op=USub(),\n" -" operand=Name(id='a', ctx=Load())))],\n" -" type_ignores=[])" +" operand=Name(id='a', ctx=Load())))])" -#: ../../library/ast.rst:469 +#: ../../library/ast.rst:478 msgid "" "A unary operation. ``op`` is the operator, and ``operand`` any expression " "node." msgstr "" "一元運算 (unary operation)。``op`` 是運算子,``operand`` 是任何運算式節點。" -#: ../../library/ast.rst:478 +#: ../../library/ast.rst:487 msgid "" "Unary operator tokens. :class:`Not` is the ``not`` keyword, :class:`Invert` " "is the ``~`` operator." @@ -965,7 +973,7 @@ msgstr "" "一元運算子標記。 :class:`Not` 是 ``not`` 關鍵字、:class:`Invert` 是 ``~`` 運" "算子。" -#: ../../library/ast.rst:481 +#: ../../library/ast.rst:490 msgid "" ">>> print(ast.dump(ast.parse('not x', mode='eval'), indent=4))\n" "Expression(\n" @@ -979,7 +987,7 @@ msgstr "" " op=Not(),\n" " operand=Name(id='x', ctx=Load())))" -#: ../../library/ast.rst:492 +#: ../../library/ast.rst:501 msgid "" "A binary operation (like addition or division). ``op`` is the operator, and " "``left`` and ``right`` are any expression nodes." @@ -987,7 +995,7 @@ msgstr "" "二元運算 (binary operation)(如加法或除法)。 ``op`` 是運算子、``left`` 和 " "``right`` 是任意運算式節點。" -#: ../../library/ast.rst:495 +#: ../../library/ast.rst:504 msgid "" ">>> print(ast.dump(ast.parse('x + y', mode='eval'), indent=4))\n" "Expression(\n" @@ -1003,11 +1011,11 @@ msgstr "" " op=Add(),\n" " right=Name(id='y', ctx=Load())))" -#: ../../library/ast.rst:519 +#: ../../library/ast.rst:528 msgid "Binary operator tokens." msgstr "二元運算子 token。" -#: ../../library/ast.rst:524 +#: ../../library/ast.rst:533 msgid "" "A boolean operation, 'or' or 'and'. ``op`` is :class:`Or` or :class:`And`. " "``values`` are the values involved. Consecutive operations with the same " @@ -1018,11 +1026,11 @@ msgstr "" "有所涉及的值。使用同一運算子的連續操作(例如 ``a or b or c``\\ )會被折疊為具" "有多個值的一個節點。" -#: ../../library/ast.rst:529 +#: ../../library/ast.rst:538 msgid "This doesn't include ``not``, which is a :class:`UnaryOp`." msgstr "這不包括 ``not``,它是一個 :class:`UnaryOp`。" -#: ../../library/ast.rst:531 +#: ../../library/ast.rst:540 msgid "" ">>> print(ast.dump(ast.parse('x or y', mode='eval'), indent=4))\n" "Expression(\n" @@ -1040,11 +1048,11 @@ msgstr "" " Name(id='x', ctx=Load()),\n" " Name(id='y', ctx=Load())]))" -#: ../../library/ast.rst:545 +#: ../../library/ast.rst:554 msgid "Boolean operator tokens." msgstr "布林運算子 token。" -#: ../../library/ast.rst:550 +#: ../../library/ast.rst:559 msgid "" "A comparison of two or more values. ``left`` is the first value in the " "comparison, ``ops`` the list of operators, and ``comparators`` the list of " @@ -1053,7 +1061,7 @@ msgstr "" "兩個或多個值的比較。``left`` 是比較中的第一個值、``ops`` 是運算子串列、" "``comparators`` 是要比較的第一個元素之後值的串列。" -#: ../../library/ast.rst:554 +#: ../../library/ast.rst:563 msgid "" ">>> print(ast.dump(ast.parse('1 <= a < 10', mode='eval'), indent=4))\n" "Expression(\n" @@ -1077,11 +1085,11 @@ msgstr "" " Name(id='a', ctx=Load()),\n" " Constant(value=10)]))" -#: ../../library/ast.rst:579 +#: ../../library/ast.rst:588 msgid "Comparison operator tokens." msgstr "比較運算子 token。" -#: ../../library/ast.rst:584 +#: ../../library/ast.rst:593 msgid "" "A function call. ``func`` is the function, which will often be a :class:" "`Name` or :class:`Attribute` object. Of the arguments:" @@ -1089,25 +1097,24 @@ msgstr "" "一個函式呼叫。``func`` 是該函式,通常是一個 :class:`Name` 或 :class:" "`Attribute` 物件。而在引數中:" -#: ../../library/ast.rst:587 +#: ../../library/ast.rst:596 msgid "``args`` holds a list of the arguments passed by position." msgstr "``args`` 保存按位置傳遞的引數串列。" -#: ../../library/ast.rst:588 +#: ../../library/ast.rst:597 msgid "" "``keywords`` holds a list of :class:`.keyword` objects representing " "arguments passed by keyword." msgstr "" "``keywords`` 保存一個 :class:`.keyword` 物件串列,表示透過關鍵字傳遞的引數。" -#: ../../library/ast.rst:591 +#: ../../library/ast.rst:600 msgid "" -"When creating a ``Call`` node, ``args`` and ``keywords`` are required, but " -"they can be empty lists." -msgstr "" -"建立 ``Call`` 節點時會需要 ``args`` 和 ``keywords``,但它們可以是空串列。" +"The ``args`` and ``keywords`` arguments are optional and default to empty " +"lists." +msgstr "``args`` 和 ``keywords`` 引數是可選的,預設為空串列。" -#: ../../library/ast.rst:594 +#: ../../library/ast.rst:602 msgid "" ">>> print(ast.dump(ast.parse('func(a, b=c, *d, **e)', mode='eval'), " "indent=4))\n" @@ -1143,7 +1150,7 @@ msgstr "" " keyword(\n" " value=Name(id='e', ctx=Load()))]))" -#: ../../library/ast.rst:615 +#: ../../library/ast.rst:623 msgid "" "A keyword argument to a function call or class definition. ``arg`` is a raw " "string of the parameter name, ``value`` is a node to pass in." @@ -1151,7 +1158,7 @@ msgstr "" "函式呼叫或類別定義的關鍵字引數。``arg`` 是參數名稱的原始字串,``value`` 是要" "傳入的節點。" -#: ../../library/ast.rst:621 +#: ../../library/ast.rst:629 msgid "" "An expression such as ``a if b else c``. Each field holds a single node, so " "in the following example, all three are :class:`Name` nodes." @@ -1159,7 +1166,7 @@ msgstr "" "像是 ``a if b else c`` 之類的運算式。每個欄位都保存一個節點,因此在以下範例" "中,所有三個都是 :class:`Name` 節點。" -#: ../../library/ast.rst:624 +#: ../../library/ast.rst:632 msgid "" ">>> print(ast.dump(ast.parse('a if b else c', mode='eval'), indent=4))\n" "Expression(\n" @@ -1175,7 +1182,7 @@ msgstr "" " body=Name(id='a', ctx=Load()),\n" " orelse=Name(id='c', ctx=Load())))" -#: ../../library/ast.rst:636 +#: ../../library/ast.rst:644 msgid "" "Attribute access, e.g. ``d.keys``. ``value`` is a node, typically a :class:" "`Name`. ``attr`` is a bare string giving the name of the attribute, and " @@ -1186,7 +1193,7 @@ msgstr "" "``attr`` 是一個屬性名稱的字串,``ctx`` 根據屬性的作用方式可能是 :class:" "`Load`、:class:`Store` 或 :class:`Del`。" -#: ../../library/ast.rst:641 +#: ../../library/ast.rst:649 msgid "" ">>> print(ast.dump(ast.parse('snake.colour', mode='eval'), indent=4))\n" "Expression(\n" @@ -1202,7 +1209,7 @@ msgstr "" " attr='colour',\n" " ctx=Load()))" -#: ../../library/ast.rst:653 +#: ../../library/ast.rst:661 msgid "" "A named expression. This AST node is produced by the assignment expressions " "operator (also known as the walrus operator). As opposed to the :class:" @@ -1213,7 +1220,7 @@ msgstr "" "運算子)產生。相對於 :class:`Assign` 節點之第一個引數可為多個節點,在這種情況" "下 ``target`` 和 ``value`` 都必須是單個節點。" -#: ../../library/ast.rst:658 +#: ../../library/ast.rst:666 msgid "" ">>> print(ast.dump(ast.parse('(x := 4)', mode='eval'), indent=4))\n" "Expression(\n" @@ -1227,11 +1234,11 @@ msgstr "" " target=Name(id='x', ctx=Store()),\n" " value=Constant(value=4)))" -#: ../../library/ast.rst:669 +#: ../../library/ast.rst:677 msgid "Subscripting" msgstr "下標 (Subscripting)" -#: ../../library/ast.rst:673 +#: ../../library/ast.rst:681 msgid "" "A subscript, such as ``l[1]``. ``value`` is the subscripted object (usually " "sequence or mapping). ``slice`` is an index, slice or key. It can be a :" @@ -1243,7 +1250,7 @@ msgstr "" "下標執行的操作不同,``ctx`` 可以是 :class:`Load`、:class:`Store` 或 :class:" "`Del`。" -#: ../../library/ast.rst:679 +#: ../../library/ast.rst:687 msgid "" ">>> print(ast.dump(ast.parse('l[1:2, 3]', mode='eval'), indent=4))\n" "Expression(\n" @@ -1271,7 +1278,7 @@ msgstr "" " ctx=Load()),\n" " ctx=Load()))" -#: ../../library/ast.rst:697 +#: ../../library/ast.rst:705 msgid "" "Regular slicing (on the form ``lower:upper`` or ``lower:upper:step``). Can " "occur only inside the *slice* field of :class:`Subscript`, either directly " @@ -1280,7 +1287,7 @@ msgstr "" "常規切片(形式為 ``lower:upper`` 或 ``lower:upper:step``\\ )。只能直接或者或" "者作為 :class:`Tuple` 的元素出現在 :class:`Subscript` 的 *slice* 欄位內。" -#: ../../library/ast.rst:701 +#: ../../library/ast.rst:709 msgid "" ">>> print(ast.dump(ast.parse('l[1:2]', mode='eval'), indent=4))\n" "Expression(\n" @@ -1300,11 +1307,11 @@ msgstr "" " upper=Constant(value=2)),\n" " ctx=Load()))" -#: ../../library/ast.rst:714 +#: ../../library/ast.rst:722 msgid "Comprehensions" msgstr "綜合運算式 (comprehensions)" -#: ../../library/ast.rst:721 +#: ../../library/ast.rst:729 msgid "" "List and set comprehensions, generator expressions, and dictionary " "comprehensions. ``elt`` (or ``key`` and ``value``) is a single node " @@ -1313,14 +1320,16 @@ msgstr "" "串列和集合綜合運算、生成器運算式和字典綜合運算。``elt``\\ (或 ``key`` 和 " "``value``\\ )是單個節點,表示各個項目會被求值 (evaluate) 的部分。" -#: ../../library/ast.rst:725 +#: ../../library/ast.rst:733 msgid "``generators`` is a list of :class:`comprehension` nodes." msgstr "``generators`` 是一個 :class:`comprehension` 節點的串列。" -#: ../../library/ast.rst:727 +#: ../../library/ast.rst:735 msgid "" -">>> print(ast.dump(ast.parse('[x for x in numbers]', mode='eval'), " -"indent=4))\n" +">>> print(ast.dump(\n" +"... ast.parse('[x for x in numbers]', mode='eval'),\n" +"... indent=4,\n" +"... ))\n" "Expression(\n" " body=ListComp(\n" " elt=Name(id='x', ctx=Load()),\n" @@ -1328,10 +1337,11 @@ msgid "" " comprehension(\n" " target=Name(id='x', ctx=Store()),\n" " iter=Name(id='numbers', ctx=Load()),\n" -" ifs=[],\n" " is_async=0)]))\n" -">>> print(ast.dump(ast.parse('{x: x**2 for x in numbers}', mode='eval'), " -"indent=4))\n" +">>> print(ast.dump(\n" +"... ast.parse('{x: x**2 for x in numbers}', mode='eval'),\n" +"... indent=4,\n" +"... ))\n" "Expression(\n" " body=DictComp(\n" " key=Name(id='x', ctx=Load()),\n" @@ -1343,10 +1353,11 @@ msgid "" " comprehension(\n" " target=Name(id='x', ctx=Store()),\n" " iter=Name(id='numbers', ctx=Load()),\n" -" ifs=[],\n" " is_async=0)]))\n" -">>> print(ast.dump(ast.parse('{x for x in numbers}', mode='eval'), " -"indent=4))\n" +">>> print(ast.dump(\n" +"... ast.parse('{x for x in numbers}', mode='eval'),\n" +"... indent=4,\n" +"... ))\n" "Expression(\n" " body=SetComp(\n" " elt=Name(id='x', ctx=Load()),\n" @@ -1354,11 +1365,12 @@ msgid "" " comprehension(\n" " target=Name(id='x', ctx=Store()),\n" " iter=Name(id='numbers', ctx=Load()),\n" -" ifs=[],\n" " is_async=0)]))" msgstr "" -">>> print(ast.dump(ast.parse('[x for x in numbers]', mode='eval'), " -"indent=4))\n" +">>> print(ast.dump(\n" +"... ast.parse('[x for x in numbers]', mode='eval'),\n" +"... indent=4,\n" +"... ))\n" "Expression(\n" " body=ListComp(\n" " elt=Name(id='x', ctx=Load()),\n" @@ -1366,10 +1378,11 @@ msgstr "" " comprehension(\n" " target=Name(id='x', ctx=Store()),\n" " iter=Name(id='numbers', ctx=Load()),\n" -" ifs=[],\n" " is_async=0)]))\n" -">>> print(ast.dump(ast.parse('{x: x**2 for x in numbers}', mode='eval'), " -"indent=4))\n" +">>> print(ast.dump(\n" +"... ast.parse('{x: x**2 for x in numbers}', mode='eval'),\n" +"... indent=4,\n" +"... ))\n" "Expression(\n" " body=DictComp(\n" " key=Name(id='x', ctx=Load()),\n" @@ -1381,10 +1394,11 @@ msgstr "" " comprehension(\n" " target=Name(id='x', ctx=Store()),\n" " iter=Name(id='numbers', ctx=Load()),\n" -" ifs=[],\n" " is_async=0)]))\n" -">>> print(ast.dump(ast.parse('{x for x in numbers}', mode='eval'), " -"indent=4))\n" +">>> print(ast.dump(\n" +"... ast.parse('{x for x in numbers}', mode='eval'),\n" +"... indent=4,\n" +"... ))\n" "Expression(\n" " body=SetComp(\n" " elt=Name(id='x', ctx=Load()),\n" @@ -1392,10 +1406,9 @@ msgstr "" " comprehension(\n" " target=Name(id='x', ctx=Store()),\n" " iter=Name(id='numbers', ctx=Load()),\n" -" ifs=[],\n" " is_async=0)]))" -#: ../../library/ast.rst:767 +#: ../../library/ast.rst:781 msgid "" "One ``for`` clause in a comprehension. ``target`` is the reference to use " "for each element - typically a :class:`Name` or :class:`Tuple` node. " @@ -1406,7 +1419,7 @@ msgstr "" "class:`Name` 或 :class:`Tuple` 節點。``iter`` 是要疊代的物件。``ifs`` 是測試" "運算式的串列:每個 ``for`` 子句可以有多個 ``ifs``。" -#: ../../library/ast.rst:772 +#: ../../library/ast.rst:786 msgid "" "``is_async`` indicates a comprehension is asynchronous (using an ``async " "for`` instead of ``for``). The value is an integer (0 or 1)." @@ -1414,7 +1427,7 @@ msgstr "" "``is_async`` 表示綜合運算式是非同步的(使用 ``async for`` 而不是 ``for`` )。" "該值為整數(0 或 1)。" -#: ../../library/ast.rst:775 +#: ../../library/ast.rst:789 msgid "" ">>> print(ast.dump(ast.parse('[ord(c) for line in file for c in line]', " "mode='eval'),\n" @@ -1424,18 +1437,15 @@ msgid "" " elt=Call(\n" " func=Name(id='ord', ctx=Load()),\n" " args=[\n" -" Name(id='c', ctx=Load())],\n" -" keywords=[]),\n" +" Name(id='c', ctx=Load())]),\n" " generators=[\n" " comprehension(\n" " target=Name(id='line', ctx=Store()),\n" " iter=Name(id='file', ctx=Load()),\n" -" ifs=[],\n" " is_async=0),\n" " comprehension(\n" " target=Name(id='c', ctx=Store()),\n" " iter=Name(id='line', ctx=Load()),\n" -" ifs=[],\n" " is_async=0)]))\n" "\n" ">>> print(ast.dump(ast.parse('(n**2 for n in it if n>5 if n<10)', " @@ -1475,21 +1485,77 @@ msgid "" " comprehension(\n" " target=Name(id='i', ctx=Store()),\n" " iter=Name(id='soc', ctx=Load()),\n" -" ifs=[],\n" " is_async=1)]))" msgstr "" +">>> print(ast.dump(ast.parse('[ord(c) for line in file for c in line]', " +"mode='eval'),\n" +"... indent=4)) # Multiple comprehensions in one.\n" +"Expression(\n" +" body=ListComp(\n" +" elt=Call(\n" +" func=Name(id='ord', ctx=Load()),\n" +" args=[\n" +" Name(id='c', ctx=Load())]),\n" +" generators=[\n" +" comprehension(\n" +" target=Name(id='line', ctx=Store()),\n" +" iter=Name(id='file', ctx=Load()),\n" +" is_async=0),\n" +" comprehension(\n" +" target=Name(id='c', ctx=Store()),\n" +" iter=Name(id='line', ctx=Load()),\n" +" is_async=0)]))\n" +"\n" +">>> print(ast.dump(ast.parse('(n**2 for n in it if n>5 if n<10)', " +"mode='eval'),\n" +"... indent=4)) # generator comprehension\n" +"Expression(\n" +" body=GeneratorExp(\n" +" elt=BinOp(\n" +" left=Name(id='n', ctx=Load()),\n" +" op=Pow(),\n" +" right=Constant(value=2)),\n" +" generators=[\n" +" comprehension(\n" +" target=Name(id='n', ctx=Store()),\n" +" iter=Name(id='it', ctx=Load()),\n" +" ifs=[\n" +" Compare(\n" +" left=Name(id='n', ctx=Load()),\n" +" ops=[\n" +" Gt()],\n" +" comparators=[\n" +" Constant(value=5)]),\n" +" Compare(\n" +" left=Name(id='n', ctx=Load()),\n" +" ops=[\n" +" Lt()],\n" +" comparators=[\n" +" Constant(value=10)])],\n" +" is_async=0)]))\n" +"\n" +">>> print(ast.dump(ast.parse('[i async for i in soc]', mode='eval'),\n" +"... indent=4)) # Async comprehension\n" +"Expression(\n" +" body=ListComp(\n" +" elt=Name(id='i', ctx=Load()),\n" +" generators=[\n" +" comprehension(\n" +" target=Name(id='i', ctx=Store()),\n" +" iter=Name(id='soc', ctx=Load()),\n" +" is_async=1)]))" -#: ../../library/ast.rst:841 +#: ../../library/ast.rst:851 msgid "Statements" msgstr "陳述式" -#: ../../library/ast.rst:845 +#: ../../library/ast.rst:855 msgid "" "An assignment. ``targets`` is a list of nodes, and ``value`` is a single " "node." msgstr "一個賦值。``targets`` 是節點串列,``value`` 是單個節點。" -#: ../../library/ast.rst:847 +#: ../../library/ast.rst:857 msgid "" "Multiple nodes in ``targets`` represents assigning the same value to each. " "Unpacking is represented by putting a :class:`Tuple` or :class:`List` within " @@ -1498,13 +1564,13 @@ msgstr "" "``targets`` 中的多個節點表示為每個節點分配相同的值。解包是透過在 ``targets`` " "中放置一個 :class:`Tuple` 或 :class:`List` 來表示的。" -#: ../../library/ast.rst:853 ../../library/ast.rst:1165 -#: ../../library/ast.rst:1370 ../../library/ast.rst:1895 +#: ../../library/ast.rst:863 ../../library/ast.rst:1158 +#: ../../library/ast.rst:1352 ../../library/ast.rst:1918 msgid "" "``type_comment`` is an optional string with the type annotation as a comment." msgstr "``type_comment`` 是一個可選字串,其中的註解為型別註釋。" -#: ../../library/ast.rst:855 +#: ../../library/ast.rst:865 msgid "" ">>> print(ast.dump(ast.parse('a = b = 1'), indent=4)) # Multiple assignment\n" "Module(\n" @@ -1513,8 +1579,7 @@ msgid "" " targets=[\n" " Name(id='a', ctx=Store()),\n" " Name(id='b', ctx=Store())],\n" -" value=Constant(value=1))],\n" -" type_ignores=[])\n" +" value=Constant(value=1))])\n" "\n" ">>> print(ast.dump(ast.parse('a,b = c'), indent=4)) # Unpacking\n" "Module(\n" @@ -1526,11 +1591,30 @@ msgid "" " Name(id='a', ctx=Store()),\n" " Name(id='b', ctx=Store())],\n" " ctx=Store())],\n" -" value=Name(id='c', ctx=Load()))],\n" -" type_ignores=[])" +" value=Name(id='c', ctx=Load()))])" msgstr "" +">>> print(ast.dump(ast.parse('a = b = 1'), indent=4)) # Multiple assignment\n" +"Module(\n" +" body=[\n" +" Assign(\n" +" targets=[\n" +" Name(id='a', ctx=Store()),\n" +" Name(id='b', ctx=Store())],\n" +" value=Constant(value=1))])\n" +"\n" +">>> print(ast.dump(ast.parse('a,b = c'), indent=4)) # Unpacking\n" +"Module(\n" +" body=[\n" +" Assign(\n" +" targets=[\n" +" Tuple(\n" +" elts=[\n" +" Name(id='a', ctx=Store()),\n" +" Name(id='b', ctx=Store())],\n" +" ctx=Store())],\n" +" value=Name(id='c', ctx=Load()))])" -#: ../../library/ast.rst:883 +#: ../../library/ast.rst:891 msgid "" "An assignment with a type annotation. ``target`` is a single node and can be " "a :class:`Name`, an :class:`Attribute` or a :class:`Subscript`. " @@ -1541,20 +1625,20 @@ msgstr "" "`Attribute` 或 :class:`Subscript`。``annotation`` 是註釋,例如 :class:" "`Constant` 或 :class:`Name` 節點。``value`` 是單個可選節點。" -#: ../../library/ast.rst:888 +#: ../../library/ast.rst:896 msgid "" "``simple`` is always either 0 (indicating a \"complex\" target) or 1 " "(indicating a \"simple\" target). A \"simple\" target consists solely of a :" "class:`Name` node that does not appear between parentheses; all other " "targets are considered complex. Only simple targets appear in the :attr:" -"`__annotations__` dictionary of modules and classes." +"`~object.__annotations__` dictionary of modules and classes." msgstr "" "``simple`` 總會是 0(表示一個「複雜」目標)或 1(表示一個「簡單」目標)。一個" "「簡單」目標僅包含一個 :class:`Name` 節點,且不出現在括號之間;所有其他目標都" -"被視為是複雜的。只有簡單目標會出現在模組和類別的 :attr:`__annotations__` 字典" -"中。" +"被視為是複雜的。只有簡單目標會出現在模組和類別的 :attr:`~object." +"__annotations__` 字典中。" -#: ../../library/ast.rst:894 +#: ../../library/ast.rst:902 msgid "" ">>> print(ast.dump(ast.parse('c: int'), indent=4))\n" "Module(\n" @@ -1562,8 +1646,7 @@ msgid "" " AnnAssign(\n" " target=Name(id='c', ctx=Store()),\n" " annotation=Name(id='int', ctx=Load()),\n" -" simple=1)],\n" -" type_ignores=[])\n" +" simple=1)])\n" "\n" ">>> print(ast.dump(ast.parse('(a): int = 1'), indent=4)) # Annotation with " "parenthesis\n" @@ -1573,8 +1656,7 @@ msgid "" " target=Name(id='a', ctx=Store()),\n" " annotation=Name(id='int', ctx=Load()),\n" " value=Constant(value=1),\n" -" simple=0)],\n" -" type_ignores=[])\n" +" simple=0)])\n" "\n" ">>> print(ast.dump(ast.parse('a.b: int'), indent=4)) # Attribute annotation\n" "Module(\n" @@ -1585,8 +1667,7 @@ msgid "" " attr='b',\n" " ctx=Store()),\n" " annotation=Name(id='int', ctx=Load()),\n" -" simple=0)],\n" -" type_ignores=[])\n" +" simple=0)])\n" "\n" ">>> print(ast.dump(ast.parse('a[1]: int'), indent=4)) # Subscript " "annotation\n" @@ -1598,11 +1679,50 @@ msgid "" " slice=Constant(value=1),\n" " ctx=Store()),\n" " annotation=Name(id='int', ctx=Load()),\n" -" simple=0)],\n" -" type_ignores=[])" +" simple=0)])" msgstr "" +">>> print(ast.dump(ast.parse('c: int'), indent=4))\n" +"Module(\n" +" body=[\n" +" AnnAssign(\n" +" target=Name(id='c', ctx=Store()),\n" +" annotation=Name(id='int', ctx=Load()),\n" +" simple=1)])\n" +"\n" +">>> print(ast.dump(ast.parse('(a): int = 1'), indent=4)) # Annotation with " +"parenthesis\n" +"Module(\n" +" body=[\n" +" AnnAssign(\n" +" target=Name(id='a', ctx=Store()),\n" +" annotation=Name(id='int', ctx=Load()),\n" +" value=Constant(value=1),\n" +" simple=0)])\n" +"\n" +">>> print(ast.dump(ast.parse('a.b: int'), indent=4)) # Attribute annotation\n" +"Module(\n" +" body=[\n" +" AnnAssign(\n" +" target=Attribute(\n" +" value=Name(id='a', ctx=Load()),\n" +" attr='b',\n" +" ctx=Store()),\n" +" annotation=Name(id='int', ctx=Load()),\n" +" simple=0)])\n" +"\n" +">>> print(ast.dump(ast.parse('a[1]: int'), indent=4)) # Subscript " +"annotation\n" +"Module(\n" +" body=[\n" +" AnnAssign(\n" +" target=Subscript(\n" +" value=Name(id='a', ctx=Load()),\n" +" slice=Constant(value=1),\n" +" ctx=Store()),\n" +" annotation=Name(id='int', ctx=Load()),\n" +" simple=0)])" -#: ../../library/ast.rst:942 +#: ../../library/ast.rst:946 msgid "" "Augmented assignment, such as ``a += 1``. In the following example, " "``target`` is a :class:`Name` node for ``x`` (with the :class:`Store` " @@ -1613,7 +1733,7 @@ msgstr "" "是 ``x`` 的 :class:`Name` 節點(帶有 :class:`Store` 情境),``op`` 是 :class:" "`Add`,``value`` 是一個值為 1 的 :class:`Constant`。" -#: ../../library/ast.rst:947 +#: ../../library/ast.rst:951 msgid "" "The ``target`` attribute cannot be of class :class:`Tuple` or :class:`List`, " "unlike the targets of :class:`Assign`." @@ -1621,7 +1741,7 @@ msgstr "" "與 :class:`Assign` 的目標不同,``target`` 屬性不能屬於 :class:`Tuple` 或 :" "class:`List` 類別。" -#: ../../library/ast.rst:950 +#: ../../library/ast.rst:954 msgid "" ">>> print(ast.dump(ast.parse('x += 2'), indent=4))\n" "Module(\n" @@ -1629,8 +1749,7 @@ msgid "" " AugAssign(\n" " target=Name(id='x', ctx=Store()),\n" " op=Add(),\n" -" value=Constant(value=2))],\n" -" type_ignores=[])" +" value=Constant(value=2))])" msgstr "" ">>> print(ast.dump(ast.parse('x += 2'), indent=4))\n" "Module(\n" @@ -1638,10 +1757,9 @@ msgstr "" " AugAssign(\n" " target=Name(id='x', ctx=Store()),\n" " op=Add(),\n" -" value=Constant(value=2))],\n" -" type_ignores=[])" +" value=Constant(value=2))])" -#: ../../library/ast.rst:964 +#: ../../library/ast.rst:967 msgid "" "A ``raise`` statement. ``exc`` is the exception object to be raised, " "normally a :class:`Call` or :class:`Name`, or ``None`` for a standalone " @@ -1651,25 +1769,23 @@ msgstr "" "class:`Name`,若是獨立的 ``raise`` 則為 ``None``。``cause`` 是 ``raise x " "from y`` 中的可選部分 ``y``。" -#: ../../library/ast.rst:968 +#: ../../library/ast.rst:971 msgid "" ">>> print(ast.dump(ast.parse('raise x from y'), indent=4))\n" "Module(\n" " body=[\n" " Raise(\n" " exc=Name(id='x', ctx=Load()),\n" -" cause=Name(id='y', ctx=Load()))],\n" -" type_ignores=[])" +" cause=Name(id='y', ctx=Load()))])" msgstr "" ">>> print(ast.dump(ast.parse('raise x from y'), indent=4))\n" "Module(\n" " body=[\n" " Raise(\n" " exc=Name(id='x', ctx=Load()),\n" -" cause=Name(id='y', ctx=Load()))],\n" -" type_ignores=[])" +" cause=Name(id='y', ctx=Load()))])" -#: ../../library/ast.rst:981 +#: ../../library/ast.rst:983 msgid "" "An assertion. ``test`` holds the condition, such as a :class:`Compare` node. " "``msg`` holds the failure message." @@ -1677,25 +1793,23 @@ msgstr "" "一個斷言 (assertion)。``test`` 保存條件,例如 :class:`Compare` 節點。``msg`` " "保存失敗訊息。" -#: ../../library/ast.rst:984 +#: ../../library/ast.rst:986 msgid "" ">>> print(ast.dump(ast.parse('assert x,y'), indent=4))\n" "Module(\n" " body=[\n" " Assert(\n" " test=Name(id='x', ctx=Load()),\n" -" msg=Name(id='y', ctx=Load()))],\n" -" type_ignores=[])" +" msg=Name(id='y', ctx=Load()))])" msgstr "" ">>> print(ast.dump(ast.parse('assert x,y'), indent=4))\n" "Module(\n" " body=[\n" " Assert(\n" " test=Name(id='x', ctx=Load()),\n" -" msg=Name(id='y', ctx=Load()))],\n" -" type_ignores=[])" +" msg=Name(id='y', ctx=Load()))])" -#: ../../library/ast.rst:997 +#: ../../library/ast.rst:998 msgid "" "Represents a ``del`` statement. ``targets`` is a list of nodes, such as :" "class:`Name`, :class:`Attribute` or :class:`Subscript` nodes." @@ -1703,7 +1817,7 @@ msgstr "" "代表一個 ``del`` 陳述式。``targets`` 是節點串列,例如 :class:`Name`、:class:" "`Attribute` 或 :class:`Subscript` 節點。" -#: ../../library/ast.rst:1000 +#: ../../library/ast.rst:1001 msgid "" ">>> print(ast.dump(ast.parse('del x,y,z'), indent=4))\n" "Module(\n" @@ -1712,8 +1826,7 @@ msgid "" " targets=[\n" " Name(id='x', ctx=Del()),\n" " Name(id='y', ctx=Del()),\n" -" Name(id='z', ctx=Del())])],\n" -" type_ignores=[])" +" Name(id='z', ctx=Del())])])" msgstr "" ">>> print(ast.dump(ast.parse('del x,y,z'), indent=4))\n" "Module(\n" @@ -1722,8 +1835,7 @@ msgstr "" " targets=[\n" " Name(id='x', ctx=Del()),\n" " Name(id='y', ctx=Del()),\n" -" Name(id='z', ctx=Del())])],\n" -" type_ignores=[])" +" Name(id='z', ctx=Del())])])" #: ../../library/ast.rst:1015 msgid "A ``pass`` statement." @@ -1734,16 +1846,14 @@ msgid "" ">>> print(ast.dump(ast.parse('pass'), indent=4))\n" "Module(\n" " body=[\n" -" Pass()],\n" -" type_ignores=[])" +" Pass()])" msgstr "" ">>> print(ast.dump(ast.parse('pass'), indent=4))\n" "Module(\n" " body=[\n" -" Pass()],\n" -" type_ignores=[])" +" Pass()])" -#: ../../library/ast.rst:1028 +#: ../../library/ast.rst:1027 msgid "" "A :ref:`type alias ` created through the :keyword:`type` " "statement. ``name`` is the name of the alias, ``type_params`` is a list of :" @@ -1754,41 +1864,37 @@ msgstr "" "aliases>`。``name`` 是別名的名稱、``type_params`` 是\\ :ref:`型別參數 (type " "parameter) ` 的串列、``value`` 是型別別名的值。" -#: ../../library/ast.rst:1033 +#: ../../library/ast.rst:1032 msgid "" ">>> print(ast.dump(ast.parse('type Alias = int'), indent=4))\n" "Module(\n" " body=[\n" " TypeAlias(\n" " name=Name(id='Alias', ctx=Store()),\n" -" type_params=[],\n" -" value=Name(id='int', ctx=Load()))],\n" -" type_ignores=[])" +" value=Name(id='int', ctx=Load()))])" msgstr "" ">>> print(ast.dump(ast.parse('type Alias = int'), indent=4))\n" "Module(\n" " body=[\n" " TypeAlias(\n" " name=Name(id='Alias', ctx=Store()),\n" -" type_params=[],\n" -" value=Name(id='int', ctx=Load()))],\n" -" type_ignores=[])" +" value=Name(id='int', ctx=Load()))])" -#: ../../library/ast.rst:1046 +#: ../../library/ast.rst:1043 msgid "" "Other statements which are only applicable inside functions or loops are " "described in other sections." msgstr "其他僅適用於函式或迴圈內部的陳述式將在其他部分中描述。" -#: ../../library/ast.rst:1050 +#: ../../library/ast.rst:1047 msgid "Imports" msgstr "引入 (imports)" -#: ../../library/ast.rst:1054 +#: ../../library/ast.rst:1051 msgid "An import statement. ``names`` is a list of :class:`alias` nodes." msgstr "一個 import 陳述式。``names`` 是 :class:`alias` 節點的串列。" -#: ../../library/ast.rst:1056 +#: ../../library/ast.rst:1053 msgid "" ">>> print(ast.dump(ast.parse('import x,y,z'), indent=4))\n" "Module(\n" @@ -1797,8 +1903,7 @@ msgid "" " names=[\n" " alias(name='x'),\n" " alias(name='y'),\n" -" alias(name='z')])],\n" -" type_ignores=[])" +" alias(name='z')])])" msgstr "" ">>> print(ast.dump(ast.parse('import x,y,z'), indent=4))\n" "Module(\n" @@ -1807,10 +1912,9 @@ msgstr "" " names=[\n" " alias(name='x'),\n" " alias(name='y'),\n" -" alias(name='z')])],\n" -" type_ignores=[])" +" alias(name='z')])])" -#: ../../library/ast.rst:1071 +#: ../../library/ast.rst:1067 msgid "" "Represents ``from x import y``. ``module`` is a raw string of the 'from' " "name, without any leading dots, or ``None`` for statements such as ``from . " @@ -1821,7 +1925,7 @@ msgstr "" "點 (dot),或者對於諸如 ``from . import foo`` 之類的陳述式則為 ``None``。" "``level`` 是一個整數,保存相對引入的級別(0 表示絕對引入)。" -#: ../../library/ast.rst:1076 +#: ../../library/ast.rst:1072 msgid "" ">>> print(ast.dump(ast.parse('from y import x,y,z'), indent=4))\n" "Module(\n" @@ -1832,8 +1936,7 @@ msgid "" " alias(name='x'),\n" " alias(name='y'),\n" " alias(name='z')],\n" -" level=0)],\n" -" type_ignores=[])" +" level=0)])" msgstr "" ">>> print(ast.dump(ast.parse('from y import x,y,z'), indent=4))\n" "Module(\n" @@ -1844,10 +1947,9 @@ msgstr "" " alias(name='x'),\n" " alias(name='y'),\n" " alias(name='z')],\n" -" level=0)],\n" -" type_ignores=[])" +" level=0)])" -#: ../../library/ast.rst:1093 +#: ../../library/ast.rst:1088 msgid "" "Both parameters are raw strings of the names. ``asname`` can be ``None`` if " "the regular name is to be used." @@ -1855,7 +1957,7 @@ msgstr "" "這兩個參數都是名稱的原始字串。如果要使用常規名稱,``asname`` 可以為 " "``None``。" -#: ../../library/ast.rst:1096 +#: ../../library/ast.rst:1091 msgid "" ">>> print(ast.dump(ast.parse('from ..foo.bar import a as b, c'), indent=4))\n" "Module(\n" @@ -1865,8 +1967,7 @@ msgid "" " names=[\n" " alias(name='a', asname='b'),\n" " alias(name='c')],\n" -" level=2)],\n" -" type_ignores=[])" +" level=2)])" msgstr "" ">>> print(ast.dump(ast.parse('from ..foo.bar import a as b, c'), indent=4))\n" "Module(\n" @@ -1876,20 +1977,19 @@ msgstr "" " names=[\n" " alias(name='a', asname='b'),\n" " alias(name='c')],\n" -" level=2)],\n" -" type_ignores=[])" +" level=2)])" -#: ../../library/ast.rst:1110 +#: ../../library/ast.rst:1104 msgid "Control flow" msgstr "流程控制" -#: ../../library/ast.rst:1113 +#: ../../library/ast.rst:1107 msgid "" "Optional clauses such as ``else`` are stored as an empty list if they're not " "present." msgstr "諸如 ``else`` 之類的可選子句如果不存在,則將被儲存為空串列。" -#: ../../library/ast.rst:1118 +#: ../../library/ast.rst:1112 msgid "" "An ``if`` statement. ``test`` holds a single node, such as a :class:" "`Compare` node. ``body`` and ``orelse`` each hold a list of nodes." @@ -1897,7 +1997,7 @@ msgstr "" "一個 ``if`` 陳述式。``test`` 保存單個節點,例如 :class:`Compare` 節點。" "``body`` 和 ``orelse`` 各自保存一個節點串列。" -#: ../../library/ast.rst:1121 +#: ../../library/ast.rst:1115 msgid "" "``elif`` clauses don't have a special representation in the AST, but rather " "appear as extra :class:`If` nodes within the ``orelse`` section of the " @@ -1906,7 +2006,7 @@ msgstr "" "``elif`` 子句在 AST 中沒有特殊表示,而是在前一個子句的 ``orelse`` 部分中作為" "額外的 :class:`If` 節點出現。" -#: ../../library/ast.rst:1125 +#: ../../library/ast.rst:1119 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... if x:\n" @@ -1931,8 +2031,7 @@ msgid "" " value=Constant(value=Ellipsis))],\n" " orelse=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... if x:\n" @@ -1957,10 +2056,9 @@ msgstr "" " value=Constant(value=Ellipsis))],\n" " orelse=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1156 +#: ../../library/ast.rst:1149 msgid "" "A ``for`` loop. ``target`` holds the variable(s) the loop assigns to, as a " "single :class:`Name`, :class:`Tuple`, :class:`List`, :class:`Attribute` or :" @@ -1975,7 +2073,7 @@ msgstr "" "行的節點串列。如果迴圈正常完成,則執行 ``orelse`` 中的內容,而不是透過 " "``break`` 陳述式執行。" -#: ../../library/ast.rst:1167 +#: ../../library/ast.rst:1160 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... for x in y:\n" @@ -1993,8 +2091,7 @@ msgid "" " value=Constant(value=Ellipsis))],\n" " orelse=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... for x in y:\n" @@ -2012,18 +2109,17 @@ msgstr "" " value=Constant(value=Ellipsis))],\n" " orelse=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])" -#: ../../library/ast.rst:1191 +#: ../../library/ast.rst:1183 msgid "" "A ``while`` loop. ``test`` holds the condition, such as a :class:`Compare` " "node." msgstr "一個 ``while`` 迴圈。``test`` 保存條件,例如 :class:`Compare` 節點。" -#: ../../library/ast.rst:1194 +#: ../../library/ast.rst:1186 msgid "" -">> print(ast.dump(ast.parse(\"\"\"\n" +">>> print(ast.dump(ast.parse(\"\"\"\n" "... while x:\n" "... ...\n" "... else:\n" @@ -2038,10 +2134,9 @@ msgid "" " value=Constant(value=Ellipsis))],\n" " orelse=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])" msgstr "" -">> print(ast.dump(ast.parse(\"\"\"\n" +">>> print(ast.dump(ast.parse(\"\"\"\n" "... while x:\n" "... ...\n" "... else:\n" @@ -2056,14 +2151,13 @@ msgstr "" " value=Constant(value=Ellipsis))],\n" " orelse=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])" -#: ../../library/ast.rst:1218 +#: ../../library/ast.rst:1209 msgid "The ``break`` and ``continue`` statements." msgstr "``break`` 和 ``continue`` 陳述式。" -#: ../../library/ast.rst:1220 +#: ../../library/ast.rst:1211 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... for a in b:\n" @@ -2089,9 +2183,7 @@ msgid "" " body=[\n" " Break()],\n" " orelse=[\n" -" Continue()])],\n" -" orelse=[])],\n" -" type_ignores=[])" +" Continue()])])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... for a in b:\n" @@ -2117,11 +2209,9 @@ msgstr "" " body=[\n" " Break()],\n" " orelse=[\n" -" Continue()])],\n" -" orelse=[])],\n" -" type_ignores=[])" +" Continue()])])])" -#: ../../library/ast.rst:1253 +#: ../../library/ast.rst:1242 msgid "" "``try`` blocks. All attributes are list of nodes to execute, except for " "``handlers``, which is a list of :class:`ExceptHandler` nodes." @@ -2129,7 +2219,7 @@ msgstr "" "``try`` 區塊。除 ``handlers`` 是 :class:`ExceptHandler` 節點的串列外,其他所" "有屬性都是要執行之節點的串列。" -#: ../../library/ast.rst:1256 +#: ../../library/ast.rst:1245 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... try:\n" @@ -2166,8 +2256,7 @@ msgid "" " value=Constant(value=Ellipsis))],\n" " finalbody=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... try:\n" @@ -2204,10 +2293,9 @@ msgstr "" " value=Constant(value=Ellipsis))],\n" " finalbody=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])" -#: ../../library/ast.rst:1299 +#: ../../library/ast.rst:1287 msgid "" "``try`` blocks which are followed by ``except*`` clauses. The attributes are " "the same as for :class:`Try` but the :class:`ExceptHandler` nodes in " @@ -2217,7 +2305,7 @@ msgstr "" "``handlers`` 中的 :class:`ExceptHandler` 節點被直譯 (interpret) 為 " "``except*`` 區塊而不是 ``except``。" -#: ../../library/ast.rst:1303 +#: ../../library/ast.rst:1291 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... try:\n" @@ -2236,10 +2324,7 @@ msgid "" " type=Name(id='Exception', ctx=Load()),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])],\n" -" orelse=[],\n" -" finalbody=[])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... try:\n" @@ -2258,12 +2343,9 @@ msgstr "" " type=Name(id='Exception', ctx=Load()),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])],\n" -" orelse=[],\n" -" finalbody=[])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1331 +#: ../../library/ast.rst:1316 msgid "" "A single ``except`` clause. ``type`` is the exception type it will match, " "typically a :class:`Name` node (or ``None`` for a catch-all ``except:`` " @@ -2275,7 +2357,7 @@ msgstr "" "``name`` 是用於保存例外的名稱之原始字串,如果子句沒有 ``as foo`` ,則為 " "``None``。``body`` 是節點串列。" -#: ../../library/ast.rst:1336 +#: ../../library/ast.rst:1321 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... try:\n" @@ -2296,10 +2378,7 @@ msgid "" " ExceptHandler(\n" " type=Name(id='TypeError', ctx=Load()),\n" " body=[\n" -" Pass()])],\n" -" orelse=[],\n" -" finalbody=[])],\n" -" type_ignores=[])" +" Pass()])])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... try:\n" @@ -2320,12 +2399,9 @@ msgstr "" " ExceptHandler(\n" " type=Name(id='TypeError', ctx=Load()),\n" " body=[\n" -" Pass()])],\n" -" orelse=[],\n" -" finalbody=[])],\n" -" type_ignores=[])" +" Pass()])])])" -#: ../../library/ast.rst:1365 +#: ../../library/ast.rst:1347 msgid "" "A ``with`` block. ``items`` is a list of :class:`withitem` nodes " "representing the context managers, and ``body`` is the indented block inside " @@ -2334,7 +2410,7 @@ msgstr "" "一個 ``with`` 區塊。``items`` 是表示情境管理器的 :class:`withitem` 節點串列," "``body`` 是情境內的縮進區塊。" -#: ../../library/ast.rst:1375 +#: ../../library/ast.rst:1357 msgid "" "A single context manager in a ``with`` block. ``context_expr`` is the " "context manager, often a :class:`Call` node. ``optional_vars`` is a :class:" @@ -2345,7 +2421,7 @@ msgstr "" "class:`Call` 節點。``Optional_vars`` 是 ``as foo`` 部分的 :class:`Name`、:" "class:`Tuple` 或 :class:`List`,或者如果不使用則為 ``None`` 。" -#: ../../library/ast.rst:1380 +#: ../../library/ast.rst:1362 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... with a as b, c as d:\n" @@ -2367,9 +2443,7 @@ msgid "" " func=Name(id='something', ctx=Load()),\n" " args=[\n" " Name(id='b', ctx=Load()),\n" -" Name(id='d', ctx=Load())],\n" -" keywords=[]))])],\n" -" type_ignores=[])" +" Name(id='d', ctx=Load())]))])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... with a as b, c as d:\n" @@ -2391,15 +2465,13 @@ msgstr "" " func=Name(id='something', ctx=Load()),\n" " args=[\n" " Name(id='b', ctx=Load()),\n" -" Name(id='d', ctx=Load())],\n" -" keywords=[]))])],\n" -" type_ignores=[])" +" Name(id='d', ctx=Load())]))])])" -#: ../../library/ast.rst:1408 +#: ../../library/ast.rst:1388 msgid "Pattern matching" msgstr "模式匹配 (pattern matching)" -#: ../../library/ast.rst:1413 +#: ../../library/ast.rst:1393 msgid "" "A ``match`` statement. ``subject`` holds the subject of the match (the " "object that is being matched against the cases) and ``cases`` contains an " @@ -2408,7 +2480,7 @@ msgstr "" "一個 ``match`` 陳述式。``subject`` 保存匹配的主題(與案例匹配的物件)," "``cases`` 包含具有不同案例的 :class:`match_case` 節點的可疊代物件。" -#: ../../library/ast.rst:1421 +#: ../../library/ast.rst:1401 msgid "" "A single case pattern in a ``match`` statement. ``pattern`` contains the " "match pattern that the subject will be matched against. Note that the :class:" @@ -2419,13 +2491,13 @@ msgstr "" "請注意,為模式生成的 :class:`AST` 節點與為運算式生成的節點不同,即使它們共享" "相同的語法。" -#: ../../library/ast.rst:1426 +#: ../../library/ast.rst:1406 msgid "" "The ``guard`` attribute contains an expression that will be evaluated if the " "pattern matches the subject." msgstr "``guard`` 屬性包含一個運算式,如果模式與主題匹配,則將對該運算式求值。" -#: ../../library/ast.rst:1429 +#: ../../library/ast.rst:1409 msgid "" "``body`` contains a list of nodes to execute if the pattern matches and the " "result of evaluating the guard expression is true." @@ -2433,7 +2505,7 @@ msgstr "" "``body`` 包含一個節點串列,如果模式匹配並且為防護運算式 (guard expression) 的" "求值 (evaluate) 結果為真,則會執行該節點串列。" -#: ../../library/ast.rst:1432 +#: ../../library/ast.rst:1412 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2462,14 +2534,10 @@ msgid "" " value=Constant(value=Ellipsis))]),\n" " match_case(\n" " pattern=MatchClass(\n" -" cls=Name(id='tuple', ctx=Load()),\n" -" patterns=[],\n" -" kwd_attrs=[],\n" -" kwd_patterns=[]),\n" +" cls=Name(id='tuple', ctx=Load())),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2498,16 +2566,12 @@ msgstr "" " value=Constant(value=Ellipsis))]),\n" " match_case(\n" " pattern=MatchClass(\n" -" cls=Name(id='tuple', ctx=Load()),\n" -" patterns=[],\n" -" kwd_attrs=[],\n" -" kwd_patterns=[]),\n" +" cls=Name(id='tuple', ctx=Load())),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1474 +#: ../../library/ast.rst:1450 msgid "" "A match literal or value pattern that compares by equality. ``value`` is an " "expression node. Permitted value nodes are restricted as described in the " @@ -2517,7 +2581,7 @@ msgstr "" "以相等性進行比較的匹配文本或值的模式。``value`` 是一個運算式節點。允許值節點" "受到匹配陳述式文件中所述的限制。如果匹配主題等於求出值,則此模式成功。" -#: ../../library/ast.rst:1479 +#: ../../library/ast.rst:1455 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2534,8 +2598,7 @@ msgid "" " value=Constant(value='Relevant')),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2552,10 +2615,9 @@ msgstr "" " value=Constant(value='Relevant')),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1503 +#: ../../library/ast.rst:1478 msgid "" "A match literal pattern that compares by identity. ``value`` is the " "singleton to be compared against: ``None``, ``True``, or ``False``. This " @@ -2565,7 +2627,7 @@ msgstr "" "``True`` 或 ``False`` 進行比較的單例 (singleton)。如果匹配主題是給定的常數," "則此模式成功。" -#: ../../library/ast.rst:1507 +#: ../../library/ast.rst:1482 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2581,8 +2643,7 @@ msgid "" " pattern=MatchSingleton(value=None),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2598,10 +2659,9 @@ msgstr "" " pattern=MatchSingleton(value=None),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1530 +#: ../../library/ast.rst:1504 msgid "" "A match sequence pattern. ``patterns`` contains the patterns to be matched " "against the subject elements if the subject is a sequence. Matches a " @@ -2611,7 +2671,7 @@ msgstr "" "匹配序列模式。如果主題是一個序列,``patterns`` 包含與主題元素匹配的模式。如果" "子模式之一是 ``MatchStar`` 節點,則匹配可變長度序列,否則匹配固定長度序列。" -#: ../../library/ast.rst:1535 +#: ../../library/ast.rst:1509 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2632,8 +2692,7 @@ msgid "" " value=Constant(value=2))]),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2654,10 +2713,9 @@ msgstr "" " value=Constant(value=2))]),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1563 +#: ../../library/ast.rst:1536 msgid "" "Matches the rest of the sequence in a variable length match sequence " "pattern. If ``name`` is not ``None``, a list containing the remaining " @@ -2667,7 +2725,7 @@ msgstr "" "以可變長度匹配序列模式匹配序列的其餘部分。如果 ``name`` 不是 ``None``,則如果" "整體序列模式成功,則包含其餘序列元素的串列將綁定到該名稱。" -#: ../../library/ast.rst:1567 +#: ../../library/ast.rst:1540 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2698,8 +2756,7 @@ msgid "" " MatchStar()]),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2730,10 +2787,9 @@ msgstr "" " MatchStar()]),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1605 +#: ../../library/ast.rst:1577 msgid "" "A match mapping pattern. ``keys`` is a sequence of expression nodes. " "``patterns`` is a corresponding sequence of pattern nodes. ``rest`` is an " @@ -2745,7 +2801,7 @@ msgstr "" "列。``rest`` 是一個可選名稱,可以指定它來捕獲剩餘的對映元素。允許的鍵運算式受" "到匹配陳述式文件中所述的限制。" -#: ../../library/ast.rst:1611 +#: ../../library/ast.rst:1583 msgid "" "This pattern succeeds if the subject is a mapping, all evaluated key " "expressions are present in the mapping, and the value corresponding to each " @@ -2757,7 +2813,7 @@ msgstr "" "應的子模式匹配,則此模式成功。如果 ``rest`` 不是 ``None``,則如果整體對映模式" "成功,則包含其餘對映元素的字典將綁定到該名稱。" -#: ../../library/ast.rst:1617 +#: ../../library/ast.rst:1589 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2783,12 +2839,10 @@ msgid "" " Expr(\n" " value=Constant(value=Ellipsis))]),\n" " match_case(\n" -" pattern=MatchMapping(keys=[], patterns=[], " -"rest='rest'),\n" +" pattern=MatchMapping(rest='rest'),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2814,14 +2868,12 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))]),\n" " match_case(\n" -" pattern=MatchMapping(keys=[], patterns=[], " -"rest='rest'),\n" +" pattern=MatchMapping(rest='rest'),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1653 +#: ../../library/ast.rst:1624 msgid "" "A match class pattern. ``cls`` is an expression giving the nominal class to " "be matched. ``patterns`` is a sequence of pattern nodes to be matched " @@ -2836,7 +2888,7 @@ msgstr "" "``kwd_attrs`` 是要匹配的附加屬性序列(在類別模式中指定為關鍵字引數)," "``kwd_patterns`` 是相應的模式(在類別模式中指定為關鍵字的值)。" -#: ../../library/ast.rst:1660 +#: ../../library/ast.rst:1631 msgid "" "This pattern succeeds if the subject is an instance of the nominated class, " "all positional patterns match the corresponding class-defined attributes, " @@ -2845,7 +2897,7 @@ msgstr "" "如果主題是指定類別的實例,所有位置模式都與相應的類別定義屬性匹配,並且任何指" "定的關鍵字屬性與其相應模式匹配,則此模式成功。" -#: ../../library/ast.rst:1664 +#: ../../library/ast.rst:1635 msgid "" "Note: classes may define a property that returns self in order to match a " "pattern node against the instance being matched. Several builtin types are " @@ -2854,7 +2906,7 @@ msgstr "" "注意:類別可以定義一個回傳 self 的特性 (property),以便將模式節點與正在匹配的" "實例進行匹配。一些內建型別也以這種方式匹配,如同匹配陳述式文件中所述。" -#: ../../library/ast.rst:1668 +#: ../../library/ast.rst:1639 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2875,16 +2927,13 @@ msgid "" " MatchValue(\n" " value=Constant(value=0)),\n" " MatchValue(\n" -" value=Constant(value=0))],\n" -" kwd_attrs=[],\n" -" kwd_patterns=[]),\n" +" value=Constant(value=0))]),\n" " body=[\n" " Expr(\n" " value=Constant(value=Ellipsis))]),\n" " match_case(\n" " pattern=MatchClass(\n" " cls=Name(id='Point3D', ctx=Load()),\n" -" patterns=[],\n" " kwd_attrs=[\n" " 'x',\n" " 'y',\n" @@ -2898,8 +2947,7 @@ msgid "" " value=Constant(value=0))]),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2920,16 +2968,13 @@ msgstr "" " MatchValue(\n" " value=Constant(value=0)),\n" " MatchValue(\n" -" value=Constant(value=0))],\n" -" kwd_attrs=[],\n" -" kwd_patterns=[]),\n" +" value=Constant(value=0))]),\n" " body=[\n" " Expr(\n" " value=Constant(value=Ellipsis))]),\n" " match_case(\n" " pattern=MatchClass(\n" " cls=Name(id='Point3D', ctx=Load()),\n" -" patterns=[],\n" " kwd_attrs=[\n" " 'x',\n" " 'y',\n" @@ -2943,10 +2988,9 @@ msgstr "" " value=Constant(value=0))]),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1719 +#: ../../library/ast.rst:1686 msgid "" "A match \"as-pattern\", capture pattern or wildcard pattern. ``pattern`` " "contains the match pattern that the subject will be matched against. If the " @@ -2957,7 +3001,7 @@ msgstr "" "(wildcard pattern)。``pattern`` 包含主題將與之匹配的匹配模式。如果模式為 " "``None``,則該節點代表捕獲模式(即裸名 (bare name))並且始終會成功。" -#: ../../library/ast.rst:1724 +#: ../../library/ast.rst:1691 msgid "" "The ``name`` attribute contains the name that will be bound if the pattern " "is successful. If ``name`` is ``None``, ``pattern`` must also be ``None`` " @@ -2966,7 +3010,7 @@ msgstr "" "``name`` 屬性包含模式成功時將綁定的名稱。如果 ``name`` 為 ``None``,則 " "``pattern`` 也必須為 ``None``,並且節點代表通配模式。" -#: ../../library/ast.rst:1728 +#: ../../library/ast.rst:1695 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2993,8 +3037,7 @@ msgid "" " pattern=MatchAs(),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -3021,10 +3064,9 @@ msgstr "" " pattern=MatchAs(),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1762 +#: ../../library/ast.rst:1728 msgid "" "A match \"or-pattern\". An or-pattern matches each of its subpatterns in " "turn to the subject, until one succeeds. The or-pattern is then deemed to " @@ -3036,7 +3078,7 @@ msgstr "" "到成功為止,然後 or 模式就會被認為是成功的。如果沒有一個子模式成功,則 or 模" "式將失敗。 ``patterns`` 屬性包含將與主題進行匹配的匹配模式節點串列。" -#: ../../library/ast.rst:1768 +#: ../../library/ast.rst:1734 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -3057,8 +3099,7 @@ msgid "" " MatchAs(name='y')]),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -3079,32 +3120,98 @@ msgstr "" " MatchAs(name='y')]),\n" " body=[\n" " Expr(\n" -" value=Constant(value=Ellipsis))])])],\n" -" type_ignores=[])" +" value=Constant(value=Ellipsis))])])])" + +#: ../../library/ast.rst:1761 +msgid "Type annotations" +msgstr "" + +#: ../../library/ast.rst:1765 +msgid "" +"A ``# type: ignore`` comment located at *lineno*. *tag* is the optional tag " +"specified by the form ``# type: ignore ``." +msgstr "" + +#: ../../library/ast.rst:1768 +msgid "" +">>> print(ast.dump(ast.parse('x = 1 # type: ignore', type_comments=True), " +"indent=4))\n" +"Module(\n" +" body=[\n" +" Assign(\n" +" targets=[\n" +" Name(id='x', ctx=Store())],\n" +" value=Constant(value=1))],\n" +" type_ignores=[\n" +" TypeIgnore(lineno=1, tag='')])\n" +">>> print(ast.dump(ast.parse('x: bool = 1 # type: ignore[assignment]', " +"type_comments=True), indent=4))\n" +"Module(\n" +" body=[\n" +" AnnAssign(\n" +" target=Name(id='x', ctx=Store()),\n" +" annotation=Name(id='bool', ctx=Load()),\n" +" value=Constant(value=1),\n" +" simple=1)],\n" +" type_ignores=[\n" +" TypeIgnore(lineno=1, tag='[assignment]')])" +msgstr "" +">>> print(ast.dump(ast.parse('x = 1 # type: ignore', type_comments=True), " +"indent=4))\n" +"Module(\n" +" body=[\n" +" Assign(\n" +" targets=[\n" +" Name(id='x', ctx=Store())],\n" +" value=Constant(value=1))],\n" +" type_ignores=[\n" +" TypeIgnore(lineno=1, tag='')])\n" +">>> print(ast.dump(ast.parse('x: bool = 1 # type: ignore[assignment]', " +"type_comments=True), indent=4))\n" +"Module(\n" +" body=[\n" +" AnnAssign(\n" +" target=Name(id='x', ctx=Store()),\n" +" annotation=Name(id='bool', ctx=Load()),\n" +" value=Constant(value=1),\n" +" simple=1)],\n" +" type_ignores=[\n" +" TypeIgnore(lineno=1, tag='[assignment]')])" + +#: ../../library/ast.rst:1791 +msgid "" +":class:`!TypeIgnore` nodes are not generated when the *type_comments* " +"parameter is set to ``False`` (default). See :func:`ast.parse` for more " +"details." +msgstr "" -#: ../../library/ast.rst:1797 +#: ../../library/ast.rst:1799 msgid "Type parameters" msgstr "型別參數 (type parameters)" -#: ../../library/ast.rst:1799 +#: ../../library/ast.rst:1801 msgid "" ":ref:`Type parameters ` can exist on classes, functions, and " "type aliases." msgstr ":ref:`型別參數 `\\ 可以存在於類別、函式和型別別名上。" -#: ../../library/ast.rst:1804 +#: ../../library/ast.rst:1806 msgid "" "A :class:`typing.TypeVar`. ``name`` is the name of the type variable. " "``bound`` is the bound or constraints, if any. If ``bound`` is a :class:" -"`Tuple`, it represents constraints; otherwise it represents the bound." +"`Tuple`, it represents constraints; otherwise it represents the bound. " +"``default_value`` is the default value; if the :class:`!TypeVar` has no " +"default, this attribute will be set to ``None``." msgstr "" "一個 :class:`typing.TypeVar`。``name`` 是型別變數的名稱。``bound`` 是(如果有" "存在的)界限 (bound) 或約束 (constraint)。如果 ``bound`` 是一個 :class:" -"`Tuple`,它代表約束;否則它代表界限。" +"`Tuple`,它代表約束;否則它代表界限。``default_value`` 為預設值;如果 :class:" +"`!TypeVar` 沒有預設值,那此屬性會被設為 ``None``。" -#: ../../library/ast.rst:1808 +#: ../../library/ast.rst:1812 msgid "" -">>> print(ast.dump(ast.parse(\"type Alias[T: int] = list[T]\"), indent=4))\n" +">>> print(ast.dump(ast.parse(\"type Alias[T: int = bool] = list[T]\"), " +"indent=4))\n" "Module(\n" " body=[\n" " TypeAlias(\n" @@ -3112,14 +3219,15 @@ msgid "" " type_params=[\n" " TypeVar(\n" " name='T',\n" -" bound=Name(id='int', ctx=Load()))],\n" +" bound=Name(id='int', ctx=Load()),\n" +" default_value=Name(id='bool', ctx=Load()))],\n" " value=Subscript(\n" " value=Name(id='list', ctx=Load()),\n" " slice=Name(id='T', ctx=Load()),\n" -" ctx=Load()))],\n" -" type_ignores=[])" +" ctx=Load()))])" msgstr "" -">>> print(ast.dump(ast.parse(\"type Alias[T: int] = list[T]\"), indent=4))\n" +">>> print(ast.dump(ast.parse(\"type Alias[T: int = bool] = list[T]\"), " +"indent=4))\n" "Module(\n" " body=[\n" " TypeAlias(\n" @@ -3127,29 +3235,43 @@ msgstr "" " type_params=[\n" " TypeVar(\n" " name='T',\n" -" bound=Name(id='int', ctx=Load()))],\n" +" bound=Name(id='int', ctx=Load()),\n" +" default_value=Name(id='bool', ctx=Load()))],\n" " value=Subscript(\n" " value=Name(id='list', ctx=Load()),\n" " slice=Name(id='T', ctx=Load()),\n" -" ctx=Load()))],\n" -" type_ignores=[])" +" ctx=Load()))])" -#: ../../library/ast.rst:1829 +#: ../../library/ast.rst:1831 ../../library/ast.rst:1866 +#: ../../library/ast.rst:1898 +msgid "Added the *default_value* parameter." +msgstr "新增 *default_value* 參數。" + +#: ../../library/ast.rst:1836 msgid "" "A :class:`typing.ParamSpec`. ``name`` is the name of the parameter " -"specification." -msgstr "A :class:`typing.ParamSpec`。``name`` 是參數規範的名稱。" +"specification. ``default_value`` is the default value; if the :class:`!" +"ParamSpec` has no default, this attribute will be set to ``None``." +msgstr "" +"一個 :class:`typing.ParamSpec`。``name`` 是參數規範的名稱。``default_value`` " +"是預設值;如果 :class:`!ParamSpec` 沒有預設值,則該屬性將設定為 ``None``。" -#: ../../library/ast.rst:1831 +#: ../../library/ast.rst:1840 msgid "" -">>> print(ast.dump(ast.parse(\"type Alias[**P] = Callable[P, int]\"), " -"indent=4))\n" +">>> print(ast.dump(ast.parse(\"type Alias[**P = [int, str]] = Callable[P, " +"int]\"), indent=4))\n" "Module(\n" " body=[\n" " TypeAlias(\n" " name=Name(id='Alias', ctx=Store()),\n" " type_params=[\n" -" ParamSpec(name='P')],\n" +" ParamSpec(\n" +" name='P',\n" +" default_value=List(\n" +" elts=[\n" +" Name(id='int', ctx=Load()),\n" +" Name(id='str', ctx=Load())],\n" +" ctx=Load()))],\n" " value=Subscript(\n" " value=Name(id='Callable', ctx=Load()),\n" " slice=Tuple(\n" @@ -3157,17 +3279,22 @@ msgid "" " Name(id='P', ctx=Load()),\n" " Name(id='int', ctx=Load())],\n" " ctx=Load()),\n" -" ctx=Load()))],\n" -" type_ignores=[])" +" ctx=Load()))])" msgstr "" -">>> print(ast.dump(ast.parse(\"type Alias[**P] = Callable[P, int]\"), " -"indent=4))\n" +">>> print(ast.dump(ast.parse(\"type Alias[**P = [int, str]] = Callable[P, " +"int]\"), indent=4))\n" "Module(\n" " body=[\n" " TypeAlias(\n" " name=Name(id='Alias', ctx=Store()),\n" " type_params=[\n" -" ParamSpec(name='P')],\n" +" ParamSpec(\n" +" name='P',\n" +" default_value=List(\n" +" elts=[\n" +" Name(id='int', ctx=Load()),\n" +" Name(id='str', ctx=Load())],\n" +" ctx=Load()))],\n" " value=Subscript(\n" " value=Name(id='Callable', ctx=Load()),\n" " slice=Tuple(\n" @@ -3175,24 +3302,30 @@ msgstr "" " Name(id='P', ctx=Load()),\n" " Name(id='int', ctx=Load())],\n" " ctx=Load()),\n" -" ctx=Load()))],\n" -" type_ignores=[])" +" ctx=Load()))])" -#: ../../library/ast.rst:1854 +#: ../../library/ast.rst:1871 msgid "" "A :class:`typing.TypeVarTuple`. ``name`` is the name of the type variable " -"tuple." -msgstr "一個 :class:`typing.TypeVarTuple`。``name`` 是型別變數元組的名稱。" +"tuple. ``default_value`` is the default value; if the :class:`!TypeVarTuple` " +"has no default, this attribute will be set to ``None``." +msgstr "" +"一個 :class:`typing.TypeVarTuple`。``name`` 是型別變數元組的名稱。" +"``default_value`` 為預設值;如果 :class:`!TypeVarTuple` 沒有預設值,那此屬性" +"會被設為 ``None``。" -#: ../../library/ast.rst:1856 +#: ../../library/ast.rst:1875 msgid "" -">>> print(ast.dump(ast.parse(\"type Alias[*Ts] = tuple[*Ts]\"), indent=4))\n" +">>> print(ast.dump(ast.parse(\"type Alias[*Ts = ()] = tuple[*Ts]\"), " +"indent=4))\n" "Module(\n" " body=[\n" " TypeAlias(\n" " name=Name(id='Alias', ctx=Store()),\n" " type_params=[\n" -" TypeVarTuple(name='Ts')],\n" +" TypeVarTuple(\n" +" name='Ts',\n" +" default_value=Tuple(ctx=Load()))],\n" " value=Subscript(\n" " value=Name(id='tuple', ctx=Load()),\n" " slice=Tuple(\n" @@ -3201,16 +3334,18 @@ msgid "" " value=Name(id='Ts', ctx=Load()),\n" " ctx=Load())],\n" " ctx=Load()),\n" -" ctx=Load()))],\n" -" type_ignores=[])" +" ctx=Load()))])" msgstr "" -">>> print(ast.dump(ast.parse(\"type Alias[*Ts] = tuple[*Ts]\"), indent=4))\n" +">>> print(ast.dump(ast.parse(\"type Alias[*Ts = ()] = tuple[*Ts]\"), " +"indent=4))\n" "Module(\n" " body=[\n" " TypeAlias(\n" " name=Name(id='Alias', ctx=Store()),\n" " type_params=[\n" -" TypeVarTuple(name='Ts')],\n" +" TypeVarTuple(\n" +" name='Ts',\n" +" default_value=Tuple(ctx=Load()))],\n" " value=Subscript(\n" " value=Name(id='tuple', ctx=Load()),\n" " slice=Tuple(\n" @@ -3219,30 +3354,29 @@ msgstr "" " value=Name(id='Ts', ctx=Load()),\n" " ctx=Load())],\n" " ctx=Load()),\n" -" ctx=Load()))],\n" -" type_ignores=[])" +" ctx=Load()))])" -#: ../../library/ast.rst:1879 +#: ../../library/ast.rst:1902 msgid "Function and class definitions" msgstr "函式和類別定義" -#: ../../library/ast.rst:1883 +#: ../../library/ast.rst:1906 msgid "A function definition." msgstr "一個函式定義。" -#: ../../library/ast.rst:1885 +#: ../../library/ast.rst:1908 msgid "``name`` is a raw string of the function name." msgstr "``name`` 是函式名稱的原始字串。" -#: ../../library/ast.rst:1886 +#: ../../library/ast.rst:1909 msgid "``args`` is an :class:`arguments` node." msgstr "``args`` 是一個 :class:`arguments` 節點。" -#: ../../library/ast.rst:1887 +#: ../../library/ast.rst:1910 msgid "``body`` is the list of nodes inside the function." msgstr "``body`` 是函式內節點的串列。" -#: ../../library/ast.rst:1888 +#: ../../library/ast.rst:1911 msgid "" "``decorator_list`` is the list of decorators to be applied, stored outermost " "first (i.e. the first in the list will be applied last)." @@ -3250,20 +3384,20 @@ msgstr "" "``decorator_list`` 是要應用的裝飾器串列,在最外層者會被儲存在首位(即串列中首" "位將會是最後一個被應用的那個)。" -#: ../../library/ast.rst:1890 +#: ../../library/ast.rst:1913 msgid "``returns`` is the return annotation." msgstr "``returns`` 是回傳註釋。" -#: ../../library/ast.rst:1891 ../../library/ast.rst:2067 +#: ../../library/ast.rst:1914 ../../library/ast.rst:2077 msgid "``type_params`` is a list of :ref:`type parameters `." msgstr "``type_params`` 是\\ :ref:`型別參數 `\\ 的串列。" -#: ../../library/ast.rst:1897 ../../library/ast.rst:2096 -#: ../../library/ast.rst:2107 +#: ../../library/ast.rst:1920 ../../library/ast.rst:2104 +#: ../../library/ast.rst:2115 msgid "Added ``type_params``." msgstr "新增了 ``type_params``。" -#: ../../library/ast.rst:1903 +#: ../../library/ast.rst:1926 msgid "" "``lambda`` is a minimal function definition that can be used inside an " "expression. Unlike :class:`FunctionDef`, ``body`` holds a single node." @@ -3271,7 +3405,7 @@ msgstr "" "``lambda`` 是可以在運算式內使用的最小函式定義。與 :class:`FunctionDef` 不同," "``body`` 保存單個節點。" -#: ../../library/ast.rst:1906 +#: ../../library/ast.rst:1929 msgid "" ">>> print(ast.dump(ast.parse('lambda x,y: ...'), indent=4))\n" "Module(\n" @@ -3279,15 +3413,10 @@ msgid "" " Expr(\n" " value=Lambda(\n" " args=arguments(\n" -" posonlyargs=[],\n" " args=[\n" " arg(arg='x'),\n" -" arg(arg='y')],\n" -" kwonlyargs=[],\n" -" kw_defaults=[],\n" -" defaults=[]),\n" -" body=Constant(value=Ellipsis)))],\n" -" type_ignores=[])" +" arg(arg='y')]),\n" +" body=Constant(value=Ellipsis)))])" msgstr "" ">>> print(ast.dump(ast.parse('lambda x,y: ...'), indent=4))\n" "Module(\n" @@ -3295,27 +3424,22 @@ msgstr "" " Expr(\n" " value=Lambda(\n" " args=arguments(\n" -" posonlyargs=[],\n" " args=[\n" " arg(arg='x'),\n" -" arg(arg='y')],\n" -" kwonlyargs=[],\n" -" kw_defaults=[],\n" -" defaults=[]),\n" -" body=Constant(value=Ellipsis)))],\n" -" type_ignores=[])" +" arg(arg='y')]),\n" +" body=Constant(value=Ellipsis)))])" -#: ../../library/ast.rst:1927 +#: ../../library/ast.rst:1945 msgid "The arguments for a function." msgstr "函式的引數。" -#: ../../library/ast.rst:1929 +#: ../../library/ast.rst:1947 msgid "" "``posonlyargs``, ``args`` and ``kwonlyargs`` are lists of :class:`arg` nodes." msgstr "" "``posonlyargs``、``args`` 和 ``kwonlyargs`` 是 :class:`arg` 節點的串列。" -#: ../../library/ast.rst:1930 +#: ../../library/ast.rst:1948 msgid "" "``vararg`` and ``kwarg`` are single :class:`arg` nodes, referring to the " "``*args, **kwargs`` parameters." @@ -3323,7 +3447,7 @@ msgstr "" "``vararg`` 和 ``kwarg`` 是單個 :class:`arg` 節點,指的是 ``*args, **kwargs`` " "參數。" -#: ../../library/ast.rst:1932 +#: ../../library/ast.rst:1950 msgid "" "``kw_defaults`` is a list of default values for keyword-only arguments. If " "one is ``None``, the corresponding argument is required." @@ -3331,7 +3455,7 @@ msgstr "" "``kw_defaults`` 是僅限關鍵字引數的預設值串列。如果其中某個為 ``None``,則相應" "參數就會是必要的。" -#: ../../library/ast.rst:1934 +#: ../../library/ast.rst:1952 msgid "" "``defaults`` is a list of default values for arguments that can be passed " "positionally. If there are fewer defaults, they correspond to the last n " @@ -3340,7 +3464,7 @@ msgstr "" "``defaults`` 是可以按位置傳遞的引數的預設值串列。如果預設值較少,則它們對應於" "最後 n 個引數。" -#: ../../library/ast.rst:1941 +#: ../../library/ast.rst:1959 msgid "" "A single argument in a list. ``arg`` is a raw string of the argument name; " "``annotation`` is its annotation, such as a :class:`Name` node." @@ -3348,12 +3472,12 @@ msgstr "" "串列中的單個引數。``arg`` 是引數名稱的原始字串,``annotation`` 是它的註釋,例" "如 :class:`Name` 節點。" -#: ../../library/ast.rst:1946 +#: ../../library/ast.rst:1964 msgid "" "``type_comment`` is an optional string with the type annotation as a comment" msgstr "``type_comment`` 是一個可選字串,其註解為型別註釋" -#: ../../library/ast.rst:1948 +#: ../../library/ast.rst:1966 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... @decorator1\n" @@ -3367,7 +3491,6 @@ msgid "" " FunctionDef(\n" " name='f',\n" " args=arguments(\n" -" posonlyargs=[],\n" " args=[\n" " arg(\n" " arg='a',\n" @@ -3390,9 +3513,7 @@ msgid "" " decorator_list=[\n" " Name(id='decorator1', ctx=Load()),\n" " Name(id='decorator2', ctx=Load())],\n" -" returns=Constant(value='return annotation'),\n" -" type_params=[])],\n" -" type_ignores=[])" +" returns=Constant(value='return annotation'))])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... @decorator1\n" @@ -3406,7 +3527,6 @@ msgstr "" " FunctionDef(\n" " name='f',\n" " args=arguments(\n" -" posonlyargs=[],\n" " args=[\n" " arg(\n" " arg='a',\n" @@ -3429,31 +3549,27 @@ msgstr "" " decorator_list=[\n" " Name(id='decorator1', ctx=Load()),\n" " Name(id='decorator2', ctx=Load())],\n" -" returns=Constant(value='return annotation'),\n" -" type_params=[])],\n" -" type_ignores=[])" +" returns=Constant(value='return annotation'))])" -#: ../../library/ast.rst:1991 +#: ../../library/ast.rst:2006 msgid "A ``return`` statement." msgstr "一個 ``return`` 陳述式。" -#: ../../library/ast.rst:1993 +#: ../../library/ast.rst:2008 msgid "" ">>> print(ast.dump(ast.parse('return 4'), indent=4))\n" "Module(\n" " body=[\n" " Return(\n" -" value=Constant(value=4))],\n" -" type_ignores=[])" +" value=Constant(value=4))])" msgstr "" ">>> print(ast.dump(ast.parse('return 4'), indent=4))\n" "Module(\n" " body=[\n" " Return(\n" -" value=Constant(value=4))],\n" -" type_ignores=[])" +" value=Constant(value=4))])" -#: ../../library/ast.rst:2006 +#: ../../library/ast.rst:2020 msgid "" "A ``yield`` or ``yield from`` expression. Because these are expressions, " "they must be wrapped in an :class:`Expr` node if the value sent back is not " @@ -3462,46 +3578,42 @@ msgstr "" "一個 ``yield`` 或 ``yield from`` 運算式。因為這些是運算式,所以如果不使用發送" "回來的值,則必須將它們包裝在 :class:`Expr` 節點中。" -#: ../../library/ast.rst:2009 +#: ../../library/ast.rst:2023 msgid "" ">>> print(ast.dump(ast.parse('yield x'), indent=4))\n" "Module(\n" " body=[\n" " Expr(\n" " value=Yield(\n" -" value=Name(id='x', ctx=Load())))],\n" -" type_ignores=[])\n" +" value=Name(id='x', ctx=Load())))])\n" "\n" ">>> print(ast.dump(ast.parse('yield from x'), indent=4))\n" "Module(\n" " body=[\n" " Expr(\n" " value=YieldFrom(\n" -" value=Name(id='x', ctx=Load())))],\n" -" type_ignores=[])" +" value=Name(id='x', ctx=Load())))])" msgstr "" ">>> print(ast.dump(ast.parse('yield x'), indent=4))\n" "Module(\n" " body=[\n" " Expr(\n" " value=Yield(\n" -" value=Name(id='x', ctx=Load())))],\n" -" type_ignores=[])\n" +" value=Name(id='x', ctx=Load())))])\n" "\n" ">>> print(ast.dump(ast.parse('yield from x'), indent=4))\n" "Module(\n" " body=[\n" " Expr(\n" " value=YieldFrom(\n" -" value=Name(id='x', ctx=Load())))],\n" -" type_ignores=[])" +" value=Name(id='x', ctx=Load())))])" -#: ../../library/ast.rst:2031 +#: ../../library/ast.rst:2043 msgid "" "``global`` and ``nonlocal`` statements. ``names`` is a list of raw strings." msgstr "``global`` 和 ``nonlocal`` 陳述式。``names`` 是原始字串的串列。" -#: ../../library/ast.rst:2033 +#: ../../library/ast.rst:2045 msgid "" ">>> print(ast.dump(ast.parse('global x,y,z'), indent=4))\n" "Module(\n" @@ -3510,8 +3622,7 @@ msgid "" " names=[\n" " 'x',\n" " 'y',\n" -" 'z'])],\n" -" type_ignores=[])\n" +" 'z'])])\n" "\n" ">>> print(ast.dump(ast.parse('nonlocal x,y,z'), indent=4))\n" "Module(\n" @@ -3520,8 +3631,7 @@ msgid "" " names=[\n" " 'x',\n" " 'y',\n" -" 'z'])],\n" -" type_ignores=[])" +" 'z'])])" msgstr "" ">>> print(ast.dump(ast.parse('global x,y,z'), indent=4))\n" "Module(\n" @@ -3530,8 +3640,7 @@ msgstr "" " names=[\n" " 'x',\n" " 'y',\n" -" 'z'])],\n" -" type_ignores=[])\n" +" 'z'])])\n" "\n" ">>> print(ast.dump(ast.parse('nonlocal x,y,z'), indent=4))\n" "Module(\n" @@ -3540,22 +3649,21 @@ msgstr "" " names=[\n" " 'x',\n" " 'y',\n" -" 'z'])],\n" -" type_ignores=[])" +" 'z'])])" -#: ../../library/ast.rst:2058 +#: ../../library/ast.rst:2068 msgid "A class definition." msgstr "一個類別定義。" -#: ../../library/ast.rst:2060 +#: ../../library/ast.rst:2070 msgid "``name`` is a raw string for the class name" -msgstr "``name`` 是類別名的原始字串" +msgstr "``name`` 是類別名稱的原始字串" -#: ../../library/ast.rst:2061 +#: ../../library/ast.rst:2071 msgid "``bases`` is a list of nodes for explicitly specified base classes." msgstr "``bases`` 是被顯式指定的基底類別節點串列。" -#: ../../library/ast.rst:2062 +#: ../../library/ast.rst:2072 msgid "" "``keywords`` is a list of :class:`.keyword` nodes, principally for " "'metaclass'. Other keywords will be passed to the metaclass, as per :pep:" @@ -3564,17 +3672,17 @@ msgstr "" "``keywords`` 是一個 :class:`.keyword` 節點的串列,主要用於 'metaclass'(元類" "別)。如 :pep:`3115` 所述,其他關鍵字將被傳遞到 metaclass。" -#: ../../library/ast.rst:2064 +#: ../../library/ast.rst:2074 msgid "" "``body`` is a list of nodes representing the code within the class " "definition." msgstr "``body`` 是表示類別定義中程式碼的節點串列。" -#: ../../library/ast.rst:2066 +#: ../../library/ast.rst:2076 msgid "``decorator_list`` is a list of nodes, as in :class:`FunctionDef`." msgstr "``decorator_list`` 是一個節點串列,如 :class:`FunctionDef` 中所示。" -#: ../../library/ast.rst:2069 +#: ../../library/ast.rst:2079 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... @decorator1\n" @@ -3597,9 +3705,7 @@ msgid "" " Pass()],\n" " decorator_list=[\n" " Name(id='decorator1', ctx=Load()),\n" -" Name(id='decorator2', ctx=Load())],\n" -" type_params=[])],\n" -" type_ignores=[])" +" Name(id='decorator2', ctx=Load())])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... @decorator1\n" @@ -3622,21 +3728,19 @@ msgstr "" " Pass()],\n" " decorator_list=[\n" " Name(id='decorator1', ctx=Load()),\n" -" Name(id='decorator2', ctx=Load())],\n" -" type_params=[])],\n" -" type_ignores=[])" +" Name(id='decorator2', ctx=Load())])])" -#: ../../library/ast.rst:2100 +#: ../../library/ast.rst:2108 msgid "Async and await" msgstr "async 和 await" -#: ../../library/ast.rst:2104 +#: ../../library/ast.rst:2112 msgid "" "An ``async def`` function definition. Has the same fields as :class:" "`FunctionDef`." msgstr "一個 ``async def`` 函式定義。與 :class:`FunctionDef` 具有相同的欄位。" -#: ../../library/ast.rst:2113 +#: ../../library/ast.rst:2121 msgid "" "An ``await`` expression. ``value`` is what it waits for. Only valid in the " "body of an :class:`AsyncFunctionDef`." @@ -3644,7 +3748,7 @@ msgstr "" "一個 ``await`` 運算式。``value`` 是它等待的東西。僅在 :class:" "`AsyncFunctionDef` 主體 (body) 中有效。" -#: ../../library/ast.rst:2116 +#: ../../library/ast.rst:2124 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... async def f():\n" @@ -3654,22 +3758,12 @@ msgid "" " body=[\n" " AsyncFunctionDef(\n" " name='f',\n" -" args=arguments(\n" -" posonlyargs=[],\n" -" args=[],\n" -" kwonlyargs=[],\n" -" kw_defaults=[],\n" -" defaults=[]),\n" +" args=arguments(),\n" " body=[\n" " Expr(\n" " value=Await(\n" " value=Call(\n" -" func=Name(id='other_func', ctx=Load()),\n" -" args=[],\n" -" keywords=[])))],\n" -" decorator_list=[],\n" -" type_params=[])],\n" -" type_ignores=[])" +" func=Name(id='other_func', ctx=Load()))))])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... async def f():\n" @@ -3679,24 +3773,14 @@ msgstr "" " body=[\n" " AsyncFunctionDef(\n" " name='f',\n" -" args=arguments(\n" -" posonlyargs=[],\n" -" args=[],\n" -" kwonlyargs=[],\n" -" kw_defaults=[],\n" -" defaults=[]),\n" +" args=arguments(),\n" " body=[\n" " Expr(\n" " value=Await(\n" " value=Call(\n" -" func=Name(id='other_func', ctx=Load()),\n" -" args=[],\n" -" keywords=[])))],\n" -" decorator_list=[],\n" -" type_params=[])],\n" -" type_ignores=[])" +" func=Name(id='other_func', ctx=Load()))))])])" -#: ../../library/ast.rst:2147 +#: ../../library/ast.rst:2145 msgid "" "``async for`` loops and ``async with`` context managers. They have the same " "fields as :class:`For` and :class:`With`, respectively. Only valid in the " @@ -3705,7 +3789,7 @@ msgstr "" "``async for`` 迴圈和 ``async with`` 情境管理器。它們分別具有與 :class:`For` " "和 :class:`With` 相同的欄位。僅在 :class:`AsyncFunctionDef` 主體中有效。" -#: ../../library/ast.rst:2152 +#: ../../library/ast.rst:2150 msgid "" "When a string is parsed by :func:`ast.parse`, operator nodes (subclasses of :" "class:`ast.operator`, :class:`ast.unaryop`, :class:`ast.cmpop`, :class:`ast." @@ -3718,11 +3802,11 @@ msgstr "" "boolop` 和 :class:`ast.expr_context`\\ )將是單例。對其中之一的更改將反映在所" "有其他出現的相同值中(例如 :class:`ast.Add`\\ )。" -#: ../../library/ast.rst:2160 +#: ../../library/ast.rst:2158 msgid ":mod:`ast` Helpers" msgstr ":mod:`ast` 輔助程式" -#: ../../library/ast.rst:2162 +#: ../../library/ast.rst:2160 msgid "" "Apart from the node classes, the :mod:`ast` module defines these utility " "functions and classes for traversing abstract syntax trees:" @@ -3730,13 +3814,16 @@ msgstr "" "除了節點類別之外,:mod:`ast` 模組還定義了這些用於遍歷 (traverse) 抽象語法樹的" "實用函式和類別:" -#: ../../library/ast.rst:2167 +#: ../../library/ast.rst:2165 msgid "" "Parse the source into an AST node. Equivalent to ``compile(source, " -"filename, mode, ast.PyCF_ONLY_AST)``." +"filename, mode, flags=FLAGS_VALUE, optimize=optimize)``, where " +"``FLAGS_VALUE`` is ``ast.PyCF_ONLY_AST`` if ``optimize <= 0`` and ``ast." +"PyCF_OPTIMIZED_AST`` otherwise." msgstr "" -"將原始碼剖析為 AST 節點。相當於 ``compile(source, filename, mode, ast." -"PyCF_ONLY_AST)``。" +"將原始碼剖析為 AST 節點,相當於 ``compile(source, filename, mode, " +"flags=FLAGS_VALUE, optimize=optimize)``,其中 ``FLAGS_VALUE`` 在 ``optimize " +"<= 0`` 時為 ``ast.PyCF_ONLY_AST``,否則為 ``ast.PyCF_OPTIMIZED_AST``。" #: ../../library/ast.rst:2170 msgid "" @@ -3773,16 +3860,16 @@ msgid "" "\"best-effort\" attempt to parse using that Python version's grammar. For " "example, setting ``feature_version=(3, 9)`` will attempt to disallow parsing " "of :keyword:`match` statements. Currently ``major`` must equal to ``3``. The " -"lowest supported version is ``(3, 4)`` (and this may increase in future " +"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``." msgstr "" "將 ``feature_version`` 設定為元組 ``(major, minor)`` 將「盡可能」嘗試使用該 " -"Python 版本的文法進行剖析。當前 ``major`` 必須等於 ``3``。例如,設定 " -"``feature_version=(3, 4)`` 將嘗試禁止剖析 :keyword:`match` 陳述式。目前 " -"``major`` 必須為 ``3``、支援的最低版本為 ``(3, 4)``\\ (這在未來的 Python 版" +"Python 版本的文法進行剖析。目前 ``major`` 必須等於 ``3``。例如,設定 " +"``feature_version=(3, 9)`` 將嘗試禁止剖析 :keyword:`match` 陳述式。目前 " +"``major`` 必須為 ``3``、支援的最低版本為 ``(3, 7)``\\ (這在未來的 Python 版" "本中可能會增加);最高的是 ``sys.version_info[0:2]``。「盡可能」嘗試意味著不" "能保證剖析(或剖析的成功)與在與 ``feature_version`` 對應的 Python 版本上運行" "時相同。" @@ -3825,7 +3912,15 @@ msgstr "" msgid "Added ``type_comments``, ``mode='func_type'`` and ``feature_version``." msgstr "新增 ``type_comments``、``mode='func_type'`` 與 ``feature_version``。" -#: ../../library/ast.rst:2218 +#: ../../library/ast.rst:2215 +msgid "" +"The minimum supported version for ``feature_version`` is now ``(3, 7)``. The " +"``optimize`` argument was added." +msgstr "" +"``feature_version`` 的最低支援版本現在是 ``(3, 7)``。新增了 ``optimize`` 引" +"數。" + +#: ../../library/ast.rst:2222 msgid "" "Unparse an :class:`ast.AST` object and generate a string with code that " "would produce an equivalent :class:`ast.AST` object if parsed back with :" @@ -3834,7 +3929,7 @@ msgstr "" "反剖析 :class:`ast.AST` 物件並生成一個帶有程式碼的字串,如果使用 :func:`ast." "parse` 剖析回來,該程式碼將生成等效的 :class:`ast.AST` 物件。" -#: ../../library/ast.rst:2223 +#: ../../library/ast.rst:2227 msgid "" "The produced code string will not necessarily be equal to the original code " "that generated the :class:`ast.AST` object (without any compiler " @@ -3843,13 +3938,13 @@ msgstr "" "生成的程式碼字串不一定等於生成 :class:`ast.AST` 物件的原始程式碼(沒有任何編" "譯器最佳化,例如常數元組/凍結集合)。" -#: ../../library/ast.rst:2228 +#: ../../library/ast.rst:2232 msgid "" "Trying to unparse a highly complex expression would result with :exc:" "`RecursionError`." msgstr "嘗試剖析高度複雜的運算式會導致 :exc:`RecursionError`。" -#: ../../library/ast.rst:2236 +#: ../../library/ast.rst:2240 msgid "" "Evaluate an expression node or a string containing only a Python literal or " "container display. The string or node provided may only consist of the " @@ -3860,7 +3955,7 @@ msgstr "" "能包含以下 Python 文本結構:字串、位元組、數字、元組、串列、字典、集合、布林" "值、``None`` 和 ``Ellipsis``。" -#: ../../library/ast.rst:2241 +#: ../../library/ast.rst:2245 msgid "" "This can be used for evaluating strings containing Python values without the " "need to parse the values oneself. It is not capable of evaluating " @@ -3869,7 +3964,7 @@ msgstr "" "這可用於為包含 Python 值的字串求值,而無需自己剖析這些值。它無法計算任意複雜" "的運算式,例如涉及運算子或索引。" -#: ../../library/ast.rst:2246 +#: ../../library/ast.rst:2250 msgid "" "This function had been documented as \"safe\" in the past without defining " "what that meant. That was misleading. This is specifically designed not to " @@ -3886,13 +3981,13 @@ msgstr "" "盡或 C 堆疊耗盡,從而導致行程崩潰。某些輸入也可能會出現 CPU 消耗過多而導致拒" "絕服務的情況。因此不建議在不受信任的資料上呼叫它。" -#: ../../library/ast.rst:2256 +#: ../../library/ast.rst:2260 msgid "" "It is possible to crash the Python interpreter due to stack depth " "limitations in Python's AST compiler." msgstr "由於 Python AST 編譯器的堆疊深度限制,Python 直譯器可能會崩潰。" -#: ../../library/ast.rst:2259 +#: ../../library/ast.rst:2263 msgid "" "It can raise :exc:`ValueError`, :exc:`TypeError`, :exc:`SyntaxError`, :exc:" "`MemoryError` and :exc:`RecursionError` depending on the malformed input." @@ -3900,19 +3995,19 @@ msgstr "" "它可能會引發 :exc:`ValueError`、:exc:`TypeError`、:exc:`SyntaxError`、:exc:" "`MemoryError` 和 :exc:`RecursionError`,具體取決於格式錯誤的輸入。" -#: ../../library/ast.rst:2263 +#: ../../library/ast.rst:2267 msgid "Now allows bytes and set literals." msgstr "現在允許位元組和集合文本 (set literal)。" -#: ../../library/ast.rst:2266 +#: ../../library/ast.rst:2270 msgid "Now supports creating empty sets with ``'set()'``." msgstr "現在支援使用 ``'set()'`` 建立空集合。" -#: ../../library/ast.rst:2269 +#: ../../library/ast.rst:2273 msgid "For string inputs, leading spaces and tabs are now stripped." msgstr "對於字串輸入,前導空格和定位字元 (tab) 現在已被去除。" -#: ../../library/ast.rst:2275 +#: ../../library/ast.rst:2279 msgid "" "Return the docstring of the given *node* (which must be a :class:" "`FunctionDef`, :class:`AsyncFunctionDef`, :class:`ClassDef`, or :class:" @@ -3924,22 +4019,22 @@ msgstr "" "件字串則為 ``None``。如果 *clean* 為 true,則使用 :func:`inspect.cleandoc` 清" "理文件字串的縮排。" -#: ../../library/ast.rst:2281 +#: ../../library/ast.rst:2285 msgid ":class:`AsyncFunctionDef` is now supported." msgstr "目前已支援 :class:`AsyncFunctionDef`。" -#: ../../library/ast.rst:2287 +#: ../../library/ast.rst:2291 msgid "" "Get source code segment of the *source* that generated *node*. If some " "location information (:attr:`~ast.AST.lineno`, :attr:`~ast.AST.end_lineno`, :" "attr:`~ast.AST.col_offset`, or :attr:`~ast.AST.end_col_offset`) is missing, " "return ``None``." msgstr "" -"獲取生成 *node* 的 *source* 的原始碼片段。如果某些位置資訊(:attr:`~ast.AST." +"取得生成 *node* 的 *source* 的原始碼片段。如果某些位置資訊(:attr:`~ast.AST." "lineno`、:attr:`~ast.AST.end_lineno`、:attr:`~ast.AST.col_offset` 或 :attr:" "`~ast.AST.end_col_offset`\\ )遺漏,則回傳 ``None``。" -#: ../../library/ast.rst:2291 +#: ../../library/ast.rst:2295 msgid "" "If *padded* is ``True``, the first line of a multi-line statement will be " "padded with spaces to match its original position." @@ -3947,7 +4042,7 @@ msgstr "" "如果 *padded* 為 ``True``,則多列陳述式的第一列將用空格填充 (padded) 以匹配其" "原始位置。" -#: ../../library/ast.rst:2299 +#: ../../library/ast.rst:2303 msgid "" "When you compile a node tree with :func:`compile`, the compiler expects :" "attr:`~ast.AST.lineno` and :attr:`~ast.AST.col_offset` attributes for every " @@ -3961,7 +4056,7 @@ msgstr "" "要存在。填入生成的節點相當繁瑣,因此該輔助工具透過將這些屬性設定為父節點的" "值,在尚未設定的地方遞迴地新增這些屬性。它從 *node* 開始遞迴地作用。" -#: ../../library/ast.rst:2308 +#: ../../library/ast.rst:2312 msgid "" "Increment the line number and end line number of each node in the tree " "starting at *node* by *n*. This is useful to \"move code\" to a different " @@ -3970,7 +4065,7 @@ msgstr "" "將樹中從 *node* 開始的每個節點的列號和結束列號增加 *n*。這對於「移動程式碼」" "到檔案中的不同位置很有用。" -#: ../../library/ast.rst:2315 +#: ../../library/ast.rst:2319 msgid "" "Copy source location (:attr:`~ast.AST.lineno`, :attr:`~ast.AST.col_offset`, :" "attr:`~ast.AST.end_lineno`, and :attr:`~ast.AST.end_col_offset`) from " @@ -3980,7 +4075,7 @@ msgstr "" "attr:`~ast.AST.end_lineno` 和 :attr:`~ast.AST.end_col_offset` )從 " "*old_node* 複製到 *new_node*,並回傳 *new_node* 。" -#: ../../library/ast.rst:2322 +#: ../../library/ast.rst:2326 msgid "" "Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields`` " "that is present on *node*." @@ -3988,7 +4083,7 @@ msgstr "" "為 *node* 上存在的 ``node._fields`` 中的每個欄位生成一個 ``(fieldname, " "value)`` 元組。" -#: ../../library/ast.rst:2328 +#: ../../library/ast.rst:2332 msgid "" "Yield all direct child nodes of *node*, that is, all fields that are nodes " "and all items of fields that are lists of nodes." @@ -3996,7 +4091,7 @@ msgstr "" "生成 *node* 的所有直接子節點,即作為節點的所有欄位以及作為節點串列欄位的所有" "項目。" -#: ../../library/ast.rst:2334 +#: ../../library/ast.rst:2338 msgid "" "Recursively yield all descendant nodes in the tree starting at *node* " "(including *node* itself), in no specified order. This is useful if you " @@ -4005,58 +4100,58 @@ msgstr "" "遞迴地生成樹中從 *node* 開始的所有後代節點(包括 *node* 本身),不按指定順" "序。如果你只想就地修改節點而不關心情境,這非常有用。" -#: ../../library/ast.rst:2341 +#: ../../library/ast.rst:2345 msgid "" "A node visitor base class that walks the abstract syntax tree and calls a " "visitor function for every node found. This function may return a value " "which is forwarded by the :meth:`visit` method." msgstr "" -"節點訪問者基底類別,它遍歷抽象語法樹並為找到的每個節點呼叫訪問者函式。該函式" +"節點瀏覽者基底類別,它遍歷抽象語法樹並為找到的每個節點呼叫瀏覽者函式。該函式" "可能會回傳一個由 :meth:`visit` 方法轉發的值。" -#: ../../library/ast.rst:2345 +#: ../../library/ast.rst:2349 msgid "" "This class is meant to be subclassed, with the subclass adding visitor " "methods." -msgstr "這個類別應該被子類別化,子類別新增訪問者方法。" +msgstr "這個類別應該被子類別化,子類別新增瀏覽者方法。" -#: ../../library/ast.rst:2350 +#: ../../library/ast.rst:2354 msgid "" "Visit a node. The default implementation calls the method called :samp:" "`self.visit_{classname}` where *classname* is the name of the node class, " "or :meth:`generic_visit` if that method doesn't exist." msgstr "" -"訪問一個節點。預設實作呼叫名為 :samp:`self.visit_{classname}` 的方法,其中 " +"瀏覽一個節點。預設實作呼叫名為 :samp:`self.visit_{classname}` 的方法,其中 " "*classname* 是節點類別的名稱,或者在該方法不存在時呼叫 :meth:" "`generic_visit`。" -#: ../../library/ast.rst:2356 +#: ../../library/ast.rst:2360 msgid "This visitor calls :meth:`visit` on all children of the node." -msgstr "該訪問者對該節點的所有子節點呼叫 :meth:`visit`。" +msgstr "該瀏覽者對該節點的所有子節點呼叫 :meth:`visit`。" -#: ../../library/ast.rst:2358 +#: ../../library/ast.rst:2362 msgid "" "Note that child nodes of nodes that have a custom visitor method won't be " "visited unless the visitor calls :meth:`generic_visit` or visits them itself." msgstr "" -"請注意,除非訪問者呼叫 :meth:`generic_visit` 或訪問它們本身,否則不會訪問具有" -"自定義訪問者方法的節點之子節點。" +"請注意,除非瀏覽者呼叫 :meth:`generic_visit` 或瀏覽它們本身,否則不會瀏覽具有" +"自定義瀏覽者方法的節點之子節點。" -#: ../../library/ast.rst:2364 +#: ../../library/ast.rst:2368 msgid "Handles all constant nodes." msgstr "處理所有常數節點。" -#: ../../library/ast.rst:2366 +#: ../../library/ast.rst:2370 msgid "" "Don't use the :class:`NodeVisitor` if you want to apply changes to nodes " "during traversal. For this a special visitor exists (:class:" "`NodeTransformer`) that allows modifications." msgstr "" "如果你想在遍歷期間將變更應用 (apply) 於節點,請不要使用 :class:" -"`NodeVisitor`。為此,有個允許修改的特殊遍歷訪問者工具 :class:" +"`NodeVisitor`。為此,有個允許修改的特殊遍歷瀏覽者工具 :class:" "`NodeTransformer`。" -#: ../../library/ast.rst:2372 +#: ../../library/ast.rst:2376 msgid "" "Methods :meth:`!visit_Num`, :meth:`!visit_Str`, :meth:`!visit_Bytes`, :meth:" "`!visit_NameConstant` and :meth:`!visit_Ellipsis` are deprecated now and " @@ -4067,13 +4162,13 @@ msgstr "" "visit_NameConstant` 和 :meth:`!visit_Ellipsis` 方法現已棄用,並且不會在未來的" "Python 版本中被呼叫。新增 :meth:`visit_Constant` 方法來處理所有常數節點。" -#: ../../library/ast.rst:2380 +#: ../../library/ast.rst:2384 msgid "" "A :class:`NodeVisitor` subclass that walks the abstract syntax tree and " "allows modification of nodes." msgstr "一個 :class:`NodeVisitor` 子類別,它會遍歷抽象語法樹並允許修改節點。" -#: ../../library/ast.rst:2383 +#: ../../library/ast.rst:2387 msgid "" "The :class:`NodeTransformer` will walk the AST and use the return value of " "the visitor methods to replace or remove the old node. If the return value " @@ -4081,11 +4176,11 @@ msgid "" "location, otherwise it is replaced with the return value. The return value " "may be the original node in which case no replacement takes place." msgstr "" -":class:`NodeTransformer` 將遍歷 AST 並使用訪問者方法的回傳值來替換或刪除舊節" -"點。如果訪問者方法的回傳值為 ``None``,則該節點將從其位置中刪除,否則將被替換" +":class:`NodeTransformer` 將遍歷 AST 並使用瀏覽者方法的回傳值來替換或刪除舊節" +"點。如果瀏覽者方法的回傳值為 ``None``,則該節點將從其位置中刪除,否則將被替換" "為回傳值。回傳值可能是原始節點,在這種情況下不會發生替換。" -#: ../../library/ast.rst:2389 +#: ../../library/ast.rst:2393 msgid "" "Here is an example transformer that rewrites all occurrences of name lookups " "(``foo``) to ``data['foo']``::" @@ -4093,7 +4188,7 @@ msgstr "" "下面是一個示範用的 transformer,它將查找所有出現名稱 (``foo``) 並改寫為 " "``data['foo']``: ::" -#: ../../library/ast.rst:2392 +#: ../../library/ast.rst:2396 msgid "" "class RewriteName(NodeTransformer):\n" "\n" @@ -4113,7 +4208,7 @@ msgstr "" " ctx=node.ctx\n" " )" -#: ../../library/ast.rst:2401 +#: ../../library/ast.rst:2405 msgid "" "Keep in mind that if the node you're operating on has child nodes you must " "either transform the child nodes yourself or call the :meth:`~ast." @@ -4122,16 +4217,16 @@ msgstr "" "請記住,如果你正在操作的節點有子節點,你必須自己轉換子節點或先呼叫該節點的 :" "meth:`~ast.NodeVisitor.generic_visit` 方法。" -#: ../../library/ast.rst:2405 +#: ../../library/ast.rst:2409 msgid "" "For nodes that were part of a collection of statements (that applies to all " "statement nodes), the visitor may also return a list of nodes rather than " "just a single node." msgstr "" -"對於屬於陳述式總集 (collection) 一部分的節點(適用於所有陳述式節點),訪問者" +"對於屬於陳述式總集 (collection) 一部分的節點(適用於所有陳述式節點),瀏覽者" "還可以回傳節點串列,而不僅僅是單個節點。" -#: ../../library/ast.rst:2409 +#: ../../library/ast.rst:2413 msgid "" "If :class:`NodeTransformer` introduces new nodes (that weren't part of " "original tree) without giving them location information (such as :attr:`~ast." @@ -4142,7 +4237,7 @@ msgstr "" "它們提供位置資訊(例如 :attr:`~ast.AST.lineno`\\ ),則應使用新的子樹呼叫 :" "func:`fix_missing_locations` 以重新計算位置資訊: ::" -#: ../../library/ast.rst:2414 +#: ../../library/ast.rst:2418 msgid "" "tree = ast.parse('foo', mode='eval')\n" "new_tree = fix_missing_locations(RewriteName().visit(tree))" @@ -4150,15 +4245,15 @@ msgstr "" "tree = ast.parse('foo', mode='eval')\n" "new_tree = fix_missing_locations(RewriteName().visit(tree))" -#: ../../library/ast.rst:2417 +#: ../../library/ast.rst:2421 msgid "Usually you use the transformer like this::" msgstr "你通常會像這樣使用 transformer: ::" -#: ../../library/ast.rst:2419 +#: ../../library/ast.rst:2423 msgid "node = YourTransformer().visit(node)" msgstr "node = YourTransformer().visit(node)" -#: ../../library/ast.rst:2424 +#: ../../library/ast.rst:2428 msgid "" "Return a formatted dump of the tree in *node*. This is mainly useful for " "debugging purposes. If *annotate_fields* is true (by default), the returned " @@ -4174,7 +4269,7 @@ msgstr "" "潔。預設情況下,不會傾印列號和行偏移量等屬性。如果需要,可以設定 " "*include_attributes* 為 true。" -#: ../../library/ast.rst:2432 +#: ../../library/ast.rst:2436 msgid "" "If *indent* is a non-negative integer or string, then the tree will be " "pretty-printed with that indent level. An indent level of 0, negative, or " @@ -4188,21 +4283,85 @@ msgstr "" "(預設值)代表選擇單列表示。使用正整數縮排可以在每個級別縮排相同數量的空格。" "如果 *indent* 是一個字串(例如 ``\"\\t\"``\\ ),則該字串用於縮排每個級別。" -#: ../../library/ast.rst:2439 +#: ../../library/ast.rst:2443 +msgid "" +"If *show_empty* is false (the default), optional empty lists will be omitted " +"from the output. Optional ``None`` values are always omitted." +msgstr "" +"如果 *show_empty* 為 false(預設值),則輸出中將省略可選的空串列。" +"可選的 ``None`` 值總是會被省略。" + +#: ../../library/ast.rst:2447 msgid "Added the *indent* option." msgstr "新增 *indent* 選項。" -#: ../../library/ast.rst:2446 +#: ../../library/ast.rst:2450 +msgid "Added the *show_empty* option." +msgstr "新增 *show_empty* 選項。" + +#: ../../library/ast.rst:2453 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\\\n" +"... async def f():\n" +"... await other_func()\n" +"... \"\"\"), indent=4, show_empty=True))\n" +"Module(\n" +" body=[\n" +" AsyncFunctionDef(\n" +" name='f',\n" +" args=arguments(\n" +" posonlyargs=[],\n" +" args=[],\n" +" kwonlyargs=[],\n" +" kw_defaults=[],\n" +" defaults=[]),\n" +" body=[\n" +" Expr(\n" +" value=Await(\n" +" value=Call(\n" +" func=Name(id='other_func', ctx=Load()),\n" +" args=[],\n" +" keywords=[])))],\n" +" decorator_list=[],\n" +" type_params=[])],\n" +" type_ignores=[])" +msgstr "" +">>> print(ast.dump(ast.parse(\"\"\"\\\n" +"... async def f():\n" +"... await other_func()\n" +"... \"\"\"), indent=4, show_empty=True))\n" +"Module(\n" +" body=[\n" +" AsyncFunctionDef(\n" +" name='f',\n" +" args=arguments(\n" +" posonlyargs=[],\n" +" args=[],\n" +" kwonlyargs=[],\n" +" kw_defaults=[],\n" +" defaults=[]),\n" +" body=[\n" +" Expr(\n" +" value=Await(\n" +" value=Call(\n" +" func=Name(id='other_func', ctx=Load()),\n" +" args=[],\n" +" keywords=[])))],\n" +" decorator_list=[],\n" +" type_params=[])],\n" +" type_ignores=[])" + +#: ../../library/ast.rst:2484 msgid "Compiler Flags" msgstr "編譯器旗標" -#: ../../library/ast.rst:2448 +#: ../../library/ast.rst:2486 msgid "" "The following flags may be passed to :func:`compile` in order to change " "effects on the compilation of a program:" msgstr "可以將以下旗標傳遞給 :func:`compile` 以變更對程式的編譯效果:" -#: ../../library/ast.rst:2453 +#: ../../library/ast.rst:2491 msgid "" "Enables support for top-level ``await``, ``async for``, ``async with`` and " "async comprehensions." @@ -4210,13 +4369,21 @@ msgstr "" "啟用對最高階 ``await``、``async for``、``async with`` 和非同步綜合運算的支" "援。" -#: ../../library/ast.rst:2460 +#: ../../library/ast.rst:2498 msgid "" "Generates and returns an abstract syntax tree instead of returning a " "compiled code object." msgstr "生成並回傳抽象語法樹,而不是回傳已編譯的程式碼物件。" -#: ../../library/ast.rst:2465 +#: ../../library/ast.rst:2503 +msgid "" +"The returned AST is optimized according to the *optimize* argument in :func:" +"`compile` or :func:`ast.parse`." +msgstr "" +"回傳的 AST 會根據 :func:`compile` 或 :func:`ast.parse` 中的 *optimize* 引數進" +"行最佳化。" + +#: ../../library/ast.rst:2510 msgid "" "Enables support for :pep:`484` and :pep:`526` style type comments (``# type: " "``, ``# type: ignore ``)." @@ -4224,47 +4391,47 @@ msgstr "" "啟用對 :pep:`484` 和 :pep:`526` 樣式型別註釋的支援 (``# type: ``, ``# " "type: ignore ``)。" -#: ../../library/ast.rst:2474 +#: ../../library/ast.rst:2519 msgid "Command-Line Usage" msgstr "命令列用法" -#: ../../library/ast.rst:2478 +#: ../../library/ast.rst:2523 msgid "" "The :mod:`ast` module can be executed as a script from the command line. It " "is as simple as:" msgstr ":mod:`ast` 模組可以作為腳本從命令列執行,可以像這樣簡單地做到:" -#: ../../library/ast.rst:2481 +#: ../../library/ast.rst:2526 msgid "python -m ast [-m ] [-a] [infile]" msgstr "python -m ast [-m ] [-a] [infile]" -#: ../../library/ast.rst:2485 +#: ../../library/ast.rst:2530 msgid "The following options are accepted:" msgstr "以下選項可被接受:" -#: ../../library/ast.rst:2491 +#: ../../library/ast.rst:2536 msgid "Show the help message and exit." msgstr "顯示幫助訊息並退出。" -#: ../../library/ast.rst:2496 +#: ../../library/ast.rst:2541 msgid "" "Specify what kind of code must be compiled, like the *mode* argument in :" "func:`parse`." msgstr "指定必須編譯哪種類型的程式碼,像是 :func:`parse` 中的 *mode* 引數。" -#: ../../library/ast.rst:2501 +#: ../../library/ast.rst:2546 msgid "Don't parse type comments." msgstr "不要剖析型別註解。" -#: ../../library/ast.rst:2505 +#: ../../library/ast.rst:2550 msgid "Include attributes such as line numbers and column offsets." msgstr "包括列號和行偏移量等屬性。" -#: ../../library/ast.rst:2510 +#: ../../library/ast.rst:2555 msgid "Indentation of nodes in AST (number of spaces)." msgstr "AST 中節點的縮進(空格數)。" -#: ../../library/ast.rst:2512 +#: ../../library/ast.rst:2557 msgid "" "If :file:`infile` is specified its contents are parsed to AST and dumped to " "stdout. Otherwise, the content is read from stdin." @@ -4272,7 +4439,7 @@ msgstr "" "如果指定了 :file:`infile`,則其內容將被剖析為 AST 並傾印 (dump) 到 stdout。否" "則會從 stdin 讀取內容。" -#: ../../library/ast.rst:2518 +#: ../../library/ast.rst:2563 msgid "" "`Green Tree Snakes `_, an external " "documentation resource, has good details on working with Python ASTs." @@ -4280,7 +4447,7 @@ msgstr "" "`Green Tree Snakes `_ 是一個外部文件" "資源,提供了有關使用 Python AST 的詳細資訊。" -#: ../../library/ast.rst:2521 +#: ../../library/ast.rst:2566 msgid "" "`ASTTokens `_ " "annotates Python ASTs with the positions of tokens and text in the source " @@ -4291,7 +4458,7 @@ msgstr "" "用生成它們的原始碼中的標記和文本的位置來註釋 Python AST。這對於進行原始碼轉換" "的工具很有幫助。" -#: ../../library/ast.rst:2526 +#: ../../library/ast.rst:2571 msgid "" "`leoAst.py `_ unifies the token-based and parse-tree-based views of python programs " @@ -4301,7 +4468,7 @@ msgstr "" "py>`_ 透過在 token 和 ast 節點之間插入雙向鏈結,統一了 python 程式的基於 " "token 和基於剖析樹的視圖。" -#: ../../library/ast.rst:2531 +#: ../../library/ast.rst:2576 msgid "" "`LibCST `_ parses code as a Concrete Syntax " "Tree that looks like an ast tree and keeps all formatting details. It's " @@ -4311,7 +4478,7 @@ msgstr "" "(Concrete Syntax Tree),看起來像 ast 樹並保留所有格式詳細資訊。它對於建置自動" "重構 (codemod) 應用程式和 linter 非常有用。" -#: ../../library/ast.rst:2536 +#: ../../library/ast.rst:2581 msgid "" "`Parso `_ is a Python parser that supports " "error recovery and round-trip parsing for different Python versions (in " diff --git a/library/asynchat.po b/library/asynchat.po new file mode 100644 index 0000000000..cd03892c96 --- /dev/null +++ b/library/asynchat.po @@ -0,0 +1,43 @@ +# Copyright (C) 2001-2024, Python Software Foundation +# This file is distributed under the same license as the Python package. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.13\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-18 00:15+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" +"Language: zh_TW\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../../library/asynchat.rst:2 +msgid ":mod:`!asynchat` --- Asynchronous socket command/response handler" +msgstr ":mod:`!asynchat` --- 非同步 socket 指令/回應處理函式" + +#: ../../library/asynchat.rst:10 +msgid "" +"This module is no longer part of the Python standard library. It was :ref:" +"`removed in Python 3.12 ` after being deprecated in " +"Python 3.6. The removal was decided in :pep:`594`." +msgstr "" +"這個模組已不再是 Python 標準函式庫的一部分。它在 Python 3.6 中被棄用,並\\ :" +"ref:`已在 Python 3.12 中被移除 `。它的移除是在 :pep:" +"`594` 中決定的。" + +#: ../../library/asynchat.rst:14 +msgid "Applications should use the :mod:`asyncio` module instead." +msgstr "應用程式應改用 :mod:`asyncio` 模組。" + +#: ../../library/asynchat.rst:16 +msgid "" +"The last version of Python that provided the :mod:`!asynchat` module was " +"`Python 3.11 `_." +msgstr "" +"最後提供 :mod:`!asynchat` 模組的 Python 版本是 `Python 3.11 `_。" diff --git a/library/asyncio-api-index.po b/library/asyncio-api-index.po index a69cf76a68..dee0c33f50 100644 --- a/library/asyncio-api-index.po +++ b/library/asyncio-api-index.po @@ -5,7 +5,7 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2022-10-31 08:13+0000\n" "PO-Revision-Date: 2022-01-27 21:25+0800\n" @@ -87,7 +87,7 @@ msgstr ":func:`current_task`" #: ../../library/asyncio-api-index.rst:39 msgid "Return the current Task." -msgstr "回傳當前 Task 物件。" +msgstr "回傳目前 Task 物件。" #: ../../library/asyncio-api-index.rst:41 msgid ":func:`all_tasks`" @@ -341,7 +341,7 @@ msgstr "傳送網路資料的高階 async/await 物件。" #: ../../library/asyncio-api-index.rst:170 msgid ":ref:`Example TCP client `." -msgstr ":ref:`TCP 客戶端範例 `。" +msgstr ":ref:`TCP 用戶端範例 `。" #: ../../library/asyncio-api-index.rst:172 msgid "See also the :ref:`streams APIs ` documentation." diff --git a/library/asyncio-dev.po b/library/asyncio-dev.po index 97a689f12a..ca430f7225 100644 --- a/library/asyncio-dev.po +++ b/library/asyncio-dev.po @@ -6,9 +6,9 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2023-02-18 14:17+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -101,15 +101,6 @@ msgstr "啟用除錯模式時:" #: ../../library/asyncio-dev.rst:49 msgid "" -"asyncio checks for :ref:`coroutines that were not awaited ` and logs them; this mitigates the \"forgotten await\" " -"pitfall." -msgstr "" -"asyncio 會檢查\\ :ref:`未被等待的協程 `\\ 並" -"記錄他們;這會減輕\"被遺忘的等待 (forgotten await)\" 問題。" - -#: ../../library/asyncio-dev.rst:53 -msgid "" "Many non-threadsafe asyncio APIs (such as :meth:`loop.call_soon` and :meth:" "`loop.call_at` methods) raise an exception if they are called from a wrong " "thread." @@ -118,7 +109,7 @@ msgstr "" "call_soon` 和 :meth:`loop.call_at` 方法),如果從錯誤的執行緒呼叫就會引發例" "外。" -#: ../../library/asyncio-dev.rst:57 +#: ../../library/asyncio-dev.rst:53 msgid "" "The execution time of the I/O selector is logged if it takes too long to " "perform an I/O operation." @@ -126,7 +117,7 @@ msgstr "" "如果執行一個 I/O 操作花費的時間太長,則將 I/O 選擇器 (selector) 的執行時間記" "錄到日誌中。" -#: ../../library/asyncio-dev.rst:60 +#: ../../library/asyncio-dev.rst:56 msgid "" "Callbacks taking longer than 100 milliseconds are logged. The :attr:`loop." "slow_callback_duration` attribute can be used to set the minimum execution " @@ -136,11 +127,11 @@ msgstr "" "slow_callback_duration` 可用於設定以秒為單位的最小執行持續時間,超過這個值執" "行時間就會被視為\"緩慢\"。" -#: ../../library/asyncio-dev.rst:68 +#: ../../library/asyncio-dev.rst:64 msgid "Concurrency and Multithreading" msgstr "並行性和多執行緒 (Concurrency and Multithreading)" -#: ../../library/asyncio-dev.rst:70 +#: ../../library/asyncio-dev.rst:66 msgid "" "An event loop runs in a thread (typically the main thread) and executes all " "callbacks and Tasks in its thread. While a Task is running in the event " @@ -153,7 +144,7 @@ msgstr "" "運行。當一個 Task 執行一個 ``await`` 運算式時,正在執行的 Task 會被暫停,而事" "件迴圈會執行下一個 Task。" -#: ../../library/asyncio-dev.rst:76 +#: ../../library/asyncio-dev.rst:72 msgid "" "To schedule a :term:`callback` from another OS thread, the :meth:`loop." "call_soon_threadsafe` method should be used. Example::" @@ -161,11 +152,11 @@ msgstr "" "要從不同的 OS 執行緒為一個 :term:`callback` 排程,應該使用 :meth:`loop." "call_soon_threadsafe` 方法。例如: ::" -#: ../../library/asyncio-dev.rst:79 +#: ../../library/asyncio-dev.rst:75 msgid "loop.call_soon_threadsafe(callback, *args)" msgstr "loop.call_soon_threadsafe(callback, *args)" -#: ../../library/asyncio-dev.rst:81 +#: ../../library/asyncio-dev.rst:77 msgid "" "Almost all asyncio objects are not thread safe, which is typically not a " "problem unless there is code that works with them from outside of a Task or " @@ -176,11 +167,11 @@ msgstr "" "在 Task 或回呼函式之外有程式需要和它們一起運作。如果需要這樣的程式來呼叫低階 " "asyncio API,應該使用 :meth:`loop.call_soon_threadsafe` 方法,例如: ::" -#: ../../library/asyncio-dev.rst:87 +#: ../../library/asyncio-dev.rst:83 msgid "loop.call_soon_threadsafe(fut.cancel)" msgstr "loop.call_soon_threadsafe(fut.cancel)" -#: ../../library/asyncio-dev.rst:89 +#: ../../library/asyncio-dev.rst:85 msgid "" "To schedule a coroutine object from a different OS thread, the :func:" "`run_coroutine_threadsafe` function should be used. It returns a :class:" @@ -190,7 +181,7 @@ msgstr "" "`run_coroutine_threadsafe` 函式。它會回傳一個 :class:`concurrent.futures." "Future` 以存取結果: ::" -#: ../../library/asyncio-dev.rst:93 +#: ../../library/asyncio-dev.rst:89 msgid "" "async def coro_func():\n" " return await asyncio.sleep(1, 42)\n" @@ -202,11 +193,11 @@ msgid "" "result = future.result()" msgstr "" -#: ../../library/asyncio-dev.rst:102 +#: ../../library/asyncio-dev.rst:98 msgid "To handle signals the event loop must be run in the main thread." msgstr "為了能夠處理訊號,事件迴圈必須於主執行緒中運行。" -#: ../../library/asyncio-dev.rst:105 +#: ../../library/asyncio-dev.rst:101 msgid "" "The :meth:`loop.run_in_executor` method can be used with a :class:" "`concurrent.futures.ThreadPoolExecutor` to execute blocking code in a " @@ -217,7 +208,7 @@ msgstr "" "ThreadPoolExecutor` 一起使用,這能夠在作業系統上另一個不同的執行緒中執行阻塞" "程式,且避免阻塞執行事件迴圈的執行緒。" -#: ../../library/asyncio-dev.rst:110 +#: ../../library/asyncio-dev.rst:106 msgid "" "There is currently no way to schedule coroutines or callbacks directly from " "a different process (such as one started with :mod:`multiprocessing`). The :" @@ -237,11 +228,11 @@ msgstr "" "run_in_executor` 方法也可和 :class:`concurrent.futures.ProcessPoolExecutor` " "搭配使用,以在另一個行程中執行程式。" -#: ../../library/asyncio-dev.rst:124 +#: ../../library/asyncio-dev.rst:120 msgid "Running Blocking Code" msgstr "執行阻塞的程式" -#: ../../library/asyncio-dev.rst:126 +#: ../../library/asyncio-dev.rst:122 msgid "" "Blocking (CPU-bound) code should not be called directly. For example, if a " "function performs a CPU-intensive calculation for 1 second, all concurrent " @@ -250,7 +241,7 @@ msgstr "" "不應該直接呼叫阻塞(CPU 密集型)程式。例如一個執行 1 秒 CPU 密集型計算的函" "式,那麼所有並行非同步 Tasks 和 IO 操作都會被延遲 1 秒。" -#: ../../library/asyncio-dev.rst:131 +#: ../../library/asyncio-dev.rst:127 msgid "" "An executor can be used to run a task in a different thread or even in a " "different process to avoid blocking the OS thread with the event loop. See " @@ -260,11 +251,11 @@ msgstr "" "以避免使用事件迴圈阻塞 OS 執行緒。詳情請見 :meth:`loop.run_in_executor` 方" "法。" -#: ../../library/asyncio-dev.rst:140 +#: ../../library/asyncio-dev.rst:136 msgid "Logging" msgstr "日誌記錄" -#: ../../library/asyncio-dev.rst:142 +#: ../../library/asyncio-dev.rst:138 msgid "" "asyncio uses the :mod:`logging` module and all logging is performed via the " "``\"asyncio\"`` logger." @@ -272,17 +263,17 @@ msgstr "" "asyncio 使用 :mod:`logging` 模組,所有日誌記錄都是透過 ``\"asyncio\"`` " "logger 執行的。" -#: ../../library/asyncio-dev.rst:145 +#: ../../library/asyncio-dev.rst:141 msgid "" "The default log level is :py:const:`logging.INFO`, which can be easily " "adjusted::" msgstr "日誌級別被預設為 :py:const:`logging.INFO`,它可以很容易地被調整: ::" -#: ../../library/asyncio-dev.rst:148 +#: ../../library/asyncio-dev.rst:144 msgid "logging.getLogger(\"asyncio\").setLevel(logging.WARNING)" msgstr "logging.getLogger(\"asyncio\").setLevel(logging.WARNING)" -#: ../../library/asyncio-dev.rst:151 +#: ../../library/asyncio-dev.rst:147 msgid "" "Network logging can block the event loop. It is recommended to use a " "separate thread for handling logs or use non-blocking IO. For example, see :" @@ -291,11 +282,11 @@ msgstr "" "網路日誌記錄可能會阻塞事件迴圈。建議使用獨立的執行緒來處理日誌或使用非阻塞 " "IO,範例請參見 :ref:`blocking-handlers`。" -#: ../../library/asyncio-dev.rst:159 +#: ../../library/asyncio-dev.rst:155 msgid "Detect never-awaited coroutines" msgstr "偵測從未被等待的 (never-awaited) 協程" -#: ../../library/asyncio-dev.rst:161 +#: ../../library/asyncio-dev.rst:157 msgid "" "When a coroutine function is called, but not awaited (e.g. ``coro()`` " "instead of ``await coro()``) or the coroutine is not scheduled with :meth:" @@ -305,7 +296,7 @@ msgstr "" "者協程沒有透過 :meth:`asyncio.create_task` 被排程,asyncio 將會發出 :exc:" "`RuntimeWarning`: ::" -#: ../../library/asyncio-dev.rst:166 +#: ../../library/asyncio-dev.rst:162 msgid "" "import asyncio\n" "\n" @@ -318,11 +309,11 @@ msgid "" "asyncio.run(main())" msgstr "" -#: ../../library/asyncio-dev.rst:176 ../../library/asyncio-dev.rst:221 +#: ../../library/asyncio-dev.rst:172 ../../library/asyncio-dev.rst:217 msgid "Output::" msgstr "輸出: ::" -#: ../../library/asyncio-dev.rst:178 +#: ../../library/asyncio-dev.rst:174 msgid "" "test.py:7: RuntimeWarning: coroutine 'test' was never awaited\n" " test()" @@ -330,11 +321,11 @@ msgstr "" "test.py:7: RuntimeWarning: coroutine 'test' was never awaited\n" " test()" -#: ../../library/asyncio-dev.rst:181 ../../library/asyncio-dev.rst:237 +#: ../../library/asyncio-dev.rst:177 ../../library/asyncio-dev.rst:233 msgid "Output in debug mode::" msgstr "除錯模式中的輸出: ::" -#: ../../library/asyncio-dev.rst:183 +#: ../../library/asyncio-dev.rst:179 msgid "" "test.py:7: RuntimeWarning: coroutine 'test' was never awaited\n" "Coroutine created at (most recent call last)\n" @@ -358,14 +349,14 @@ msgstr "" " test()\n" " test()" -#: ../../library/asyncio-dev.rst:194 +#: ../../library/asyncio-dev.rst:190 msgid "" "The usual fix is to either await the coroutine or call the :meth:`asyncio." "create_task` function::" msgstr "" "常用的修復方法是去等待協程或者呼叫 :meth:`asyncio.create_task` 函式: ::" -#: ../../library/asyncio-dev.rst:197 +#: ../../library/asyncio-dev.rst:193 msgid "" "async def main():\n" " await test()" @@ -373,11 +364,11 @@ msgstr "" "async def main():\n" " await test()" -#: ../../library/asyncio-dev.rst:202 +#: ../../library/asyncio-dev.rst:198 msgid "Detect never-retrieved exceptions" -msgstr "偵測從未被獲取的 (never-retrieved) 例外" +msgstr "偵測從未被取得的 (never-retrieved) 例外" -#: ../../library/asyncio-dev.rst:204 +#: ../../library/asyncio-dev.rst:200 msgid "" "If a :meth:`Future.set_exception` is called but the Future object is never " "awaited on, the exception would never be propagated to the user code. In " @@ -388,11 +379,11 @@ msgstr "" "傳播 (propagate) 到使用者程式。在這種情況下,當 Future 物件被垃圾回收 " "(garbage collected) 時,asyncio 將發出一則日誌訊息。" -#: ../../library/asyncio-dev.rst:209 +#: ../../library/asyncio-dev.rst:205 msgid "Example of an unhandled exception::" msgstr "未處理例外的例子: ::" -#: ../../library/asyncio-dev.rst:211 +#: ../../library/asyncio-dev.rst:207 msgid "" "import asyncio\n" "\n" @@ -414,7 +405,7 @@ msgstr "" "\n" "asyncio.run(main())" -#: ../../library/asyncio-dev.rst:223 +#: ../../library/asyncio-dev.rst:219 msgid "" "Task exception was never retrieved\n" "future: \n" @@ -434,7 +425,7 @@ msgstr "" " raise Exception(\"not consumed\")\n" "Exception: not consumed" -#: ../../library/asyncio-dev.rst:232 +#: ../../library/asyncio-dev.rst:228 msgid "" ":ref:`Enable the debug mode ` to get the traceback where " "the task was created::" @@ -442,11 +433,11 @@ msgstr "" ":ref:`啟用除錯模式 `\\ 以取得任務建立處的追蹤資訊 " "(traceback): ::" -#: ../../library/asyncio-dev.rst:235 +#: ../../library/asyncio-dev.rst:231 msgid "asyncio.run(main(), debug=True)" msgstr "asyncio.run(main(), debug=True)" -#: ../../library/asyncio-dev.rst:239 +#: ../../library/asyncio-dev.rst:235 msgid "" "Task exception was never retrieved\n" "future: \n" diff --git a/library/asyncio-eventloop.po b/library/asyncio-eventloop.po index 80d65813b7..26091449c9 100644 --- a/library/asyncio-eventloop.po +++ b/library/asyncio-eventloop.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2022-02-20 12:36+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -68,7 +67,7 @@ msgstr "以下的低階函式可用於取得、設置或建立事件迴圈:" #: ../../library/asyncio-eventloop.rst:34 msgid "Return the running event loop in the current OS thread." -msgstr "在當前作業系統執行緒中回傳正在運行的事件迴圈。" +msgstr "在目前作業系統執行緒中回傳正在運行的事件迴圈。" #: ../../library/asyncio-eventloop.rst:36 msgid "Raise a :exc:`RuntimeError` if there is no running event loop." @@ -122,12 +121,12 @@ msgid "" "Deprecation warning is emitted if there is no current event loop. In some " "future Python release this will become an error." msgstr "" -"如果沒有當前事件迴圈,則會發出棄用警告。在未來的某個 Python 發行版中,這將變" +"如果沒有目前事件迴圈,則會發出棄用警告。在未來的某個 Python 發行版中,這將變" "成錯誤。" #: ../../library/asyncio-eventloop.rst:68 msgid "Set *loop* as the current event loop for the current OS thread." -msgstr "將 *loop* 設置為當前 OS 執行緒的當前事件迴圈。" +msgstr "將 *loop* 設置為目前 OS 執行緒的目前事件迴圈。" #: ../../library/asyncio-eventloop.rst:72 msgid "Create and return a new event loop object." @@ -229,8 +228,8 @@ msgid "" "and then exit." msgstr "" "如果在呼叫 :meth:`run_forever` 之前呼叫 :meth:`stop`,則迴圈將使用超時為零的" -"方式輪詢 I/O 選擇器,運行所有回應 I/O 事件(以及已經排程的事件)的回呼函數," -"然後退出。" +"方式輪詢 I/O 選擇器,運行所有回應 I/O 事件(以及已經排程的事件)的回呼,然後" +"退出。" #: ../../library/asyncio-eventloop.rst:134 msgid "" @@ -240,7 +239,7 @@ msgid "" "will run the next time :meth:`run_forever` or :meth:`run_until_complete` is " "called." msgstr "" -"如果在 :meth:`run_forever` 運行時呼叫 :meth:`stop`,則迴圈將運行當前批次的回" +"如果在 :meth:`run_forever` 運行時呼叫 :meth:`stop`,則迴圈將運行目前批次的回" "呼函式,然後退出。請注意,由回呼函式排程的新回呼在此情況下不會運行;而是在下" "次呼叫 :meth:`run_forever` 或 :meth:`run_until_complete` 時運行。" @@ -250,7 +249,7 @@ msgstr "停止事件迴圈。" #: ../../library/asyncio-eventloop.rst:146 msgid "Return ``True`` if the event loop is currently running." -msgstr "如果事件迴圈當前正在運行,則回傳 ``True``。" +msgstr "如果事件迴圈目前正在運行,則回傳 ``True``。" #: ../../library/asyncio-eventloop.rst:150 msgid "Return ``True`` if the event loop was closed." @@ -278,30 +277,30 @@ msgid "" "called after the event loop is closed." msgstr "此方法是冪等且不可逆的。在事件迴圈關閉後不應呼叫其他方法。" -#: ../../library/asyncio-eventloop.rst:167 +#: ../../library/asyncio-eventloop.rst:168 msgid "" "Schedule all currently open :term:`asynchronous generator` objects to close " "with an :meth:`~agen.aclose` 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." msgstr "" -"排程所有當前打開的\\ :term:`非同步產生器 `\\ 物件使" +"排程所有目前打開的\\ :term:`非同步產生器 `\\ 物件使" "用 :meth:`~agen.aclose` 呼叫來關閉。呼叫此方法後,如果疊代新的非同步產生器," "事件迴圈將發出警告。應該使用此方法可靠地完成所有已排程的非同步產生器。" -#: ../../library/asyncio-eventloop.rst:173 +#: ../../library/asyncio-eventloop.rst:174 msgid "" "Note that there is no need to call this function when :func:`asyncio.run` is " "used." msgstr "請注意,使用 :func:`asyncio.run` 時不需要呼叫此函式。" -#: ../../library/asyncio-eventloop.rst:176 -#: ../../library/asyncio-eventloop.rst:1253 -#: ../../library/asyncio-eventloop.rst:1671 +#: ../../library/asyncio-eventloop.rst:177 +#: ../../library/asyncio-eventloop.rst:1320 +#: ../../library/asyncio-eventloop.rst:1769 msgid "Example::" msgstr "範例: ::" -#: ../../library/asyncio-eventloop.rst:178 +#: ../../library/asyncio-eventloop.rst:179 msgid "" "try:\n" " loop.run_forever()\n" @@ -315,7 +314,7 @@ msgstr "" " loop.run_until_complete(loop.shutdown_asyncgens())\n" " loop.close()" -#: ../../library/asyncio-eventloop.rst:188 +#: ../../library/asyncio-eventloop.rst:190 msgid "" "Schedule the closure of the default executor and wait for it to join all of " "the threads in the :class:`~concurrent.futures.ThreadPoolExecutor`. Once " @@ -326,7 +325,7 @@ msgstr "" "ThreadPoolExecutor` 中的所有執行緒。一旦呼叫了此方法,使用預設執行器與 :meth:" "`loop.run_in_executor` 將引發 :exc:`RuntimeError`。" -#: ../../library/asyncio-eventloop.rst:194 +#: ../../library/asyncio-eventloop.rst:196 msgid "" "The *timeout* parameter specifies the amount of time (in :class:`float` " "seconds) the executor will be given to finish joining. With the default, " @@ -335,7 +334,7 @@ msgstr "" "*timeout* 參數指定執行器完成加入所需的時間(以 :class:`float` 秒為單位)。預" "設情況下為 ``None``,不會限制執行器所花費的時間。" -#: ../../library/asyncio-eventloop.rst:199 +#: ../../library/asyncio-eventloop.rst:201 msgid "" "If the *timeout* is reached, a :exc:`RuntimeWarning` is emitted and the " "default executor is terminated without waiting for its threads to finish " @@ -344,7 +343,7 @@ msgstr "" "如果達到 *timeout*,將發出 :exc:`RuntimeWarning` 警告,預設執行器將立即終止," "不等待其執行緒完成加入。" -#: ../../library/asyncio-eventloop.rst:205 +#: ../../library/asyncio-eventloop.rst:207 msgid "" "Do not call this method when using :func:`asyncio.run`, as the latter " "handles default executor shutdown automatically." @@ -352,47 +351,47 @@ msgstr "" "使用 :func:`asyncio.run` 時請勿呼叫此方法,因為後者會自動處理預設執行器的關" "閉。" -#: ../../library/asyncio-eventloop.rst:210 +#: ../../library/asyncio-eventloop.rst:212 msgid "Added the *timeout* parameter." msgstr "加入 *timeout* 參數。" -#: ../../library/asyncio-eventloop.rst:214 +#: ../../library/asyncio-eventloop.rst:216 msgid "Scheduling callbacks" msgstr "排程回呼函式" -#: ../../library/asyncio-eventloop.rst:218 +#: ../../library/asyncio-eventloop.rst:220 msgid "" "Schedule the *callback* :term:`callback` to be called with *args* arguments " "at the next iteration of the event loop." msgstr "" "在事件迴圈的下一次疊代中排程以 *args* 引數呼叫 *callback* :term:`callback`。" -#: ../../library/asyncio-eventloop.rst:221 +#: ../../library/asyncio-eventloop.rst:223 msgid "" "Return an instance of :class:`asyncio.Handle`, which can be used later to " "cancel the callback." msgstr "回傳 :class:`asyncio.Handle` 的實例,稍後可以用於取消回呼函式。" -#: ../../library/asyncio-eventloop.rst:224 +#: ../../library/asyncio-eventloop.rst:226 msgid "" "Callbacks are called in the order in which they are registered. Each " "callback will be called exactly once." msgstr "回呼函式按照其註冊的順序呼叫。每個回呼函式將被呼叫恰好一次。" -#: ../../library/asyncio-eventloop.rst:227 +#: ../../library/asyncio-eventloop.rst:229 msgid "" "The optional keyword-only *context* argument specifies a custom :class:" "`contextvars.Context` for the *callback* to run in. Callbacks use the " "current context when no *context* is provided." msgstr "" "選用的僅限關鍵字引數 *context* 指定了要給 *callback* 執行的自定義 :class:" -"`contextvars.Context`。當未提供 *context* 時,回呼函式使用當前情境。" +"`contextvars.Context`。當未提供 *context* 時,回呼函式使用目前情境。" -#: ../../library/asyncio-eventloop.rst:231 +#: ../../library/asyncio-eventloop.rst:233 msgid "Unlike :meth:`call_soon_threadsafe`, this method is not thread-safe." msgstr "與 :meth:`call_soon_threadsafe` 不同,此方法不是執行緒安全的。" -#: ../../library/asyncio-eventloop.rst:235 +#: ../../library/asyncio-eventloop.rst:237 msgid "" "A thread-safe variant of :meth:`call_soon`. When scheduling callbacks from " "another thread, this function *must* be used, since :meth:`call_soon` is not " @@ -401,7 +400,14 @@ msgstr "" "這是 :meth:`call_soon` 的執行緒安全變體。當從另一個執行緒排程回呼函式時,*必" "須*\\ 使用此函式,因為 :meth:`call_soon` 不是執行緒安全的。" -#: ../../library/asyncio-eventloop.rst:239 +#: ../../library/asyncio-eventloop.rst:241 +msgid "" +"This function is safe to be called from a reentrant context or signal " +"handler, however, it is not safe or fruitful to use the returned handle in " +"such contexts." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:244 msgid "" "Raises :exc:`RuntimeError` if called on a loop that's been closed. This can " "happen on a secondary thread when the main application is shutting down." @@ -409,21 +415,21 @@ msgstr "" "如果在已關閉的迴圈上呼叫,則引發 :exc:`RuntimeError`。在主應用程式關閉時,這" "可能發生在次要執行緒上。" -#: ../../library/asyncio-eventloop.rst:243 +#: ../../library/asyncio-eventloop.rst:248 msgid "" "See the :ref:`concurrency and multithreading ` " "section of the documentation." msgstr "請參閱文件的\\ :ref:`並行和多執行緒 `\\ 部分。" -#: ../../library/asyncio-eventloop.rst:246 -#: ../../library/asyncio-eventloop.rst:296 -#: ../../library/asyncio-eventloop.rst:316 +#: ../../library/asyncio-eventloop.rst:251 +#: ../../library/asyncio-eventloop.rst:301 +#: ../../library/asyncio-eventloop.rst:321 msgid "" "The *context* keyword-only parameter was added. See :pep:`567` for more " "details." msgstr "新增了 *context* 僅限關鍵字參數。詳細資訊請參閱 :pep:`567`。" -#: ../../library/asyncio-eventloop.rst:254 +#: ../../library/asyncio-eventloop.rst:259 msgid "" "Most :mod:`asyncio` scheduling functions don't allow passing keyword " "arguments. To do that, use :func:`functools.partial`::" @@ -431,14 +437,17 @@ msgstr "" "大多數 :mod:`asyncio` 排程函式不允許傳遞關鍵字引數。要傳遞關鍵字引數,請使" "用 :func:`functools.partial`: ::" -#: ../../library/asyncio-eventloop.rst:257 +#: ../../library/asyncio-eventloop.rst:262 msgid "" "# will schedule \"print(\"Hello\", flush=True)\"\n" "loop.call_soon(\n" " functools.partial(print, \"Hello\", flush=True))" msgstr "" +"# 將會排程 \"print(\"Hello\", flush=True)\"\n" +"loop.call_soon(\n" +" functools.partial(print, \"Hello\", flush=True))" -#: ../../library/asyncio-eventloop.rst:261 +#: ../../library/asyncio-eventloop.rst:266 msgid "" "Using partial objects is usually more convenient than using lambdas, as " "asyncio can render partial objects better in debug and error messages." @@ -446,11 +455,11 @@ msgstr "" "通常使用 partial 物件比使用 lambda 更方便,因為 asyncio 可以在除錯和錯誤訊息" "中更好地呈現 partial 物件。" -#: ../../library/asyncio-eventloop.rst:269 +#: ../../library/asyncio-eventloop.rst:274 msgid "Scheduling delayed callbacks" msgstr "排程延遲的回呼函式" -#: ../../library/asyncio-eventloop.rst:271 +#: ../../library/asyncio-eventloop.rst:276 msgid "" "Event loop provides mechanisms to schedule callback functions to be called " "at some point in the future. Event loop uses monotonic clocks to track time." @@ -458,20 +467,20 @@ msgstr "" "事件迴圈提供為回呼函式排程在將來某個時間點才呼叫的機制。事件迴圈使用了單調時" "鐘來追蹤時間。" -#: ../../library/asyncio-eventloop.rst:278 +#: ../../library/asyncio-eventloop.rst:283 msgid "" "Schedule *callback* to be called after the given *delay* number of seconds " "(can be either an int or a float)." msgstr "排程 *callback* 在給定的 *delay* 秒數後呼叫(可以是整數或浮點數)。" -#: ../../library/asyncio-eventloop.rst:281 -#: ../../library/asyncio-eventloop.rst:313 +#: ../../library/asyncio-eventloop.rst:286 +#: ../../library/asyncio-eventloop.rst:318 msgid "" "An instance of :class:`asyncio.TimerHandle` is returned which can be used to " "cancel the callback." msgstr "回傳 :class:`asyncio.TimerHandle` 的實例,可用於取消回呼函式。" -#: ../../library/asyncio-eventloop.rst:284 +#: ../../library/asyncio-eventloop.rst:289 msgid "" "*callback* will be called exactly once. If two callbacks are scheduled for " "exactly the same time, the order in which they are called is undefined." @@ -479,7 +488,7 @@ msgstr "" "*callback* 將只被呼叫恰好一次。如果有兩個回呼函式被排程在完全相同的時間,則其" "呼叫順序是不定的。" -#: ../../library/asyncio-eventloop.rst:288 +#: ../../library/asyncio-eventloop.rst:293 msgid "" "The optional positional *args* will be passed to the callback when it is " "called. If you want the callback to be called with keyword arguments use :" @@ -488,16 +497,16 @@ msgstr "" "可選的位置引數 *args* 將在呼叫回呼函式時傳遞。如果要使用關鍵字引數呼叫回呼函" "數,請使用 :func:`functools.partial`。" -#: ../../library/asyncio-eventloop.rst:292 +#: ../../library/asyncio-eventloop.rst:297 msgid "" "An optional keyword-only *context* argument allows specifying a custom :" "class:`contextvars.Context` for the *callback* to run in. The current " "context is used when no *context* is provided." msgstr "" "可選的僅限關鍵字 *context* 引數允許為 *callback* 指定自定義的 :class:" -"`contextvars.Context` 以提供運行。當未提供 *context* 時,將使用當前情境。" +"`contextvars.Context` 以提供運行。當未提供 *context* 時,將使用目前情境。" -#: ../../library/asyncio-eventloop.rst:300 +#: ../../library/asyncio-eventloop.rst:305 msgid "" "In Python 3.7 and earlier with the default event loop implementation, the " "*delay* could not exceed one day. This has been fixed in Python 3.8." @@ -505,7 +514,7 @@ msgstr "" "在 Python 3.7 及更早版本中,使用預設事件迴圈實作時,*delay* 不能超過一天。這" "在 Python 3.8 中已經修復。" -#: ../../library/asyncio-eventloop.rst:307 +#: ../../library/asyncio-eventloop.rst:312 msgid "" "Schedule *callback* to be called at the given absolute timestamp *when* (an " "int or a float), using the same time reference as :meth:`loop.time`." @@ -513,26 +522,26 @@ msgstr "" "排程 *callback* 在給定的絕對時間戳 *when* (整數或浮點數)處呼叫,使用與 :" "meth:`loop.time` 相同的時間參照。" -#: ../../library/asyncio-eventloop.rst:311 +#: ../../library/asyncio-eventloop.rst:316 msgid "This method's behavior is the same as :meth:`call_later`." msgstr "此方法的行為與 :meth:`call_later` 相同。" -#: ../../library/asyncio-eventloop.rst:320 +#: ../../library/asyncio-eventloop.rst:325 msgid "" "In Python 3.7 and earlier with the default event loop implementation, the " "difference between *when* and the current time could not exceed one day. " "This has been fixed in Python 3.8." msgstr "" -"在 Python 3.7 及更早版本中,使用預設事件迴圈實作時,*when* 和當前時間之間的差" +"在 Python 3.7 及更早版本中,使用預設事件迴圈實作時,*when* 和目前時間之間的差" "值不能超過一天。這在 Python 3.8 中已經修復。" -#: ../../library/asyncio-eventloop.rst:327 +#: ../../library/asyncio-eventloop.rst:332 msgid "" "Return the current time, as a :class:`float` value, according to the event " "loop's internal monotonic clock." -msgstr "根據事件迴圈的內部單調時鐘,回傳當前時間,以 :class:`float` 值表示。" +msgstr "根據事件迴圈的內部單調時鐘,回傳目前時間,以 :class:`float` 值表示。" -#: ../../library/asyncio-eventloop.rst:331 +#: ../../library/asyncio-eventloop.rst:336 msgid "" "In Python 3.7 and earlier timeouts (relative *delay* or absolute *when*) " "should not exceed one day. This has been fixed in Python 3.8." @@ -540,19 +549,19 @@ msgstr "" "在 Python 3.7 及更早版本中,超時(相對 *delay* 或絕對 *when*)不應超過一天。" "這在 Python 3.8 中已經修復。" -#: ../../library/asyncio-eventloop.rst:337 +#: ../../library/asyncio-eventloop.rst:342 msgid "The :func:`asyncio.sleep` function." msgstr "函式 :func:`asyncio.sleep`。" -#: ../../library/asyncio-eventloop.rst:341 +#: ../../library/asyncio-eventloop.rst:346 msgid "Creating Futures and Tasks" msgstr "建立 Futures 和 Tasks" -#: ../../library/asyncio-eventloop.rst:345 +#: ../../library/asyncio-eventloop.rst:350 msgid "Create an :class:`asyncio.Future` object attached to the event loop." msgstr "建立附加到事件迴圈的 :class:`asyncio.Future` 物件。" -#: ../../library/asyncio-eventloop.rst:347 +#: ../../library/asyncio-eventloop.rst:352 msgid "" "This is the preferred way to create Futures in asyncio. This lets third-" "party event loops provide alternative implementations of the Future object " @@ -561,13 +570,13 @@ msgstr "" "這是在 asyncio 中建立 Futures 的首選方式。這允許第三方事件迴圈提供 Future 物" "件的替代實作(具有更好的性能或儀器計測表現)。" -#: ../../library/asyncio-eventloop.rst:355 +#: ../../library/asyncio-eventloop.rst:360 msgid "" "Schedule the execution of :ref:`coroutine ` *coro*. Return a :" "class:`Task` object." msgstr "排程執行\\ :ref:`協程 ` *coro*。回傳 :class:`Task` 物件。" -#: ../../library/asyncio-eventloop.rst:358 +#: ../../library/asyncio-eventloop.rst:363 msgid "" "Third-party event loops can use their own subclass of :class:`Task` for " "interoperability. In this case, the result type is a subclass of :class:" @@ -576,7 +585,15 @@ msgstr "" "第三方事件迴圈可以使用其自己的 :class:`Task` 子類別以實現互操作性" "(interoperability)。在這種情況下,結果類型是 :class:`Task` 的子類別。" -#: ../../library/asyncio-eventloop.rst:362 +#: ../../library/asyncio-eventloop.rst:367 +msgid "" +"The full function signature is largely the same as that of the :class:`Task` " +"constructor (or factory) - all of the keyword arguments to this function are " +"passed through to that interface, except *name*, or *context* if it is " +"``None``." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:372 msgid "" "If the *name* argument is provided and not ``None``, it is set as the name " "of the task using :meth:`Task.set_name`." @@ -584,56 +601,79 @@ msgstr "" "如果提供了 *name* 引數且不為 ``None``,則將其設置為任務的名稱,使用 :meth:" "`Task.set_name`。" -#: ../../library/asyncio-eventloop.rst:365 +#: ../../library/asyncio-eventloop.rst:375 msgid "" "An optional keyword-only *context* argument allows specifying a custom :" "class:`contextvars.Context` for the *coro* to run in. The current context " "copy is created when no *context* is provided." msgstr "" "可選的僅限關鍵字 *context* 引數允許為 *coro* 指定自定義的 :class:" -"`contextvars.Context` 以提供運行。當未提供 *context* 時,將建立當前情境的副" +"`contextvars.Context` 以提供運行。當未提供 *context* 時,將建立目前情境的副" "本。" -#: ../../library/asyncio-eventloop.rst:369 +#: ../../library/asyncio-eventloop.rst:379 msgid "Added the *name* parameter." msgstr "加入 *name* 參數。" -#: ../../library/asyncio-eventloop.rst:372 +#: ../../library/asyncio-eventloop.rst:382 msgid "Added the *context* parameter." msgstr "加入 *context* 參數。" -#: ../../library/asyncio-eventloop.rst:377 +#: ../../library/asyncio-eventloop.rst:385 +msgid "" +"Added ``kwargs`` which passes on arbitrary extra parameters, including " +"``name`` and ``context``." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:388 +msgid "" +"Rolled back the change that passes on *name* and *context* (if it is None), " +"while still passing on other arbitrary keyword arguments (to avoid breaking " +"backwards compatibility with 3.13.3)." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:394 msgid "Set a task factory that will be used by :meth:`loop.create_task`." msgstr "設置將由 :meth:`loop.create_task` 使用的任務工廠。" -#: ../../library/asyncio-eventloop.rst:380 +#: ../../library/asyncio-eventloop.rst:397 msgid "" "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 :class:`asyncio." -"Future`-compatible object." +"**kwargs)``, where *loop* is a reference to the active event loop, and " +"*coro* is a coroutine object. The callable must pass on all *kwargs*, and " +"return a :class:`asyncio.Task`-compatible object." msgstr "" "如果 *factory* 為 ``None``,將設置預設的任務工廠。否則,*factory* 必須是一個" -"具有匹配簽名 ``(loop, coro, context=None)`` 的 *callable*,其中 *loop* 是有效" -"事件迴圈的參照,*coro* 是一個協程物件。該可呼叫物件必須回傳一個與 :class:" -"`asyncio.Future` 相容的物件。" +"具有匹配簽名 ``(loop, coro, **kwargs)`` 的 *callable*,其中 *loop* 是有效事件" +"迴圈的參照、*coro* 是一個協程物件。該可呼叫物件必須傳遞所有 *kwargs* 並回傳一" +"個與 :class:`asyncio.Task` 相容的物件。" -#: ../../library/asyncio-eventloop.rst:388 +#: ../../library/asyncio-eventloop.rst:403 +msgid "Required that all *kwargs* are passed on to :class:`asyncio.Task`." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:406 +msgid "" +"*name* is no longer passed to task factories. *context* is no longer passed " +"to task factories if it is ``None``." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:412 msgid "Return a task factory or ``None`` if the default one is in use." msgstr "回傳任務工廠,如果使用預設任務工廠則回傳 ``None``。" -#: ../../library/asyncio-eventloop.rst:392 +#: ../../library/asyncio-eventloop.rst:416 msgid "Opening network connections" msgstr "打開網路連線" -#: ../../library/asyncio-eventloop.rst:403 +#: ../../library/asyncio-eventloop.rst:428 msgid "" "Open a streaming transport connection to a given address specified by *host* " "and *port*." msgstr "打開以 *host* 和 *port* 指定之給定地址的串流傳輸連線。" -#: ../../library/asyncio-eventloop.rst:406 +#: ../../library/asyncio-eventloop.rst:431 msgid "" "The socket family can be either :py:const:`~socket.AF_INET` or :py:const:" "`~socket.AF_INET6` depending on *host* (or the *family* argument, if " @@ -642,13 +682,13 @@ msgstr "" "根據 *host*(或提供的 *family* 引數)的情況,socket 家族可以是 :py:const:" "`~socket.AF_INET` 或 :py:const:`~socket.AF_INET6`。" -#: ../../library/asyncio-eventloop.rst:410 +#: ../../library/asyncio-eventloop.rst:435 msgid "The socket type will be :py:const:`~socket.SOCK_STREAM`." msgstr "Socket 類型將為 :py:const:`~socket.SOCK_STREAM`。" -#: ../../library/asyncio-eventloop.rst:412 -#: ../../library/asyncio-eventloop.rst:1164 -#: ../../library/asyncio-eventloop.rst:1180 +#: ../../library/asyncio-eventloop.rst:437 +#: ../../library/asyncio-eventloop.rst:1230 +#: ../../library/asyncio-eventloop.rst:1247 msgid "" "*protocol_factory* must be a callable returning an :ref:`asyncio protocol " "` implementation." @@ -656,24 +696,24 @@ msgstr "" "*protocol_factory* 必須是一個回傳 :ref:`asyncio protocol ` " "實作的可呼叫函式。" -#: ../../library/asyncio-eventloop.rst:415 +#: ../../library/asyncio-eventloop.rst:440 msgid "" "This method will try to establish the connection in the background. When " "successful, it returns a ``(transport, protocol)`` pair." msgstr "" "此方法將嘗試在背景建立連線。成功時,它將回傳一對 ``(transport, protocol)``。" -#: ../../library/asyncio-eventloop.rst:418 +#: ../../library/asyncio-eventloop.rst:443 msgid "The chronological synopsis of the underlying operation is as follows:" msgstr "底層操作的時間軸簡介如下:" -#: ../../library/asyncio-eventloop.rst:420 +#: ../../library/asyncio-eventloop.rst:445 msgid "" "The connection is established and a :ref:`transport ` is " "created for it." msgstr "建立連線並為其建立\\ :ref:`傳輸 `。" -#: ../../library/asyncio-eventloop.rst:423 +#: ../../library/asyncio-eventloop.rst:448 msgid "" "*protocol_factory* is called without arguments and is expected to return a :" "ref:`protocol ` instance." @@ -681,29 +721,29 @@ msgstr "" "*protocol_factory* 在無引數的情況下被呼叫,並且預計回傳一個 :ref:`協定 " "` 實例。" -#: ../../library/asyncio-eventloop.rst:426 +#: ../../library/asyncio-eventloop.rst:451 msgid "" "The protocol instance is coupled with the transport by calling its :meth:" "`~BaseProtocol.connection_made` method." msgstr "" -"通過呼叫其 :meth:`~BaseProtocol.connection_made` 方法,將協議實例與傳輸連線在" +"通過呼叫其 :meth:`~BaseProtocol.connection_made` 方法,將協定實例與傳輸連線在" "一起。" -#: ../../library/asyncio-eventloop.rst:429 +#: ../../library/asyncio-eventloop.rst:454 msgid "A ``(transport, protocol)`` tuple is returned on success." msgstr "成功時回傳一個 ``(transport, protocol)`` 元組。" -#: ../../library/asyncio-eventloop.rst:431 +#: ../../library/asyncio-eventloop.rst:456 msgid "" "The created transport is an implementation-dependent bidirectional stream." msgstr "建立的傳輸是一個依賴實作的雙向串流。" -#: ../../library/asyncio-eventloop.rst:434 -#: ../../library/asyncio-eventloop.rst:566 +#: ../../library/asyncio-eventloop.rst:459 +#: ../../library/asyncio-eventloop.rst:592 msgid "Other arguments:" msgstr "其他引數:" -#: ../../library/asyncio-eventloop.rst:436 +#: ../../library/asyncio-eventloop.rst:461 msgid "" "*ssl*: if given and not false, a SSL/TLS transport is created (by default a " "plain TCP transport is created). If *ssl* is a :class:`ssl.SSLContext` " @@ -715,11 +755,11 @@ msgstr "" "果 *ssl* 為 :class:`ssl.SSLContext` 物件,則使用該情境來建立傳輸;如果 *ssl* " "為 :const:`True`,則使用 :func:`ssl.create_default_context` 回傳的預設情境。" -#: ../../library/asyncio-eventloop.rst:442 +#: ../../library/asyncio-eventloop.rst:467 msgid ":ref:`SSL/TLS security considerations `" msgstr ":ref:`SSL/TLS 安全考量 `" -#: ../../library/asyncio-eventloop.rst:444 +#: ../../library/asyncio-eventloop.rst:469 msgid "" "*server_hostname* sets or overrides the hostname that the target server's " "certificate will be matched against. Should only be passed if *ssl* is not " @@ -734,18 +774,18 @@ msgstr "" "預設值,必須傳遞 *server_hostname* 的值。若 *server_hostname* 為空字串,將停" "用主機名稱匹配(這是一個嚴重的安全風險,可能導致中間人攻擊)。" -#: ../../library/asyncio-eventloop.rst:452 +#: ../../library/asyncio-eventloop.rst:477 msgid "" "*family*, *proto*, *flags* are the optional address family, protocol and " "flags to be passed through to getaddrinfo() for *host* resolution. If given, " "these should all be integers from the corresponding :mod:`socket` module " "constants." msgstr "" -"*family*、*proto*、*flags* 是可選的位址家族、協議和旗標,用於傳遞至 " +"*family*、*proto*、*flags* 是可選的位址家族、協定和旗標,用於傳遞至 " "getaddrinfo() 進行 *host* 解析。若有給定這些應該都是相應 :mod:`socket` 模組常" "數的整數。" -#: ../../library/asyncio-eventloop.rst:457 +#: ../../library/asyncio-eventloop.rst:482 msgid "" "*happy_eyeballs_delay*, if given, enables Happy Eyeballs for this " "connection. It should be a floating-point number representing the amount of " @@ -759,7 +799,7 @@ msgstr "" "`8305` 中定義的「連線嘗試延遲」。RFC 建議的合理預設值為 ``0.25`` 秒(250 毫" "秒)。" -#: ../../library/asyncio-eventloop.rst:465 +#: ../../library/asyncio-eventloop.rst:490 msgid "" "*interleave* controls address reordering when a host name resolves to " "multiple IP addresses. If ``0`` or unspecified, no reordering is done, and " @@ -775,7 +815,7 @@ msgstr "" "族計數」。如果未指定 *happy_eyeballs_delay*,則預設值為 ``0``,如果指定則為 " "``1``。" -#: ../../library/asyncio-eventloop.rst:474 +#: ../../library/asyncio-eventloop.rst:499 msgid "" "*sock*, if given, should be an existing, already connected :class:`socket." "socket` object to be used by the transport. If *sock* is given, none of " @@ -786,9 +826,9 @@ msgstr "" "輸使用。如果提供了 *sock*,則不應指定 *host*、*port*、*family*、*proto*、" "*flags*、*happy_eyeballs_delay*、*interleave* 和 *local_addr* 中的任何一項。" -#: ../../library/asyncio-eventloop.rst:482 -#: ../../library/asyncio-eventloop.rst:597 -#: ../../library/asyncio-eventloop.rst:825 +#: ../../library/asyncio-eventloop.rst:507 +#: ../../library/asyncio-eventloop.rst:623 +#: ../../library/asyncio-eventloop.rst:871 msgid "" "The *sock* argument transfers ownership of the socket to the transport " "created. To close the socket, call the transport's :meth:`~asyncio." @@ -797,7 +837,7 @@ msgstr "" "引數 *sock* 將 socket 所有權轉移給所建立的傳輸 socket,請呼叫傳輸的 :meth:" "`~asyncio.BaseTransport.close` 方法。" -#: ../../library/asyncio-eventloop.rst:486 +#: ../../library/asyncio-eventloop.rst:511 msgid "" "*local_addr*, if given, is a ``(local_host, local_port)`` tuple used to bind " "the socket locally. The *local_host* and *local_port* are looked up using " @@ -807,8 +847,8 @@ msgstr "" "地綁定 socket。將使用 ``getaddrinfo()`` 查找 *local_host* 和 *local_port*,方" "式類似於 *host* 和 *port*。" -#: ../../library/asyncio-eventloop.rst:490 -#: ../../library/asyncio-eventloop.rst:919 +#: ../../library/asyncio-eventloop.rst:515 +#: ../../library/asyncio-eventloop.rst:967 msgid "" "*ssl_handshake_timeout* is (for a TLS connection) the time in seconds to " "wait for the TLS handshake to complete before aborting the connection. " @@ -818,10 +858,10 @@ msgstr "" "在那之前若未完成則會中斷連線。如果為 ``None`` (預設值),則會等待 ``60.0`` " "秒。" -#: ../../library/asyncio-eventloop.rst:494 -#: ../../library/asyncio-eventloop.rst:742 -#: ../../library/asyncio-eventloop.rst:836 -#: ../../library/asyncio-eventloop.rst:923 +#: ../../library/asyncio-eventloop.rst:519 +#: ../../library/asyncio-eventloop.rst:778 +#: ../../library/asyncio-eventloop.rst:882 +#: ../../library/asyncio-eventloop.rst:971 msgid "" "*ssl_shutdown_timeout* is the time in seconds to wait for the SSL shutdown " "to complete before aborting the connection. ``30.0`` seconds if ``None`` " @@ -830,7 +870,7 @@ msgstr "" "*ssl_shutdown_timeout* 是等待 SSL 關閉完成以前中斷連線的時間,以秒為單位。如" "果為 ``None`` (預設值),則會等待 ``30.0`` 秒。" -#: ../../library/asyncio-eventloop.rst:498 +#: ../../library/asyncio-eventloop.rst:523 msgid "" "*all_errors* determines what exceptions are raised when a connection cannot " "be created. By default, only a single ``Exception`` is raised: the first " @@ -844,12 +884,12 @@ msgstr "" "包含所有錯誤訊息的單一 ``OSError``。當 ``all_errors`` 為 ``True`` 時,將引發" "包含所有例外的 ``ExceptionGroup`` (即使只有一個例外)。" -#: ../../library/asyncio-eventloop.rst:508 -#: ../../library/asyncio-eventloop.rst:754 +#: ../../library/asyncio-eventloop.rst:533 +#: ../../library/asyncio-eventloop.rst:790 msgid "Added support for SSL/TLS in :class:`ProactorEventLoop`." msgstr "新增 :class:`ProactorEventLoop` 中的 SSL/TLS 支援。" -#: ../../library/asyncio-eventloop.rst:512 +#: ../../library/asyncio-eventloop.rst:537 msgid "" "The socket option :ref:`socket.TCP_NODELAY ` is set " "by default for all TCP connections." @@ -857,16 +897,16 @@ msgstr "" "所有 TCP 連線都預設有 :ref:`socket.TCP_NODELAY ` " "socket 選項。" -#: ../../library/asyncio-eventloop.rst:517 -#: ../../library/asyncio-eventloop.rst:846 +#: ../../library/asyncio-eventloop.rst:542 +#: ../../library/asyncio-eventloop.rst:892 msgid "Added the *ssl_handshake_timeout* parameter." msgstr "增加 *ssl_handshake_timeout* 參數。" -#: ../../library/asyncio-eventloop.rst:521 +#: ../../library/asyncio-eventloop.rst:546 msgid "Added the *happy_eyeballs_delay* and *interleave* parameters." msgstr "加入 *happy_eyeballs_delay* 和 *interleave* 參數。" -#: ../../library/asyncio-eventloop.rst:523 +#: ../../library/asyncio-eventloop.rst:548 msgid "" "Happy Eyeballs Algorithm: Success with Dual-Stack Hosts. When a server's " "IPv4 path and protocol are working, but the server's IPv6 path and protocol " @@ -877,29 +917,29 @@ msgid "" "visible delay and provides an algorithm." msgstr "" "Happy Eyeballs 演算法:雙協定堆疊主機 (Dual-Stack Hosts) 的成功。當伺服器的 " -"IPv4 路徑和協議運作正常,但伺服器的 IPv6 路徑和協議不運作時,雙棧用戶端應用程" +"IPv4 路徑和協定運作正常,但伺服器的 IPv6 路徑和協定不運作時,雙棧用戶端應用程" "式會比僅具 IPv4 的用戶端體驗到顯著的連線延遲。這是不希望的,因為這會導致雙棧" "用戶端的使用者體驗變差。本文件具體說明了減少此用戶可見延遲的演算法要求並提供" "了一種演算法。" -#: ../../library/asyncio-eventloop.rst:532 +#: ../../library/asyncio-eventloop.rst:557 msgid "For more information: https://datatracker.ietf.org/doc/html/rfc6555" msgstr "更多資訊請見: https://datatracker.ietf.org/doc/html/rfc6555" -#: ../../library/asyncio-eventloop.rst:536 -#: ../../library/asyncio-eventloop.rst:660 -#: ../../library/asyncio-eventloop.rst:768 -#: ../../library/asyncio-eventloop.rst:803 -#: ../../library/asyncio-eventloop.rst:850 -#: ../../library/asyncio-eventloop.rst:931 +#: ../../library/asyncio-eventloop.rst:561 +#: ../../library/asyncio-eventloop.rst:687 +#: ../../library/asyncio-eventloop.rst:804 +#: ../../library/asyncio-eventloop.rst:844 +#: ../../library/asyncio-eventloop.rst:896 +#: ../../library/asyncio-eventloop.rst:979 msgid "Added the *ssl_shutdown_timeout* parameter." msgstr "增加 *ssl_shutdown_timeout* 參數。" -#: ../../library/asyncio-eventloop.rst:538 +#: ../../library/asyncio-eventloop.rst:563 msgid "*all_errors* was added." msgstr "已新增 *all_errors*。" -#: ../../library/asyncio-eventloop.rst:543 +#: ../../library/asyncio-eventloop.rst:568 msgid "" "The :func:`open_connection` function is a high-level alternative API. It " "returns a pair of (:class:`StreamReader`, :class:`StreamWriter`) that can be " @@ -908,11 +948,11 @@ msgstr "" "函式 :func:`open_connection` 是高階的替代 API。它回傳一對 (:class:" "`StreamReader`, :class:`StreamWriter`) 可直接在 async/await 程式碼中使用。" -#: ../../library/asyncio-eventloop.rst:553 +#: ../../library/asyncio-eventloop.rst:579 msgid "Create a datagram connection." msgstr "建立一個資料報連線。" -#: ../../library/asyncio-eventloop.rst:555 +#: ../../library/asyncio-eventloop.rst:581 msgid "" "The socket family can be either :py:const:`~socket.AF_INET`, :py:const:" "`~socket.AF_INET6`, or :py:const:`~socket.AF_UNIX`, depending on *host* (or " @@ -922,13 +962,13 @@ msgstr "" "或 :py:const:`~socket.AF_UNIX`,視乎 *host*\\ (或提供的 *family* 引數)而" "定。" -#: ../../library/asyncio-eventloop.rst:559 +#: ../../library/asyncio-eventloop.rst:585 msgid "The socket type will be :py:const:`~socket.SOCK_DGRAM`." msgstr "Socket 類型將為 :py:const:`~socket.SOCK_DGRAM`。" -#: ../../library/asyncio-eventloop.rst:561 -#: ../../library/asyncio-eventloop.rst:685 -#: ../../library/asyncio-eventloop.rst:817 +#: ../../library/asyncio-eventloop.rst:587 +#: ../../library/asyncio-eventloop.rst:714 +#: ../../library/asyncio-eventloop.rst:863 msgid "" "*protocol_factory* must be a callable returning a :ref:`protocol ` implementation." @@ -936,12 +976,12 @@ msgstr "" "*protocol_factory* 必須是可呼叫的函式,回傳 :ref:`protocol ` 實作。" -#: ../../library/asyncio-eventloop.rst:564 -#: ../../library/asyncio-eventloop.rst:642 +#: ../../library/asyncio-eventloop.rst:590 +#: ../../library/asyncio-eventloop.rst:669 msgid "A tuple of ``(transport, protocol)`` is returned on success." msgstr "成功時回傳 ``(transport, protocol)`` 元組。" -#: ../../library/asyncio-eventloop.rst:568 +#: ../../library/asyncio-eventloop.rst:594 msgid "" "*local_addr*, if given, is a ``(local_host, local_port)`` tuple used to bind " "the socket locally. The *local_host* and *local_port* are looked up using :" @@ -950,7 +990,7 @@ msgstr "" "*local_addr*,如果提供,是一個 ``(local_host, local_port)`` 元組,用於在本地" "綁定 socket。*local_host* 和 *local_port* 使用 :meth:`getaddrinfo` 來查找。" -#: ../../library/asyncio-eventloop.rst:572 +#: ../../library/asyncio-eventloop.rst:598 msgid "" "*remote_addr*, if given, is a ``(remote_host, remote_port)`` tuple used to " "connect the socket to a remote address. The *remote_host* and *remote_port* " @@ -960,7 +1000,7 @@ msgstr "" "socket 連線到遠端位址。 *remote_host* 和 *remote_port* 使用 :meth:" "`getaddrinfo` 來查找。" -#: ../../library/asyncio-eventloop.rst:576 +#: ../../library/asyncio-eventloop.rst:602 msgid "" "*family*, *proto*, *flags* are the optional address family, protocol and " "flags to be passed through to :meth:`getaddrinfo` for *host* resolution. If " @@ -971,7 +1011,7 @@ msgstr "" "的可選地址家族、協定和旗標。如果提供,這些應該都是來自相應的 :mod:`socket` 模" "組常數的整數。" -#: ../../library/asyncio-eventloop.rst:581 +#: ../../library/asyncio-eventloop.rst:607 msgid "" "*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 " @@ -983,13 +1023,13 @@ msgstr "" "時都設定了此旗標。此選項不受 Windows 和某些 Unix 系統支援。如果未定義 :py:" "const:`~socket.SO_REUSEPORT` 常數,則不支援此功能。" -#: ../../library/asyncio-eventloop.rst:587 +#: ../../library/asyncio-eventloop.rst:613 msgid "" "*allow_broadcast* tells the kernel to allow this endpoint to send messages " "to the broadcast address." msgstr "*allow_broadcast* 告訴核心允許此端點向廣播位址發送訊息。" -#: ../../library/asyncio-eventloop.rst:590 +#: ../../library/asyncio-eventloop.rst:616 msgid "" "*sock* can optionally be specified in order to use a preexisting, already " "connected, :class:`socket.socket` object to be used by the transport. If " @@ -1000,15 +1040,15 @@ msgstr "" "供傳輸使用。如果指定,*local_addr* 和 *remote_addr* 應省略(必須是 :const:" "`None`\\ )。" -#: ../../library/asyncio-eventloop.rst:601 +#: ../../library/asyncio-eventloop.rst:627 msgid "" "See :ref:`UDP echo client protocol ` and :" "ref:`UDP echo server protocol ` examples." msgstr "" -"請參閱 :ref:`UDP 回應用戶端協議 ` 和 :ref:" -"`UDP 回應伺服器協議 ` 範例。" +"請參閱 :ref:`UDP 回應用戶端協定 ` 和 :ref:" +"`UDP 回應伺服器協定 ` 範例。" -#: ../../library/asyncio-eventloop.rst:604 +#: ../../library/asyncio-eventloop.rst:630 msgid "" "The *family*, *proto*, *flags*, *reuse_address*, *reuse_port*, " "*allow_broadcast*, and *sock* parameters were added." @@ -1016,11 +1056,11 @@ msgstr "" "新增 *family*、*proto*、*flags*、*reuse_address*、*reuse_port*、" "*allow_broadcast* 和 *sock* 參數。" -#: ../../library/asyncio-eventloop.rst:608 +#: ../../library/asyncio-eventloop.rst:634 msgid "Added support for Windows." msgstr "新增對於 Windows 的支援。" -#: ../../library/asyncio-eventloop.rst:611 +#: ../../library/asyncio-eventloop.rst:637 msgid "" "The *reuse_address* parameter is no longer supported, as using :ref:`socket." "SO_REUSEADDR ` poses a significant security concern " @@ -1029,7 +1069,7 @@ msgstr "" "不再支援 *reuse_address* 參數,因為使用 :py:const:`~sockets.SO_REUSEADDR` 對" "於 UDP 存有重大的安全疑慮。明確傳遞 ``reuse_address=True`` 將引發例外。" -#: ../../library/asyncio-eventloop.rst:617 +#: ../../library/asyncio-eventloop.rst:643 msgid "" "When multiple processes with differing UIDs assign sockets to an identical " "UDP socket address with ``SO_REUSEADDR``, incoming packets can become " @@ -1038,7 +1078,7 @@ msgstr "" "當具有不同 UID 的多個行程使用 ``SO_REUSEADDR`` 將 socket 分配給相同的 UDP " "socket 地址時,傳入的封包可能會在 socket 之間隨機分佈。" -#: ../../library/asyncio-eventloop.rst:621 +#: ../../library/asyncio-eventloop.rst:647 msgid "" "For supported platforms, *reuse_port* can be used as a replacement for " "similar functionality. With *reuse_port*, :ref:`socket.SO_REUSEPORT `: Unix." -msgstr ":ref:`適用 `:Unix。" +#: ../../library/asyncio-eventloop.rst:679 +#: ../../library/asyncio-eventloop.rst:835 +#: ../../library/asyncio-eventloop.rst:1300 +#: ../../library/asyncio-eventloop.rst:1840 +#: ../../library/asyncio-eventloop.rst:1847 +msgid "Availability" +msgstr "可用性" -#: ../../library/asyncio-eventloop.rst:654 +#: ../../library/asyncio-eventloop.rst:681 msgid "" "Added the *ssl_handshake_timeout* parameter. The *path* parameter can now be " "a :term:`path-like object`." @@ -1098,11 +1140,11 @@ msgstr "" "新增 *ssl_handshake_timeout* 參數。*path* 參數現在可以是 :term:`path-like " "object`。" -#: ../../library/asyncio-eventloop.rst:664 +#: ../../library/asyncio-eventloop.rst:691 msgid "Creating network servers" msgstr "建立網路伺服器" -#: ../../library/asyncio-eventloop.rst:678 +#: ../../library/asyncio-eventloop.rst:707 msgid "" "Create a TCP server (socket type :const:`~socket.SOCK_STREAM`) listening on " "*port* of the *host* address." @@ -1110,33 +1152,33 @@ msgstr "" "建立一個 TCP 伺服器(socket 類型 :const:`~socket.SOCK_STREAM`\\ ),監聽 " "*host* 位址的 *port*。" -#: ../../library/asyncio-eventloop.rst:681 +#: ../../library/asyncio-eventloop.rst:710 msgid "Returns a :class:`Server` object." msgstr "回傳一個 :class:`Server` 物件。" -#: ../../library/asyncio-eventloop.rst:683 +#: ../../library/asyncio-eventloop.rst:712 msgid "Arguments:" msgstr "引數:" -#: ../../library/asyncio-eventloop.rst:688 +#: ../../library/asyncio-eventloop.rst:717 msgid "" "The *host* parameter can be set to several types which determine where the " "server would be listening:" msgstr "可以將 *host* 參數設為幾種類型,以確定伺服器將監聽的位置:" -#: ../../library/asyncio-eventloop.rst:691 +#: ../../library/asyncio-eventloop.rst:720 msgid "" "If *host* is a string, the TCP server is bound to a single network interface " "specified by *host*." msgstr "如果 *host* 是字串,則 TCP 伺服器綁定到由 *host* 指定的單個網路介面。" -#: ../../library/asyncio-eventloop.rst:694 +#: ../../library/asyncio-eventloop.rst:723 msgid "" "If *host* is a sequence of strings, the TCP server is bound to all network " "interfaces specified by the sequence." msgstr "如果 *host* 是字串序列,則 TCP 伺服器綁定到序列指定的所有網路介面。" -#: ../../library/asyncio-eventloop.rst:697 +#: ../../library/asyncio-eventloop.rst:726 msgid "" "If *host* is an empty string or ``None``, all interfaces are assumed and a " "list of multiple sockets will be returned (most likely one for IPv4 and " @@ -1145,7 +1187,7 @@ msgstr "" "若 *host* 是空字串或 ``None``,則所有介面都被假定並回傳多個 socket 的清單(可" "能一個用於 IPv4,另一個用於 IPv6)。" -#: ../../library/asyncio-eventloop.rst:701 +#: ../../library/asyncio-eventloop.rst:730 msgid "" "The *port* parameter can be set to specify which port the server should " "listen on. If ``0`` or ``None`` (the default), a random unused port will be " @@ -1156,7 +1198,7 @@ msgstr "" "設值),將隨機選擇一個未使用的埠(請注意,如果 *host* 解析為多個網路介面,將" "為每個介面隨機選擇不同的隨機埠)。" -#: ../../library/asyncio-eventloop.rst:706 +#: ../../library/asyncio-eventloop.rst:735 msgid "" "*family* can be set to either :const:`socket.AF_INET` or :const:`~socket." "AF_INET6` to force the socket to use IPv4 or IPv6. If not set, the *family* " @@ -1166,11 +1208,11 @@ msgstr "" "制使用 IPv4 或 IPv6。如果未設定,*family* 將從主機名稱決定(預設為 :const:" "`~socket.AF_UNSPEC`\\ )。" -#: ../../library/asyncio-eventloop.rst:711 +#: ../../library/asyncio-eventloop.rst:740 msgid "*flags* is a bitmask for :meth:`getaddrinfo`." msgstr "*flags* 是 :meth:`getaddrinfo` 的位元遮罩。" -#: ../../library/asyncio-eventloop.rst:713 +#: ../../library/asyncio-eventloop.rst:742 msgid "" "*sock* can optionally be specified in order to use a preexisting socket " "object. If specified, *host* and *port* must not be specified." @@ -1178,7 +1220,7 @@ msgstr "" "可以可選地指定 *sock* 以使用現有的 socket 物件。如果指定了,*host* 和 *port* " "不能指定。" -#: ../../library/asyncio-eventloop.rst:718 +#: ../../library/asyncio-eventloop.rst:747 msgid "" "The *sock* argument transfers ownership of the socket to the server created. " "To close the socket, call the server's :meth:`~asyncio.Server.close` method." @@ -1186,7 +1228,7 @@ msgstr "" "*sock* 引數將 socket 的所有權轉移給建立的伺服器。要關閉 socket,請呼叫伺服器" "的 :meth:`~asyncio.Server.close` 方法。" -#: ../../library/asyncio-eventloop.rst:722 +#: ../../library/asyncio-eventloop.rst:751 msgid "" "*backlog* is the maximum number of queued connections passed to :meth:" "`~socket.socket.listen` (defaults to 100)." @@ -1194,14 +1236,14 @@ msgstr "" "*backlog* 是傳遞給 :meth:`~socket.socket.listen` 的最大佇列連線數(預設為 " "100)。" -#: ../../library/asyncio-eventloop.rst:725 +#: ../../library/asyncio-eventloop.rst:754 msgid "" "*ssl* can be set to an :class:`~ssl.SSLContext` instance to enable TLS over " "the accepted connections." msgstr "" "*ssl* 可以設定為 :class:`~ssl.SSLContext` 實例以在接受的連線上啟用 TLS。" -#: ../../library/asyncio-eventloop.rst:728 +#: ../../library/asyncio-eventloop.rst:757 msgid "" "*reuse_address* tells the kernel to reuse a local socket in ``TIME_WAIT`` " "state, without waiting for its natural timeout to expire. If not specified " @@ -1210,7 +1252,7 @@ msgstr "" "*reuse_address* 告訴內核重用 ``TIME_WAIT`` 狀態下的本地 socket,而不等待其自" "然超時過期。如果未指定,在 Unix 上將自動設置為 ``True``。" -#: ../../library/asyncio-eventloop.rst:733 +#: ../../library/asyncio-eventloop.rst:762 msgid "" "*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 " @@ -1219,7 +1261,17 @@ msgstr "" "*reuse_port* 告訴內核允許此端點繫結到與其他現有端點繫結的相同埠,只要它們在建" "立時都設置了此旗標。此選項在旗標 Windows 上不受支援。" -#: ../../library/asyncio-eventloop.rst:738 +#: ../../library/asyncio-eventloop.rst:767 +msgid "" +"*keep_alive* set to ``True`` keeps connections active by enabling the " +"periodic transmission of messages." +msgstr "將 *keep_alive* 設為 ``True`` 透過啟用定期的訊息傳輸來保持連線活躍。" + +#: ../../library/asyncio-eventloop.rst:772 +msgid "Added the *keep_alive* parameter." +msgstr "加入 *keep_alive* 參數。" + +#: ../../library/asyncio-eventloop.rst:774 msgid "" "*ssl_handshake_timeout* is (for a TLS server) the time in seconds to wait " "for the TLS handshake to complete before aborting the connection. ``60.0`` " @@ -1228,7 +1280,7 @@ msgstr "" "(對於 TLS 伺服器)\\ *ssl_handshake_timeout* 是在中斷連線之前等待 TLS 握手完" "成的時間(以秒為單位)。如果為 ``None``\\ (預設),則為 ``60.0`` 秒。" -#: ../../library/asyncio-eventloop.rst:746 +#: ../../library/asyncio-eventloop.rst:782 msgid "" "*start_serving* set to ``True`` (the default) causes the created server to " "start accepting connections immediately. When set to ``False``, the user " @@ -1239,11 +1291,11 @@ msgstr "" "接。當設置為 ``False`` 時,用戶應該等待 :meth:`Server.start_serving` 或 :" "meth:`Server.serve_forever` 來使伺服器開始接受連線。" -#: ../../library/asyncio-eventloop.rst:758 +#: ../../library/asyncio-eventloop.rst:794 msgid "The *host* parameter can be a sequence of strings." msgstr "*host* 參數可以是字串序列。" -#: ../../library/asyncio-eventloop.rst:762 +#: ../../library/asyncio-eventloop.rst:798 msgid "" "Added *ssl_handshake_timeout* and *start_serving* parameters. The socket " "option :ref:`socket.TCP_NODELAY ` is set by default " @@ -1252,7 +1304,7 @@ msgstr "" "新增 *ssl_handshake_timeout* 與 *start_serving* 參數。所有 TCP 連線都預設有 :" "ref:`socket.TCP_NODELAY ` socket 選項。" -#: ../../library/asyncio-eventloop.rst:772 +#: ../../library/asyncio-eventloop.rst:808 msgid "" "The :func:`start_server` function is a higher-level alternative API that " "returns a pair of :class:`StreamReader` and :class:`StreamWriter` that can " @@ -1261,7 +1313,7 @@ msgstr "" ":func:`start_server` 函式是一個更高階的替代 API,它回傳一對 :class:" "`StreamReader` 和 :class:`StreamWriter`,可以在 async/await 程式碼中使用。" -#: ../../library/asyncio-eventloop.rst:783 +#: ../../library/asyncio-eventloop.rst:820 msgid "" "Similar to :meth:`loop.create_server` but works with the :py:const:`~socket." "AF_UNIX` socket family." @@ -1269,7 +1321,7 @@ msgstr "" "類似 :meth:`loop.create_server`,但適用於 :py:const:`~socket.AF_UNIX` socket " "家族。" -#: ../../library/asyncio-eventloop.rst:786 +#: ../../library/asyncio-eventloop.rst:823 msgid "" "*path* is the name of a Unix domain socket, and is required, unless a *sock* " "argument is provided. Abstract Unix sockets, :class:`str`, :class:`bytes`, " @@ -1279,13 +1331,22 @@ msgstr "" "象 Unix sockets、:class:`str`、:class:`bytes` 和 :class:`~pathlib.Path` 路" "徑。" -#: ../../library/asyncio-eventloop.rst:791 +#: ../../library/asyncio-eventloop.rst:828 +msgid "" +"If *cleanup_socket* is true then the Unix socket will automatically be " +"removed from the filesystem when the server is closed, unless the socket has " +"been replaced after the server has been created." +msgstr "" +"如果 *cleanup_socket* 為真,則 Unix socket 將在伺服器關閉時自動從檔案系統中刪" +"除,除非在建立伺服器後替換了 socket。" + +#: ../../library/asyncio-eventloop.rst:832 msgid "" "See the documentation of the :meth:`loop.create_server` method for " "information about arguments to this method." msgstr "有關此方法的引數資訊,請參閱 :meth:`loop.create_server` 方法的文件。" -#: ../../library/asyncio-eventloop.rst:798 +#: ../../library/asyncio-eventloop.rst:839 msgid "" "Added the *ssl_handshake_timeout* and *start_serving* parameters. The *path* " "parameter can now be a :class:`~pathlib.Path` object." @@ -1293,22 +1354,26 @@ msgstr "" "新增 *ssl_handshake_timeout* 與 *start_serving* 參數。*path* 參數現在可為一" "個 :class:`~pathlib.Path` 物件。" -#: ../../library/asyncio-eventloop.rst:810 +#: ../../library/asyncio-eventloop.rst:848 +msgid "Added the *cleanup_socket* parameter." +msgstr "加入 *cleanup_socket* 參數。" + +#: ../../library/asyncio-eventloop.rst:856 msgid "Wrap an already accepted connection into a transport/protocol pair." -msgstr "將已接受的連線包裝成傳輸層/協議對。" +msgstr "將已接受的連線包裝成傳輸層/協定對。" -#: ../../library/asyncio-eventloop.rst:812 +#: ../../library/asyncio-eventloop.rst:858 msgid "" "This method can be used by servers that accept connections outside of " "asyncio but that use asyncio to handle them." msgstr "此方法可以由在 asyncio 外接受連線但使用 asyncio 處理連線的伺服器使用。" -#: ../../library/asyncio-eventloop.rst:815 -#: ../../library/asyncio-eventloop.rst:905 +#: ../../library/asyncio-eventloop.rst:861 +#: ../../library/asyncio-eventloop.rst:953 msgid "Parameters:" msgstr "參數:" -#: ../../library/asyncio-eventloop.rst:820 +#: ../../library/asyncio-eventloop.rst:866 msgid "" "*sock* is a preexisting socket object returned from :meth:`socket.accept " "`." @@ -1316,13 +1381,13 @@ msgstr "" "*sock* 是從 :meth:`socket.accept ` 回傳的預先存在的 " "socket 物件。" -#: ../../library/asyncio-eventloop.rst:829 +#: ../../library/asyncio-eventloop.rst:875 msgid "" "*ssl* can be set to an :class:`~ssl.SSLContext` to enable SSL over the " "accepted connections." msgstr "*ssl* 可以設置為 :class:`~ssl.SSLContext` 以在已接受的連線上啟用 SSL。" -#: ../../library/asyncio-eventloop.rst:832 +#: ../../library/asyncio-eventloop.rst:878 msgid "" "*ssl_handshake_timeout* is (for an SSL connection) the time in seconds to " "wait for the SSL handshake to complete before aborting the connection. " @@ -1331,29 +1396,29 @@ msgstr "" "(對於 SSL 連線)\\ *ssl_handshake_timeout* 是在中斷連線之前等待 SSL 握手完成" "的時間(以秒為單位)。如果為 ``None``\\ (預設),則為 ``60.0`` 秒。" -#: ../../library/asyncio-eventloop.rst:840 +#: ../../library/asyncio-eventloop.rst:886 msgid "Returns a ``(transport, protocol)`` pair." msgstr "回傳 ``(transport, protocol)`` 對。" -#: ../../library/asyncio-eventloop.rst:854 +#: ../../library/asyncio-eventloop.rst:900 msgid "Transferring files" msgstr "傳輸檔案" -#: ../../library/asyncio-eventloop.rst:859 +#: ../../library/asyncio-eventloop.rst:906 msgid "" "Send a *file* over a *transport*. Return the total number of bytes sent." msgstr "通過 *transport* 發送 *file*。回傳發送的總位元組數。" -#: ../../library/asyncio-eventloop.rst:862 +#: ../../library/asyncio-eventloop.rst:909 msgid "The method uses high-performance :meth:`os.sendfile` if available." msgstr "如果可用,該方法使用高性能 :meth:`os.sendfile`。" -#: ../../library/asyncio-eventloop.rst:864 +#: ../../library/asyncio-eventloop.rst:911 msgid "*file* must be a regular file object opened in binary mode." msgstr "*file* 必須是以二進位模式打開的常規檔案物件。" -#: ../../library/asyncio-eventloop.rst:866 -#: ../../library/asyncio-eventloop.rst:1111 +#: ../../library/asyncio-eventloop.rst:913 +#: ../../library/asyncio-eventloop.rst:1174 msgid "" "*offset* tells from where to start reading the file. If specified, *count* " "is the total number of bytes to transmit as opposed to sending the file " @@ -1365,7 +1430,7 @@ msgstr "" "不是發送檔案直到達到 EOF。即使此方法引發錯誤時,檔案位置也始終更新,可以使" "用 :meth:`file.tell() ` 取得實際發送的位元組數。" -#: ../../library/asyncio-eventloop.rst:873 +#: ../../library/asyncio-eventloop.rst:920 msgid "" "*fallback* set to ``True`` makes asyncio to manually read and send the file " "when the platform does not support the sendfile system call (e.g. Windows or " @@ -1374,7 +1439,7 @@ msgstr "" "將 *fallback* 設置為 ``True`` 會使 asyncio 在平台不支援 sendfile 系統呼叫時" "(例如 Windows 或 Unix 上的 SSL socket)手動讀取和發送檔案。" -#: ../../library/asyncio-eventloop.rst:877 +#: ../../library/asyncio-eventloop.rst:924 msgid "" "Raise :exc:`SendfileNotAvailableError` if the system does not support the " "*sendfile* syscall and *fallback* is ``False``." @@ -1382,24 +1447,24 @@ msgstr "" "如果系統不支援 *sendfile* 系統呼叫且 *fallback* 為 ``False``,則引發 :exc:" "`SendfileNotAvailableError`。" -#: ../../library/asyncio-eventloop.rst:884 +#: ../../library/asyncio-eventloop.rst:931 msgid "TLS Upgrade" msgstr "TLS 升級" -#: ../../library/asyncio-eventloop.rst:891 +#: ../../library/asyncio-eventloop.rst:939 msgid "Upgrade an existing transport-based connection to TLS." msgstr "將基於傳輸的現有連線升級到 TLS。" -#: ../../library/asyncio-eventloop.rst:893 +#: ../../library/asyncio-eventloop.rst:941 msgid "" "Create a TLS coder/decoder instance and insert it between the *transport* " "and the *protocol*. The coder/decoder implements both *transport*-facing " "protocol and *protocol*-facing transport." msgstr "" "建立 TLS 編解碼器實例並在 *transport* 和 *protocol* 之間插入它。編解碼器既實" -"作了對於 *transport* 的協議,也實作了對於 *protocol* 的傳輸。" +"作了對於 *transport* 的協定,也實作了對於 *protocol* 的傳輸。" -#: ../../library/asyncio-eventloop.rst:897 +#: ../../library/asyncio-eventloop.rst:945 msgid "" "Return the created two-interface instance. After *await*, the *protocol* " "must stop using the original *transport* and communicate with the returned " @@ -1410,13 +1475,13 @@ msgstr "" "*transport*,僅與回傳的物件通信,因為編碼器快取了 *protocol* 端的資料,並且" "與 *transport* 間歇性地交換額外的 TLS session 封包。" -#: ../../library/asyncio-eventloop.rst:902 +#: ../../library/asyncio-eventloop.rst:950 msgid "" "In some situations (e.g. when the passed transport is already closing) this " "may return ``None``." msgstr "在某些情況下(例如傳入的傳輸已經關閉),此函式可能回傳 ``None``。" -#: ../../library/asyncio-eventloop.rst:907 +#: ../../library/asyncio-eventloop.rst:955 msgid "" "*transport* and *protocol* instances that methods like :meth:`~loop." "create_server` and :meth:`~loop.create_connection` return." @@ -1424,11 +1489,11 @@ msgstr "" "*transport* 和 *protocol* 實例,由像 :meth:`~loop.create_server` 和 :meth:" "`~loop.create_connection` 等方法回傳。" -#: ../../library/asyncio-eventloop.rst:911 +#: ../../library/asyncio-eventloop.rst:959 msgid "*sslcontext*: a configured instance of :class:`~ssl.SSLContext`." msgstr "*sslcontext*:配置好的 :class:`~ssl.SSLContext` 實例。" -#: ../../library/asyncio-eventloop.rst:913 +#: ../../library/asyncio-eventloop.rst:961 msgid "" "*server_side* pass ``True`` when a server-side connection is being upgraded " "(like the one created by :meth:`~loop.create_server`)." @@ -1436,25 +1501,32 @@ msgstr "" "當升級伺服器端連線時(像由 :meth:`~loop.create_server` 建立的那樣)傳遞 " "``True``。" -#: ../../library/asyncio-eventloop.rst:916 +#: ../../library/asyncio-eventloop.rst:964 msgid "" "*server_hostname*: sets or overrides the host name that the target server's " "certificate will be matched against." msgstr "*server_hostname*:設置或覆蓋將用於匹配目標伺服器憑證的主機名。" -#: ../../library/asyncio-eventloop.rst:936 +#: ../../library/asyncio-eventloop.rst:984 msgid "Watching file descriptors" msgstr "監視檔案描述器" -#: ../../library/asyncio-eventloop.rst:940 +#: ../../library/asyncio-eventloop.rst:988 msgid "" "Start monitoring the *fd* file descriptor for read availability and invoke " "*callback* with the specified arguments once *fd* is available for reading." msgstr "" -"開始監視 *fd* 檔案描述器的讀取可用性,一但 *fd* 可讀取,使用指定引數呼叫 " +"開始監視 *fd* 檔案描述器的讀取可用性,一但 *fd* 可讀取,使用指定引數叫用 " "*callback*。" -#: ../../library/asyncio-eventloop.rst:946 +#: ../../library/asyncio-eventloop.rst:992 +#: ../../library/asyncio-eventloop.rst:1006 +msgid "" +"Any preexisting callback registered for *fd* is cancelled and replaced by " +"*callback*." +msgstr "任何預先存在、為 *fd* 註冊的回呼函式將被取消並替換為 *callback*。" + +#: ../../library/asyncio-eventloop.rst:997 msgid "" "Stop monitoring the *fd* file descriptor for read availability. Returns " "``True`` if *fd* was previously being monitored for reads." @@ -1462,16 +1534,16 @@ msgstr "" "停止監視 *fd* 檔案描述器的讀取可用性。如果 *fd* 之前正在監視讀取,則回傳 " "``True``。" -#: ../../library/asyncio-eventloop.rst:951 +#: ../../library/asyncio-eventloop.rst:1002 msgid "" "Start monitoring the *fd* file descriptor for write availability and invoke " "*callback* with the specified arguments once *fd* is available for writing." msgstr "" -"開始監視 *fd* 檔案描述器的寫入可用性,一旦 *fd* 可寫入,使用指定引數呼叫 " +"開始監視 *fd* 檔案描述器的寫入可用性,一旦 *fd* 可寫入,使用指定引數叫用 " "*callback*。" -#: ../../library/asyncio-eventloop.rst:955 -#: ../../library/asyncio-eventloop.rst:1220 +#: ../../library/asyncio-eventloop.rst:1009 +#: ../../library/asyncio-eventloop.rst:1287 msgid "" "Use :func:`functools.partial` :ref:`to pass keyword arguments ` to *callback*." @@ -1479,7 +1551,7 @@ msgstr "" "使用 :func:`functools.partial` 向 *callback* :ref:`傳送關鍵字引數 `。" -#: ../../library/asyncio-eventloop.rst:960 +#: ../../library/asyncio-eventloop.rst:1014 msgid "" "Stop monitoring the *fd* file descriptor for write availability. Returns " "``True`` if *fd* was previously being monitored for writes." @@ -1487,7 +1559,7 @@ msgstr "" "停止監視 *fd* 檔案描述器的寫入可用性。如果 *fd* 之前正在監視寫入,則回傳 " "``True``。" -#: ../../library/asyncio-eventloop.rst:963 +#: ../../library/asyncio-eventloop.rst:1017 msgid "" "See also :ref:`Platform Support ` section for some " "limitations of these methods." @@ -1495,11 +1567,11 @@ msgstr "" "另請參閱\\ :ref:`平台支援 `\\ 部分以了解這些方法的" "一些限制。" -#: ../../library/asyncio-eventloop.rst:968 +#: ../../library/asyncio-eventloop.rst:1022 msgid "Working with socket objects directly" msgstr "直接使用 socket 物件" -#: ../../library/asyncio-eventloop.rst:970 +#: ../../library/asyncio-eventloop.rst:1024 msgid "" "In general, protocol implementations that use transport-based APIs such as :" "meth:`loop.create_connection` and :meth:`loop.create_server` are faster than " @@ -1508,10 +1580,10 @@ msgid "" "socket` objects directly is more convenient." msgstr "" "一般情況下,使用基於傳輸的 API(如 :meth:`loop.create_connection` 和 :meth:" -"`loop.create_server`\\ )的協議實作比直接使用 socket 的實作更快。然而在某些情" +"`loop.create_server`)的協定實作比直接使用 socket 的實作更快。然而在某些情" "況下性能不是關鍵,直接使用 :class:`~socket.socket` 物件更方便。" -#: ../../library/asyncio-eventloop.rst:979 +#: ../../library/asyncio-eventloop.rst:1034 msgid "" "Receive up to *nbytes* from *sock*. Asynchronous version of :meth:`socket." "recv() `." @@ -1519,23 +1591,23 @@ msgstr "" "從 *sock* 接收最多 *nbytes*。:meth:`socket.recv() ` 的非" "同步版本。" -#: ../../library/asyncio-eventloop.rst:982 +#: ../../library/asyncio-eventloop.rst:1037 msgid "Return the received data as a bytes object." msgstr "將接收到的資料作為 bytes 物件回傳。" -#: ../../library/asyncio-eventloop.rst:984 -#: ../../library/asyncio-eventloop.rst:998 -#: ../../library/asyncio-eventloop.rst:1009 -#: ../../library/asyncio-eventloop.rst:1021 -#: ../../library/asyncio-eventloop.rst:1036 -#: ../../library/asyncio-eventloop.rst:1051 -#: ../../library/asyncio-eventloop.rst:1061 -#: ../../library/asyncio-eventloop.rst:1087 -#: ../../library/asyncio-eventloop.rst:1125 +#: ../../library/asyncio-eventloop.rst:1039 +#: ../../library/asyncio-eventloop.rst:1054 +#: ../../library/asyncio-eventloop.rst:1066 +#: ../../library/asyncio-eventloop.rst:1079 +#: ../../library/asyncio-eventloop.rst:1095 +#: ../../library/asyncio-eventloop.rst:1111 +#: ../../library/asyncio-eventloop.rst:1122 +#: ../../library/asyncio-eventloop.rst:1149 +#: ../../library/asyncio-eventloop.rst:1188 msgid "*sock* must be a non-blocking socket." msgstr "*sock* 必須是非阻塞 socket。" -#: ../../library/asyncio-eventloop.rst:986 +#: ../../library/asyncio-eventloop.rst:1041 msgid "" "Even though this method was always documented as a coroutine method, " "releases before Python 3.7 returned a :class:`Future`. Since Python 3.7 this " @@ -1544,7 +1616,7 @@ msgstr "" "儘管此方法一直記錄為協程方法,但 Python 3.7 之前的版本回傳 :class:`Future`。" "自 Python 3.7 起,這是 ``async def`` 方法。" -#: ../../library/asyncio-eventloop.rst:993 +#: ../../library/asyncio-eventloop.rst:1049 msgid "" "Receive data from *sock* into the *buf* buffer. Modeled after the blocking :" "meth:`socket.recv_into() ` method." @@ -1552,11 +1624,11 @@ msgstr "" "從 *sock* 接收資料到 *buf* 緩衝區。仿照阻塞 :meth:`socket.recv_into() " "` 方法。" -#: ../../library/asyncio-eventloop.rst:996 +#: ../../library/asyncio-eventloop.rst:1052 msgid "Return the number of bytes written to the buffer." msgstr "回傳寫入緩衝區位元組的數目。" -#: ../../library/asyncio-eventloop.rst:1004 +#: ../../library/asyncio-eventloop.rst:1061 msgid "" "Receive a datagram of up to *bufsize* from *sock*. Asynchronous version of :" "meth:`socket.recvfrom() `." @@ -1564,11 +1636,11 @@ msgstr "" "從 *sock* 接收最多 *bufsize* 大小的資料單元。:meth:`socket.recvfrom() " "` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1007 +#: ../../library/asyncio-eventloop.rst:1064 msgid "Return a tuple of (received data, remote address)." msgstr "回傳一個元組 (received data, remote address)。" -#: ../../library/asyncio-eventloop.rst:1015 +#: ../../library/asyncio-eventloop.rst:1073 msgid "" "Receive a datagram of up to *nbytes* from *sock* into *buf*. Asynchronous " "version of :meth:`socket.recvfrom_into() `." @@ -1576,11 +1648,11 @@ msgstr "" "從 *sock* 接收最多 *nbytes* 大小的資料單元到 *buf*。:meth:`socket." "recvfrom_into() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1019 +#: ../../library/asyncio-eventloop.rst:1077 msgid "Return a tuple of (number of bytes received, remote address)." msgstr "回傳一個元組 (number of bytes received, remote address)。" -#: ../../library/asyncio-eventloop.rst:1027 +#: ../../library/asyncio-eventloop.rst:1086 msgid "" "Send *data* to the *sock* socket. Asynchronous version of :meth:`socket." "sendall() `." @@ -1588,7 +1660,7 @@ msgstr "" "將 *data* 發送到 *sock* socket。:meth:`socket.sendall() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1030 +#: ../../library/asyncio-eventloop.rst:1089 msgid "" "This method continues to send to the socket until either all data in *data* " "has been sent or an error occurs. ``None`` is returned on success. On " @@ -1600,8 +1672,8 @@ msgstr "" "回傳 ``None``。錯誤時引發例外。此外,沒有辦法確定接收端成功處理了多少資料(如" "果有的話)。" -#: ../../library/asyncio-eventloop.rst:1038 -#: ../../library/asyncio-eventloop.rst:1089 +#: ../../library/asyncio-eventloop.rst:1097 +#: ../../library/asyncio-eventloop.rst:1151 msgid "" "Even though the method was always documented as a coroutine method, before " "Python 3.7 it returned a :class:`Future`. Since Python 3.7, this is an " @@ -1610,7 +1682,7 @@ msgstr "" "儘管該方法一直被記錄為協程方法,但在 Python 3.7 之前它回傳 :class:`Future`。" "從 Python 3.7 開始,這是一個 ``async def`` 方法。" -#: ../../library/asyncio-eventloop.rst:1045 +#: ../../library/asyncio-eventloop.rst:1105 msgid "" "Send a datagram from *sock* to *address*. Asynchronous version of :meth:" "`socket.sendto() `." @@ -1618,20 +1690,20 @@ msgstr "" "從 *sock* 向 *address* 發送一個資料單元。:meth:`socket.sendto() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1049 +#: ../../library/asyncio-eventloop.rst:1109 msgid "Return the number of bytes sent." msgstr "回傳發送的位元組數。" -#: ../../library/asyncio-eventloop.rst:1057 +#: ../../library/asyncio-eventloop.rst:1118 msgid "Connect *sock* to a remote socket at *address*." msgstr "將 *sock* 連線到位於 *address* 的遠端 socket。" -#: ../../library/asyncio-eventloop.rst:1059 +#: ../../library/asyncio-eventloop.rst:1120 msgid "" "Asynchronous version of :meth:`socket.connect() `." msgstr ":meth:`socket.connect() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1063 +#: ../../library/asyncio-eventloop.rst:1124 msgid "" "``address`` no longer needs to be resolved. ``sock_connect`` will try to " "check if the *address* is already resolved by calling :func:`socket." @@ -1642,7 +1714,7 @@ msgstr "" "inet_pton` 檢查 *address* 是否已解析。如果沒有,將使用 :meth:`loop." "getaddrinfo` 解析 *address*。" -#: ../../library/asyncio-eventloop.rst:1072 +#: ../../library/asyncio-eventloop.rst:1133 msgid "" ":meth:`loop.create_connection` and :func:`asyncio.open_connection() " "`." @@ -1650,7 +1722,7 @@ msgstr "" ":meth:`loop.create_connection` 和 :func:`asyncio.open_connection() " "`。" -#: ../../library/asyncio-eventloop.rst:1078 +#: ../../library/asyncio-eventloop.rst:1140 msgid "" "Accept a connection. Modeled after the blocking :meth:`socket.accept() " "` method." @@ -1658,7 +1730,7 @@ msgstr "" "接受一個連線。模擬阻塞的 :meth:`socket.accept() ` 方" "法。" -#: ../../library/asyncio-eventloop.rst:1081 +#: ../../library/asyncio-eventloop.rst:1143 msgid "" "The socket must be bound to an address and listening for connections. The " "return value is a pair ``(conn, address)`` where *conn* is a *new* socket " @@ -1669,34 +1741,34 @@ msgstr "" "中 *conn* 是一個 *新* socket 物件,可在連線上發送和接收資料,*address* 是連接" "另一端對應的 socket 地址。" -#: ../../library/asyncio-eventloop.rst:1096 +#: ../../library/asyncio-eventloop.rst:1158 msgid ":meth:`loop.create_server` and :func:`start_server`." msgstr ":meth:`loop.create_server` 和 :func:`start_server`。" -#: ../../library/asyncio-eventloop.rst:1101 +#: ../../library/asyncio-eventloop.rst:1164 msgid "" "Send a file using high-performance :mod:`os.sendfile` if possible. Return " "the total number of bytes sent." msgstr "" "如果可行,使用高性能 :mod:`os.sendfile` 發送檔案。回傳發送的總位元組數。" -#: ../../library/asyncio-eventloop.rst:1104 +#: ../../library/asyncio-eventloop.rst:1167 msgid "" "Asynchronous version of :meth:`socket.sendfile() `." msgstr ":meth:`socket.sendfile() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1106 +#: ../../library/asyncio-eventloop.rst:1169 msgid "" "*sock* must be a non-blocking :const:`socket.SOCK_STREAM` :class:`~socket." "socket`." msgstr "" "*sock* 必須是非阻塞的 :const:`socket.SOCK_STREAM` :class:`~socket.socket`。" -#: ../../library/asyncio-eventloop.rst:1109 +#: ../../library/asyncio-eventloop.rst:1172 msgid "*file* must be a regular file object open in binary mode." msgstr "*file* 必須是以二進位模式打開的常規檔案物件。" -#: ../../library/asyncio-eventloop.rst:1118 +#: ../../library/asyncio-eventloop.rst:1181 msgid "" "*fallback*, when set to ``True``, makes asyncio manually read and send the " "file when the platform does not support the sendfile syscall (e.g. Windows " @@ -1705,7 +1777,7 @@ msgstr "" "當設置為 ``True`` 時,*fallback* 使 asyncio 在平台不支援 sendfile 系統呼叫時" "(例如 Windows 或 Unix 上的 SSL socket)手動讀取和發送檔案。" -#: ../../library/asyncio-eventloop.rst:1122 +#: ../../library/asyncio-eventloop.rst:1185 msgid "" "Raise :exc:`SendfileNotAvailableError` if the system does not support " "*sendfile* syscall and *fallback* is ``False``." @@ -1713,19 +1785,19 @@ msgstr "" "如果系統不支援 *sendfile* 系統呼叫且 *fallback* 為 ``False``,引發 :exc:" "`SendfileNotAvailableError`。" -#: ../../library/asyncio-eventloop.rst:1131 +#: ../../library/asyncio-eventloop.rst:1194 msgid "DNS" msgstr "DNS" -#: ../../library/asyncio-eventloop.rst:1136 +#: ../../library/asyncio-eventloop.rst:1200 msgid "Asynchronous version of :meth:`socket.getaddrinfo`." msgstr ":meth:`socket.getaddrinfo` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1140 +#: ../../library/asyncio-eventloop.rst:1205 msgid "Asynchronous version of :meth:`socket.getnameinfo`." msgstr ":meth:`socket.getnameinfo` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1143 +#: ../../library/asyncio-eventloop.rst:1208 msgid "" "Both *getaddrinfo* and *getnameinfo* internally utilize their synchronous " "versions through the loop's default thread pool executor. When this executor " @@ -1735,7 +1807,7 @@ msgid "" "executor with a larger number of workers." msgstr "" -#: ../../library/asyncio-eventloop.rst:1150 +#: ../../library/asyncio-eventloop.rst:1215 msgid "" "Both *getaddrinfo* and *getnameinfo* methods were always documented to " "return a coroutine, but prior to Python 3.7 they were, in fact, returning :" @@ -1746,19 +1818,19 @@ msgstr "" "它們實際上回傳 :class:`asyncio.Future` 物件。從 Python 3.7 開始,兩個方法都是" "協程。" -#: ../../library/asyncio-eventloop.rst:1158 +#: ../../library/asyncio-eventloop.rst:1223 msgid "Working with pipes" msgstr "使用管道" -#: ../../library/asyncio-eventloop.rst:1162 +#: ../../library/asyncio-eventloop.rst:1228 msgid "Register the read end of *pipe* in the event loop." msgstr "在事件迴圈中註冊 *pipe* 的讀取端。" -#: ../../library/asyncio-eventloop.rst:1167 +#: ../../library/asyncio-eventloop.rst:1233 msgid "*pipe* is a :term:`file-like object `." msgstr "*pipe* 是 :term:`類檔案物件 `。" -#: ../../library/asyncio-eventloop.rst:1169 +#: ../../library/asyncio-eventloop.rst:1235 msgid "" "Return pair ``(transport, protocol)``, where *transport* supports the :class:" "`ReadTransport` interface and *protocol* is an object instantiated by the " @@ -1767,22 +1839,22 @@ msgstr "" "回傳 ``(transport, protocol)`` 對,其中 *transport* 支援 :class:" "`ReadTransport` 介面,*protocol* 是由 *protocol_factory* 實例化的物件。" -#: ../../library/asyncio-eventloop.rst:1173 -#: ../../library/asyncio-eventloop.rst:1189 +#: ../../library/asyncio-eventloop.rst:1239 +#: ../../library/asyncio-eventloop.rst:1256 msgid "" "With :class:`SelectorEventLoop` event loop, the *pipe* is set to non-" "blocking mode." msgstr "使用 :class:`SelectorEventLoop` 事件迴圈時,*pipe* 設置為非阻塞模式。" -#: ../../library/asyncio-eventloop.rst:1178 +#: ../../library/asyncio-eventloop.rst:1245 msgid "Register the write end of *pipe* in the event loop." msgstr "在事件迴圈中註冊 *pipe* 的寫入端。" -#: ../../library/asyncio-eventloop.rst:1183 +#: ../../library/asyncio-eventloop.rst:1250 msgid "*pipe* is :term:`file-like object `." msgstr "*pipe* 是 :term:`file-like object `。" -#: ../../library/asyncio-eventloop.rst:1185 +#: ../../library/asyncio-eventloop.rst:1252 msgid "" "Return pair ``(transport, protocol)``, where *transport* supports :class:" "`WriteTransport` interface and *protocol* is an object instantiated by the " @@ -1791,7 +1863,7 @@ msgstr "" "回傳 ``(transport, protocol)`` 對,其中 *transport* 支援 :class:" "`WriteTransport` 介面,*protocol* 是由 *protocol_factory* 實例化的物件。" -#: ../../library/asyncio-eventloop.rst:1194 +#: ../../library/asyncio-eventloop.rst:1261 msgid "" ":class:`SelectorEventLoop` does not support the above methods on Windows. " "Use :class:`ProactorEventLoop` instead for Windows." @@ -1799,31 +1871,31 @@ msgstr "" ":class:`SelectorEventLoop` 在 Windows 上不支援上述方法。對於 Windows 請使用 :" "class:`ProactorEventLoop`。" -#: ../../library/asyncio-eventloop.rst:1199 +#: ../../library/asyncio-eventloop.rst:1266 msgid "" "The :meth:`loop.subprocess_exec` and :meth:`loop.subprocess_shell` methods." msgstr ":meth:`loop.subprocess_exec` 和 :meth:`loop.subprocess_shell` 方法。" -#: ../../library/asyncio-eventloop.rst:1204 +#: ../../library/asyncio-eventloop.rst:1271 msgid "Unix signals" msgstr "Unix 訊號" -#: ../../library/asyncio-eventloop.rst:1210 +#: ../../library/asyncio-eventloop.rst:1277 msgid "Set *callback* as the handler for the *signum* signal." msgstr "將 *callback* 設置為 *signum* 訊號的處理程式。" -#: ../../library/asyncio-eventloop.rst:1212 +#: ../../library/asyncio-eventloop.rst:1279 msgid "" "The callback will be invoked by *loop*, along with other queued callbacks " "and runnable coroutines of that event loop. Unlike signal handlers " "registered using :func:`signal.signal`, a callback registered with this " "function is allowed to interact with the event loop." msgstr "" -"該回呼將由 *loop* 呼叫,與該事件迴圈的其他排隊回呼和可運行的協程一起。與使" +"該回呼將由 *loop* 叫用,與該事件迴圈的其他排隊回呼和可運行的協程一起。與使" "用 :func:`signal.signal` 註冊的訊號處理程式不同,使用此函式註冊的回呼允許與事" "件迴圈進行互動。" -#: ../../library/asyncio-eventloop.rst:1217 +#: ../../library/asyncio-eventloop.rst:1284 msgid "" "Raise :exc:`ValueError` if the signal number is invalid or uncatchable. " "Raise :exc:`RuntimeError` if there is a problem setting up the handler." @@ -1831,16 +1903,16 @@ msgstr "" "如果訊號號無效或不可捕獲,引發 :exc:`ValueError`。如果設定處理程序有問題,拋" "出 :exc:`RuntimeError`。" -#: ../../library/asyncio-eventloop.rst:1223 +#: ../../library/asyncio-eventloop.rst:1290 msgid "" "Like :func:`signal.signal`, this function must be invoked in the main thread." -msgstr "像 :func:`signal.signal` 一樣,此函式必須在主執行緒中呼叫。" +msgstr "像 :func:`signal.signal` 一樣,此函式必須在主執行緒中叫用。" -#: ../../library/asyncio-eventloop.rst:1228 +#: ../../library/asyncio-eventloop.rst:1295 msgid "Remove the handler for the *sig* signal." msgstr "移除 *sig* 訊號的處理程式。" -#: ../../library/asyncio-eventloop.rst:1230 +#: ../../library/asyncio-eventloop.rst:1297 msgid "" "Return ``True`` if the signal handler was removed, or ``False`` if no " "handler was set for the given signal." @@ -1848,19 +1920,19 @@ msgstr "" "如果訊號處理程式被移除,回傳 ``True``;如果給定訊號沒有設置處理程式,回傳 " "``False``。" -#: ../../library/asyncio-eventloop.rst:1237 +#: ../../library/asyncio-eventloop.rst:1304 msgid "The :mod:`signal` module." msgstr ":mod:`signal` 模組。" -#: ../../library/asyncio-eventloop.rst:1241 +#: ../../library/asyncio-eventloop.rst:1308 msgid "Executing code in thread or process pools" msgstr "在執行緒池或行程池中執行程式碼" -#: ../../library/asyncio-eventloop.rst:1245 +#: ../../library/asyncio-eventloop.rst:1312 msgid "Arrange for *func* to be called in the specified executor." msgstr "安排在指定的執行器中呼叫 *func*。" -#: ../../library/asyncio-eventloop.rst:1247 +#: ../../library/asyncio-eventloop.rst:1314 msgid "" "The *executor* argument should be an :class:`concurrent.futures.Executor` " "instance. The default executor is used if *executor* is ``None``. The " @@ -1869,7 +1941,7 @@ msgid "" "and used by :func:`run_in_executor` if needed." msgstr "" -#: ../../library/asyncio-eventloop.rst:1255 +#: ../../library/asyncio-eventloop.rst:1322 msgid "" "import asyncio\n" "import concurrent.futures\n" @@ -1912,7 +1984,7 @@ msgid "" " asyncio.run(main())" msgstr "" -#: ../../library/asyncio-eventloop.rst:1295 +#: ../../library/asyncio-eventloop.rst:1362 msgid "" "Note that the entry point guard (``if __name__ == '__main__'``) is required " "for option 3 due to the peculiarities of :mod:`multiprocessing`, which is " @@ -1924,11 +1996,11 @@ msgstr "" "== '__main__'``\\ )。請參閱\\ :ref:`主模組的安全引入 `。" -#: ../../library/asyncio-eventloop.rst:1300 +#: ../../library/asyncio-eventloop.rst:1367 msgid "This method returns a :class:`asyncio.Future` object." msgstr "此方法回傳 :class:`asyncio.Future` 物件。" -#: ../../library/asyncio-eventloop.rst:1302 +#: ../../library/asyncio-eventloop.rst:1369 msgid "" "Use :func:`functools.partial` :ref:`to pass keyword arguments ` to *func*." @@ -1936,7 +2008,7 @@ msgstr "" "使用 :func:`functools.partial` 將來\\ :ref:`關鍵字引數傳遞 `\\ 給 *func*。" -#: ../../library/asyncio-eventloop.rst:1305 +#: ../../library/asyncio-eventloop.rst:1372 msgid "" ":meth:`loop.run_in_executor` no longer configures the ``max_workers`` of the " "thread pool executor it creates, instead leaving it up to the thread pool " @@ -1947,7 +2019,7 @@ msgstr "" "``max_workers``,而是讓執行緒池執行器(\\ :class:`~concurrent.futures." "ThreadPoolExecutor`)設定預設值。" -#: ../../library/asyncio-eventloop.rst:1314 +#: ../../library/asyncio-eventloop.rst:1381 msgid "" "Set *executor* as the default executor used by :meth:`run_in_executor`. " "*executor* must be an instance of :class:`~concurrent.futures." @@ -1956,26 +2028,26 @@ msgstr "" "將 *executor* 設置為 :meth:`run_in_executor` 使用的預設執行器。*executor* 必" "須是 :class:`~concurrent.futures.ThreadPoolExecutor` 的實例。" -#: ../../library/asyncio-eventloop.rst:1318 +#: ../../library/asyncio-eventloop.rst:1385 msgid "" "*executor* must be an instance of :class:`~concurrent.futures." "ThreadPoolExecutor`." msgstr "" "*executor* 必須是 :class:`~concurrent.futures.ThreadPoolExecutor` 的實例。" -#: ../../library/asyncio-eventloop.rst:1324 +#: ../../library/asyncio-eventloop.rst:1391 msgid "Error Handling API" msgstr "錯誤處理 API" -#: ../../library/asyncio-eventloop.rst:1326 +#: ../../library/asyncio-eventloop.rst:1393 msgid "Allows customizing how exceptions are handled in the event loop." msgstr "允許自定義事件迴圈中的例外處理方式。" -#: ../../library/asyncio-eventloop.rst:1330 +#: ../../library/asyncio-eventloop.rst:1397 msgid "Set *handler* as the new event loop exception handler." msgstr "將 *handler* 設定為新的事件迴圈例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1332 +#: ../../library/asyncio-eventloop.rst:1399 msgid "" "If *handler* is ``None``, the default exception handler will be set. " "Otherwise, *handler* must be a callable with the signature matching ``(loop, " @@ -1988,7 +2060,7 @@ msgstr "" "圈的,``context`` 是包含例外詳細資訊的 ``dict`` 物件(有關情境的詳細資訊,請" "參閱 :meth:`call_exception_handler` 文件)。" -#: ../../library/asyncio-eventloop.rst:1340 +#: ../../library/asyncio-eventloop.rst:1407 msgid "" "If the handler is called on behalf of a :class:`~asyncio.Task` or :class:" "`~asyncio.Handle`, it is run in the :class:`contextvars.Context` of that " @@ -1997,7 +2069,7 @@ msgstr "" "如果代表 :class:`~asyncio.Task` 或 :class:`~asyncio.Handle` 呼叫處理程式,它" "將在該任務或回呼處理程式的 :class:`contextvars.Context` 中運行。" -#: ../../library/asyncio-eventloop.rst:1346 +#: ../../library/asyncio-eventloop.rst:1413 msgid "" "The handler may be called in the :class:`~contextvars.Context` of the task " "or handle where the exception originated." @@ -2005,18 +2077,18 @@ msgstr "" "處理程式可能在引發例外的任務或處理程式的 :class:`~contextvars.Context` 中被呼" "叫。" -#: ../../library/asyncio-eventloop.rst:1351 +#: ../../library/asyncio-eventloop.rst:1418 msgid "" "Return the current exception handler, or ``None`` if no custom exception " "handler was set." msgstr "" -"回傳當前的例外處理程式,如果未設置自定義例外處理程式,則回傳 ``None``。" +"回傳目前的例外處理程式,如果未設置自定義例外處理程式,則回傳 ``None``。" -#: ../../library/asyncio-eventloop.rst:1358 +#: ../../library/asyncio-eventloop.rst:1425 msgid "Default exception handler." msgstr "預設例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1360 +#: ../../library/asyncio-eventloop.rst:1427 msgid "" "This is called when an exception occurs and no exception handler is set. " "This can be called by a custom exception handler that wants to defer to the " @@ -2025,17 +2097,17 @@ msgstr "" "當發生例外且未設置例外處理程式時呼叫此函式。自定義例外處理程式可以呼叫此函式" "以轉由預設處理程式處理。" -#: ../../library/asyncio-eventloop.rst:1364 +#: ../../library/asyncio-eventloop.rst:1431 msgid "" "*context* parameter has the same meaning as in :meth:" "`call_exception_handler`." msgstr "*context* 參數與 :meth:`call_exception_handler` 中的意思相同。" -#: ../../library/asyncio-eventloop.rst:1369 +#: ../../library/asyncio-eventloop.rst:1436 msgid "Call the current event loop exception handler." -msgstr "呼叫當前事件迴圈例外處理程式。" +msgstr "呼叫目前事件迴圈例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1371 +#: ../../library/asyncio-eventloop.rst:1438 msgid "" "*context* is a ``dict`` object containing the following keys (new keys may " "be introduced in future Python versions):" @@ -2043,47 +2115,55 @@ msgstr "" "*context* 是一個包含以下鍵的 ``dict`` 物件(未來的 Python 版本中可能會引入新" "的鍵):" -#: ../../library/asyncio-eventloop.rst:1374 +#: ../../library/asyncio-eventloop.rst:1441 msgid "'message': Error message;" msgstr "'message':錯誤訊息;" -#: ../../library/asyncio-eventloop.rst:1375 +#: ../../library/asyncio-eventloop.rst:1442 msgid "'exception' (optional): Exception object;" msgstr "'exception'(可選):例外物件;" -#: ../../library/asyncio-eventloop.rst:1376 +#: ../../library/asyncio-eventloop.rst:1443 msgid "'future' (optional): :class:`asyncio.Future` instance;" msgstr "'future'(可選): :class:`asyncio.Future` 實例;" -#: ../../library/asyncio-eventloop.rst:1377 +#: ../../library/asyncio-eventloop.rst:1444 msgid "'task' (optional): :class:`asyncio.Task` instance;" msgstr "'task'(可選): :class:`asyncio.Task` 實例;" -#: ../../library/asyncio-eventloop.rst:1378 +#: ../../library/asyncio-eventloop.rst:1445 msgid "'handle' (optional): :class:`asyncio.Handle` instance;" msgstr "'handle'(可選): :class:`asyncio.Handle` 實例;" -#: ../../library/asyncio-eventloop.rst:1379 +#: ../../library/asyncio-eventloop.rst:1446 msgid "'protocol' (optional): :ref:`Protocol ` instance;" msgstr "'protocol'(可選): :ref:`Protocol ` 實例;" -#: ../../library/asyncio-eventloop.rst:1380 +#: ../../library/asyncio-eventloop.rst:1447 msgid "'transport' (optional): :ref:`Transport ` instance;" msgstr "'transport'(可選): :ref:`Transport ` 實例;" -#: ../../library/asyncio-eventloop.rst:1381 +#: ../../library/asyncio-eventloop.rst:1448 msgid "'socket' (optional): :class:`socket.socket` instance;" msgstr "'socket'(可選): :class:`socket.socket` 實例;" -#: ../../library/asyncio-eventloop.rst:1382 +#: ../../library/asyncio-eventloop.rst:1449 +msgid "'source_traceback' (optional): Traceback of the source;" +msgstr "" + +#: ../../library/asyncio-eventloop.rst:1450 +msgid "'handle_traceback' (optional): Traceback of the handle;" +msgstr "" + +#: ../../library/asyncio-eventloop.rst:1451 msgid "'asyncgen' (optional): Asynchronous generator that caused" msgstr "'asyncgen'(可選): 非同步產生器引發" -#: ../../library/asyncio-eventloop.rst:1383 +#: ../../library/asyncio-eventloop.rst:1452 msgid "the exception." msgstr "例外。" -#: ../../library/asyncio-eventloop.rst:1387 +#: ../../library/asyncio-eventloop.rst:1456 msgid "" "This method should not be overloaded in subclassed event loops. For custom " "exception handling, use the :meth:`set_exception_handler` method." @@ -2091,15 +2171,15 @@ msgstr "" "此方法不應在子類別事件迴圈中被覆寫。為了自定義例外處理,請使用 :meth:" "`set_exception_handler` 方法。" -#: ../../library/asyncio-eventloop.rst:1392 +#: ../../library/asyncio-eventloop.rst:1461 msgid "Enabling debug mode" msgstr "啟用除錯模式" -#: ../../library/asyncio-eventloop.rst:1396 +#: ../../library/asyncio-eventloop.rst:1465 msgid "Get the debug mode (:class:`bool`) of the event loop." msgstr "取得事件迴圈的除錯模式(\\ :class:`bool`\\ )。" -#: ../../library/asyncio-eventloop.rst:1398 +#: ../../library/asyncio-eventloop.rst:1467 msgid "" "The default value is ``True`` if the environment variable :envvar:" "`PYTHONASYNCIODEBUG` is set to a non-empty string, ``False`` otherwise." @@ -2107,17 +2187,17 @@ msgstr "" "如果環境變數 :envvar:`PYTHONASYNCIODEBUG` 被設定為非空字串,則預設值為 " "``True``,否則為 ``False``。" -#: ../../library/asyncio-eventloop.rst:1404 +#: ../../library/asyncio-eventloop.rst:1473 msgid "Set the debug mode of the event loop." msgstr "設定事件迴圈的除錯模式。" -#: ../../library/asyncio-eventloop.rst:1408 +#: ../../library/asyncio-eventloop.rst:1477 msgid "" "The new :ref:`Python Development Mode ` can now also be used to " "enable the debug mode." msgstr "現在也可以使用新的 :ref:`Python 開發模式 ` 啟用除錯模式。" -#: ../../library/asyncio-eventloop.rst:1413 +#: ../../library/asyncio-eventloop.rst:1482 msgid "" "This attribute can be used to set the minimum execution duration in seconds " "that is considered \"slow\". When debug mode is enabled, \"slow\" callbacks " @@ -2126,19 +2206,19 @@ msgstr "" "此屬性可用於設定被視為\"慢\"的最短執行時間(以秒為單位)。啟用偵錯模式" "後,\"慢\"回呼將被記錄。" -#: ../../library/asyncio-eventloop.rst:1417 +#: ../../library/asyncio-eventloop.rst:1486 msgid "Default value is 100 milliseconds." msgstr "預設值為 100 毫秒" -#: ../../library/asyncio-eventloop.rst:1421 +#: ../../library/asyncio-eventloop.rst:1490 msgid "The :ref:`debug mode of asyncio `." msgstr ":ref:`asyncio 的除錯模式 `。" -#: ../../library/asyncio-eventloop.rst:1425 +#: ../../library/asyncio-eventloop.rst:1494 msgid "Running Subprocesses" msgstr "運行子行程" -#: ../../library/asyncio-eventloop.rst:1427 +#: ../../library/asyncio-eventloop.rst:1496 msgid "" "Methods described in this subsections are low-level. In regular async/await " "code consider using the high-level :func:`asyncio.create_subprocess_shell` " @@ -2148,7 +2228,7 @@ msgstr "" "func:`asyncio.create_subprocess_shell` 和 :func:`asyncio." "create_subprocess_exec` 輔助功能而不是。" -#: ../../library/asyncio-eventloop.rst:1434 +#: ../../library/asyncio-eventloop.rst:1503 msgid "" "On Windows, the default event loop :class:`ProactorEventLoop` supports " "subprocesses, whereas :class:`SelectorEventLoop` does not. See :ref:" @@ -2158,26 +2238,26 @@ msgstr "" "`SelectorEventLoop` 不支援。詳細資訊請參見 :ref:`Windows 上對於子行程的支援 " "`。" -#: ../../library/asyncio-eventloop.rst:1445 +#: ../../library/asyncio-eventloop.rst:1515 msgid "" "Create a subprocess from one or more string arguments specified by *args*." msgstr "從 *args* 指定的一個或多個字串引數建立子行程。" -#: ../../library/asyncio-eventloop.rst:1448 +#: ../../library/asyncio-eventloop.rst:1518 msgid "*args* must be a list of strings represented by:" msgstr "*args* 必須是由以下項表示的字串串列:" -#: ../../library/asyncio-eventloop.rst:1450 +#: ../../library/asyncio-eventloop.rst:1520 msgid ":class:`str`;" msgstr ":class:`str`;" -#: ../../library/asyncio-eventloop.rst:1451 +#: ../../library/asyncio-eventloop.rst:1521 msgid "" "or :class:`bytes`, encoded to the :ref:`filesystem encoding `." msgstr "或 :class:`bytes`,編碼為 :ref:`檔案系統編碼 `。" -#: ../../library/asyncio-eventloop.rst:1454 +#: ../../library/asyncio-eventloop.rst:1524 msgid "" "The first string specifies the program executable, and the remaining strings " "specify the arguments. Together, string arguments form the ``argv`` of the " @@ -2186,7 +2266,7 @@ msgstr "" "第一個字串指定程序可執行檔案,其餘字串指定引數。字串引數一起組成程序的 " "``argv``。" -#: ../../library/asyncio-eventloop.rst:1458 +#: ../../library/asyncio-eventloop.rst:1528 msgid "" "This is similar to the standard library :class:`subprocess.Popen` class " "called with ``shell=False`` and the list of strings passed as the first " @@ -2197,7 +2277,7 @@ msgstr "" "字串串列作為第一個引數傳遞;然而,:class:`~subprocess.Popen` 接受單個字串串列" "引數,*subprocess_exec* 接受多個字串引數。" -#: ../../library/asyncio-eventloop.rst:1464 +#: ../../library/asyncio-eventloop.rst:1534 msgid "" "The *protocol_factory* must be a callable returning a subclass of the :class:" "`asyncio.SubprocessProtocol` class." @@ -2205,67 +2285,67 @@ msgstr "" "*protocol_factory* 必須是回傳 :class:`asyncio.SubprocessProtocol` 子類別的可" "呼叫物件。" -#: ../../library/asyncio-eventloop.rst:1467 +#: ../../library/asyncio-eventloop.rst:1537 msgid "Other parameters:" msgstr "其他參數:" -#: ../../library/asyncio-eventloop.rst:1469 +#: ../../library/asyncio-eventloop.rst:1539 msgid "*stdin* can be any of these:" msgstr "*stdin* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1471 -#: ../../library/asyncio-eventloop.rst:1482 -#: ../../library/asyncio-eventloop.rst:1492 +#: ../../library/asyncio-eventloop.rst:1541 +#: ../../library/asyncio-eventloop.rst:1552 +#: ../../library/asyncio-eventloop.rst:1562 msgid "a file-like object" msgstr "類檔案物件" -#: ../../library/asyncio-eventloop.rst:1472 +#: ../../library/asyncio-eventloop.rst:1542 msgid "" "an existing file descriptor (a positive integer), for example those created " "with :meth:`os.pipe`" msgstr "現有的檔案描述器(正整數),例如用 :meth:`os.pipe` 建立的" -#: ../../library/asyncio-eventloop.rst:1473 -#: ../../library/asyncio-eventloop.rst:1483 -#: ../../library/asyncio-eventloop.rst:1493 +#: ../../library/asyncio-eventloop.rst:1543 +#: ../../library/asyncio-eventloop.rst:1553 +#: ../../library/asyncio-eventloop.rst:1563 msgid "" "the :const:`subprocess.PIPE` constant (default) which will create a new pipe " "and connect it," msgstr ":const:`subprocess.PIPE` 常數(預設),它將建立一個新的管道並連線," -#: ../../library/asyncio-eventloop.rst:1475 -#: ../../library/asyncio-eventloop.rst:1485 -#: ../../library/asyncio-eventloop.rst:1495 +#: ../../library/asyncio-eventloop.rst:1545 +#: ../../library/asyncio-eventloop.rst:1555 +#: ../../library/asyncio-eventloop.rst:1565 msgid "" "the value ``None`` which will make the subprocess inherit the file " "descriptor from this process" msgstr "值 ``None`` 將使子行程從此行程繼承檔案描述器" -#: ../../library/asyncio-eventloop.rst:1477 -#: ../../library/asyncio-eventloop.rst:1487 -#: ../../library/asyncio-eventloop.rst:1497 +#: ../../library/asyncio-eventloop.rst:1547 +#: ../../library/asyncio-eventloop.rst:1557 +#: ../../library/asyncio-eventloop.rst:1567 msgid "" "the :const:`subprocess.DEVNULL` constant which indicates that the special :" "data:`os.devnull` file will be used" msgstr "" ":const:`subprocess.DEVNULL` 常數,表示將使用特殊的 :data:`os.devnull` 檔案" -#: ../../library/asyncio-eventloop.rst:1480 +#: ../../library/asyncio-eventloop.rst:1550 msgid "*stdout* can be any of these:" msgstr "*stdout* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1490 +#: ../../library/asyncio-eventloop.rst:1560 msgid "*stderr* can be any of these:" msgstr "*stderr* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1499 +#: ../../library/asyncio-eventloop.rst:1569 msgid "" "the :const:`subprocess.STDOUT` constant which will connect the standard " "error stream to the process' standard output stream" msgstr "" ":const:`subprocess.STDOUT` 常數,它將標準錯誤串流連線到行程的標準輸出串流" -#: ../../library/asyncio-eventloop.rst:1502 +#: ../../library/asyncio-eventloop.rst:1572 msgid "" "All other keyword arguments are passed to :class:`subprocess.Popen` without " "interpretation, except for *bufsize*, *universal_newlines*, *shell*, *text*, " @@ -2275,7 +2355,7 @@ msgstr "" "*bufsize*、*universal_newlines*、*shell*、*text*、*encoding* 和 *errors* 除" "外,這些不應該指定。" -#: ../../library/asyncio-eventloop.rst:1507 +#: ../../library/asyncio-eventloop.rst:1577 msgid "" "The ``asyncio`` subprocess API does not support decoding the streams as " "text. :func:`bytes.decode` can be used to convert the bytes returned from " @@ -2284,7 +2364,7 @@ msgstr "" "``asyncio`` 子行程 API 不支援將串流解碼為文本。可以使用 :func:`bytes.decode` " "將從串流回傳的位元組轉換為文本。" -#: ../../library/asyncio-eventloop.rst:1511 +#: ../../library/asyncio-eventloop.rst:1581 msgid "" "If a file-like object passed as *stdin*, *stdout* or *stderr* represents a " "pipe, then the other side of this pipe should be registered with :meth:" @@ -2295,13 +2375,13 @@ msgstr "" "端應該使用 :meth:`~loop.connect_write_pipe` 或 :meth:`~loop." "connect_read_pipe` 註冊到事件迴圈中。" -#: ../../library/asyncio-eventloop.rst:1516 +#: ../../library/asyncio-eventloop.rst:1586 msgid "" "See the constructor of the :class:`subprocess.Popen` class for documentation " "on other arguments." msgstr "有關其他引數的文件,請參閱 :class:`subprocess.Popen` 類別的建構函式。" -#: ../../library/asyncio-eventloop.rst:1519 +#: ../../library/asyncio-eventloop.rst:1589 msgid "" "Returns a pair of ``(transport, protocol)``, where *transport* conforms to " "the :class:`asyncio.SubprocessTransport` base class and *protocol* is an " @@ -2311,16 +2391,16 @@ msgstr "" "SubprocessTransport` 基底類別,*protocol* 是由 *protocol_factory* 實例化的物" "件。" -#: ../../library/asyncio-eventloop.rst:1527 +#: ../../library/asyncio-eventloop.rst:1598 msgid "" "Create a subprocess from *cmd*, which can be a :class:`str` or a :class:" "`bytes` string encoded to the :ref:`filesystem encoding `, using the platform's \"shell\" syntax." msgstr "" -"使用平台的 “shell” 語法從 *cmd* 建立子行程,*cmd* 可以是 :class:`str` 或編碼" -"為 :ref:`檔案系統編碼 ` 的 :class:`bytes` 字串。" +"使用平台的 \"shell\" 語法從 *cmd* 建立子行程,*cmd* 可以是 :class:`str` 或編" +"碼為 :ref:`檔案系統編碼 ` 的 :class:`bytes` 字串。" -#: ../../library/asyncio-eventloop.rst:1532 +#: ../../library/asyncio-eventloop.rst:1603 msgid "" "This is similar to the standard library :class:`subprocess.Popen` class " "called with ``shell=True``." @@ -2328,7 +2408,7 @@ msgstr "" "這類似於標準函式庫中的 :class:`subprocess.Popen` 類別,使用 ``shell=True`` 呼" "叫。" -#: ../../library/asyncio-eventloop.rst:1535 +#: ../../library/asyncio-eventloop.rst:1606 msgid "" "The *protocol_factory* must be a callable returning a subclass of the :class:" "`SubprocessProtocol` class." @@ -2336,13 +2416,13 @@ msgstr "" "*protocol_factory* 必須是回傳 :class:`SubprocessProtocol` 子類別的可呼叫物" "件。" -#: ../../library/asyncio-eventloop.rst:1538 +#: ../../library/asyncio-eventloop.rst:1609 msgid "" "See :meth:`~loop.subprocess_exec` for more details about the remaining " "arguments." msgstr "有關其餘引數的更多詳細資訊,請參閱 :meth:`~loop.subprocess_exec`。" -#: ../../library/asyncio-eventloop.rst:1541 +#: ../../library/asyncio-eventloop.rst:1612 msgid "" "Returns a pair of ``(transport, protocol)``, where *transport* conforms to " "the :class:`SubprocessTransport` base class and *protocol* is an object " @@ -2352,7 +2432,7 @@ msgstr "" "`SubprocessTransport` 基底類別,而 *protocol* 是由 *protocol_factory* 實例化" "的物件。" -#: ../../library/asyncio-eventloop.rst:1546 +#: ../../library/asyncio-eventloop.rst:1617 msgid "" "It is the application's responsibility to ensure that all whitespace and " "special characters are quoted appropriately to avoid `shell injection " @@ -2365,11 +2445,11 @@ msgstr "" "wikipedia.org/wiki/Shell_injection#Shell_injection>`_\\ 風險。可以使用 :func:" "`shlex.quote` 函式來正確跳脫用於構建 shell 命令的字串中的空白和特殊字元。" -#: ../../library/asyncio-eventloop.rst:1555 +#: ../../library/asyncio-eventloop.rst:1626 msgid "Callback Handles" msgstr "回呼處理" -#: ../../library/asyncio-eventloop.rst:1559 +#: ../../library/asyncio-eventloop.rst:1630 msgid "" "A callback wrapper object returned by :meth:`loop.call_soon`, :meth:`loop." "call_soon_threadsafe`." @@ -2377,46 +2457,46 @@ msgstr "" "由 :meth:`loop.call_soon` 和 :meth:`loop.call_soon_threadsafe` 回傳的回呼包裝" "器。" -#: ../../library/asyncio-eventloop.rst:1564 +#: ../../library/asyncio-eventloop.rst:1635 msgid "" "Return the :class:`contextvars.Context` object associated with the handle." msgstr "回傳與處理相關聯的 :class:`contextvars.Context` 物件。" -#: ../../library/asyncio-eventloop.rst:1571 +#: ../../library/asyncio-eventloop.rst:1642 msgid "" "Cancel the callback. If the callback has already been canceled or executed, " "this method has no effect." msgstr "取消回呼。如果回呼已被取消或執行,此方法將不起作用。" -#: ../../library/asyncio-eventloop.rst:1576 +#: ../../library/asyncio-eventloop.rst:1647 msgid "Return ``True`` if the callback was cancelled." msgstr "如果回呼已被取消,回傳 ``True``。" -#: ../../library/asyncio-eventloop.rst:1582 +#: ../../library/asyncio-eventloop.rst:1653 msgid "" "A callback wrapper object returned by :meth:`loop.call_later`, and :meth:" "`loop.call_at`." msgstr "由 :meth:`loop.call_later` 和 :meth:`loop.call_at` 回傳的回呼包裝器。" -#: ../../library/asyncio-eventloop.rst:1585 +#: ../../library/asyncio-eventloop.rst:1656 msgid "This class is a subclass of :class:`Handle`." msgstr "這個類別是 :class:`Handle` 的子類別。" -#: ../../library/asyncio-eventloop.rst:1589 +#: ../../library/asyncio-eventloop.rst:1660 msgid "Return a scheduled callback time as :class:`float` seconds." msgstr "回傳預定的回呼時間,以 :class:`float` 秒為單位。" -#: ../../library/asyncio-eventloop.rst:1591 +#: ../../library/asyncio-eventloop.rst:1662 msgid "" "The time is an absolute timestamp, using the same time reference as :meth:" "`loop.time`." msgstr "時間是一個絕對的時間戳,使用與 :meth:`loop.time` 相同的時間參照。" -#: ../../library/asyncio-eventloop.rst:1598 +#: ../../library/asyncio-eventloop.rst:1669 msgid "Server Objects" msgstr "Server 物件" -#: ../../library/asyncio-eventloop.rst:1600 +#: ../../library/asyncio-eventloop.rst:1671 msgid "" "Server objects are created by :meth:`loop.create_server`, :meth:`loop." "create_unix_server`, :func:`start_server`, and :func:`start_unix_server` " @@ -2426,11 +2506,11 @@ msgstr "" "create_unix_server`、:func:`start_server` 和 :func:`start_unix_server` 函式所" "建立。" -#: ../../library/asyncio-eventloop.rst:1604 +#: ../../library/asyncio-eventloop.rst:1675 msgid "Do not instantiate the :class:`Server` class directly." msgstr "請勿直接實例化 :class:`Server` 類別。" -#: ../../library/asyncio-eventloop.rst:1608 +#: ../../library/asyncio-eventloop.rst:1679 msgid "" "*Server* objects are asynchronous context managers. When used in an ``async " "with`` statement, it's guaranteed that the Server object is closed and not " @@ -2439,7 +2519,7 @@ msgstr "" "*Server* 物件是非同步情境管理器。當在 ``async with`` 陳述中使用時,可以保證在" "完成 ``async with`` 陳述時,Server 物件將會關閉並停止接受新的連線: ::" -#: ../../library/asyncio-eventloop.rst:1613 +#: ../../library/asyncio-eventloop.rst:1684 msgid "" "srv = await loop.create_server(...)\n" "\n" @@ -2448,31 +2528,37 @@ msgid "" "\n" "# At this point, srv is closed and no longer accepts new connections." msgstr "" +"srv = await loop.create_server(...)\n" +"\n" +"async with srv:\n" +" # 一些程式碼\n" +"\n" +"# 此時 srv 已關閉,不再接受新的連線。" -#: ../../library/asyncio-eventloop.rst:1621 +#: ../../library/asyncio-eventloop.rst:1692 msgid "Server object is an asynchronous context manager since Python 3.7." msgstr "自 Python 3.7 起,Server 物件是非同步情境管理器。" -#: ../../library/asyncio-eventloop.rst:1624 +#: ../../library/asyncio-eventloop.rst:1695 msgid "" "This class was exposed publicly as ``asyncio.Server`` in Python 3.9.11, " "3.10.3 and 3.11." msgstr "" "此類別在 Python 3.9.11、3.10.3 和 3.11 中以 ``asyncio.Server`` 的形式被公開。" -#: ../../library/asyncio-eventloop.rst:1629 +#: ../../library/asyncio-eventloop.rst:1700 msgid "" "Stop serving: close listening sockets and set the :attr:`sockets` attribute " "to ``None``." msgstr "停止服務:關閉監聽的 sockets 並將 :attr:`sockets` 屬性設為 ``None``。" -#: ../../library/asyncio-eventloop.rst:1632 +#: ../../library/asyncio-eventloop.rst:1703 msgid "" "The sockets that represent existing incoming client connections are left " "open." msgstr "代表現有傳入用戶端連線的 sockets 仍然保持開啟。" -#: ../../library/asyncio-eventloop.rst:1635 +#: ../../library/asyncio-eventloop.rst:1706 msgid "" "The server is closed asynchronously; use the :meth:`wait_closed` coroutine " "to wait until the server is closed (and no more connections are active)." @@ -2480,21 +2566,53 @@ msgstr "" "伺服器以非同步方式關閉;使用 :meth:`wait_close` 協程等待伺服器關閉(不再有活" "躍連線)。" -#: ../../library/asyncio-eventloop.rst:1641 +#: ../../library/asyncio-eventloop.rst:1712 +msgid "Close all existing incoming client connections." +msgstr "關閉所有現有的傳入用戶端連線。" + +#: ../../library/asyncio-eventloop.rst:1714 +msgid "" +"Calls :meth:`~asyncio.BaseTransport.close` on all associated transports." +msgstr "在所有關聯的傳輸上呼叫 :meth:`~asyncio.BaseTransport.close`。" + +#: ../../library/asyncio-eventloop.rst:1717 +msgid "" +":meth:`close` should be called before :meth:`close_clients` when closing the " +"server to avoid races with new clients connecting." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:1724 +msgid "" +"Close all existing incoming client connections immediately, without waiting " +"for pending operations to complete." +msgstr "立即關閉所有現有的傳入用戶端連線,而不等待待定操作完成。" + +#: ../../library/asyncio-eventloop.rst:1727 +msgid "" +"Calls :meth:`~asyncio.WriteTransport.abort` on all associated transports." +msgstr "在所有關聯的傳輸上呼叫 :meth:`~asyncio.BaseTransport.close`。" + +#: ../../library/asyncio-eventloop.rst:1730 +msgid "" +":meth:`close` should be called before :meth:`abort_clients` when closing the " +"server to avoid races with new clients connecting." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:1737 msgid "Return the event loop associated with the server object." msgstr "回傳與伺服器物件關聯的事件迴圈。" -#: ../../library/asyncio-eventloop.rst:1647 +#: ../../library/asyncio-eventloop.rst:1744 msgid "Start accepting connections." msgstr "開始接受連線。" -#: ../../library/asyncio-eventloop.rst:1649 +#: ../../library/asyncio-eventloop.rst:1746 msgid "" "This method is idempotent, so it can be called when the server is already " "serving." msgstr "此方法是幂等的,因此可以在伺服器已經運行時呼叫。" -#: ../../library/asyncio-eventloop.rst:1652 +#: ../../library/asyncio-eventloop.rst:1749 msgid "" "The *start_serving* keyword-only parameter to :meth:`loop.create_server` " "and :meth:`asyncio.start_server` allows creating a Server object that is not " @@ -2507,14 +2625,14 @@ msgstr "" "種情況下,可以使用 ``Server.start_serving()`` 或 :meth:`Server." "serve_forever` 來使 Server 開始接受連線。" -#: ../../library/asyncio-eventloop.rst:1663 +#: ../../library/asyncio-eventloop.rst:1761 msgid "" "Start accepting connections until the coroutine is cancelled. Cancellation " "of ``serve_forever`` task causes the server to be closed." msgstr "" "開始接受連線,直到協程被取消。取消 ``serve_forever`` 任務會導致伺服器關閉。" -#: ../../library/asyncio-eventloop.rst:1667 +#: ../../library/asyncio-eventloop.rst:1765 msgid "" "This method can be called if the server is already accepting connections. " "Only one ``serve_forever`` task can exist per one *Server* object." @@ -2522,7 +2640,7 @@ msgstr "" "如果伺服器已經接受連線,則可以呼叫此方法。每個 *Server* 物件只能存在一個 " "``serve_forever`` 任務。" -#: ../../library/asyncio-eventloop.rst:1673 +#: ../../library/asyncio-eventloop.rst:1771 msgid "" "async def client_connected(reader, writer):\n" " # Communicate with the client with\n" @@ -2536,25 +2654,36 @@ msgid "" "\n" "asyncio.run(main('127.0.0.1', 0))" msgstr "" +"async def client_connected(reader, writer):\n" +" # 透過讀取器/寫入器串流\n" +" # 與用戶端溝通。例如:\n" +" await reader.readline()\n" +"\n" +"async def main(host, port):\n" +" srv = await asyncio.start_server(\n" +" client_connected, host, port)\n" +" await srv.serve_forever()\n" +"\n" +"asyncio.run(main('127.0.0.1', 0))" -#: ../../library/asyncio-eventloop.rst:1689 +#: ../../library/asyncio-eventloop.rst:1787 msgid "Return ``True`` if the server is accepting new connections." msgstr "如果伺服器正在接受新連線,則回傳 ``True``。" -#: ../../library/asyncio-eventloop.rst:1695 +#: ../../library/asyncio-eventloop.rst:1794 msgid "" "Wait until the :meth:`close` method completes and all active connections " "have finished." msgstr "等待 :meth:`close` 方法完成且所有活動連線都已結束。" -#: ../../library/asyncio-eventloop.rst:1700 +#: ../../library/asyncio-eventloop.rst:1799 msgid "" "List of socket-like objects, ``asyncio.trsock.TransportSocket``, which the " "server is listening on." msgstr "" "伺服器正在監聽的類似 socket 的物件串列,``asyncio.trsock.TransportSocket``。" -#: ../../library/asyncio-eventloop.rst:1703 +#: ../../library/asyncio-eventloop.rst:1802 msgid "" "Prior to Python 3.7 ``Server.sockets`` used to return an internal list of " "server sockets directly. In 3.7 a copy of that list is returned." @@ -2562,11 +2691,11 @@ msgstr "" "在 Python 3.7 之前,``Server.sockets`` 曾經直接回傳內部伺服器 sockets 的串" "列。在 3.7 中回傳了該串列的副本。" -#: ../../library/asyncio-eventloop.rst:1713 +#: ../../library/asyncio-eventloop.rst:1812 msgid "Event Loop Implementations" msgstr "事件迴圈實作" -#: ../../library/asyncio-eventloop.rst:1715 +#: ../../library/asyncio-eventloop.rst:1814 msgid "" "asyncio ships with two different event loop implementations: :class:" "`SelectorEventLoop` and :class:`ProactorEventLoop`." @@ -2574,19 +2703,17 @@ msgstr "" "asyncio 內附兩個不同的事件迴圈實作::class:`SelectorEventLoop` 和 :class:" "`ProactorEventLoop`。" -#: ../../library/asyncio-eventloop.rst:1718 -msgid "" -"By default asyncio is configured to use :class:`SelectorEventLoop` on Unix " -"and :class:`ProactorEventLoop` on Windows." -msgstr "" -"預設情況下,asyncio 配置為在 Unix 上使用 :class:`SelectorEventLoop`,在 " -"Windows 上使用 :class:`ProactorEventLoop`。" +#: ../../library/asyncio-eventloop.rst:1817 +msgid "By default asyncio is configured to use :class:`EventLoop`." +msgstr "預設情況下,asyncio 被配置為要使用 :class:`EventLoop`。" -#: ../../library/asyncio-eventloop.rst:1724 -msgid "An event loop based on the :mod:`selectors` module." -msgstr "基於 :mod:`selectors` 模組的事件迴圈。" +#: ../../library/asyncio-eventloop.rst:1822 +msgid "" +"A subclass of :class:`AbstractEventLoop` based on the :mod:`selectors` " +"module." +msgstr "基於 :mod:`selectors` 模組的一個 :class:`AbstractEventLoop` 子類別。" -#: ../../library/asyncio-eventloop.rst:1726 +#: ../../library/asyncio-eventloop.rst:1825 msgid "" "Uses the most efficient *selector* available for the given platform. It is " "also possible to manually configure the exact selector implementation to be " @@ -2595,7 +2722,7 @@ msgstr "" "使用特定平台上最有效的 *selector*。也可以手動配置要使用的確切 selector 實" "作: ::" -#: ../../library/asyncio-eventloop.rst:1730 +#: ../../library/asyncio-eventloop.rst:1829 msgid "" "import asyncio\n" "import selectors\n" @@ -2617,31 +2744,41 @@ msgstr "" "\n" "asyncio.set_event_loop_policy(MyPolicy())" -#: ../../library/asyncio-eventloop.rst:1741 -msgid ":ref:`Availability `: Unix, Windows." -msgstr ":ref:`適用 `:Unix、Windows。" +#: ../../library/asyncio-eventloop.rst:1845 +msgid "" +"A subclass of :class:`AbstractEventLoop` for Windows that uses \"I/O " +"Completion Ports\" (IOCP)." +msgstr "" +"用於 Windows 的 :class:`AbstractEventLoop` 子類別,使用「I/O 完成埠 (IOCP, I/" +"O Completion Ports)」。" -#: ../../library/asyncio-eventloop.rst:1746 -msgid "An event loop for Windows that uses \"I/O Completion Ports\" (IOCP)." -msgstr "用於 Windows 的事件迴圈,使用\"I/O 完成埠\"(IOCP)。" +#: ../../library/asyncio-eventloop.rst:1851 +msgid "" +"`MSDN documentation on I/O Completion Ports `_." +msgstr "" +"`I/O 完成埠的 MSDN 文件 `_。" -#: ../../library/asyncio-eventloop.rst:1748 -msgid ":ref:`Availability `: Windows." -msgstr ":ref:`適用 `:Windows。" +#: ../../library/asyncio-eventloop.rst:1856 +msgid "" +"An alias to the most efficient available subclass of :class:" +"`AbstractEventLoop` for the given platform." +msgstr "" -#: ../../library/asyncio-eventloop.rst:1752 +#: ../../library/asyncio-eventloop.rst:1859 msgid "" -"`MSDN documentation on I/O Completion Ports `_." +"It is an alias to :class:`SelectorEventLoop` on Unix and :class:" +"`ProactorEventLoop` on Windows." msgstr "" -"`I/O 完成埠(I/O Completion Ports)的 MSDN 文件 `_。" +"在 Unix 上是 :class:`SelectorEventLoop` 的別名,在 Windows 上是 :class:" +"`ProactorEventLoop` 的別名。" -#: ../../library/asyncio-eventloop.rst:1758 +#: ../../library/asyncio-eventloop.rst:1865 msgid "Abstract base class for asyncio-compliant event loops." msgstr "為符合 asyncio 標準的事件迴圈的抽象基礎類別。" -#: ../../library/asyncio-eventloop.rst:1760 +#: ../../library/asyncio-eventloop.rst:1867 msgid "" "The :ref:`asyncio-event-loop-methods` section lists all methods that an " "alternative implementation of ``AbstractEventLoop`` should have defined." @@ -2649,11 +2786,11 @@ msgstr "" ":ref:`asyncio-event-loop-methods` 部分列出了替代 ``AbstractEventLoop`` 實作應" "該定義的所有方法。" -#: ../../library/asyncio-eventloop.rst:1766 +#: ../../library/asyncio-eventloop.rst:1873 msgid "Examples" msgstr "範例" -#: ../../library/asyncio-eventloop.rst:1768 +#: ../../library/asyncio-eventloop.rst:1875 msgid "" "Note that all examples in this section **purposefully** show how to use the " "low-level event loop APIs, such as :meth:`loop.run_forever` and :meth:`loop." @@ -2664,11 +2801,11 @@ msgstr "" "`loop.run_forever` 和 :meth:`loop.call_soon`。現代 asyncio 應用程式很少需要這" "種方式撰寫;請考慮使用高階的函式,如 :func:`asyncio.run`。" -#: ../../library/asyncio-eventloop.rst:1778 +#: ../../library/asyncio-eventloop.rst:1885 msgid "Hello World with call_soon()" msgstr "使用 call_soon() 的 Hello World 範例" -#: ../../library/asyncio-eventloop.rst:1780 +#: ../../library/asyncio-eventloop.rst:1887 msgid "" "An example using the :meth:`loop.call_soon` method to schedule a callback. " "The callback displays ``\"Hello World\"`` and then stops the event loop::" @@ -2676,7 +2813,7 @@ msgstr "" "使用 :meth:`loop.call_soon` 方法排程回呼的範例。回呼會顯示 ``\"Hello " "World\"``,然後停止事件迴圈: ::" -#: ../../library/asyncio-eventloop.rst:1784 +#: ../../library/asyncio-eventloop.rst:1891 msgid "" "import asyncio\n" "\n" @@ -2696,19 +2833,36 @@ msgid "" "finally:\n" " loop.close()" msgstr "" +"import asyncio\n" +"\n" +"def hello_world(loop):\n" +" \"\"\"列印 'Hello World' 並停止事件迴圈的回呼\"\"\"\n" +" print('Hello World')\n" +" loop.stop()\n" +"\n" +"loop = asyncio.new_event_loop()\n" +"\n" +"# 排程對 hello_world() 的呼叫\n" +"loop.call_soon(hello_world, loop)\n" +"\n" +"# 阻塞呼叫被 loop.stop() 中斷\n" +"try:\n" +" loop.run_forever()\n" +"finally:\n" +" loop.close()" -#: ../../library/asyncio-eventloop.rst:1804 +#: ../../library/asyncio-eventloop.rst:1911 msgid "" "A similar :ref:`Hello World ` example created with a coroutine " "and the :func:`run` function." msgstr "" "使用協程和 :func:`run` 函式建立的類似 :ref:`Hello World ` 範例。" -#: ../../library/asyncio-eventloop.rst:1811 +#: ../../library/asyncio-eventloop.rst:1918 msgid "Display the current date with call_later()" msgstr "使用 call_later() 顯示目前日期" -#: ../../library/asyncio-eventloop.rst:1813 +#: ../../library/asyncio-eventloop.rst:1920 msgid "" "An example of a callback displaying the current date every second. The " "callback uses the :meth:`loop.call_later` method to reschedule itself after " @@ -2717,7 +2871,7 @@ msgstr "" "一個回呼的範例,每秒顯示目前日期。回呼使用 :meth:`loop.call_later` 方法在 5 " "秒後重新排程自己,然後停止事件迴圈: ::" -#: ../../library/asyncio-eventloop.rst:1817 +#: ../../library/asyncio-eventloop.rst:1924 msgid "" "import asyncio\n" "import datetime\n" @@ -2741,8 +2895,29 @@ msgid "" "finally:\n" " loop.close()" msgstr "" +"import asyncio\n" +"import datetime\n" +"\n" +"def display_date(end_time, loop):\n" +" print(datetime.datetime.now())\n" +" if (loop.time() + 1.0) < end_time:\n" +" loop.call_later(1, display_date, end_time, loop)\n" +" else:\n" +" loop.stop()\n" +"\n" +"loop = asyncio.new_event_loop()\n" +"\n" +"# 排程 display_date() 的第一次呼叫\n" +"end_time = loop.time() + 5.0\n" +"loop.call_soon(display_date, end_time, loop)\n" +"\n" +"# 阻塞呼叫被 loop.stop() 中斷\n" +"try:\n" +" loop.run_forever()\n" +"finally:\n" +" loop.close()" -#: ../../library/asyncio-eventloop.rst:1841 +#: ../../library/asyncio-eventloop.rst:1948 msgid "" "A similar :ref:`current date ` example created with a " "coroutine and the :func:`run` function." @@ -2750,11 +2925,11 @@ msgstr "" "使用協程和 :func:`run` 函式建立的類似 :ref:`current date " "` 範例。" -#: ../../library/asyncio-eventloop.rst:1848 +#: ../../library/asyncio-eventloop.rst:1955 msgid "Watch a file descriptor for read events" msgstr "監聽檔案描述器以進行讀取事件" -#: ../../library/asyncio-eventloop.rst:1850 +#: ../../library/asyncio-eventloop.rst:1957 msgid "" "Wait until a file descriptor received some data using the :meth:`loop." "add_reader` method and then close the event loop::" @@ -2762,7 +2937,7 @@ msgstr "" "使用 :meth:`loop.add_reader` 方法等待檔案描述器接收到某些資料,然後關閉事件迴" "圈: ::" -#: ../../library/asyncio-eventloop.rst:1853 +#: ../../library/asyncio-eventloop.rst:1960 msgid "" "import asyncio\n" "from socket import socketpair\n" @@ -2797,8 +2972,40 @@ msgid "" " wsock.close()\n" " loop.close()" msgstr "" +"import asyncio\n" +"from socket import socketpair\n" +"\n" +"# 建立一對連接的檔案描述器\n" +"rsock, wsock = socketpair()\n" +"\n" +"loop = asyncio.new_event_loop()\n" +"\n" +"def reader():\n" +" data = rsock.recv(100)\n" +" print(\"Received:\", data.decode())\n" +"\n" +" # 我們完成了:註銷檔案描述器\n" +" loop.remove_reader(rsock)\n" +"\n" +" # 停止事件迴圈\n" +" loop.stop()\n" +"\n" +"# 為讀取事件註冊檔案描述器\n" +"loop.add_reader(rsock, reader)\n" +"\n" +"# 模擬從網路接收資料\n" +"loop.call_soon(wsock.send, 'abc'.encode())\n" +"\n" +"try:\n" +" # 運行事件迴圈\n" +" loop.run_forever()\n" +"finally:\n" +" # 我們完成了。關閉 socket 和事件迴圈。\n" +" rsock.close()\n" +" wsock.close()\n" +" loop.close()" -#: ../../library/asyncio-eventloop.rst:1888 +#: ../../library/asyncio-eventloop.rst:1995 msgid "" "A similar :ref:`example ` using " "transports, protocols, and the :meth:`loop.create_connection` method." @@ -2806,7 +3013,7 @@ msgstr "" "使用傳輸、協定和 :meth:`loop.create_connection` 方法的類似 :ref:`範例 " "`。" -#: ../../library/asyncio-eventloop.rst:1892 +#: ../../library/asyncio-eventloop.rst:1999 msgid "" "Another similar :ref:`example ` " "using the high-level :func:`asyncio.open_connection` function and streams." @@ -2814,15 +3021,15 @@ msgstr "" "另一個使用高階 :func:`asyncio.open_connection` 函式和串流的類似 :ref:`範例 " "`。" -#: ../../library/asyncio-eventloop.rst:1900 +#: ../../library/asyncio-eventloop.rst:2007 msgid "Set signal handlers for SIGINT and SIGTERM" msgstr "設定 SIGINT 和 SIGTERM 的訊號處理程式" -#: ../../library/asyncio-eventloop.rst:1902 +#: ../../library/asyncio-eventloop.rst:2009 msgid "(This ``signals`` example only works on Unix.)" msgstr "(此 ``signals`` 範例僅在 Unix 上運作。)" -#: ../../library/asyncio-eventloop.rst:1904 +#: ../../library/asyncio-eventloop.rst:2011 msgid "" "Register handlers for signals :const:`~signal.SIGINT` and :const:`~signal." "SIGTERM` using the :meth:`loop.add_signal_handler` method::" @@ -2830,7 +3037,7 @@ msgstr "" "使用 :meth:`loop.add_signal_handler` 方法註冊訊號 :py:data:`SIGINT` 和 :py:" "data:`SIGTERM` 的處理程式: ::" -#: ../../library/asyncio-eventloop.rst:1907 +#: ../../library/asyncio-eventloop.rst:2014 msgid "" "import asyncio\n" "import functools\n" @@ -2856,3 +3063,26 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"import functools\n" +"import os\n" +"import signal\n" +"\n" +"def ask_exit(signame, loop):\n" +" print(\"got signal %s: exit\" % signame)\n" +" loop.stop()\n" +"\n" +"async def main():\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" for signame in {'SIGINT', 'SIGTERM'}:\n" +" loop.add_signal_handler(\n" +" getattr(signal, signame),\n" +" functools.partial(ask_exit, signame, loop))\n" +"\n" +" await asyncio.sleep(3600)\n" +"\n" +"print(\"Event loop running for 1 hour, press Ctrl+C to interrupt.\")\n" +"print(f\"pid {os.getpid()}: send SIGINT or SIGTERM to exit.\")\n" +"\n" +"asyncio.run(main())" diff --git a/library/asyncio-exceptions.po b/library/asyncio-exceptions.po index edf7cb0316..e08327656e 100644 --- a/library/asyncio-exceptions.po +++ b/library/asyncio-exceptions.po @@ -6,7 +6,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-07-06 00:19+0000\n" "PO-Revision-Date: 2022-01-31 21:41+0800\n" diff --git a/library/asyncio-extending.po b/library/asyncio-extending.po index 630ff63a24..f7a1ab412f 100644 --- a/library/asyncio-extending.po +++ b/library/asyncio-extending.po @@ -1,4 +1,3 @@ -# SOME DESCRIPTIVE TITLE. # Copyright (C) 2001-2022, Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR , YEAR. @@ -6,12 +5,13 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-07-29 10:36+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" diff --git a/library/asyncio-future.po b/library/asyncio-future.po index fb7a7be464..94e7426522 100644 --- a/library/asyncio-future.po +++ b/library/asyncio-future.po @@ -5,7 +5,7 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2022-01-25 01:29+0800\n" @@ -285,7 +285,7 @@ msgid "" "context is used when no *context* is provided." msgstr "" "可選僅限關鍵字引數 *context* 用來指定一個讓 *callback* 執行於其中的客製化 :" -"class:`contextvars.Context` 物件。如果沒有提供 *context*,則使用當前情境。" +"class:`contextvars.Context` 物件。如果沒有提供 *context*,則使用目前情境。" #: ../../library/asyncio-future.rst:171 msgid "" diff --git a/library/asyncio-llapi-index.po b/library/asyncio-llapi-index.po index 8cd2352ae1..22a41d34ec 100644 --- a/library/asyncio-llapi-index.po +++ b/library/asyncio-llapi-index.po @@ -6,7 +6,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-10-11 17:13+0000\n" "PO-Revision-Date: 2023-10-12 11:27+0800\n" @@ -29,7 +29,7 @@ msgstr "本頁列出所有低階 asyncio APIs。" #: ../../library/asyncio-llapi-index.rst:12 msgid "Obtaining the Event Loop" -msgstr "獲取事件迴圈" +msgstr "取得事件迴圈" #: ../../library/asyncio-llapi-index.rst:18 msgid ":func:`asyncio.get_running_loop`" @@ -37,7 +37,7 @@ msgstr ":func:`asyncio.get_running_loop`" #: ../../library/asyncio-llapi-index.rst:19 msgid "The **preferred** function to get the running event loop." -msgstr "**推薦使用**\\ 於獲取當前運行事件迴圈 (event loop) 的函式。" +msgstr "**推薦使用**\\ 於取得目前運行事件迴圈 (event loop) 的函式。" #: ../../library/asyncio-llapi-index.rst:21 msgid ":func:`asyncio.get_event_loop`" @@ -45,7 +45,7 @@ msgstr ":func:`asyncio.get_event_loop`" #: ../../library/asyncio-llapi-index.rst:22 msgid "Get an event loop instance (running or current via the current policy)." -msgstr "獲得一個(正在運行的或透過當前 policy 建立的)事件迴圈實例。" +msgstr "獲得一個(正在運行的或透過目前 policy 建立的)事件迴圈實例。" #: ../../library/asyncio-llapi-index.rst:24 msgid ":func:`asyncio.set_event_loop`" @@ -53,7 +53,7 @@ msgstr ":func:`asyncio.set_event_loop`" #: ../../library/asyncio-llapi-index.rst:25 msgid "Set the event loop as current via the current policy." -msgstr "透過當前 policy 來設定當前事件迴圈。" +msgstr "透過目前 policy 來設定目前事件迴圈。" #: ../../library/asyncio-llapi-index.rst:27 msgid ":func:`asyncio.new_event_loop`" @@ -160,7 +160,7 @@ msgstr ":meth:`loop.get_debug`" #: ../../library/asyncio-llapi-index.rst:78 msgid "Get the current debug mode." -msgstr "獲取當前除錯模式。" +msgstr "取得目前除錯模式。" #: ../../library/asyncio-llapi-index.rst:81 msgid "Scheduling Callbacks" @@ -172,7 +172,7 @@ msgstr ":meth:`loop.call_soon`" #: ../../library/asyncio-llapi-index.rst:87 msgid "Invoke a callback soon." -msgstr "儘快調用回呼函式 (callback)。" +msgstr "儘快呼叫回呼函式 (callback)。" #: ../../library/asyncio-llapi-index.rst:89 msgid ":meth:`loop.call_soon_threadsafe`" @@ -188,7 +188,7 @@ msgstr ":meth:`loop.call_later`" #: ../../library/asyncio-llapi-index.rst:93 msgid "Invoke a callback *after* the given time." -msgstr "在給定時間\\ *之後*\\ 調用回呼函式。" +msgstr "在給定時間\\ *之後*\\ 呼叫回呼函式。" #: ../../library/asyncio-llapi-index.rst:95 msgid ":meth:`loop.call_at`" @@ -196,7 +196,7 @@ msgstr ":meth:`loop.call_at`" #: ../../library/asyncio-llapi-index.rst:96 msgid "Invoke a callback *at* the given time." -msgstr "在給定時間\\ *當下*\\ 調用回呼函式。" +msgstr "在給定時間\\ *當下*\\ 呼叫回呼函式。" #: ../../library/asyncio-llapi-index.rst:99 msgid "Thread/Process Pool" @@ -263,7 +263,7 @@ msgid "" "Get the factory :meth:`loop.create_task` uses to create :class:`Tasks " "`." msgstr "" -"獲取被 :meth:`loop.create_task` 用來建立 :class:`Tasks ` 的工廠函式。" +"取得被 :meth:`loop.create_task` 用來建立 :class:`Tasks ` 的工廠函式。" #: ../../library/asyncio-llapi-index.rst:132 msgid "DNS" @@ -544,7 +544,7 @@ msgstr ":meth:`loop.get_exception_handler`" #: ../../library/asyncio-llapi-index.rst:262 msgid "Get the current exception handler." -msgstr "獲取當前例外處理函式。" +msgstr "取得目前例外處理函式。" #: ../../library/asyncio-llapi-index.rst:264 msgid ":meth:`loop.default_exception_handler`" @@ -571,7 +571,7 @@ msgid "" "Using ``loop.create_connection()`` to implement :ref:`an echo-client " "`." msgstr "" -"使用 ``loop.create_connection()`` 以實作\\ :ref:`一個 echo 客戶端 " +"使用 ``loop.create_connection()`` 以實作\\ :ref:`一個 echo 用戶端 " "`。" #: ../../library/asyncio-llapi-index.rst:278 @@ -644,7 +644,7 @@ msgstr ":meth:`transport.get_protocol() `" #: ../../library/asyncio-llapi-index.rst:311 msgid "Return the current protocol." -msgstr "回傳當前協定。" +msgstr "回傳目前協定。" #: ../../library/asyncio-llapi-index.rst:314 msgid "" @@ -749,7 +749,7 @@ msgstr "" #: ../../library/asyncio-llapi-index.rst:361 msgid "Return the current size of the output buffer." -msgstr "回傳當前輸出緩衝區的大小。" +msgstr "回傳目前輸出緩衝區的大小。" #: ../../library/asyncio-llapi-index.rst:363 msgid "" @@ -1042,7 +1042,7 @@ msgstr ":meth:`asyncio.get_event_loop_policy`" #: ../../library/asyncio-llapi-index.rst:517 msgid "Return the current process-wide policy." -msgstr "回傳當前整個行程中的 Policy。" +msgstr "回傳目前整個行程中的 Policy。" #: ../../library/asyncio-llapi-index.rst:519 msgid ":meth:`asyncio.set_event_loop_policy`" diff --git a/library/asyncio-platforms.po b/library/asyncio-platforms.po index 9d39d00beb..cc9f8570c6 100644 --- a/library/asyncio-platforms.po +++ b/library/asyncio-platforms.po @@ -8,7 +8,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2022-01-17 11:37+0800\n" diff --git a/library/asyncio-policy.po b/library/asyncio-policy.po index 3902da6867..41fd70c5a6 100644 --- a/library/asyncio-policy.po +++ b/library/asyncio-policy.po @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-10-11 00:13+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -160,8 +160,8 @@ msgid "" msgstr "" #: ../../library/asyncio-policy.rst:131 ../../library/asyncio-policy.rst:139 -msgid ":ref:`Availability `: Windows." -msgstr ":ref:`適用 `:Windows。" +msgid "Availability" +msgstr "可用性" #: ../../library/asyncio-policy.rst:136 msgid "" diff --git a/library/asyncio-protocol.po b/library/asyncio-protocol.po index 58e37add6f..9b58685f3e 100644 --- a/library/asyncio-protocol.po +++ b/library/asyncio-protocol.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2018-05-23 14:39+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -501,7 +501,14 @@ msgid "" "the target address given on transport creation." msgstr "" -#: ../../library/asyncio-protocol.rst:367 +#: ../../library/asyncio-protocol.rst:365 +msgid "" +"This method can be called with an empty bytes object to send a zero-length " +"datagram. The buffer size calculation used for flow control is also updated " +"to account for the datagram header." +msgstr "" + +#: ../../library/asyncio-protocol.rst:372 msgid "" "Close the transport immediately, without waiting for pending operations to " "complete. Buffered data will be lost. No more data will be received. The " @@ -509,110 +516,110 @@ msgid "" "method will eventually be called with :const:`None` as its argument." msgstr "" -#: ../../library/asyncio-protocol.rst:377 +#: ../../library/asyncio-protocol.rst:382 msgid "Subprocess Transports" msgstr "" -#: ../../library/asyncio-protocol.rst:381 +#: ../../library/asyncio-protocol.rst:386 msgid "Return the subprocess process id as an integer." msgstr "" -#: ../../library/asyncio-protocol.rst:385 +#: ../../library/asyncio-protocol.rst:390 msgid "" "Return the transport for the communication pipe corresponding to the integer " "file descriptor *fd*:" msgstr "" -#: ../../library/asyncio-protocol.rst:388 +#: ../../library/asyncio-protocol.rst:393 msgid "" "``0``: readable streaming transport of the standard input (*stdin*), or :" "const:`None` if the subprocess was not created with ``stdin=PIPE``" msgstr "" -#: ../../library/asyncio-protocol.rst:390 +#: ../../library/asyncio-protocol.rst:395 msgid "" "``1``: writable streaming transport of the standard output (*stdout*), or :" "const:`None` if the subprocess was not created with ``stdout=PIPE``" msgstr "" -#: ../../library/asyncio-protocol.rst:392 +#: ../../library/asyncio-protocol.rst:397 msgid "" "``2``: writable streaming transport of the standard error (*stderr*), or :" "const:`None` if the subprocess was not created with ``stderr=PIPE``" msgstr "" -#: ../../library/asyncio-protocol.rst:394 +#: ../../library/asyncio-protocol.rst:399 msgid "other *fd*: :const:`None`" msgstr "" -#: ../../library/asyncio-protocol.rst:398 +#: ../../library/asyncio-protocol.rst:403 msgid "" "Return the subprocess return code as an integer or :const:`None` if it " "hasn't returned, which is similar to the :attr:`subprocess.Popen.returncode` " "attribute." msgstr "" -#: ../../library/asyncio-protocol.rst:404 +#: ../../library/asyncio-protocol.rst:409 msgid "Kill the subprocess." msgstr "" -#: ../../library/asyncio-protocol.rst:406 +#: ../../library/asyncio-protocol.rst:411 msgid "" "On POSIX systems, the function sends SIGKILL to the subprocess. On Windows, " "this method is an alias for :meth:`terminate`." msgstr "" -#: ../../library/asyncio-protocol.rst:409 +#: ../../library/asyncio-protocol.rst:414 msgid "See also :meth:`subprocess.Popen.kill`." msgstr "另請參閱 :meth:`subprocess.Popen.kill`。" -#: ../../library/asyncio-protocol.rst:413 +#: ../../library/asyncio-protocol.rst:418 msgid "" "Send the *signal* number to the subprocess, as in :meth:`subprocess.Popen." "send_signal`." msgstr "" -#: ../../library/asyncio-protocol.rst:418 +#: ../../library/asyncio-protocol.rst:423 msgid "Stop the subprocess." msgstr "" -#: ../../library/asyncio-protocol.rst:420 +#: ../../library/asyncio-protocol.rst:425 msgid "" "On POSIX systems, this method sends :py:const:`~signal.SIGTERM` to the " "subprocess. On Windows, the Windows API function :c:func:`!TerminateProcess` " "is called to stop the subprocess." msgstr "" -#: ../../library/asyncio-protocol.rst:424 +#: ../../library/asyncio-protocol.rst:429 msgid "See also :meth:`subprocess.Popen.terminate`." msgstr "另請參閱 :meth:`subprocess.Popen.terminate`。" -#: ../../library/asyncio-protocol.rst:428 +#: ../../library/asyncio-protocol.rst:433 msgid "Kill the subprocess by calling the :meth:`kill` method." msgstr "" -#: ../../library/asyncio-protocol.rst:430 +#: ../../library/asyncio-protocol.rst:435 msgid "" "If the subprocess hasn't returned yet, and close transports of *stdin*, " "*stdout*, and *stderr* pipes." msgstr "" -#: ../../library/asyncio-protocol.rst:437 +#: ../../library/asyncio-protocol.rst:442 msgid "Protocols" msgstr "" -#: ../../library/asyncio-protocol.rst:439 +#: ../../library/asyncio-protocol.rst:444 msgid "**Source code:** :source:`Lib/asyncio/protocols.py`" msgstr "**原始碼:**\\ :source:`Lib/asyncio/protocols.py`" -#: ../../library/asyncio-protocol.rst:443 +#: ../../library/asyncio-protocol.rst:448 msgid "" "asyncio provides a set of abstract base classes that should be used to " "implement network protocols. Those classes are meant to be used together " "with :ref:`transports `." msgstr "" -#: ../../library/asyncio-protocol.rst:447 +#: ../../library/asyncio-protocol.rst:452 msgid "" "Subclasses of abstract base protocol classes may implement some or all " "methods. All these methods are callbacks: they are called by transports on " @@ -620,117 +627,117 @@ msgid "" "method should be called by the corresponding transport." msgstr "" -#: ../../library/asyncio-protocol.rst:454 +#: ../../library/asyncio-protocol.rst:459 msgid "Base Protocols" msgstr "" -#: ../../library/asyncio-protocol.rst:458 +#: ../../library/asyncio-protocol.rst:463 msgid "Base protocol with methods that all protocols share." msgstr "" -#: ../../library/asyncio-protocol.rst:462 +#: ../../library/asyncio-protocol.rst:467 msgid "" "The base class for implementing streaming protocols (TCP, Unix sockets, etc)." msgstr "" -#: ../../library/asyncio-protocol.rst:467 +#: ../../library/asyncio-protocol.rst:472 msgid "" "A base class for implementing streaming protocols with manual control of the " "receive buffer." msgstr "" -#: ../../library/asyncio-protocol.rst:472 +#: ../../library/asyncio-protocol.rst:477 msgid "The base class for implementing datagram (UDP) protocols." msgstr "" -#: ../../library/asyncio-protocol.rst:476 +#: ../../library/asyncio-protocol.rst:481 msgid "" "The base class for implementing protocols communicating with child processes " "(unidirectional pipes)." msgstr "" -#: ../../library/asyncio-protocol.rst:481 +#: ../../library/asyncio-protocol.rst:486 msgid "Base Protocol" msgstr "" -#: ../../library/asyncio-protocol.rst:483 +#: ../../library/asyncio-protocol.rst:488 msgid "All asyncio protocols can implement Base Protocol callbacks." msgstr "" -#: ../../library/asyncio-protocol.rst:486 +#: ../../library/asyncio-protocol.rst:491 msgid "Connection Callbacks" msgstr "" -#: ../../library/asyncio-protocol.rst:487 +#: ../../library/asyncio-protocol.rst:492 msgid "" "Connection callbacks are called on all protocols, exactly once per a " "successful connection. All other protocol callbacks can only be called " "between those two methods." msgstr "" -#: ../../library/asyncio-protocol.rst:493 +#: ../../library/asyncio-protocol.rst:498 msgid "Called when a connection is made." msgstr "" -#: ../../library/asyncio-protocol.rst:495 +#: ../../library/asyncio-protocol.rst:500 msgid "" "The *transport* argument is the transport representing the connection. The " "protocol is responsible for storing the reference to its transport." msgstr "" -#: ../../library/asyncio-protocol.rst:501 +#: ../../library/asyncio-protocol.rst:506 msgid "Called when the connection is lost or closed." msgstr "" -#: ../../library/asyncio-protocol.rst:503 +#: ../../library/asyncio-protocol.rst:508 msgid "" "The argument is either an exception object or :const:`None`. The latter " "means a regular EOF is received, or the connection was aborted or closed by " "this side of the connection." msgstr "" -#: ../../library/asyncio-protocol.rst:509 +#: ../../library/asyncio-protocol.rst:514 msgid "Flow Control Callbacks" msgstr "" -#: ../../library/asyncio-protocol.rst:510 +#: ../../library/asyncio-protocol.rst:515 msgid "" "Flow control callbacks can be called by transports to pause or resume " "writing performed by the protocol." msgstr "" -#: ../../library/asyncio-protocol.rst:513 +#: ../../library/asyncio-protocol.rst:518 msgid "" "See the documentation of the :meth:`~WriteTransport.set_write_buffer_limits` " "method for more details." msgstr "" -#: ../../library/asyncio-protocol.rst:518 +#: ../../library/asyncio-protocol.rst:523 msgid "Called when the transport's buffer goes over the high watermark." msgstr "" -#: ../../library/asyncio-protocol.rst:522 +#: ../../library/asyncio-protocol.rst:527 msgid "Called when the transport's buffer drains below the low watermark." msgstr "" -#: ../../library/asyncio-protocol.rst:524 +#: ../../library/asyncio-protocol.rst:529 msgid "" "If the buffer size equals the high watermark, :meth:`~BaseProtocol." "pause_writing` is not called: the buffer size must go strictly over." msgstr "" -#: ../../library/asyncio-protocol.rst:528 +#: ../../library/asyncio-protocol.rst:533 msgid "" "Conversely, :meth:`~BaseProtocol.resume_writing` is called when the buffer " "size is equal or lower than the low watermark. These end conditions are " "important to ensure that things go as expected when either mark is zero." msgstr "" -#: ../../library/asyncio-protocol.rst:535 +#: ../../library/asyncio-protocol.rst:540 msgid "Streaming Protocols" msgstr "" -#: ../../library/asyncio-protocol.rst:537 +#: ../../library/asyncio-protocol.rst:542 msgid "" "Event methods, such as :meth:`loop.create_server`, :meth:`loop." "create_unix_server`, :meth:`loop.create_connection`, :meth:`loop." @@ -739,13 +746,13 @@ msgid "" "that return streaming protocols." msgstr "" -#: ../../library/asyncio-protocol.rst:545 +#: ../../library/asyncio-protocol.rst:550 msgid "" "Called when some data is received. *data* is a non-empty bytes object " "containing the incoming data." msgstr "" -#: ../../library/asyncio-protocol.rst:548 +#: ../../library/asyncio-protocol.rst:553 msgid "" "Whether the data is buffered, chunked or reassembled depends on the " "transport. In general, you shouldn't rely on specific semantics and instead " @@ -753,27 +760,27 @@ msgid "" "the correct order." msgstr "" -#: ../../library/asyncio-protocol.rst:553 +#: ../../library/asyncio-protocol.rst:558 msgid "" "The method can be called an arbitrary number of times while a connection is " "open." msgstr "" -#: ../../library/asyncio-protocol.rst:556 +#: ../../library/asyncio-protocol.rst:561 msgid "" "However, :meth:`protocol.eof_received() ` is called " "at most once. Once ``eof_received()`` is called, ``data_received()`` is not " "called anymore." msgstr "" -#: ../../library/asyncio-protocol.rst:562 +#: ../../library/asyncio-protocol.rst:567 msgid "" "Called when the other end signals it won't send any more data (for example " "by calling :meth:`transport.write_eof() `, if the " "other end also uses asyncio)." msgstr "" -#: ../../library/asyncio-protocol.rst:567 +#: ../../library/asyncio-protocol.rst:572 msgid "" "This method may return a false value (including ``None``), in which case the " "transport will close itself. Conversely, if this method returns a true " @@ -782,19 +789,19 @@ msgid "" "connection." msgstr "" -#: ../../library/asyncio-protocol.rst:573 +#: ../../library/asyncio-protocol.rst:578 msgid "" "Some transports, including SSL, don't support half-closed connections, in " "which case returning true from this method will result in the connection " "being closed." msgstr "" -#: ../../library/asyncio-protocol.rst:578 -#: ../../library/asyncio-protocol.rst:636 +#: ../../library/asyncio-protocol.rst:583 +#: ../../library/asyncio-protocol.rst:641 msgid "State machine:" msgstr "" -#: ../../library/asyncio-protocol.rst:580 +#: ../../library/asyncio-protocol.rst:585 msgid "" "start -> connection_made\n" " [-> data_received]*\n" @@ -806,17 +813,17 @@ msgstr "" " [-> eof_received]?\n" "-> connection_lost -> end" -#: ../../library/asyncio-protocol.rst:589 +#: ../../library/asyncio-protocol.rst:594 msgid "Buffered Streaming Protocols" msgstr "" -#: ../../library/asyncio-protocol.rst:593 +#: ../../library/asyncio-protocol.rst:598 msgid "" "Buffered Protocols can be used with any event loop method that supports " "`Streaming Protocols`_." msgstr "" -#: ../../library/asyncio-protocol.rst:596 +#: ../../library/asyncio-protocol.rst:601 msgid "" "``BufferedProtocol`` implementations allow explicit manual allocation and " "control of the receive buffer. Event loops can then use the buffer provided " @@ -826,16 +833,16 @@ msgid "" "number of buffer allocations." msgstr "" -#: ../../library/asyncio-protocol.rst:603 +#: ../../library/asyncio-protocol.rst:608 msgid "" "The following callbacks are called on :class:`BufferedProtocol` instances:" msgstr "" -#: ../../library/asyncio-protocol.rst:608 +#: ../../library/asyncio-protocol.rst:613 msgid "Called to allocate a new receive buffer." msgstr "" -#: ../../library/asyncio-protocol.rst:610 +#: ../../library/asyncio-protocol.rst:615 msgid "" "*sizehint* is the recommended minimum size for the returned buffer. It is " "acceptable to return smaller or larger buffers than what *sizehint* " @@ -843,27 +850,27 @@ msgid "" "to return a buffer with a zero size." msgstr "" -#: ../../library/asyncio-protocol.rst:615 +#: ../../library/asyncio-protocol.rst:620 msgid "" "``get_buffer()`` must return an object implementing the :ref:`buffer " "protocol `." msgstr "" -#: ../../library/asyncio-protocol.rst:620 +#: ../../library/asyncio-protocol.rst:625 msgid "Called when the buffer was updated with the received data." msgstr "" -#: ../../library/asyncio-protocol.rst:622 +#: ../../library/asyncio-protocol.rst:627 msgid "*nbytes* is the total number of bytes that were written to the buffer." msgstr "" -#: ../../library/asyncio-protocol.rst:626 +#: ../../library/asyncio-protocol.rst:631 msgid "" "See the documentation of the :meth:`protocol.eof_received() ` method." msgstr "" -#: ../../library/asyncio-protocol.rst:630 +#: ../../library/asyncio-protocol.rst:635 msgid "" ":meth:`~BufferedProtocol.get_buffer` can be called an arbitrary number of " "times during a connection. However, :meth:`protocol.eof_received() " @@ -872,7 +879,7 @@ msgid "" "won't be called after it." msgstr "" -#: ../../library/asyncio-protocol.rst:638 +#: ../../library/asyncio-protocol.rst:643 msgid "" "start -> connection_made\n" " [-> get_buffer\n" @@ -888,44 +895,44 @@ msgstr "" " [-> eof_received]?\n" "-> connection_lost -> end" -#: ../../library/asyncio-protocol.rst:649 +#: ../../library/asyncio-protocol.rst:654 msgid "Datagram Protocols" msgstr "" -#: ../../library/asyncio-protocol.rst:651 +#: ../../library/asyncio-protocol.rst:656 msgid "" "Datagram Protocol instances should be constructed by protocol factories " "passed to the :meth:`loop.create_datagram_endpoint` method." msgstr "" -#: ../../library/asyncio-protocol.rst:656 +#: ../../library/asyncio-protocol.rst:661 msgid "" "Called when a datagram is received. *data* is a bytes object containing the " "incoming data. *addr* is the address of the peer sending the data; the " "exact format depends on the transport." msgstr "" -#: ../../library/asyncio-protocol.rst:662 +#: ../../library/asyncio-protocol.rst:667 msgid "" "Called when a previous send or receive operation raises an :class:" "`OSError`. *exc* is the :class:`OSError` instance." msgstr "" -#: ../../library/asyncio-protocol.rst:665 +#: ../../library/asyncio-protocol.rst:670 msgid "" "This method is called in rare conditions, when the transport (e.g. UDP) " "detects that a datagram could not be delivered to its recipient. In many " "conditions though, undeliverable datagrams will be silently dropped." msgstr "" -#: ../../library/asyncio-protocol.rst:672 +#: ../../library/asyncio-protocol.rst:677 msgid "" "On BSD systems (macOS, FreeBSD, etc.) flow control is not supported for " "datagram protocols, because there is no reliable way to detect send failures " "caused by writing too many packets." msgstr "" -#: ../../library/asyncio-protocol.rst:676 +#: ../../library/asyncio-protocol.rst:681 msgid "" "The socket always appears 'ready' and excess packets are dropped. An :class:" "`OSError` with ``errno`` set to :const:`errno.ENOBUFS` may or may not be " @@ -933,64 +940,64 @@ msgid "" "error_received` but otherwise ignored." msgstr "" -#: ../../library/asyncio-protocol.rst:685 +#: ../../library/asyncio-protocol.rst:690 msgid "Subprocess Protocols" msgstr "" -#: ../../library/asyncio-protocol.rst:687 +#: ../../library/asyncio-protocol.rst:692 msgid "" "Subprocess Protocol instances should be constructed by protocol factories " "passed to the :meth:`loop.subprocess_exec` and :meth:`loop.subprocess_shell` " "methods." msgstr "" -#: ../../library/asyncio-protocol.rst:693 +#: ../../library/asyncio-protocol.rst:698 msgid "" "Called when the child process writes data into its stdout or stderr pipe." msgstr "" -#: ../../library/asyncio-protocol.rst:696 +#: ../../library/asyncio-protocol.rst:701 msgid "*fd* is the integer file descriptor of the pipe." msgstr "" -#: ../../library/asyncio-protocol.rst:698 +#: ../../library/asyncio-protocol.rst:703 msgid "*data* is a non-empty bytes object containing the received data." msgstr "" -#: ../../library/asyncio-protocol.rst:702 +#: ../../library/asyncio-protocol.rst:707 msgid "" "Called when one of the pipes communicating with the child process is closed." msgstr "" -#: ../../library/asyncio-protocol.rst:705 +#: ../../library/asyncio-protocol.rst:710 msgid "*fd* is the integer file descriptor that was closed." msgstr "" -#: ../../library/asyncio-protocol.rst:709 +#: ../../library/asyncio-protocol.rst:714 msgid "Called when the child process has exited." msgstr "" -#: ../../library/asyncio-protocol.rst:711 +#: ../../library/asyncio-protocol.rst:716 msgid "" "It can be called before :meth:`~SubprocessProtocol.pipe_data_received` and :" "meth:`~SubprocessProtocol.pipe_connection_lost` methods." msgstr "" -#: ../../library/asyncio-protocol.rst:716 +#: ../../library/asyncio-protocol.rst:721 msgid "Examples" msgstr "範例" -#: ../../library/asyncio-protocol.rst:721 +#: ../../library/asyncio-protocol.rst:726 msgid "TCP Echo Server" msgstr "" -#: ../../library/asyncio-protocol.rst:723 +#: ../../library/asyncio-protocol.rst:728 msgid "" "Create a TCP echo server using the :meth:`loop.create_server` method, send " "back received data, and close the connection::" msgstr "" -#: ../../library/asyncio-protocol.rst:726 +#: ../../library/asyncio-protocol.rst:731 msgid "" "import asyncio\n" "\n" @@ -1018,7 +1025,7 @@ msgid "" " loop = asyncio.get_running_loop()\n" "\n" " server = await loop.create_server(\n" -" lambda: EchoServerProtocol(),\n" +" EchoServerProtocol,\n" " '127.0.0.1', 8888)\n" "\n" " async with server:\n" @@ -1028,23 +1035,23 @@ msgid "" "asyncio.run(main())" msgstr "" -#: ../../library/asyncio-protocol.rst:764 +#: ../../library/asyncio-protocol.rst:769 msgid "" "The :ref:`TCP echo server using streams ` " "example uses the high-level :func:`asyncio.start_server` function." msgstr "" -#: ../../library/asyncio-protocol.rst:770 +#: ../../library/asyncio-protocol.rst:775 msgid "TCP Echo Client" msgstr "" -#: ../../library/asyncio-protocol.rst:772 +#: ../../library/asyncio-protocol.rst:777 msgid "" "A TCP echo client using the :meth:`loop.create_connection` method, sends " "data, and waits until the connection is closed::" msgstr "" -#: ../../library/asyncio-protocol.rst:775 +#: ../../library/asyncio-protocol.rst:780 msgid "" "import asyncio\n" "\n" @@ -1089,23 +1096,23 @@ msgid "" "asyncio.run(main())" msgstr "" -#: ../../library/asyncio-protocol.rst:820 +#: ../../library/asyncio-protocol.rst:825 msgid "" "The :ref:`TCP echo client using streams ` " "example uses the high-level :func:`asyncio.open_connection` function." msgstr "" -#: ../../library/asyncio-protocol.rst:827 +#: ../../library/asyncio-protocol.rst:832 msgid "UDP Echo Server" msgstr "" -#: ../../library/asyncio-protocol.rst:829 +#: ../../library/asyncio-protocol.rst:834 msgid "" "A UDP echo server, using the :meth:`loop.create_datagram_endpoint` method, " "sends back received data::" msgstr "" -#: ../../library/asyncio-protocol.rst:832 +#: ../../library/asyncio-protocol.rst:837 msgid "" "import asyncio\n" "\n" @@ -1131,7 +1138,7 @@ msgid "" " # One protocol instance will be created to serve all\n" " # client requests.\n" " transport, protocol = await loop.create_datagram_endpoint(\n" -" lambda: EchoServerProtocol(),\n" +" EchoServerProtocol,\n" " local_addr=('127.0.0.1', 9999))\n" "\n" " try:\n" @@ -1143,17 +1150,17 @@ msgid "" "asyncio.run(main())" msgstr "" -#: ../../library/asyncio-protocol.rst:871 +#: ../../library/asyncio-protocol.rst:876 msgid "UDP Echo Client" msgstr "" -#: ../../library/asyncio-protocol.rst:873 +#: ../../library/asyncio-protocol.rst:878 msgid "" "A UDP echo client, using the :meth:`loop.create_datagram_endpoint` method, " "sends data and closes the transport when it receives the answer::" msgstr "" -#: ../../library/asyncio-protocol.rst:876 +#: ../../library/asyncio-protocol.rst:881 msgid "" "import asyncio\n" "\n" @@ -1204,17 +1211,17 @@ msgid "" "asyncio.run(main())" msgstr "" -#: ../../library/asyncio-protocol.rst:928 +#: ../../library/asyncio-protocol.rst:933 msgid "Connecting Existing Sockets" msgstr "" -#: ../../library/asyncio-protocol.rst:930 +#: ../../library/asyncio-protocol.rst:935 msgid "" "Wait until a socket receives data using the :meth:`loop.create_connection` " "method with a protocol::" msgstr "" -#: ../../library/asyncio-protocol.rst:933 +#: ../../library/asyncio-protocol.rst:938 msgid "" "import asyncio\n" "import socket\n" @@ -1266,35 +1273,35 @@ msgid "" "asyncio.run(main())" msgstr "" -#: ../../library/asyncio-protocol.rst:984 +#: ../../library/asyncio-protocol.rst:989 msgid "" "The :ref:`watch a file descriptor for read events " "` example uses the low-level :meth:`loop." "add_reader` method to register an FD." msgstr "" -#: ../../library/asyncio-protocol.rst:988 +#: ../../library/asyncio-protocol.rst:993 msgid "" "The :ref:`register an open socket to wait for data using streams " "` example uses high-level streams " "created by the :func:`open_connection` function in a coroutine." msgstr "" -#: ../../library/asyncio-protocol.rst:995 +#: ../../library/asyncio-protocol.rst:1000 msgid "loop.subprocess_exec() and SubprocessProtocol" msgstr "" -#: ../../library/asyncio-protocol.rst:997 +#: ../../library/asyncio-protocol.rst:1002 msgid "" "An example of a subprocess protocol used to get the output of a subprocess " "and to wait for the subprocess exit." msgstr "" -#: ../../library/asyncio-protocol.rst:1000 +#: ../../library/asyncio-protocol.rst:1005 msgid "The subprocess is created by the :meth:`loop.subprocess_exec` method::" msgstr "" -#: ../../library/asyncio-protocol.rst:1002 +#: ../../library/asyncio-protocol.rst:1007 msgid "" "import asyncio\n" "import sys\n" @@ -1355,7 +1362,7 @@ msgid "" "print(f\"Current date: {date}\")" msgstr "" -#: ../../library/asyncio-protocol.rst:1060 +#: ../../library/asyncio-protocol.rst:1065 msgid "" "See also the :ref:`same example ` " "written using high-level APIs." diff --git a/library/asyncio-queue.po b/library/asyncio-queue.po index 09bf4b429e..c12c90e6e0 100644 --- a/library/asyncio-queue.po +++ b/library/asyncio-queue.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,9 +6,9 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-07-26 00:17+0000\n" "PO-Revision-Date: 2022-02-20 18:34+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -63,7 +63,7 @@ msgid "" "it is an integer greater than ``0``, then ``await put()`` blocks when the " "queue reaches *maxsize* until an item is removed by :meth:`get`." msgstr "" -"如果 *maxsize* 小於或等於零,則佇列尺寸是無限制的。如果是大於 ``0`` 的整數," +"如果 *maxsize* 小於或等於零,則佇列大小是無限制的。如果是大於 ``0`` 的整數," "則當佇列達到 *maxsize* 時,``await put()`` 將會阻塞 (block),直到某個元素被 :" "meth:`get` 取出。" @@ -72,7 +72,7 @@ msgid "" "Unlike the standard library threading :mod:`queue`, the size of the queue is " "always known and can be returned by calling the :meth:`qsize` method." msgstr "" -"不像標準函式庫中執行緒類型的 :mod:`queue`,佇列的尺寸一直是已知的,可以透過呼" +"不像標準函式庫中執行緒類型的 :mod:`queue`,佇列的大小一直是已知的,可以透過呼" "叫 :meth:`qsize` 方法回傳。" #: ../../library/asyncio-queue.rst:39 @@ -103,22 +103,28 @@ msgstr "" "如果佇列用 ``maxsize=0`` (預設)初始化,則 :meth:`full` 永遠不會回傳 " "``True``。" -#: ../../library/asyncio-queue.rst:62 +#: ../../library/asyncio-queue.rst:63 msgid "" "Remove and return an item from the queue. If queue is empty, wait until an " "item is available." msgstr "從佇列中刪除並回傳一個元素。如果佇列為空,則持續等待直到佇列中有元素。" -#: ../../library/asyncio-queue.rst:67 +#: ../../library/asyncio-queue.rst:66 +msgid "" +"Raises :exc:`QueueShutDown` if the queue has been shut down and is empty, or " +"if the queue has been shut down immediately." +msgstr "" + +#: ../../library/asyncio-queue.rst:71 msgid "" "Return an item if one is immediately available, else raise :exc:`QueueEmpty`." msgstr "如果佇列內有值則立即回傳佇列中的元素,否則引發 :exc:`QueueEmpty`。" -#: ../../library/asyncio-queue.rst:72 +#: ../../library/asyncio-queue.rst:77 msgid "Block until all items in the queue have been received and processed." msgstr "持續阻塞直到佇列中所有的元素都被接收和處理完畢。" -#: ../../library/asyncio-queue.rst:74 +#: ../../library/asyncio-queue.rst:79 msgid "" "The count of unfinished tasks goes up whenever an item is added to the " "queue. The count goes down whenever a consumer coroutine calls :meth:" @@ -131,7 +137,7 @@ msgstr "" "成,未完成任務計數就會減少。當未完成計數降到零的時候,:meth:`join` 阻塞會被解" "除 (unblock)。" -#: ../../library/asyncio-queue.rst:82 +#: ../../library/asyncio-queue.rst:88 msgid "" "Put an item into the queue. If the queue is full, wait until a free slot is " "available before adding the item." @@ -139,81 +145,131 @@ msgstr "" "將一個元素放進佇列。如果佇列滿了,在新增元素之前,會持續等待直到有空閒插槽 " "(free slot) 能被使用。" -#: ../../library/asyncio-queue.rst:87 +#: ../../library/asyncio-queue.rst:91 +msgid "Raises :exc:`QueueShutDown` if the queue has been shut down." +msgstr "如果佇列已經被關閉,則引發 :exc:`QueueShutDown`。" + +#: ../../library/asyncio-queue.rst:95 msgid "Put an item into the queue without blocking." msgstr "不阻塞地將一個元素放入佇列。" -#: ../../library/asyncio-queue.rst:89 +#: ../../library/asyncio-queue.rst:97 msgid "If no free slot is immediately available, raise :exc:`QueueFull`." msgstr "如果沒有立即可用的空閒插槽,引發 :exc:`QueueFull`。" -#: ../../library/asyncio-queue.rst:93 +#: ../../library/asyncio-queue.rst:101 msgid "Return the number of items in the queue." msgstr "回傳佇列中的元素數量。" -#: ../../library/asyncio-queue.rst:97 -msgid "Indicate that a formerly enqueued task is complete." -msgstr "表示前面一個排隊的任務已經完成。" +#: ../../library/asyncio-queue.rst:105 +msgid "Put a :class:`Queue` instance into a shutdown mode." +msgstr "" + +#: ../../library/asyncio-queue.rst:107 +msgid "" +"The queue can no longer grow. Future calls to :meth:`~Queue.put` raise :exc:" +"`QueueShutDown`. Currently blocked callers of :meth:`~Queue.put` will be " +"unblocked and will raise :exc:`QueueShutDown` in the formerly blocked thread." +msgstr "" -#: ../../library/asyncio-queue.rst:99 +#: ../../library/asyncio-queue.rst:112 msgid "" -"Used by queue consumers. For each :meth:`~Queue.get` used to fetch a task, a " -"subsequent call to :meth:`task_done` tells the queue that the processing on " -"the task is complete." +"If *immediate* is false (the default), the queue can be wound down normally " +"with :meth:`~Queue.get` calls to extract tasks that have already been loaded." msgstr "" -"由佇列消耗者使用。對於每個用於獲取一個任務的 :meth:`~Queue.get`,接續的 :" -"meth:`task_done` 呼叫會告訴佇列這個任務的處理已經完成。" -#: ../../library/asyncio-queue.rst:103 +#: ../../library/asyncio-queue.rst:116 +msgid "" +"And if :meth:`~Queue.task_done` is called for each remaining task, a " +"pending :meth:`~Queue.join` will be unblocked normally." +msgstr "" + +#: ../../library/asyncio-queue.rst:119 +msgid "" +"Once the queue is empty, future calls to :meth:`~Queue.get` will raise :exc:" +"`QueueShutDown`." +msgstr "" + +#: ../../library/asyncio-queue.rst:122 +msgid "" +"If *immediate* is true, the queue is terminated immediately. The queue is " +"drained to be completely empty and the count of unfinished tasks is reduced " +"by the number of tasks drained. If unfinished tasks is zero, callers of :" +"meth:`~Queue.join` are unblocked. Also, blocked callers of :meth:`~Queue." +"get` are unblocked and will raise :exc:`QueueShutDown` because the queue is " +"empty." +msgstr "" + +#: ../../library/asyncio-queue.rst:130 +msgid "" +"Use caution when using :meth:`~Queue.join` with *immediate* set to true. " +"This unblocks the join even when no work has been done on the tasks, " +"violating the usual invariant for joining a queue." +msgstr "" + +#: ../../library/asyncio-queue.rst:138 +msgid "Indicate that a formerly enqueued work item is complete." +msgstr "表示前面一個排隊的工作項目已經完成。" + +#: ../../library/asyncio-queue.rst:140 +msgid "" +"Used by queue consumers. For each :meth:`~Queue.get` used to fetch a work " +"item, a subsequent call to :meth:`task_done` tells the queue that the " +"processing on the work item is complete." +msgstr "" +"由佇列消耗者使用。對於每個用於取得一個工作項目的 :meth:`~Queue.get`,接續的 :" +"meth:`task_done` 呼叫會告訴佇列這個工作項目的處理已經完成。" + +#: ../../library/asyncio-queue.rst:144 msgid "" "If a :meth:`join` is currently blocking, it will resume when all items have " "been processed (meaning that a :meth:`task_done` call was received for every " "item that had been :meth:`~Queue.put` into the queue)." msgstr "" -"如果 :meth:`join` 當前正在阻塞,在所有項目都被處理後會解除阻塞(意味著每個" -"以 :meth:`~Queue.put` 放進佇列的條目都會收到一個 :meth:`task_done`\\ )。" +"如果 :meth:`join` 目前正在阻塞,在所有項目都被處理後會解除阻塞(意味著每個" +"以 :meth:`~Queue.put` 放進佇列的條目都會收到一個 :meth:`task_done`)。" -#: ../../library/asyncio-queue.rst:108 +#: ../../library/asyncio-queue.rst:149 msgid "" "Raises :exc:`ValueError` if called more times than there were items placed " "in the queue." msgstr "如果被呼叫的次數多於放入佇列中的項目數量,將引發 :exc:`ValueError`。" -#: ../../library/asyncio-queue.rst:113 +#: ../../library/asyncio-queue.rst:154 msgid "Priority Queue" msgstr "Priority Queue(優先佇列)" -#: ../../library/asyncio-queue.rst:117 +#: ../../library/asyncio-queue.rst:158 msgid "" "A variant of :class:`Queue`; retrieves entries in priority order (lowest " "first)." msgstr ":class:`Queue` 的變形;按優先順序取出條目 (最小的先取出)。" -#: ../../library/asyncio-queue.rst:120 +#: ../../library/asyncio-queue.rst:161 msgid "Entries are typically tuples of the form ``(priority_number, data)``." msgstr "條目通常是 ``(priority_number, data)`` 形式的 tuple(元組)。" -#: ../../library/asyncio-queue.rst:125 +#: ../../library/asyncio-queue.rst:166 msgid "LIFO Queue" msgstr "LIFO Queue" -#: ../../library/asyncio-queue.rst:129 +#: ../../library/asyncio-queue.rst:170 msgid "" "A variant of :class:`Queue` that retrieves most recently added entries first " "(last in, first out)." msgstr ":class:`Queue` 的變形,先取出最近新增的條目(後進先出)。" -#: ../../library/asyncio-queue.rst:134 +#: ../../library/asyncio-queue.rst:175 msgid "Exceptions" msgstr "例外" -#: ../../library/asyncio-queue.rst:138 +#: ../../library/asyncio-queue.rst:179 msgid "" "This exception is raised when the :meth:`~Queue.get_nowait` method is called " "on an empty queue." msgstr "當佇列為空的時候,呼叫 :meth:`~Queue.get_nowait` 方法會引發這個例外。" -#: ../../library/asyncio-queue.rst:144 +#: ../../library/asyncio-queue.rst:185 msgid "" "Exception raised when the :meth:`~Queue.put_nowait` method is called on a " "queue that has reached its *maxsize*." @@ -221,16 +277,22 @@ msgstr "" "當佇列中條目數量已經達到它的 *maxsize* 時,呼叫 :meth:`~Queue.put_nowait` 方" "法會引發這個例外。" -#: ../../library/asyncio-queue.rst:149 +#: ../../library/asyncio-queue.rst:191 +msgid "" +"Exception raised when :meth:`~Queue.put` or :meth:`~Queue.get` is called on " +"a queue which has been shut down." +msgstr "" + +#: ../../library/asyncio-queue.rst:198 msgid "Examples" msgstr "範例" -#: ../../library/asyncio-queue.rst:153 +#: ../../library/asyncio-queue.rst:202 msgid "" "Queues can be used to distribute workload between several concurrent tasks::" msgstr "佇列能被用於多個並行任務的工作分配:" -#: ../../library/asyncio-queue.rst:156 +#: ../../library/asyncio-queue.rst:205 msgid "" "import asyncio\n" "import random\n" diff --git a/library/asyncio-runner.po b/library/asyncio-runner.po index 40885e75a9..edf75f6778 100644 --- a/library/asyncio-runner.po +++ b/library/asyncio-runner.po @@ -1,4 +1,3 @@ -# SOME DESCRIPTIVE TITLE. # Copyright (C) 2001-2022, Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR , YEAR. @@ -6,12 +5,13 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -54,17 +54,17 @@ msgstr "" "這個函式負責運行被傳入的協程、管理 asyncio 的事件迴圈、*終結非同步產生器*,以" "及關閉執行器。" -#: ../../library/asyncio-runner.rst:33 ../../library/asyncio-runner.rst:113 +#: ../../library/asyncio-runner.rst:33 ../../library/asyncio-runner.rst:115 msgid "" "This function cannot be called when another asyncio event loop is running in " "the same thread." msgstr "當另一個非同步事件迴圈在同一執行緒中執行時,無法呼叫此函式。" -#: ../../library/asyncio-runner.rst:36 ../../library/asyncio-runner.rst:83 +#: ../../library/asyncio-runner.rst:36 ../../library/asyncio-runner.rst:85 msgid "" "If *debug* is ``True``, the event loop will be run in debug mode. ``False`` " -"disables debug mode explicitly. ``None`` is used to respect the global :ref:" -"`asyncio-debug-mode` settings." +"disables debug mode explicitly. ``None`` is used to respect the " +"global :ref:`asyncio-debug-mode` settings." msgstr "" "如果 *debug* 為 ``True``,事件迴圈會以除錯模式執行。``False`` 則會關閉除錯模" "式。``None`` 則會優先使用\\ :ref:`除錯模式 `\\ 的全域設" @@ -76,25 +76,28 @@ msgid "" "otherwise :func:`asyncio.new_event_loop` 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." +"*loop_factory* to configure the event loop instead of policies. " +"Passing :class:`asyncio.EventLoop` allows running asyncio without the policy " +"system." msgstr "" "如果 *loop_factory* 不為 ``None``,它會被用於建立一個新的事件迴圈;否則會改" "用 :func:`asyncio.new_event_loop`。迴圈會在最後關閉。這個函式應該要作為" "asyncio 程式的主要進入點,且理想上僅會被呼叫一次。推薦使用 *loop_factory* 來" -"設定事件迴圈時而不是使用 policies(政策)。" +"設定事件迴圈時而不是使用 policies(政策)。傳遞 :class:`asyncio.EventLoop` 可" +"以讓 asyncio 在沒有政策系統的情況下運行。" -#: ../../library/asyncio-runner.rst:46 +#: ../../library/asyncio-runner.rst:48 msgid "" "The executor is given a timeout duration of 5 minutes to shutdown. If the " "executor hasn't finished within that duration, a warning is emitted and the " "executor is closed." msgstr "" -#: ../../library/asyncio-runner.rst:50 +#: ../../library/asyncio-runner.rst:52 msgid "Example::" msgstr "範例: ::" -#: ../../library/asyncio-runner.rst:52 +#: ../../library/asyncio-runner.rst:54 msgid "" "async def main():\n" " await asyncio.sleep(1)\n" @@ -108,36 +111,36 @@ msgstr "" "\n" "asyncio.run(main())" -#: ../../library/asyncio-runner.rst:60 +#: ../../library/asyncio-runner.rst:62 msgid "Updated to use :meth:`loop.shutdown_default_executor`." msgstr "" -#: ../../library/asyncio-runner.rst:65 +#: ../../library/asyncio-runner.rst:67 msgid "" "*debug* is ``None`` by default to respect the global debug mode settings." msgstr "" -#: ../../library/asyncio-runner.rst:69 +#: ../../library/asyncio-runner.rst:71 msgid "Added *loop_factory* parameter." msgstr "新增 *loop_factory* 參數。" -#: ../../library/asyncio-runner.rst:73 +#: ../../library/asyncio-runner.rst:75 msgid "Runner context manager" msgstr "" -#: ../../library/asyncio-runner.rst:77 +#: ../../library/asyncio-runner.rst:79 msgid "" "A context manager that simplifies *multiple* async function calls in the " "same context." msgstr "" -#: ../../library/asyncio-runner.rst:80 +#: ../../library/asyncio-runner.rst:82 msgid "" -"Sometimes several top-level async functions should be called in the same :" -"ref:`event loop ` and :class:`contextvars.Context`." +"Sometimes several top-level async functions should be called in the " +"same :ref:`event loop ` and :class:`contextvars.Context`." msgstr "" -#: ../../library/asyncio-runner.rst:87 +#: ../../library/asyncio-runner.rst:89 msgid "" "*loop_factory* could be used for overriding the loop creation. It is the " "responsibility of the *loop_factory* to set the created loop as the current " @@ -145,13 +148,13 @@ msgid "" "event loop with :func:`asyncio.set_event_loop` if *loop_factory* is ``None``." msgstr "" -#: ../../library/asyncio-runner.rst:92 +#: ../../library/asyncio-runner.rst:94 msgid "" "Basically, :func:`asyncio.run` example can be rewritten with the runner " "usage::" msgstr "" -#: ../../library/asyncio-runner.rst:94 +#: ../../library/asyncio-runner.rst:96 msgid "" "async def main():\n" " await asyncio.sleep(1)\n" @@ -167,92 +170,92 @@ msgstr "" "with asyncio.Runner() as runner:\n" " runner.run(main())" -#: ../../library/asyncio-runner.rst:105 +#: ../../library/asyncio-runner.rst:107 msgid "Run a :term:`coroutine ` *coro* in the embedded loop." msgstr "" -#: ../../library/asyncio-runner.rst:107 +#: ../../library/asyncio-runner.rst:109 msgid "Return the coroutine's result or raise its exception." msgstr "" -#: ../../library/asyncio-runner.rst:109 +#: ../../library/asyncio-runner.rst:111 msgid "" -"An optional keyword-only *context* argument allows specifying a custom :" -"class:`contextvars.Context` for the *coro* to run in. The runner's default " -"context is used if ``None``." +"An optional keyword-only *context* argument allows specifying a " +"custom :class:`contextvars.Context` for the *coro* to run in. The runner's " +"default context is used if ``None``." msgstr "" -#: ../../library/asyncio-runner.rst:118 +#: ../../library/asyncio-runner.rst:120 msgid "Close the runner." msgstr "" -#: ../../library/asyncio-runner.rst:120 +#: ../../library/asyncio-runner.rst:122 msgid "" "Finalize asynchronous generators, shutdown default executor, close the event " "loop and release embedded :class:`contextvars.Context`." msgstr "" -#: ../../library/asyncio-runner.rst:125 +#: ../../library/asyncio-runner.rst:127 msgid "Return the event loop associated with the runner instance." msgstr "" -#: ../../library/asyncio-runner.rst:129 +#: ../../library/asyncio-runner.rst:131 msgid "" ":class:`Runner` uses the lazy initialization strategy, its constructor " "doesn't initialize underlying low-level structures." msgstr "" -#: ../../library/asyncio-runner.rst:132 +#: ../../library/asyncio-runner.rst:134 msgid "" "Embedded *loop* and *context* are created at the :keyword:`with` body " "entering or the first call of :meth:`run` or :meth:`get_loop`." msgstr "" -#: ../../library/asyncio-runner.rst:137 +#: ../../library/asyncio-runner.rst:139 msgid "Handling Keyboard Interruption" msgstr "" -#: ../../library/asyncio-runner.rst:141 +#: ../../library/asyncio-runner.rst:143 msgid "" -"When :const:`signal.SIGINT` is raised by :kbd:`Ctrl-C`, :exc:" -"`KeyboardInterrupt` exception is raised in the main thread by default. " -"However this doesn't work with :mod:`asyncio` because it can interrupt " -"asyncio internals and can hang the program from exiting." +"When :const:`signal.SIGINT` is raised by :kbd:`Ctrl-" +"C`, :exc:`KeyboardInterrupt` exception is raised in the main thread by " +"default. However this doesn't work with :mod:`asyncio` because it can " +"interrupt asyncio internals and can hang the program from exiting." msgstr "" -#: ../../library/asyncio-runner.rst:146 +#: ../../library/asyncio-runner.rst:148 msgid "" "To mitigate this issue, :mod:`asyncio` handles :const:`signal.SIGINT` as " "follows:" msgstr "" -#: ../../library/asyncio-runner.rst:148 +#: ../../library/asyncio-runner.rst:150 msgid "" ":meth:`asyncio.Runner.run` installs a custom :const:`signal.SIGINT` handler " "before any user code is executed and removes it when exiting from the " "function." msgstr "" -#: ../../library/asyncio-runner.rst:150 +#: ../../library/asyncio-runner.rst:152 msgid "" "The :class:`~asyncio.Runner` creates the main task for the passed coroutine " "for its execution." msgstr "" -#: ../../library/asyncio-runner.rst:152 +#: ../../library/asyncio-runner.rst:154 msgid "" "When :const:`signal.SIGINT` is raised by :kbd:`Ctrl-C`, the custom signal " "handler cancels the main task by calling :meth:`asyncio.Task.cancel` which " "raises :exc:`asyncio.CancelledError` 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, :meth:`asyncio." -"Runner.run` raises :exc:`KeyboardInterrupt`." +"used for resource cleanup. After the main task is " +"cancelled, :meth:`asyncio.Runner.run` raises :exc:`KeyboardInterrupt`." msgstr "" -#: ../../library/asyncio-runner.rst:158 +#: ../../library/asyncio-runner.rst:160 msgid "" -"A user could write a tight loop which cannot be interrupted by :meth:" -"`asyncio.Task.cancel`, in which case the second following :kbd:`Ctrl-C` " -"immediately raises the :exc:`KeyboardInterrupt` without cancelling the main " -"task." +"A user could write a tight loop which cannot be interrupted " +"by :meth:`asyncio.Task.cancel`, in which case the second " +"following :kbd:`Ctrl-C` immediately raises the :exc:`KeyboardInterrupt` " +"without cancelling the main task." msgstr "" diff --git a/library/asyncio-stream.po b/library/asyncio-stream.po index a64d70e90e..e3597d945a 100644 --- a/library/asyncio-stream.po +++ b/library/asyncio-stream.po @@ -6,9 +6,9 @@ # Matt Wang , 2022-2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2022-10-31 16:28+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -40,9 +40,9 @@ msgstr "" #: ../../library/asyncio-stream.rst:19 msgid "Here is an example of a TCP echo client written using asyncio streams::" -msgstr "這是一個使用 asyncio 串流編寫的 TCP echo 客戶端範例: ::" +msgstr "這是一個使用 asyncio 串流編寫的 TCP echo 用戶端範例: ::" -#: ../../library/asyncio-stream.rst:22 ../../library/asyncio-stream.rst:404 +#: ../../library/asyncio-stream.rst:22 ../../library/asyncio-stream.rst:437 msgid "" "import asyncio\n" "\n" @@ -96,13 +96,13 @@ msgid "" "with streams:" msgstr "下面的高階 asyncio 函式可以用來建立和處理串流:" -#: ../../library/asyncio-stream.rst:58 +#: ../../library/asyncio-stream.rst:59 msgid "" "Establish a network connection and return a pair of ``(reader, writer)`` " "objects." msgstr "建立網路連線並回傳一對 ``(reader, writer)`` 物件。" -#: ../../library/asyncio-stream.rst:61 +#: ../../library/asyncio-stream.rst:62 msgid "" "The returned *reader* and *writer* objects are instances of :class:" "`StreamReader` and :class:`StreamWriter` classes." @@ -110,7 +110,7 @@ msgstr "" "回傳的 *reader* 和 *writer* 物件是 :class:`StreamReader` 和 :class:" "`StreamWriter` 類別的實例。" -#: ../../library/asyncio-stream.rst:64 ../../library/asyncio-stream.rst:109 +#: ../../library/asyncio-stream.rst:65 ../../library/asyncio-stream.rst:112 msgid "" "*limit* determines the buffer size limit used by the returned :class:" "`StreamReader` instance. By default the *limit* is set to 64 KiB." @@ -118,54 +118,54 @@ msgstr "" "*limit* 指定了回傳的 :class:`StreamReader` 實例所使用的緩衝區 (buffer) 大小限" "制。*limit* 預設為 64 KiB。" -#: ../../library/asyncio-stream.rst:68 +#: ../../library/asyncio-stream.rst:69 msgid "" "The rest of the arguments are passed directly to :meth:`loop." "create_connection`." msgstr "其餘的引數會直接傳遞到 :meth:`loop.create_connection`。" -#: ../../library/asyncio-stream.rst:73 ../../library/asyncio-stream.rst:147 +#: ../../library/asyncio-stream.rst:74 ../../library/asyncio-stream.rst:154 msgid "" "The *sock* argument transfers ownership of the socket to the :class:" "`StreamWriter` created. To close the socket, call its :meth:`~asyncio." "StreamWriter.close` method." msgstr "" -#: ../../library/asyncio-stream.rst:77 +#: ../../library/asyncio-stream.rst:78 msgid "Added the *ssl_handshake_timeout* parameter." msgstr "新增 *ssl_handshake_timeout* 參數。" -#: ../../library/asyncio-stream.rst:80 +#: ../../library/asyncio-stream.rst:81 msgid "Added the *happy_eyeballs_delay* and *interleave* parameters." msgstr "新增 *happy_eyeballs_delay* 和 *interleave* 參數。" -#: ../../library/asyncio-stream.rst:83 ../../library/asyncio-stream.rst:125 -#: ../../library/asyncio-stream.rst:157 ../../library/asyncio-stream.rst:187 +#: ../../library/asyncio-stream.rst:84 ../../library/asyncio-stream.rst:128 +#: ../../library/asyncio-stream.rst:164 ../../library/asyncio-stream.rst:199 msgid "Removed the *loop* parameter." msgstr "移除 *loop* 參數。" -#: ../../library/asyncio-stream.rst:86 ../../library/asyncio-stream.rst:128 -#: ../../library/asyncio-stream.rst:160 ../../library/asyncio-stream.rst:190 -#: ../../library/asyncio-stream.rst:372 +#: ../../library/asyncio-stream.rst:87 ../../library/asyncio-stream.rst:131 +#: ../../library/asyncio-stream.rst:167 ../../library/asyncio-stream.rst:202 +#: ../../library/asyncio-stream.rst:404 msgid "Added the *ssl_shutdown_timeout* parameter." msgstr "新增 *ssl_shutdown_timeout* 參數。" -#: ../../library/asyncio-stream.rst:98 +#: ../../library/asyncio-stream.rst:101 msgid "Start a socket server." msgstr "啟動 socket 伺服器。" -#: ../../library/asyncio-stream.rst:100 +#: ../../library/asyncio-stream.rst:103 msgid "" "The *client_connected_cb* callback is called whenever a new client " "connection is established. It receives a ``(reader, writer)`` pair as two " "arguments, instances of the :class:`StreamReader` and :class:`StreamWriter` " "classes." msgstr "" -"當一個新的客戶端連線被建立時,回呼函式 *client_connected_cb* 就會被呼叫。該函" +"當一個新的用戶端連線被建立時,回呼函式 *client_connected_cb* 就會被呼叫。該函" "式會接收到一對引數 ``(reader, writer)``,分別為 :class:`StreamReader` 和 :" "class:`StreamWriter` 的實例。" -#: ../../library/asyncio-stream.rst:105 +#: ../../library/asyncio-stream.rst:108 msgid "" "*client_connected_cb* can be a plain callable or a :ref:`coroutine function " "`; if it is a coroutine function, it will be automatically " @@ -175,43 +175,47 @@ msgstr "" "ref:`協程函式 `;如果它是一個協程函式,它將自動作為 :class:`Task` " "來被排程。" -#: ../../library/asyncio-stream.rst:113 +#: ../../library/asyncio-stream.rst:116 msgid "" "The rest of the arguments are passed directly to :meth:`loop.create_server`." msgstr "剩下的引數將會直接傳遞給 :meth:`loop.create_server`。" -#: ../../library/asyncio-stream.rst:118 ../../library/asyncio-stream.rst:177 +#: ../../library/asyncio-stream.rst:121 ../../library/asyncio-stream.rst:189 msgid "" "The *sock* argument transfers ownership of the socket to the server created. " "To close the socket, call the server's :meth:`~asyncio.Server.close` method." msgstr "" -#: ../../library/asyncio-stream.rst:122 +#: ../../library/asyncio-stream.rst:125 msgid "Added the *ssl_handshake_timeout* and *start_serving* parameters." msgstr "新增 *ssl_handshake_timeout* 與 *start_serving* 參數。" -#: ../../library/asyncio-stream.rst:133 +#: ../../library/asyncio-stream.rst:134 +msgid "Added the *keep_alive* parameter." +msgstr "新增 *keep_alive* 參數。" + +#: ../../library/asyncio-stream.rst:139 msgid "Unix Sockets" msgstr "Unix Sockets" -#: ../../library/asyncio-stream.rst:138 +#: ../../library/asyncio-stream.rst:145 msgid "" "Establish a Unix socket connection and return a pair of ``(reader, writer)``." msgstr "建立一個 Unix socket 連線並回傳一對 ``(reader, writer)``。" -#: ../../library/asyncio-stream.rst:141 +#: ../../library/asyncio-stream.rst:148 msgid "Similar to :func:`open_connection` but operates on Unix sockets." msgstr "與 :func:`open_connection` 相似,但是是操作 Unix sockets。" -#: ../../library/asyncio-stream.rst:143 +#: ../../library/asyncio-stream.rst:150 msgid "See also the documentation of :meth:`loop.create_unix_connection`." msgstr "另請參閱 :meth:`loop.create_unix_connection` 文件。" -#: ../../library/asyncio-stream.rst:151 ../../library/asyncio-stream.rst:181 -msgid ":ref:`Availability `: Unix." -msgstr ":ref:`適用 `:Unix。" +#: ../../library/asyncio-stream.rst:158 ../../library/asyncio-stream.rst:193 +msgid "Availability" +msgstr "可用性" -#: ../../library/asyncio-stream.rst:153 +#: ../../library/asyncio-stream.rst:160 msgid "" "Added the *ssl_handshake_timeout* parameter. The *path* parameter can now be " "a :term:`path-like object`" @@ -219,19 +223,26 @@ msgstr "" "新增 *ssl_handshake_timeout* 參數。*path* 參數現在可以是個 :term:`path-like " "object`" -#: ../../library/asyncio-stream.rst:169 +#: ../../library/asyncio-stream.rst:177 msgid "Start a Unix socket server." msgstr "啟動一個 Unix socket 伺服器。" -#: ../../library/asyncio-stream.rst:171 +#: ../../library/asyncio-stream.rst:179 msgid "Similar to :func:`start_server` but works with Unix sockets." msgstr "與 :func:`start_server` 相似,但會是操作 Unix sockets。" -#: ../../library/asyncio-stream.rst:173 +#: ../../library/asyncio-stream.rst:181 +msgid "" +"If *cleanup_socket* is true then the Unix socket will automatically be " +"removed from the filesystem when the server is closed, unless the socket has " +"been replaced after the server has been created." +msgstr "" + +#: ../../library/asyncio-stream.rst:185 msgid "See also the documentation of :meth:`loop.create_unix_server`." msgstr "另請參閱 :meth:`loop.create_unix_server` 文件。" -#: ../../library/asyncio-stream.rst:183 +#: ../../library/asyncio-stream.rst:195 msgid "" "Added the *ssl_handshake_timeout* and *start_serving* parameters. The *path* " "parameter can now be a :term:`path-like object`." @@ -239,11 +250,15 @@ msgstr "" "新增 *ssl_handshake_timeout* 與 *start_serving* 參數。*path* 參數現在可以是" "個 :term:`path-like object`。" -#: ../../library/asyncio-stream.rst:195 +#: ../../library/asyncio-stream.rst:205 +msgid "Added the *cleanup_socket* parameter." +msgstr "新增 *cleanup_socket* 參數。" + +#: ../../library/asyncio-stream.rst:210 msgid "StreamReader" msgstr "StreamReader" -#: ../../library/asyncio-stream.rst:199 +#: ../../library/asyncio-stream.rst:214 msgid "" "Represents a reader object that provides APIs to read data from the IO " "stream. As an :term:`asynchronous iterable`, the object supports the :" @@ -252,7 +267,7 @@ msgstr "" "表示一個有提供 API 來從 IO 串流中讀取資料的 reader 物件。作為一個 :term:" "`asynchronous iterable`,此物件支援 :keyword:`async for` 陳述式。" -#: ../../library/asyncio-stream.rst:203 +#: ../../library/asyncio-stream.rst:218 msgid "" "It is not recommended to instantiate *StreamReader* objects directly; use :" "func:`open_connection` and :func:`start_server` instead." @@ -260,15 +275,15 @@ msgstr "" "不建議直接實例化 *StreamReader* 物件;使用 :func:`open_connection` 和 :func:" "`start_server` 會是較好的做法。" -#: ../../library/asyncio-stream.rst:209 +#: ../../library/asyncio-stream.rst:224 msgid "Acknowledge the EOF." msgstr "" -#: ../../library/asyncio-stream.rst:213 +#: ../../library/asyncio-stream.rst:229 msgid "Read up to *n* bytes from the stream." msgstr "從串流中讀取至多 *n* 個位元組的資料。" -#: ../../library/asyncio-stream.rst:215 +#: ../../library/asyncio-stream.rst:231 msgid "" "If *n* is not provided or set to ``-1``, read until EOF, then return all " "read :class:`bytes`. If EOF was received and the internal buffer is empty, " @@ -278,53 +293,53 @@ msgstr "" "的 :class:`bytes`。讀取到 EOF 且內部緩衝區是空的,則回傳一個空的 ``bytes`` 物" "件。" -#: ../../library/asyncio-stream.rst:220 +#: ../../library/asyncio-stream.rst:236 msgid "If *n* is ``0``, return an empty ``bytes`` object immediately." msgstr "如果 *n* 為 ``0``,則立即回傳一個空的 ``bytes`` 物件。" -#: ../../library/asyncio-stream.rst:222 +#: ../../library/asyncio-stream.rst:238 msgid "" "If *n* is positive, return at most *n* available ``bytes`` as soon as at " "least 1 byte is available in the internal buffer. If EOF is received before " "any byte is read, return an empty ``bytes`` object." msgstr "" -#: ../../library/asyncio-stream.rst:229 +#: ../../library/asyncio-stream.rst:246 msgid "" "Read one line, where \"line\" is a sequence of bytes ending with ``\\n``." msgstr "讀取一行,其中\"行\"指的是以 ``\\n`` 結尾的位元組序列。" -#: ../../library/asyncio-stream.rst:232 +#: ../../library/asyncio-stream.rst:249 msgid "" "If EOF is received and ``\\n`` was not found, the method returns partially " "read data." msgstr "如果讀取到 EOF 而沒有找到 ``\\n``,該方法會回傳部分的已讀取資料。" -#: ../../library/asyncio-stream.rst:235 +#: ../../library/asyncio-stream.rst:252 msgid "" "If EOF is received and the internal buffer is empty, return an empty " "``bytes`` object." msgstr "如果讀取到 EOF 且內部緩衝區是空的,則回傳一個空的 ``bytes`` 物件。" -#: ../../library/asyncio-stream.rst:240 +#: ../../library/asyncio-stream.rst:258 msgid "Read exactly *n* bytes." msgstr "讀取剛好 *n* 個位元組。" -#: ../../library/asyncio-stream.rst:242 +#: ../../library/asyncio-stream.rst:260 msgid "" "Raise an :exc:`IncompleteReadError` if EOF is reached before *n* can be " "read. Use the :attr:`IncompleteReadError.partial` attribute to get the " "partially read data." msgstr "" "如果在讀取完 *n* 個位元組之前讀取到 EOF,則會引發 :exc:" -"`IncompleteReadError`。使用 :attr:`IncompleteReadError.partial` 屬性來獲取串" +"`IncompleteReadError`。使用 :attr:`IncompleteReadError.partial` 屬性來取得串" "流結束前已讀取的部分資料。" -#: ../../library/asyncio-stream.rst:248 +#: ../../library/asyncio-stream.rst:267 msgid "Read data from the stream until *separator* is found." msgstr "從串流中持續讀取資料直到出現 *separator*。" -#: ../../library/asyncio-stream.rst:250 +#: ../../library/asyncio-stream.rst:269 msgid "" "On success, the data and separator will be removed from the internal buffer " "(consumed). Returned data will include the separator at the end." @@ -332,7 +347,7 @@ msgstr "" "成功後,資料和 separator(分隔符號)會從內部緩衝區中刪除(或者說是被消費掉 " "(consumed))。回傳的資料在末尾會有一個 separator。" -#: ../../library/asyncio-stream.rst:254 +#: ../../library/asyncio-stream.rst:273 msgid "" "If the amount of data read exceeds the configured stream limit, a :exc:" "`LimitOverrunError` exception is raised, and the data is left in the " @@ -341,7 +356,7 @@ msgstr "" "如果讀取的資料量超過了設定的串流限制,將會引發 :exc:`LimitOverrunError` 例" "外,資料將被留在內部緩衝區中,並可以再次被讀取。" -#: ../../library/asyncio-stream.rst:258 +#: ../../library/asyncio-stream.rst:277 msgid "" "If EOF is reached before the complete separator is found, an :exc:" "`IncompleteReadError` exception is raised, and the internal buffer is " @@ -352,20 +367,32 @@ msgstr "" "`IncompleteReadError` 例外,且內部緩衝區會被重置。:attr:`IncompleteReadError." "partial` 屬性可能包含一部分的 separator。" -#: ../../library/asyncio-stream.rst:267 +#: ../../library/asyncio-stream.rst:282 +msgid "" +"The *separator* may also be a tuple of separators. In this case the return " +"value will be the shortest possible that has any separator as the suffix. " +"For the purposes of :exc:`LimitOverrunError`, the shortest possible " +"separator is considered to be the one that matched." +msgstr "" + +#: ../../library/asyncio-stream.rst:292 +msgid "The *separator* parameter may now be a :class:`tuple` of separators." +msgstr "現在 *separator* 參數可以是一個分隔符號的 :class:`tuple`。" + +#: ../../library/asyncio-stream.rst:297 msgid "Return ``True`` if the buffer is empty and :meth:`feed_eof` was called." msgstr "如果緩衝區是空的且 :meth:`feed_eof` 曾被呼叫則回傳 ``True``。" -#: ../../library/asyncio-stream.rst:272 +#: ../../library/asyncio-stream.rst:302 msgid "StreamWriter" msgstr "StreamWriter" -#: ../../library/asyncio-stream.rst:276 +#: ../../library/asyncio-stream.rst:306 msgid "" "Represents a writer object that provides APIs to write data to the IO stream." msgstr "表示一個有提供 API 來將資料寫入 IO 串流的 writer 物件。" -#: ../../library/asyncio-stream.rst:279 +#: ../../library/asyncio-stream.rst:309 msgid "" "It is not recommended to instantiate *StreamWriter* objects directly; use :" "func:`open_connection` and :func:`start_server` instead." @@ -373,7 +400,7 @@ msgstr "" "不建議直接實例化 *StreamWriter* 物件;使用 :func:`open_connection` 和 :func:" "`start_server` 會是較好的做法。" -#: ../../library/asyncio-stream.rst:285 +#: ../../library/asyncio-stream.rst:315 msgid "" "The method attempts to write the *data* to the underlying socket " "immediately. If that fails, the data is queued in an internal write buffer " @@ -382,11 +409,11 @@ msgstr "" "此方法會嘗試立即將 *data* 寫入到底層的 socket。如果失敗,資料會被放到內部寫入" "緩衝中排隊等待 (queue),直到它可被發送。" -#: ../../library/asyncio-stream.rst:289 ../../library/asyncio-stream.rst:301 +#: ../../library/asyncio-stream.rst:319 ../../library/asyncio-stream.rst:331 msgid "The method should be used along with the ``drain()`` method::" msgstr "此方法應當與 ``drain()`` 方法一起使用: ::" -#: ../../library/asyncio-stream.rst:291 +#: ../../library/asyncio-stream.rst:321 msgid "" "stream.write(data)\n" "await stream.drain()" @@ -394,7 +421,7 @@ msgstr "" "stream.write(data)\n" "await stream.drain()" -#: ../../library/asyncio-stream.rst:296 +#: ../../library/asyncio-stream.rst:326 msgid "" "The method writes a list (or any iterable) of bytes to the underlying socket " "immediately. If that fails, the data is queued in an internal write buffer " @@ -403,7 +430,7 @@ msgstr "" "此方法會立即嘗試將一個位元組 list(或任何可疊代物件 (iterable))寫入到底層的 " "socket。如果失敗,資料會被放到內部寫入緩衝中排隊等待,直到它可被發送。" -#: ../../library/asyncio-stream.rst:303 +#: ../../library/asyncio-stream.rst:333 msgid "" "stream.writelines(lines)\n" "await stream.drain()" @@ -411,17 +438,17 @@ msgstr "" "stream.writelines(lines)\n" "await stream.drain()" -#: ../../library/asyncio-stream.rst:308 +#: ../../library/asyncio-stream.rst:338 msgid "The method closes the stream and the underlying socket." msgstr "此方法會關閉串流以及底層的 socket。" -#: ../../library/asyncio-stream.rst:310 +#: ../../library/asyncio-stream.rst:340 msgid "" "The method should be used, though not mandatory, along with the " "``wait_closed()`` method::" msgstr "此方法應與 ``wait_closed()`` 方法一起使用,但並非強制: ::" -#: ../../library/asyncio-stream.rst:313 +#: ../../library/asyncio-stream.rst:343 msgid "" "stream.close()\n" "await stream.wait_closed()" @@ -429,7 +456,7 @@ msgstr "" "stream.close()\n" "await stream.wait_closed()" -#: ../../library/asyncio-stream.rst:318 +#: ../../library/asyncio-stream.rst:348 msgid "" "Return ``True`` if the underlying transport supports the :meth:`write_eof` " "method, ``False`` otherwise." @@ -437,26 +464,26 @@ msgstr "" "如果底層的傳輸支援 :meth:`write_eof` 方法就回傳 ``True``,否則回傳 " "``False``。" -#: ../../library/asyncio-stream.rst:323 +#: ../../library/asyncio-stream.rst:353 msgid "" "Close the write end of the stream after the buffered write data is flushed." msgstr "在已緩衝的寫入資料被清理 (flush) 後關閉串流的寫入端。" -#: ../../library/asyncio-stream.rst:328 +#: ../../library/asyncio-stream.rst:358 msgid "Return the underlying asyncio transport." msgstr "回傳底層的 asyncio 傳輸。" -#: ../../library/asyncio-stream.rst:332 +#: ../../library/asyncio-stream.rst:362 msgid "" "Access optional transport information; see :meth:`BaseTransport." "get_extra_info` for details." msgstr "存取可選的傳輸資訊;詳情請見 :meth:`BaseTransport.get_extra_info`。" -#: ../../library/asyncio-stream.rst:337 +#: ../../library/asyncio-stream.rst:368 msgid "Wait until it is appropriate to resume writing to the stream. Example::" msgstr "等待直到可以繼續寫入到串流。範例: ::" -#: ../../library/asyncio-stream.rst:340 +#: ../../library/asyncio-stream.rst:371 msgid "" "writer.write(data)\n" "await writer.drain()" @@ -464,7 +491,7 @@ msgstr "" "writer.write(data)\n" "await writer.drain()" -#: ../../library/asyncio-stream.rst:343 +#: ../../library/asyncio-stream.rst:374 msgid "" "This is a flow control method that interacts with the underlying IO write " "buffer. When the size of the buffer reaches the high watermark, *drain()* " @@ -476,48 +503,48 @@ msgstr "" "(high watermark) 時,*drain()* 會阻塞直到緩衝區大小減少至最低標記位 (low " "watermark) 以便繼續寫入。當沒有要等待的資料時,:meth:`drain` 會立即回傳。" -#: ../../library/asyncio-stream.rst:353 +#: ../../library/asyncio-stream.rst:385 msgid "Upgrade an existing stream-based connection to TLS." -msgstr "" +msgstr "將現有的基於串流的連線升級到 TLS。" -#: ../../library/asyncio-stream.rst:355 +#: ../../library/asyncio-stream.rst:387 msgid "Parameters:" msgstr "參數:" -#: ../../library/asyncio-stream.rst:357 +#: ../../library/asyncio-stream.rst:389 msgid "*sslcontext*: a configured instance of :class:`~ssl.SSLContext`." -msgstr "" +msgstr "*sslcontext*:一個 :class:`~ssl.SSLContext` 的已配置實例。" -#: ../../library/asyncio-stream.rst:359 +#: ../../library/asyncio-stream.rst:391 msgid "" "*server_hostname*: sets or overrides the host name that the target server's " "certificate will be matched against." -msgstr "" +msgstr "*server_hostname*:設定或覆寫將會被目標伺服器憑證比對的主機名稱。" -#: ../../library/asyncio-stream.rst:362 +#: ../../library/asyncio-stream.rst:394 msgid "" "*ssl_handshake_timeout* is the time in seconds to wait for the TLS handshake " "to complete before aborting the connection. ``60.0`` seconds if ``None`` " "(default)." msgstr "" -#: ../../library/asyncio-stream.rst:366 +#: ../../library/asyncio-stream.rst:398 msgid "" "*ssl_shutdown_timeout* is the time in seconds to wait for the SSL shutdown " "to complete before aborting the connection. ``30.0`` seconds if ``None`` " "(default)." msgstr "" -#: ../../library/asyncio-stream.rst:378 +#: ../../library/asyncio-stream.rst:410 msgid "" "Return ``True`` if the stream is closed or in the process of being closed." msgstr "如果串流已被關閉或正在被關閉則回傳 ``True``。" -#: ../../library/asyncio-stream.rst:385 +#: ../../library/asyncio-stream.rst:418 msgid "Wait until the stream is closed." msgstr "等待直到串流被關閉。" -#: ../../library/asyncio-stream.rst:387 +#: ../../library/asyncio-stream.rst:420 msgid "" "Should be called after :meth:`close` to wait until the underlying connection " "is closed, ensuring that all data has been flushed before e.g. exiting the " @@ -526,36 +553,36 @@ msgstr "" "應當在 :meth:`close` 之後才被呼叫,這會持續等待直到底層的連線被關閉,以確保在" "這之前(例如在程式退出前)所有資料都已經被清空" -#: ../../library/asyncio-stream.rst:395 +#: ../../library/asyncio-stream.rst:428 msgid "Examples" msgstr "範例" -#: ../../library/asyncio-stream.rst:400 +#: ../../library/asyncio-stream.rst:433 msgid "TCP echo client using streams" -msgstr "使用串流的 TCP echo 客戶端" +msgstr "使用串流的 TCP echo 用戶端" -#: ../../library/asyncio-stream.rst:402 +#: ../../library/asyncio-stream.rst:435 msgid "TCP echo client using the :func:`asyncio.open_connection` function::" -msgstr "使用 :func:`asyncio.open_connection` 函式的 TCP echo 客戶端: ::" +msgstr "使用 :func:`asyncio.open_connection` 函式的 TCP echo 用戶端: ::" -#: ../../library/asyncio-stream.rst:426 +#: ../../library/asyncio-stream.rst:459 msgid "" "The :ref:`TCP echo client protocol " "` example uses the low-level :meth:" "`loop.create_connection` method." msgstr "" -"使用低階 :meth:`loop.create_connection` 方法的 :ref:`TCP echo 客戶端協定 " +"使用低階 :meth:`loop.create_connection` 方法的 :ref:`TCP echo 用戶端協定 " "`\\ 範例。" -#: ../../library/asyncio-stream.rst:433 +#: ../../library/asyncio-stream.rst:466 msgid "TCP echo server using streams" msgstr "使用串流的 TCP echo 伺服器" -#: ../../library/asyncio-stream.rst:435 +#: ../../library/asyncio-stream.rst:468 msgid "TCP echo server using the :func:`asyncio.start_server` function::" msgstr "TCP echo 伺服器使用 :func:`asyncio.start_server` 函式: ::" -#: ../../library/asyncio-stream.rst:437 +#: ../../library/asyncio-stream.rst:470 msgid "" "import asyncio\n" "\n" @@ -615,7 +642,7 @@ msgstr "" "\n" "asyncio.run(main())" -#: ../../library/asyncio-stream.rst:469 +#: ../../library/asyncio-stream.rst:502 msgid "" "The :ref:`TCP echo server protocol " "` example uses the :meth:`loop." @@ -624,16 +651,16 @@ msgstr "" "使用 :meth:`loop.create_server` 方法的 :ref:`TCP echo 伺服器協定 " "` 範例。" -#: ../../library/asyncio-stream.rst:474 +#: ../../library/asyncio-stream.rst:507 msgid "Get HTTP headers" -msgstr "獲取 HTTP 標頭" +msgstr "取得 HTTP 標頭" -#: ../../library/asyncio-stream.rst:476 +#: ../../library/asyncio-stream.rst:509 msgid "" "Simple example querying HTTP headers of the URL passed on the command line::" msgstr "查詢自命令列傳入之 URL 所帶有 HTTP 標頭的簡單範例: ::" -#: ../../library/asyncio-stream.rst:478 +#: ../../library/asyncio-stream.rst:511 msgid "" "import asyncio\n" "import urllib.parse\n" @@ -672,34 +699,34 @@ msgid "" "asyncio.run(print_http_headers(url))" msgstr "" -#: ../../library/asyncio-stream.rst:515 +#: ../../library/asyncio-stream.rst:548 msgid "Usage::" msgstr "用法: ::" -#: ../../library/asyncio-stream.rst:517 +#: ../../library/asyncio-stream.rst:550 msgid "python example.py http://example.com/path/page.html" msgstr "python example.py http://example.com/path/page.html" -#: ../../library/asyncio-stream.rst:519 +#: ../../library/asyncio-stream.rst:552 msgid "or with HTTPS::" msgstr "或使用 HTTPS: ::" -#: ../../library/asyncio-stream.rst:521 +#: ../../library/asyncio-stream.rst:554 msgid "python example.py https://example.com/path/page.html" msgstr "python example.py https://example.com/path/page.html" -#: ../../library/asyncio-stream.rst:527 +#: ../../library/asyncio-stream.rst:560 msgid "Register an open socket to wait for data using streams" msgstr "註冊一個使用串流來等待資料的開放 socket" -#: ../../library/asyncio-stream.rst:529 +#: ../../library/asyncio-stream.rst:562 msgid "" "Coroutine waiting until a socket receives data using the :func:" "`open_connection` function::" msgstr "" "等待直到 socket 透過使用 :func:`open_connection` 函式接收到資料的協程: ::" -#: ../../library/asyncio-stream.rst:532 +#: ../../library/asyncio-stream.rst:565 msgid "" "import asyncio\n" "import socket\n" @@ -732,7 +759,7 @@ msgid "" "asyncio.run(wait_for_data())" msgstr "" -#: ../../library/asyncio-stream.rst:564 +#: ../../library/asyncio-stream.rst:597 msgid "" "The :ref:`register an open socket to wait for data using a protocol " "` example uses a low-level protocol and " @@ -742,7 +769,7 @@ msgstr "" "`\\ 範例中,有使用了低階協定以及 :meth:" "`loop.create_connection` 方法。" -#: ../../library/asyncio-stream.rst:568 +#: ../../library/asyncio-stream.rst:601 msgid "" "The :ref:`watch a file descriptor for read events " "` example uses the low-level :meth:`loop." diff --git a/library/asyncio-subprocess.po b/library/asyncio-subprocess.po index 363fa836b1..8669d045c3 100644 --- a/library/asyncio-subprocess.po +++ b/library/asyncio-subprocess.po @@ -6,9 +6,9 @@ # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-03-12 00:14+0000\n" "PO-Revision-Date: 2018-05-23 14:39+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -127,43 +127,44 @@ msgstr "另請參閱\\ `Examples`_。" msgid "Creating Subprocesses" msgstr "建立子行程" -#: ../../library/asyncio-subprocess.rst:67 +#: ../../library/asyncio-subprocess.rst:68 msgid "Create a subprocess." msgstr "" -#: ../../library/asyncio-subprocess.rst:69 -#: ../../library/asyncio-subprocess.rst:87 +#: ../../library/asyncio-subprocess.rst:70 +#: ../../library/asyncio-subprocess.rst:89 msgid "" "The *limit* argument sets the buffer limit for :class:`StreamReader` " -"wrappers for :attr:`Process.stdout` and :attr:`Process.stderr` (if :const:" -"`subprocess.PIPE` is passed to *stdout* and *stderr* arguments)." +"wrappers for :attr:`~asyncio.subprocess.Process.stdout` and :attr:`~asyncio." +"subprocess.Process.stderr` (if :const:`subprocess.PIPE` is passed to " +"*stdout* and *stderr* arguments)." msgstr "" -#: ../../library/asyncio-subprocess.rst:73 -#: ../../library/asyncio-subprocess.rst:91 +#: ../../library/asyncio-subprocess.rst:74 +#: ../../library/asyncio-subprocess.rst:93 msgid "Return a :class:`~asyncio.subprocess.Process` instance." msgstr "" -#: ../../library/asyncio-subprocess.rst:75 +#: ../../library/asyncio-subprocess.rst:76 msgid "" "See the documentation of :meth:`loop.subprocess_exec` for other parameters." msgstr "" -#: ../../library/asyncio-subprocess.rst:78 -#: ../../library/asyncio-subprocess.rst:105 +#: ../../library/asyncio-subprocess.rst:79 +#: ../../library/asyncio-subprocess.rst:107 msgid "Removed the *loop* parameter." msgstr "" -#: ../../library/asyncio-subprocess.rst:85 +#: ../../library/asyncio-subprocess.rst:87 msgid "Run the *cmd* shell command." msgstr "" -#: ../../library/asyncio-subprocess.rst:93 +#: ../../library/asyncio-subprocess.rst:95 msgid "" "See the documentation of :meth:`loop.subprocess_shell` for other parameters." msgstr "" -#: ../../library/asyncio-subprocess.rst:98 +#: ../../library/asyncio-subprocess.rst:100 msgid "" "It is the application's responsibility to ensure that all whitespace and " "special characters are quoted appropriately to avoid `shell injection " @@ -173,14 +174,14 @@ msgid "" "be used to construct shell commands." msgstr "" -#: ../../library/asyncio-subprocess.rst:110 +#: ../../library/asyncio-subprocess.rst:112 msgid "" "Subprocesses are available for Windows if a :class:`ProactorEventLoop` is " "used. See :ref:`Subprocess Support on Windows ` " "for details." msgstr "" -#: ../../library/asyncio-subprocess.rst:116 +#: ../../library/asyncio-subprocess.rst:118 msgid "" "asyncio also has the following *low-level* APIs to work with subprocesses: :" "meth:`loop.subprocess_exec`, :meth:`loop.subprocess_shell`, :meth:`loop." @@ -189,47 +190,47 @@ msgid "" "Protocols `." msgstr "" -#: ../../library/asyncio-subprocess.rst:124 +#: ../../library/asyncio-subprocess.rst:126 msgid "Constants" msgstr "常數" -#: ../../library/asyncio-subprocess.rst:129 +#: ../../library/asyncio-subprocess.rst:131 msgid "Can be passed to the *stdin*, *stdout* or *stderr* parameters." msgstr "" -#: ../../library/asyncio-subprocess.rst:131 +#: ../../library/asyncio-subprocess.rst:133 msgid "" "If *PIPE* is passed to *stdin* argument, the :attr:`Process.stdin ` attribute will point to a :class:`StreamWriter` " -"instance." +"subprocess.Process.stdin>` attribute will point to a :class:`~asyncio." +"StreamWriter` instance." msgstr "" -#: ../../library/asyncio-subprocess.rst:135 +#: ../../library/asyncio-subprocess.rst:137 msgid "" "If *PIPE* is passed to *stdout* or *stderr* arguments, the :attr:`Process." "stdout ` and :attr:`Process.stderr " "` attributes will point to :class:" -"`StreamReader` instances." +"`~asyncio.StreamReader` instances." msgstr "" -#: ../../library/asyncio-subprocess.rst:143 +#: ../../library/asyncio-subprocess.rst:145 msgid "" "Special value that can be used as the *stderr* argument and indicates that " "standard error should be redirected into standard output." msgstr "" -#: ../../library/asyncio-subprocess.rst:149 +#: ../../library/asyncio-subprocess.rst:151 msgid "" "Special value that can be used as the *stdin*, *stdout* or *stderr* argument " "to process creation functions. It indicates that the special file :data:`os." "devnull` will be used for the corresponding subprocess stream." msgstr "" -#: ../../library/asyncio-subprocess.rst:155 +#: ../../library/asyncio-subprocess.rst:157 msgid "Interacting with Subprocesses" msgstr "" -#: ../../library/asyncio-subprocess.rst:157 +#: ../../library/asyncio-subprocess.rst:159 msgid "" "Both :func:`create_subprocess_exec` and :func:`create_subprocess_shell` " "functions return instances of the *Process* class. *Process* is a high-" @@ -237,61 +238,62 @@ msgid "" "their completion." msgstr "" -#: ../../library/asyncio-subprocess.rst:165 +#: ../../library/asyncio-subprocess.rst:167 msgid "" -"An object that wraps OS processes created by the :func:" -"`create_subprocess_exec` and :func:`create_subprocess_shell` functions." +"An object that wraps OS processes created by the :func:`~asyncio." +"create_subprocess_exec` and :func:`~asyncio.create_subprocess_shell` " +"functions." msgstr "" -#: ../../library/asyncio-subprocess.rst:169 +#: ../../library/asyncio-subprocess.rst:171 msgid "" "This class is designed to have a similar API to the :class:`subprocess." "Popen` class, but there are some notable differences:" msgstr "" -#: ../../library/asyncio-subprocess.rst:173 +#: ../../library/asyncio-subprocess.rst:175 msgid "" "unlike Popen, Process instances do not have an equivalent to the :meth:" "`~subprocess.Popen.poll` method;" msgstr "" -#: ../../library/asyncio-subprocess.rst:176 +#: ../../library/asyncio-subprocess.rst:178 msgid "" "the :meth:`~asyncio.subprocess.Process.communicate` and :meth:`~asyncio." "subprocess.Process.wait` methods don't have a *timeout* parameter: use the :" "func:`~asyncio.wait_for` function;" msgstr "" -#: ../../library/asyncio-subprocess.rst:180 +#: ../../library/asyncio-subprocess.rst:182 msgid "" "the :meth:`Process.wait() ` method is " "asynchronous, whereas :meth:`subprocess.Popen.wait` method is implemented as " "a blocking busy loop;" msgstr "" -#: ../../library/asyncio-subprocess.rst:184 +#: ../../library/asyncio-subprocess.rst:186 msgid "the *universal_newlines* parameter is not supported." msgstr "" -#: ../../library/asyncio-subprocess.rst:186 +#: ../../library/asyncio-subprocess.rst:188 msgid "This class is :ref:`not thread safe `." msgstr "" -#: ../../library/asyncio-subprocess.rst:188 +#: ../../library/asyncio-subprocess.rst:190 msgid "" "See also the :ref:`Subprocess and Threads ` " "section." msgstr "" -#: ../../library/asyncio-subprocess.rst:193 +#: ../../library/asyncio-subprocess.rst:196 msgid "Wait for the child process to terminate." msgstr "" -#: ../../library/asyncio-subprocess.rst:195 +#: ../../library/asyncio-subprocess.rst:198 msgid "Set and return the :attr:`returncode` attribute." msgstr "" -#: ../../library/asyncio-subprocess.rst:199 +#: ../../library/asyncio-subprocess.rst:202 msgid "" "This method can deadlock when using ``stdout=PIPE`` or ``stderr=PIPE`` and " "the child process generates so much output that it blocks waiting for the OS " @@ -299,37 +301,37 @@ msgid "" "using pipes to avoid this condition." msgstr "" -#: ../../library/asyncio-subprocess.rst:207 +#: ../../library/asyncio-subprocess.rst:211 msgid "Interact with process:" msgstr "" -#: ../../library/asyncio-subprocess.rst:209 +#: ../../library/asyncio-subprocess.rst:213 msgid "send data to *stdin* (if *input* is not ``None``);" msgstr "" -#: ../../library/asyncio-subprocess.rst:210 +#: ../../library/asyncio-subprocess.rst:214 msgid "closes *stdin*;" msgstr "" -#: ../../library/asyncio-subprocess.rst:211 +#: ../../library/asyncio-subprocess.rst:215 msgid "read data from *stdout* and *stderr*, until EOF is reached;" msgstr "" -#: ../../library/asyncio-subprocess.rst:212 +#: ../../library/asyncio-subprocess.rst:216 msgid "wait for process to terminate." msgstr "" -#: ../../library/asyncio-subprocess.rst:214 +#: ../../library/asyncio-subprocess.rst:218 msgid "" "The optional *input* argument is the data (:class:`bytes` object) that will " "be sent to the child process." msgstr "" -#: ../../library/asyncio-subprocess.rst:217 +#: ../../library/asyncio-subprocess.rst:221 msgid "Return a tuple ``(stdout_data, stderr_data)``." msgstr "" -#: ../../library/asyncio-subprocess.rst:219 +#: ../../library/asyncio-subprocess.rst:223 msgid "" "If either :exc:`BrokenPipeError` or :exc:`ConnectionResetError` exception is " "raised when writing *input* into *stdin*, the exception is ignored. This " @@ -337,7 +339,7 @@ msgid "" "*stdin*." msgstr "" -#: ../../library/asyncio-subprocess.rst:224 +#: ../../library/asyncio-subprocess.rst:228 msgid "" "If it is desired to send data to the process' *stdin*, the process needs to " "be created with ``stdin=PIPE``. Similarly, to get anything other than " @@ -345,75 +347,76 @@ msgid "" "``stdout=PIPE`` and/or ``stderr=PIPE`` arguments." msgstr "" -#: ../../library/asyncio-subprocess.rst:230 +#: ../../library/asyncio-subprocess.rst:234 msgid "" "Note, that the data read is buffered in memory, so do not use this method if " "the data size is large or unlimited." msgstr "" -#: ../../library/asyncio-subprocess.rst:235 -msgid "*stdin* gets closed when `input=None` too." +#: ../../library/asyncio-subprocess.rst:239 +msgid "*stdin* gets closed when ``input=None`` too." msgstr "" -#: ../../library/asyncio-subprocess.rst:239 +#: ../../library/asyncio-subprocess.rst:243 msgid "Sends the signal *signal* to the child process." msgstr "" -#: ../../library/asyncio-subprocess.rst:243 +#: ../../library/asyncio-subprocess.rst:247 msgid "" "On Windows, :py:const:`~signal.SIGTERM` is an alias for :meth:`terminate`. " "``CTRL_C_EVENT`` and ``CTRL_BREAK_EVENT`` can be sent to processes started " "with a *creationflags* parameter which includes ``CREATE_NEW_PROCESS_GROUP``." msgstr "" -#: ../../library/asyncio-subprocess.rst:250 +#: ../../library/asyncio-subprocess.rst:254 msgid "Stop the child process." msgstr "" -#: ../../library/asyncio-subprocess.rst:252 +#: ../../library/asyncio-subprocess.rst:256 msgid "" "On POSIX systems this method sends :py:const:`~signal.SIGTERM` to the child " "process." msgstr "" -#: ../../library/asyncio-subprocess.rst:255 +#: ../../library/asyncio-subprocess.rst:259 msgid "" "On Windows the Win32 API function :c:func:`!TerminateProcess` is called to " "stop the child process." msgstr "" -#: ../../library/asyncio-subprocess.rst:260 +#: ../../library/asyncio-subprocess.rst:264 msgid "Kill the child process." msgstr "" -#: ../../library/asyncio-subprocess.rst:262 +#: ../../library/asyncio-subprocess.rst:266 msgid "" -"On POSIX systems this method sends :py:data:`SIGKILL` to the child process." +"On POSIX systems this method sends :py:data:`~signal.SIGKILL` to the child " +"process." msgstr "" -#: ../../library/asyncio-subprocess.rst:265 +#: ../../library/asyncio-subprocess.rst:269 msgid "On Windows this method is an alias for :meth:`terminate`." msgstr "" -#: ../../library/asyncio-subprocess.rst:269 +#: ../../library/asyncio-subprocess.rst:273 msgid "" -"Standard input stream (:class:`StreamWriter`) or ``None`` if the process was " -"created with ``stdin=None``." +"Standard input stream (:class:`~asyncio.StreamWriter`) or ``None`` if the " +"process was created with ``stdin=None``." msgstr "" -#: ../../library/asyncio-subprocess.rst:274 +#: ../../library/asyncio-subprocess.rst:278 msgid "" -"Standard output stream (:class:`StreamReader`) or ``None`` if the process " -"was created with ``stdout=None``." +"Standard output stream (:class:`~asyncio.StreamReader`) or ``None`` if the " +"process was created with ``stdout=None``." msgstr "" -#: ../../library/asyncio-subprocess.rst:279 +#: ../../library/asyncio-subprocess.rst:283 msgid "" -"Standard error stream (:class:`StreamReader`) or ``None`` if the process was " -"created with ``stderr=None``." +"Standard error stream (:class:`~asyncio.StreamReader`) or ``None`` if the " +"process was created with ``stderr=None``." msgstr "" -#: ../../library/asyncio-subprocess.rst:284 +#: ../../library/asyncio-subprocess.rst:288 msgid "" "Use the :meth:`communicate` method rather than :attr:`process.stdin.write() " "`, :attr:`await process.stdout.read() ` or :attr:`await " @@ -421,93 +424,94 @@ msgid "" "pausing reading or writing and blocking the child process." msgstr "" -#: ../../library/asyncio-subprocess.rst:293 +#: ../../library/asyncio-subprocess.rst:297 msgid "Process identification number (PID)." msgstr "" -#: ../../library/asyncio-subprocess.rst:295 +#: ../../library/asyncio-subprocess.rst:299 msgid "" -"Note that for processes created by the :func:`create_subprocess_shell` " -"function, this attribute is the PID of the spawned shell." +"Note that for processes created by the :func:`~asyncio." +"create_subprocess_shell` function, this attribute is the PID of the spawned " +"shell." msgstr "" -#: ../../library/asyncio-subprocess.rst:300 +#: ../../library/asyncio-subprocess.rst:304 msgid "Return code of the process when it exits." msgstr "" -#: ../../library/asyncio-subprocess.rst:302 +#: ../../library/asyncio-subprocess.rst:306 msgid "A ``None`` value indicates that the process has not terminated yet." msgstr "" -#: ../../library/asyncio-subprocess.rst:304 +#: ../../library/asyncio-subprocess.rst:308 msgid "" "A negative value ``-N`` indicates that the child was terminated by signal " "``N`` (POSIX only)." msgstr "" -#: ../../library/asyncio-subprocess.rst:311 +#: ../../library/asyncio-subprocess.rst:315 msgid "Subprocess and Threads" msgstr "子行程與線程" -#: ../../library/asyncio-subprocess.rst:313 +#: ../../library/asyncio-subprocess.rst:317 msgid "" "Standard asyncio event loop supports running subprocesses from different " "threads by default." msgstr "" -#: ../../library/asyncio-subprocess.rst:316 +#: ../../library/asyncio-subprocess.rst:320 msgid "" "On Windows subprocesses are provided by :class:`ProactorEventLoop` only " "(default), :class:`SelectorEventLoop` has no subprocess support." msgstr "" -#: ../../library/asyncio-subprocess.rst:319 +#: ../../library/asyncio-subprocess.rst:323 msgid "" "On UNIX *child watchers* are used for subprocess finish waiting, see :ref:" "`asyncio-watchers` for more info." msgstr "" -#: ../../library/asyncio-subprocess.rst:325 +#: ../../library/asyncio-subprocess.rst:329 msgid "" "UNIX switched to use :class:`ThreadedChildWatcher` for spawning subprocesses " "from different threads without any limitation." msgstr "" -#: ../../library/asyncio-subprocess.rst:328 +#: ../../library/asyncio-subprocess.rst:332 msgid "" "Spawning a subprocess with *inactive* current child watcher raises :exc:" "`RuntimeError`." msgstr "" -#: ../../library/asyncio-subprocess.rst:331 +#: ../../library/asyncio-subprocess.rst:335 msgid "" "Note that alternative event loop implementations might have own limitations; " "please refer to their documentation." msgstr "" -#: ../../library/asyncio-subprocess.rst:336 +#: ../../library/asyncio-subprocess.rst:340 msgid "" "The :ref:`Concurrency and multithreading in asyncio ` section." msgstr "" -#: ../../library/asyncio-subprocess.rst:341 +#: ../../library/asyncio-subprocess.rst:345 msgid "Examples" msgstr "範例" -#: ../../library/asyncio-subprocess.rst:343 +#: ../../library/asyncio-subprocess.rst:347 msgid "" "An example using the :class:`~asyncio.subprocess.Process` class to control a " "subprocess and the :class:`StreamReader` class to read from its standard " "output." msgstr "" -#: ../../library/asyncio-subprocess.rst:349 +#: ../../library/asyncio-subprocess.rst:353 msgid "" "The subprocess is created by the :func:`create_subprocess_exec` function::" msgstr "" -#: ../../library/asyncio-subprocess.rst:352 +#: ../../library/asyncio-subprocess.rst:356 msgid "" "import asyncio\n" "import sys\n" @@ -533,7 +537,7 @@ msgid "" "print(f\"Current date: {date}\")" msgstr "" -#: ../../library/asyncio-subprocess.rst:376 +#: ../../library/asyncio-subprocess.rst:380 msgid "" "See also the :ref:`same example ` written " "using low-level APIs." diff --git a/library/asyncio-sync.po b/library/asyncio-sync.po index f7a90d4efe..a539db9b6e 100644 --- a/library/asyncio-sync.po +++ b/library/asyncio-sync.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. # Copyright (C) 2001-2022, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-02-23 00:15+0000\n" "PO-Revision-Date: 2022-02-09 19:27+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -108,8 +107,8 @@ msgid "" " # access shared state" msgstr "" -#: ../../library/asyncio-sync.rst:56 ../../library/asyncio-sync.rst:199 -#: ../../library/asyncio-sync.rst:298 +#: ../../library/asyncio-sync.rst:56 ../../library/asyncio-sync.rst:201 +#: ../../library/asyncio-sync.rst:309 msgid "which is equivalent to::" msgstr "這等價於: ::" @@ -125,17 +124,17 @@ msgid "" " lock.release()" msgstr "" -#: ../../library/asyncio-sync.rst:67 ../../library/asyncio-sync.rst:112 -#: ../../library/asyncio-sync.rst:187 ../../library/asyncio-sync.rst:286 -#: ../../library/asyncio-sync.rst:341 +#: ../../library/asyncio-sync.rst:67 ../../library/asyncio-sync.rst:113 +#: ../../library/asyncio-sync.rst:189 ../../library/asyncio-sync.rst:297 +#: ../../library/asyncio-sync.rst:353 msgid "Removed the *loop* parameter." msgstr "移除 ``loop`` 參數。" -#: ../../library/asyncio-sync.rst:72 +#: ../../library/asyncio-sync.rst:73 msgid "Acquire the lock." msgstr "獲得鎖。" -#: ../../library/asyncio-sync.rst:74 +#: ../../library/asyncio-sync.rst:75 msgid "" "This method waits until the lock is *unlocked*, sets it to *locked* and " "returns ``True``." @@ -143,7 +142,7 @@ msgstr "" "此方法會持續等待直到鎖的狀態成為 *unlocked*,並將其設置為 *locked* 和回傳 " "``True``。" -#: ../../library/asyncio-sync.rst:77 +#: ../../library/asyncio-sync.rst:78 msgid "" "When more than one coroutine is blocked in :meth:`acquire` waiting for the " "lock to be unlocked, only one coroutine eventually proceeds." @@ -151,45 +150,45 @@ msgstr "" "當多於一個的協程 (coroutine) 在 :meth:`acquire` 中等待解鎖而被阻塞,最終只會" "有其中的一個被處理。" -#: ../../library/asyncio-sync.rst:81 +#: ../../library/asyncio-sync.rst:82 msgid "" "Acquiring a lock is *fair*: the coroutine that proceeds will be the first " "coroutine that started waiting on the lock." msgstr "" -"鎖的獲取方式是\\ *公平*\\ 的:被處理的協程會是最早開始等待解鎖的那一個。" +"鎖的取得方式是\\ *公平*\\ 的:被處理的協程會是最早開始等待解鎖的那一個。" -#: ../../library/asyncio-sync.rst:86 +#: ../../library/asyncio-sync.rst:87 msgid "Release the lock." msgstr "釋放鎖。" -#: ../../library/asyncio-sync.rst:88 +#: ../../library/asyncio-sync.rst:89 msgid "When the lock is *locked*, reset it to *unlocked* and return." msgstr "如果鎖的狀態為 *locked* 則將其重置為 *unlocked* 並回傳。" -#: ../../library/asyncio-sync.rst:90 +#: ../../library/asyncio-sync.rst:91 msgid "If the lock is *unlocked*, a :exc:`RuntimeError` is raised." msgstr "如果鎖的狀態為 *unlocked* 則 :exc:`RuntimeError` 會被引發。" -#: ../../library/asyncio-sync.rst:94 +#: ../../library/asyncio-sync.rst:95 msgid "Return ``True`` if the lock is *locked*." msgstr "如果鎖的狀態為 *locked* 則回傳 ``True``。" -#: ../../library/asyncio-sync.rst:98 +#: ../../library/asyncio-sync.rst:99 msgid "Event" msgstr "Event" -#: ../../library/asyncio-sync.rst:102 +#: ../../library/asyncio-sync.rst:103 msgid "An event object. Not thread-safe." msgstr "一個事件 (event) 物件。不支援執行緒安全。" -#: ../../library/asyncio-sync.rst:104 +#: ../../library/asyncio-sync.rst:105 msgid "" "An asyncio event can be used to notify multiple asyncio tasks that some " "event has happened." msgstr "" "一個 asyncio 事件可以被用於通知多個有發生某些事件於其中的 asyncio 任務。" -#: ../../library/asyncio-sync.rst:107 +#: ../../library/asyncio-sync.rst:108 msgid "" "An Event object manages an internal flag that can be set to *true* with the :" "meth:`~Event.set` method and reset to *false* with the :meth:`clear` " @@ -201,11 +200,11 @@ msgstr "" "wait` 方法會被阻塞 (block) 直到該旗標被設為 *true*。該旗標初始設置為 " "*false*。" -#: ../../library/asyncio-sync.rst:117 ../../library/asyncio-sync.rst:365 +#: ../../library/asyncio-sync.rst:118 ../../library/asyncio-sync.rst:377 msgid "Example::" msgstr "範例: ::" -#: ../../library/asyncio-sync.rst:119 +#: ../../library/asyncio-sync.rst:120 msgid "" "async def waiter(event):\n" " print('waiting for it ...')\n" @@ -229,11 +228,11 @@ msgid "" "asyncio.run(main())" msgstr "" -#: ../../library/asyncio-sync.rst:142 +#: ../../library/asyncio-sync.rst:144 msgid "Wait until the event is set." msgstr "持續等待直到事件被設置。" -#: ../../library/asyncio-sync.rst:144 +#: ../../library/asyncio-sync.rst:146 msgid "" "If the event is set, return ``True`` immediately. Otherwise block until " "another task calls :meth:`~Event.set`." @@ -241,19 +240,19 @@ msgstr "" "如果事件有被設置則立刻回傳 ``True``。否則持續阻塞直到另一個任務呼叫 :meth:" "`~Event.set`。" -#: ../../library/asyncio-sync.rst:149 +#: ../../library/asyncio-sync.rst:151 msgid "Set the event." msgstr "設置事件。" -#: ../../library/asyncio-sync.rst:151 +#: ../../library/asyncio-sync.rst:153 msgid "All tasks waiting for event to be set will be immediately awakened." msgstr "所有正在等待事件被設置的任務會立即被喚醒。" -#: ../../library/asyncio-sync.rst:156 +#: ../../library/asyncio-sync.rst:158 msgid "Clear (unset) the event." msgstr "清除(還原)事件。" -#: ../../library/asyncio-sync.rst:158 +#: ../../library/asyncio-sync.rst:160 msgid "" "Tasks awaiting on :meth:`~Event.wait` will now block until the :meth:`~Event." "set` method is called again." @@ -261,19 +260,19 @@ msgstr "" "正透過 :meth:`~Event.wait` 等待的 Tasks 現在會持續阻塞直到 :meth:`~Event." "set` 方法再次被呼叫。" -#: ../../library/asyncio-sync.rst:163 +#: ../../library/asyncio-sync.rst:165 msgid "Return ``True`` if the event is set." msgstr "如果事件有被設置則回傳 ``True``。" -#: ../../library/asyncio-sync.rst:167 +#: ../../library/asyncio-sync.rst:169 msgid "Condition" msgstr "Condition" -#: ../../library/asyncio-sync.rst:171 +#: ../../library/asyncio-sync.rst:173 msgid "A Condition object. Not thread-safe." msgstr "一個條件 (codition) 物件。不支援執行緒安全。" -#: ../../library/asyncio-sync.rst:173 +#: ../../library/asyncio-sync.rst:175 msgid "" "An asyncio condition primitive can be used by a task to wait for some event " "to happen and then get exclusive access to a shared resource." @@ -281,7 +280,7 @@ msgstr "" "一個 asyncio 條件原始物件可以被任務用來等待某事件發生,並獲得一個共享資源的獨" "佔存取權。" -#: ../../library/asyncio-sync.rst:177 +#: ../../library/asyncio-sync.rst:179 msgid "" "In essence, a Condition object combines the functionality of an :class:" "`Event` and a :class:`Lock`. It is possible to have multiple Condition " @@ -291,9 +290,9 @@ msgid "" msgstr "" "本質上,一個 Condition 物件會結合 :class:`Event` 和 :class:`Lock` 的功能。多" "個 Condition 物件共享一個 Lock 是有可能發生的,這能夠協調關注同一共享資源的不" -"同狀態以獲取其獨佔存取權的多個任務。" +"同狀態以取得其獨佔存取權的多個任務。" -#: ../../library/asyncio-sync.rst:183 +#: ../../library/asyncio-sync.rst:185 msgid "" "The optional *lock* argument must be a :class:`Lock` object or ``None``. In " "the latter case a new Lock object is created automatically." @@ -301,12 +300,12 @@ msgstr "" "可選的 *lock* 引數必須是一個 :class:`Lock` 物件或者為 ``None``。如為後者則一" "個新的 Lock 物件會被自動建立。" -#: ../../library/asyncio-sync.rst:190 +#: ../../library/asyncio-sync.rst:192 msgid "" "The preferred way to use a Condition is an :keyword:`async with` statement::" msgstr "使用 Condition 的推薦方式是透過 :keyword:`async with` 陳述式: ::" -#: ../../library/asyncio-sync.rst:193 +#: ../../library/asyncio-sync.rst:195 msgid "" "cond = asyncio.Condition()\n" "\n" @@ -315,7 +314,7 @@ msgid "" " await cond.wait()" msgstr "" -#: ../../library/asyncio-sync.rst:201 +#: ../../library/asyncio-sync.rst:203 msgid "" "cond = asyncio.Condition()\n" "\n" @@ -327,11 +326,11 @@ msgid "" " cond.release()" msgstr "" -#: ../../library/asyncio-sync.rst:212 +#: ../../library/asyncio-sync.rst:215 msgid "Acquire the underlying lock." -msgstr "獲取底層的鎖。" +msgstr "取得底層的鎖。" -#: ../../library/asyncio-sync.rst:214 +#: ../../library/asyncio-sync.rst:217 msgid "" "This method waits until the underlying lock is *unlocked*, sets it to " "*locked* and returns ``True``." @@ -339,15 +338,15 @@ msgstr "" "此方法會持續等待直到底層的鎖為 *unlocked*,並將其設為 *locked* 並回傳 " "``True``。" -#: ../../library/asyncio-sync.rst:219 +#: ../../library/asyncio-sync.rst:222 msgid "" -"Wake up at most *n* tasks (1 by default) waiting on this condition. The " -"method is no-op if no tasks are waiting." +"Wake up *n* tasks (1 by default) waiting on this condition. If fewer than " +"*n* tasks are waiting they are all awakened." msgstr "" -"喚醒至多 *n* 個正在等待此條件的任務(預設為 1),如果沒有正在等待的任務則此方" -"法為空操作 (no-op)。" +"喚醒至多 *n* 個正在等待此條件的任務(預設為 1),如果少於 *n* 個任務則全部被" +"喚醒。" -#: ../../library/asyncio-sync.rst:222 ../../library/asyncio-sync.rst:237 +#: ../../library/asyncio-sync.rst:225 ../../library/asyncio-sync.rst:240 msgid "" "The lock must be acquired before this method is called and released shortly " "after. If called with an *unlocked* lock a :exc:`RuntimeError` error is " @@ -356,69 +355,79 @@ msgstr "" "在此方法被呼叫前必須先獲得鎖,並在之後立刻將其釋放。如果呼叫於一個 " "*unlocked* 的鎖則 :exc:`RuntimeError` 錯誤會被引發。" -#: ../../library/asyncio-sync.rst:228 +#: ../../library/asyncio-sync.rst:231 msgid "Return ``True`` if the underlying lock is acquired." -msgstr "如果已獲取底層的鎖則回傳 ``True``。" +msgstr "如果已取得底層的鎖則回傳 ``True``。" -#: ../../library/asyncio-sync.rst:232 +#: ../../library/asyncio-sync.rst:235 msgid "Wake up all tasks waiting on this condition." msgstr "喚醒所有正在等待此條件的任務。" -#: ../../library/asyncio-sync.rst:234 +#: ../../library/asyncio-sync.rst:237 msgid "This method acts like :meth:`notify`, but wakes up all waiting tasks." msgstr "這個方法的行為就像 :meth:`notify`,但會喚醒所有正在等待的任務。" -#: ../../library/asyncio-sync.rst:243 +#: ../../library/asyncio-sync.rst:246 msgid "Release the underlying lock." msgstr "釋放底層的鎖。" -#: ../../library/asyncio-sync.rst:245 +#: ../../library/asyncio-sync.rst:248 msgid "When invoked on an unlocked lock, a :exc:`RuntimeError` is raised." -msgstr "當調用於一個未被解開的鎖之上時,會引發一個 :exc:`RuntimeError`。" +msgstr "當叫用於一個未被解開的鎖之上時,會引發一個 :exc:`RuntimeError`。" -#: ../../library/asyncio-sync.rst:250 +#: ../../library/asyncio-sync.rst:254 msgid "Wait until notified." msgstr "持續等待直到被通知 (notify)。" -#: ../../library/asyncio-sync.rst:252 +#: ../../library/asyncio-sync.rst:256 msgid "" "If the calling task has not acquired the lock when this method is called, a :" "exc:`RuntimeError` is raised." msgstr "" -"當此方法被呼叫時,如果呼叫它的任務還沒有獲取鎖的話,:exc:`RuntimeError` 會被" +"當此方法被呼叫時,如果呼叫它的任務還沒有取得鎖的話,:exc:`RuntimeError` 會被" "引發。" -#: ../../library/asyncio-sync.rst:255 +#: ../../library/asyncio-sync.rst:259 msgid "" "This method releases the underlying lock, and then blocks until it is " "awakened by a :meth:`notify` or :meth:`notify_all` call. Once awakened, the " "Condition re-acquires its lock and this method returns ``True``." msgstr "" "此方法會釋放底層的鎖,然後持續阻塞直到被 :meth:`notify` 或 :meth:" -"`notify_all` 的呼叫所喚醒。一但被喚醒,Condition 會重新獲取該鎖且此方法會回" +"`notify_all` 的呼叫所喚醒。一但被喚醒,Condition 會重新取得該鎖且此方法會回" "傳 ``True``。" -#: ../../library/asyncio-sync.rst:262 +#: ../../library/asyncio-sync.rst:264 +msgid "" +"Note that a task *may* return from this call spuriously, which is why the " +"caller should always re-check the state and be prepared to :meth:`~Condition." +"wait` again. For this reason, you may prefer to use :meth:`~Condition." +"wait_for` instead." +msgstr "" + +#: ../../library/asyncio-sync.rst:272 msgid "Wait until a predicate becomes *true*." msgstr "持續等待直到謂語 (predicate) 成為 *true*。" -#: ../../library/asyncio-sync.rst:264 +#: ../../library/asyncio-sync.rst:274 msgid "" "The predicate must be a callable which result will be interpreted as a " -"boolean value. The final value is the return value." +"boolean value. The method will repeatedly :meth:`~Condition.wait` until the " +"predicate evaluates to *true*. The final value is the return value." msgstr "" -"謂語必須是一個結果可被直譯為一個 boolean 值的可呼叫物件 (callable)。最終值為" -"回傳值。" +"謂語必須是一個結果可被直譯為一個 boolean 值的可呼叫物件 (callable)。此方法會" +"重複地 :meth:`~Condition.wait` 直到謂語求值結果為 *true*。最終的值即為回傳" +"值。" -#: ../../library/asyncio-sync.rst:270 +#: ../../library/asyncio-sync.rst:281 msgid "Semaphore" msgstr "Semaphore" -#: ../../library/asyncio-sync.rst:274 +#: ../../library/asyncio-sync.rst:285 msgid "A Semaphore object. Not thread-safe." msgstr "一個旗號 (semaphore) 物件。不支援執行緒安全。" -#: ../../library/asyncio-sync.rst:276 +#: ../../library/asyncio-sync.rst:287 msgid "" "A semaphore manages an internal counter which is decremented by each :meth:" "`acquire` call and incremented by each :meth:`release` call. The counter can " @@ -429,7 +438,7 @@ msgstr "" "呼叫 :meth:`release` 時增加一。此計數器永遠不會少於零;當 :meth:`acquire` 發" "現它是零時,它會持續阻塞並等待某任務呼叫 :meth:`release`。" -#: ../../library/asyncio-sync.rst:282 +#: ../../library/asyncio-sync.rst:293 msgid "" "The optional *value* argument gives the initial value for the internal " "counter (``1`` by default). If the given value is less than ``0`` a :exc:" @@ -438,12 +447,12 @@ msgstr "" "可選的 *value* 引數給定了內部計數器的初始值(預設為 ``1``\\ )。如給定的值少" "於 ``0`` 則 :exc:`ValueError` 會被引發。" -#: ../../library/asyncio-sync.rst:289 +#: ../../library/asyncio-sync.rst:300 msgid "" "The preferred way to use a Semaphore is an :keyword:`async with` statement::" msgstr "使用 Semaphore 的推薦方式是透過 :keyword:`async with` 陳述式: ::" -#: ../../library/asyncio-sync.rst:292 +#: ../../library/asyncio-sync.rst:303 msgid "" "sem = asyncio.Semaphore(10)\n" "\n" @@ -452,7 +461,7 @@ msgid "" " # work with shared resource" msgstr "" -#: ../../library/asyncio-sync.rst:300 +#: ../../library/asyncio-sync.rst:311 msgid "" "sem = asyncio.Semaphore(10)\n" "\n" @@ -464,11 +473,11 @@ msgid "" " sem.release()" msgstr "" -#: ../../library/asyncio-sync.rst:311 +#: ../../library/asyncio-sync.rst:323 msgid "Acquire a semaphore." -msgstr "獲取一個旗號。" +msgstr "取得一個旗號。" -#: ../../library/asyncio-sync.rst:313 +#: ../../library/asyncio-sync.rst:325 msgid "" "If the internal counter is greater than zero, decrement it by one and return " "``True`` immediately. If it is zero, wait until a :meth:`release` is called " @@ -477,19 +486,19 @@ msgstr "" "如果內部計數器大於零,將其減一並立刻回傳 ``True``。如果為零,則持續等待直到 :" "meth:`release` 被呼叫,並回傳 ``True``。" -#: ../../library/asyncio-sync.rst:319 +#: ../../library/asyncio-sync.rst:331 msgid "Returns ``True`` if semaphore can not be acquired immediately." msgstr "如果旗號無法立即被取得則回傳 ``True``。" -#: ../../library/asyncio-sync.rst:323 +#: ../../library/asyncio-sync.rst:335 msgid "" "Release a semaphore, incrementing the internal counter by one. Can wake up a " "task waiting to acquire the semaphore." msgstr "" -"釋放一個旗號,並為其內部的計數器數值增加一。可以把一個正在等待獲取旗號的任務" +"釋放一個旗號,並為其內部的計數器數值增加一。可以把一個正在等待取得旗號的任務" "叫醒。" -#: ../../library/asyncio-sync.rst:326 +#: ../../library/asyncio-sync.rst:338 msgid "" "Unlike :class:`BoundedSemaphore`, :class:`Semaphore` allows making more " "``release()`` calls than ``acquire()`` calls." @@ -497,15 +506,15 @@ msgstr "" "和 :class:`BoundedSemaphore` 不同,:class:`Semaphore` 允許 ``release()`` 的呼" "叫次數多於 ``acquire()``。" -#: ../../library/asyncio-sync.rst:331 +#: ../../library/asyncio-sync.rst:343 msgid "BoundedSemaphore" msgstr "BoundedSemaphore" -#: ../../library/asyncio-sync.rst:335 +#: ../../library/asyncio-sync.rst:347 msgid "A bounded semaphore object. Not thread-safe." msgstr "一個有界的旗號物件。不支援執行緒安全。" -#: ../../library/asyncio-sync.rst:337 +#: ../../library/asyncio-sync.rst:349 msgid "" "Bounded Semaphore is a version of :class:`Semaphore` that raises a :exc:" "`ValueError` in :meth:`~Semaphore.release` if it increases the internal " @@ -515,15 +524,15 @@ msgstr "" "加至大於初始 *value* 值的話,:exc:`ValueError` 會在 :meth:`~Semaphore." "release` 時被引發。" -#: ../../library/asyncio-sync.rst:346 +#: ../../library/asyncio-sync.rst:358 msgid "Barrier" msgstr "Barrier" -#: ../../library/asyncio-sync.rst:350 +#: ../../library/asyncio-sync.rst:362 msgid "A barrier object. Not thread-safe." msgstr "一個屏障 (barrier) 物件。不支援執行緒安全。" -#: ../../library/asyncio-sync.rst:352 +#: ../../library/asyncio-sync.rst:364 msgid "" "A barrier is a simple synchronization primitive that allows to block until " "*parties* number of tasks are waiting on it. Tasks can wait on the :meth:" @@ -532,17 +541,17 @@ msgid "" "waiting tasks would unblock simultaneously." msgstr "" -#: ../../library/asyncio-sync.rst:358 +#: ../../library/asyncio-sync.rst:370 msgid "" ":keyword:`async with` can be used as an alternative to awaiting on :meth:" "`~Barrier.wait`." msgstr "" -#: ../../library/asyncio-sync.rst:361 +#: ../../library/asyncio-sync.rst:373 msgid "The barrier can be reused any number of times." msgstr "" -#: ../../library/asyncio-sync.rst:367 +#: ../../library/asyncio-sync.rst:379 msgid "" "async def example_barrier():\n" " # barrier with 3 parties\n" @@ -566,11 +575,11 @@ msgid "" "asyncio.run(example_barrier())" msgstr "" -#: ../../library/asyncio-sync.rst:388 +#: ../../library/asyncio-sync.rst:400 msgid "Result of this example is::" msgstr "" -#: ../../library/asyncio-sync.rst:390 +#: ../../library/asyncio-sync.rst:402 msgid "" "\n" "\n" @@ -582,27 +591,27 @@ msgstr "" "barrier passed\n" "" -#: ../../library/asyncio-sync.rst:399 +#: ../../library/asyncio-sync.rst:412 msgid "" "Pass the barrier. When all the tasks party to the barrier have called this " "function, they are all unblocked simultaneously." msgstr "" -#: ../../library/asyncio-sync.rst:402 +#: ../../library/asyncio-sync.rst:415 msgid "" "When a waiting or blocked task in the barrier is cancelled, this task exits " "the barrier which stays in the same state. If the state of the barrier is " "\"filling\", the number of waiting task decreases by 1." msgstr "" -#: ../../library/asyncio-sync.rst:407 +#: ../../library/asyncio-sync.rst:420 msgid "" "The return value is an integer in the range of 0 to ``parties-1``, different " "for each task. This can be used to select a task to do some special " "housekeeping, e.g.::" msgstr "" -#: ../../library/asyncio-sync.rst:411 +#: ../../library/asyncio-sync.rst:424 msgid "" "...\n" "async with barrier as position:\n" @@ -611,56 +620,57 @@ msgid "" " print('End of *draining phase*')" msgstr "" -#: ../../library/asyncio-sync.rst:417 +#: ../../library/asyncio-sync.rst:430 msgid "" "This method may raise a :class:`BrokenBarrierError` exception if the barrier " "is broken or reset while a task is waiting. It could raise a :exc:" "`CancelledError` if a task is cancelled." msgstr "" -#: ../../library/asyncio-sync.rst:423 +#: ../../library/asyncio-sync.rst:437 msgid "" "Return the barrier to the default, empty state. Any tasks waiting on it " "will receive the :class:`BrokenBarrierError` exception." msgstr "" -#: ../../library/asyncio-sync.rst:426 +#: ../../library/asyncio-sync.rst:440 msgid "" "If a barrier is broken it may be better to just leave it and create a new " "one." msgstr "" -#: ../../library/asyncio-sync.rst:430 +#: ../../library/asyncio-sync.rst:445 msgid "" "Put the barrier into a broken state. This causes any active or future calls " -"to :meth:`wait` to fail with the :class:`BrokenBarrierError`. Use this for " -"example if one of the tasks needs to abort, to avoid infinite waiting tasks." +"to :meth:`~Barrier.wait` to fail with the :class:`BrokenBarrierError`. Use " +"this for example if one of the tasks needs to abort, to avoid infinite " +"waiting tasks." msgstr "" -#: ../../library/asyncio-sync.rst:437 +#: ../../library/asyncio-sync.rst:452 msgid "The number of tasks required to pass the barrier." msgstr "" -#: ../../library/asyncio-sync.rst:441 +#: ../../library/asyncio-sync.rst:456 msgid "The number of tasks currently waiting in the barrier while filling." msgstr "" -#: ../../library/asyncio-sync.rst:445 +#: ../../library/asyncio-sync.rst:460 msgid "A boolean that is ``True`` if the barrier is in the broken state." msgstr "" -#: ../../library/asyncio-sync.rst:450 +#: ../../library/asyncio-sync.rst:465 msgid "" "This exception, a subclass of :exc:`RuntimeError`, is raised when the :class:" "`Barrier` object is reset or broken." msgstr "" -#: ../../library/asyncio-sync.rst:458 +#: ../../library/asyncio-sync.rst:473 msgid "" "Acquiring a lock using ``await lock`` or ``yield from lock`` and/or :keyword:" "`with` statement (``with await lock``, ``with (yield from lock)``) was " "removed. Use ``async with lock`` instead." msgstr "" "透過 ``await lock`` 或 ``yield from lock`` 和/或 :keyword:`with` 陳述式 " -"(``with await lock``, ``with (yield from lock)``) 來獲取鎖的方式已被移除。請" +"(``with await lock``, ``with (yield from lock)``) 來取得鎖的方式已被移除。請" "改用 ``async with lock``。" diff --git a/library/asyncio-task.po b/library/asyncio-task.po index 60e5050715..9d69ab5503 100644 --- a/library/asyncio-task.po +++ b/library/asyncio-task.po @@ -4,9 +4,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-04-14 00:15+0000\n" "PO-Revision-Date: 2018-05-23 14:39+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -199,8 +199,8 @@ msgstr "" #: ../../library/asyncio-task.rst:110 msgid "" -"The :class:`asyncio.TaskGroup` class provides a more modern alternative to :" -"func:`create_task`. Using this API, the last example becomes::" +"The :class:`asyncio.TaskGroup` class provides a more modern alternative " +"to :func:`create_task`. Using this API, the last example becomes::" msgstr "" #: ../../library/asyncio-task.rst:114 @@ -226,7 +226,7 @@ msgstr "" #: ../../library/asyncio-task.rst:130 msgid ":class:`asyncio.TaskGroup`." -msgstr "" +msgstr ":class:`asyncio.TaskGroup`。" #: ../../library/asyncio-task.rst:137 msgid "Awaitables" @@ -234,8 +234,8 @@ msgstr "" #: ../../library/asyncio-task.rst:139 msgid "" -"We say that an object is an **awaitable** object if it can be used in an :" -"keyword:`await` expression. Many asyncio APIs are designed to accept " +"We say that an object is an **awaitable** object if it can be used in " +"an :keyword:`await` expression. Many asyncio APIs are designed to accept " "awaitables." msgstr "" @@ -262,7 +262,7 @@ msgid "" " # Nothing happens if we just call \"nested()\".\n" " # A coroutine object is created but not awaited,\n" " # so it *won't run at all*.\n" -" nested()\n" +" nested() # will raise a \"RuntimeWarning\".\n" "\n" " # Let's do it differently now and await it:\n" " print(await nested()) # will print \"42\".\n" @@ -295,8 +295,9 @@ msgstr "" #: ../../library/asyncio-task.rst:183 msgid "" -"When a coroutine is wrapped into a *Task* with functions like :func:`asyncio." -"create_task` the coroutine is automatically scheduled to run soon::" +"When a coroutine is wrapped into a *Task* with functions " +"like :func:`asyncio.create_task` the coroutine is automatically scheduled to " +"run soon::" msgstr "" #: ../../library/asyncio-task.rst:187 @@ -366,8 +367,8 @@ msgstr "" #: ../../library/asyncio-task.rst:230 msgid "" -"A good example of a low-level function that returns a Future object is :meth:" -"`loop.run_in_executor`." +"A good example of a low-level function that returns a Future object " +"is :meth:`loop.run_in_executor`." msgstr "" #: ../../library/asyncio-task.rst:235 @@ -386,21 +387,22 @@ msgstr "" #: ../../library/asyncio-task.rst:246 msgid "" -"If *name* is not ``None``, it is set as the name of the task using :meth:" -"`Task.set_name`." +"If *name* is not ``None``, it is set as the name of the task " +"using :meth:`Task.set_name`." msgstr "" #: ../../library/asyncio-task.rst:249 msgid "" -"An optional keyword-only *context* argument allows specifying a custom :" -"class:`contextvars.Context` for the *coro* to run in. The current context " -"copy is created when no *context* is provided." +"An optional keyword-only *context* argument allows specifying a " +"custom :class:`contextvars.Context` for the *coro* to run in. The current " +"context copy is created when no *context* is provided." msgstr "" #: ../../library/asyncio-task.rst:253 msgid "" -"The task is executed in the loop returned by :func:`get_running_loop`, :exc:" -"`RuntimeError` is raised if there is no running loop in current thread." +"The task is executed in the loop returned " +"by :func:`get_running_loop`, :exc:`RuntimeError` is raised if there is no " +"running loop in current thread." msgstr "" #: ../../library/asyncio-task.rst:259 @@ -435,11 +437,11 @@ msgid "" " task.add_done_callback(background_tasks.discard)" msgstr "" -#: ../../library/asyncio-task.rst:287 ../../library/asyncio-task.rst:1075 +#: ../../library/asyncio-task.rst:287 ../../library/asyncio-task.rst:1192 msgid "Added the *name* parameter." msgstr "新增 *name* 參數。" -#: ../../library/asyncio-task.rst:290 ../../library/asyncio-task.rst:1082 +#: ../../library/asyncio-task.rst:290 ../../library/asyncio-task.rst:1199 msgid "Added the *context* parameter." msgstr "新增 *context* 參數。" @@ -449,28 +451,30 @@ msgstr "" #: ../../library/asyncio-task.rst:297 msgid "" -"Tasks can easily and safely be cancelled. When a task is cancelled, :exc:" -"`asyncio.CancelledError` will be raised in the task at the next opportunity." +"Tasks can easily and safely be cancelled. When a task is " +"cancelled, :exc:`asyncio.CancelledError` will be raised in the task at the " +"next opportunity." msgstr "" #: ../../library/asyncio-task.rst:301 msgid "" "It is recommended that coroutines use ``try/finally`` blocks to robustly " "perform clean-up logic. In case :exc:`asyncio.CancelledError` is explicitly " -"caught, it should generally be propagated when clean-up is complete. :exc:" -"`asyncio.CancelledError` directly subclasses :exc:`BaseException` so most " -"code will not need to be aware of it." +"caught, it should generally be propagated when clean-up is " +"complete. :exc:`asyncio.CancelledError` directly " +"subclasses :exc:`BaseException` so most code will not need to be aware of it." msgstr "" #: ../../library/asyncio-task.rst:307 msgid "" -"The asyncio components that enable structured concurrency, like :class:" -"`asyncio.TaskGroup` and :func:`asyncio.timeout`, are implemented using " -"cancellation internally and might misbehave if a coroutine swallows :exc:" -"`asyncio.CancelledError`. Similarly, user code should not generally call :" -"meth:`uncancel `. However, in cases when suppressing :" -"exc:`asyncio.CancelledError` is truly desired, it is necessary to also call " -"``uncancel()`` to completely remove the cancellation state." +"The asyncio components that enable structured concurrency, " +"like :class:`asyncio.TaskGroup` and :func:`asyncio.timeout`, are implemented " +"using cancellation internally and might misbehave if a coroutine " +"swallows :exc:`asyncio.CancelledError`. Similarly, user code should not " +"generally call :meth:`uncancel `. However, in cases " +"when suppressing :exc:`asyncio.CancelledError` is truly desired, it is " +"necessary to also call ``uncancel()`` to completely remove the cancellation " +"state." msgstr "" #: ../../library/asyncio-task.rst:319 @@ -492,28 +496,33 @@ msgstr "" #: ../../library/asyncio-task.rst:335 msgid "" -"Create a task in this task group. The signature matches that of :func:" -"`asyncio.create_task`." +"Create a task in this task group. The signature matches that " +"of :func:`asyncio.create_task`. If the task group is inactive (e.g. not yet " +"entered, already finished, or in the process of shutting down), we will " +"close the given ``coro``." +msgstr "" + +#: ../../library/asyncio-task.rst:343 +msgid "Close the given coroutine if the task group is not active." msgstr "" -#: ../../library/asyncio-task.rst:338 ../../library/asyncio-task.rst:472 -#: ../../library/asyncio-task.rst:645 ../../library/asyncio-task.rst:703 -#: ../../library/asyncio-task.rst:729 ../../library/asyncio-task.rst:769 -#: ../../library/asyncio-task.rst:868 +#: ../../library/asyncio-task.rst:345 ../../library/asyncio-task.rst:551 +#: ../../library/asyncio-task.rst:724 ../../library/asyncio-task.rst:782 +#: ../../library/asyncio-task.rst:808 ../../library/asyncio-task.rst:849 msgid "Example::" msgstr "範例: ::" -#: ../../library/asyncio-task.rst:340 +#: ../../library/asyncio-task.rst:347 msgid "" "async def main():\n" " async with asyncio.TaskGroup() as tg:\n" " task1 = tg.create_task(some_coro(...))\n" " task2 = tg.create_task(another_coro(...))\n" -" print(f\"Both tasks have completed now: {task1.result()}, {task2." -"result()}\")" +" print(f\"Both tasks have completed now: {task1.result()}, " +"{task2.result()}\")" msgstr "" -#: ../../library/asyncio-task.rst:346 +#: ../../library/asyncio-task.rst:353 msgid "" "The ``async with`` statement will wait for all tasks in the group to finish. " "While waiting, new tasks may still be added to the group (for example, by " @@ -522,19 +531,19 @@ msgid "" "block is exited, no new tasks may be added to the group." msgstr "" -#: ../../library/asyncio-task.rst:353 +#: ../../library/asyncio-task.rst:360 msgid "" "The first time any of the tasks belonging to the group fails with an " "exception other than :exc:`asyncio.CancelledError`, the remaining tasks in " "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., :meth:`~object.__aexit__` hasn't been called yet), the task directly " -"containing the ``async with`` statement is also cancelled. The resulting :" -"exc:`asyncio.CancelledError` will interrupt an ``await``, but it will not " -"bubble out of the containing ``async with`` statement." +"this point, if the body of the ``async with`` statement is still active " +"(i.e., :meth:`~object.__aexit__` hasn't been called yet), the task directly " +"containing the ``async with`` statement is also cancelled. The " +"resulting :exc:`asyncio.CancelledError` will interrupt an ``await``, but it " +"will not bubble out of the containing ``async with`` statement." msgstr "" -#: ../../library/asyncio-task.rst:363 +#: ../../library/asyncio-task.rst:370 msgid "" "Once all tasks have finished, if any tasks have failed with an exception " "other than :exc:`asyncio.CancelledError`, those exceptions are combined in " @@ -542,59 +551,147 @@ msgid "" "their documentation) which is then raised." msgstr "" -#: ../../library/asyncio-task.rst:370 +#: ../../library/asyncio-task.rst:377 +msgid "" +"Two base exceptions are treated specially: If any task fails " +"with :exc:`KeyboardInterrupt` or :exc:`SystemExit`, the task group still " +"cancels the remaining tasks and waits for them, but then the " +"initial :exc:`KeyboardInterrupt` or :exc:`SystemExit` is re-raised instead " +"of :exc:`ExceptionGroup` or :exc:`BaseExceptionGroup`." +msgstr "" + +#: ../../library/asyncio-task.rst:383 msgid "" -"Two base exceptions are treated specially: If any task fails with :exc:" -"`KeyboardInterrupt` or :exc:`SystemExit`, the task group still cancels the " -"remaining tasks and waits for them, but then the initial :exc:" -"`KeyboardInterrupt` or :exc:`SystemExit` is re-raised instead of :exc:" -"`ExceptionGroup` or :exc:`BaseExceptionGroup`." +"If the body of the ``async with`` statement exits with an exception " +"(so :meth:`~object.__aexit__` is called with an exception set), this is " +"treated 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 :meth:`~object.__aexit__`, unless it is :exc:`asyncio.CancelledError`, " +"is also included in the exception group. The same special case is made " +"for :exc:`KeyboardInterrupt` and :exc:`SystemExit` as in the previous " +"paragraph." msgstr "" -#: ../../library/asyncio-task.rst:376 +#: ../../library/asyncio-task.rst:395 msgid "" -"If the body of the ``async with`` statement exits with an exception (so :" -"meth:`~object.__aexit__` is called with an exception set), this is treated " -"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 :meth:`~object." -"__aexit__`, unless it is :exc:`asyncio.CancelledError`, is also included in " -"the exception group. The same special case is made for :exc:" -"`KeyboardInterrupt` and :exc:`SystemExit` as in the previous paragraph." +"Task groups are careful not to mix up the internal cancellation used to " +"\"wake up\" their :meth:`~object.__aexit__` 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." msgstr "" -#: ../../library/asyncio-task.rst:390 +#: ../../library/asyncio-task.rst:403 +msgid "" +"In the case where a task group is cancelled externally and also must raise " +"an :exc:`ExceptionGroup`, it will call the parent " +"task's :meth:`~asyncio.Task.cancel` method. This ensures that " +"a :exc:`asyncio.CancelledError` will be raised at the next :keyword:`await`, " +"so the cancellation is not lost." +msgstr "" + +#: ../../library/asyncio-task.rst:409 +msgid "" +"Task groups preserve the cancellation count reported " +"by :meth:`asyncio.Task.cancelling`." +msgstr "" + +#: ../../library/asyncio-task.rst:414 +msgid "" +"Improved handling of simultaneous internal and external cancellations and " +"correct preservation of cancellation counts." +msgstr "" + +#: ../../library/asyncio-task.rst:418 +msgid "Terminating a Task Group" +msgstr "" + +#: ../../library/asyncio-task.rst:420 +msgid "" +"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:" +msgstr "" + +#: ../../library/asyncio-task.rst:424 +msgid "" +"import asyncio\n" +"from asyncio import TaskGroup\n" +"\n" +"class TerminateTaskGroup(Exception):\n" +" \"\"\"Exception raised to terminate a task group.\"\"\"\n" +"\n" +"async def force_terminate_task_group():\n" +" \"\"\"Used to force termination of a task group.\"\"\"\n" +" raise TerminateTaskGroup()\n" +"\n" +"async def job(task_id, sleep_time):\n" +" print(f'Task {task_id}: start')\n" +" await asyncio.sleep(sleep_time)\n" +" print(f'Task {task_id}: done')\n" +"\n" +"async def main():\n" +" try:\n" +" async with TaskGroup() as group:\n" +" # spawn some tasks\n" +" group.create_task(job(1, 0.5))\n" +" group.create_task(job(2, 1.5))\n" +" # sleep for 1 second\n" +" await asyncio.sleep(1)\n" +" # add an exception-raising task to force the group to terminate\n" +" group.create_task(force_terminate_task_group())\n" +" except* TerminateTaskGroup:\n" +" pass\n" +"\n" +"asyncio.run(main())" +msgstr "" + +#: ../../library/asyncio-task.rst:456 +msgid "Expected output:" +msgstr "預期的輸出: ::" + +#: ../../library/asyncio-task.rst:458 +msgid "" +"Task 1: start\n" +"Task 2: start\n" +"Task 1: done" +msgstr "" + +#: ../../library/asyncio-task.rst:465 msgid "Sleeping" msgstr "" -#: ../../library/asyncio-task.rst:394 +#: ../../library/asyncio-task.rst:470 msgid "Block for *delay* seconds." msgstr "" -#: ../../library/asyncio-task.rst:396 +#: ../../library/asyncio-task.rst:472 msgid "" "If *result* is provided, it is returned to the caller when the coroutine " "completes." msgstr "" -#: ../../library/asyncio-task.rst:399 +#: ../../library/asyncio-task.rst:475 msgid "" "``sleep()`` always suspends the current task, allowing other tasks to run." msgstr "" -#: ../../library/asyncio-task.rst:402 +#: ../../library/asyncio-task.rst:478 msgid "" "Setting the delay to 0 provides an optimized path to allow other tasks to " "run. This can be used by long-running functions to avoid blocking the event " "loop for the full duration of the function call." msgstr "" -#: ../../library/asyncio-task.rst:408 +#: ../../library/asyncio-task.rst:484 msgid "" "Example of coroutine displaying the current date every second for 5 seconds::" msgstr "" -#: ../../library/asyncio-task.rst:411 +#: ../../library/asyncio-task.rst:487 msgid "" "import asyncio\n" "import datetime\n" @@ -624,36 +721,40 @@ msgstr "" "\n" "asyncio.run(display_date())" -#: ../../library/asyncio-task.rst:426 ../../library/asyncio-task.rst:521 -#: ../../library/asyncio-task.rst:620 ../../library/asyncio-task.rst:794 -#: ../../library/asyncio-task.rst:848 ../../library/asyncio-task.rst:874 +#: ../../library/asyncio-task.rst:502 ../../library/asyncio-task.rst:600 +#: ../../library/asyncio-task.rst:699 ../../library/asyncio-task.rst:874 +#: ../../library/asyncio-task.rst:929 ../../library/asyncio-task.rst:986 msgid "Removed the *loop* parameter." msgstr "移除 *loop* 參數。" -#: ../../library/asyncio-task.rst:431 +#: ../../library/asyncio-task.rst:505 +msgid "Raises :exc:`ValueError` if *delay* is :data:`~math.nan`." +msgstr "" + +#: ../../library/asyncio-task.rst:510 msgid "Running Tasks Concurrently" msgstr "" -#: ../../library/asyncio-task.rst:435 +#: ../../library/asyncio-task.rst:514 msgid "" "Run :ref:`awaitable objects ` in the *aws* sequence " "*concurrently*." msgstr "" -#: ../../library/asyncio-task.rst:438 +#: ../../library/asyncio-task.rst:517 msgid "" "If any awaitable in *aws* is a coroutine, it is automatically scheduled as a " "Task." msgstr "" -#: ../../library/asyncio-task.rst:441 +#: ../../library/asyncio-task.rst:520 msgid "" "If all awaitables are completed successfully, the result is an aggregate " "list of returned values. The order of result values corresponds to the " "order of awaitables in *aws*." msgstr "" -#: ../../library/asyncio-task.rst:445 +#: ../../library/asyncio-task.rst:524 msgid "" "If *return_exceptions* is ``False`` (default), the first raised exception is " "immediately propagated to the task that awaits on ``gather()``. Other " @@ -661,19 +762,19 @@ msgid "" "run." msgstr "" -#: ../../library/asyncio-task.rst:450 +#: ../../library/asyncio-task.rst:529 msgid "" "If *return_exceptions* is ``True``, exceptions are treated the same as " "successful results, and aggregated in the result list." msgstr "" -#: ../../library/asyncio-task.rst:453 +#: ../../library/asyncio-task.rst:532 msgid "" "If ``gather()`` is *cancelled*, all submitted awaitables (that have not " "completed yet) are also *cancelled*." msgstr "" -#: ../../library/asyncio-task.rst:456 +#: ../../library/asyncio-task.rst:535 msgid "" "If any Task or Future from the *aws* sequence is *cancelled*, it is treated " "as if it raised :exc:`CancelledError` -- the ``gather()`` call is **not** " @@ -681,7 +782,7 @@ msgid "" "submitted Task/Future to cause other Tasks/Futures to be cancelled." msgstr "" -#: ../../library/asyncio-task.rst:463 +#: ../../library/asyncio-task.rst:542 msgid "" "A new alternative to create and run tasks concurrently and wait for their " "completion is :class:`asyncio.TaskGroup`. *TaskGroup* provides stronger " @@ -691,7 +792,7 @@ msgid "" "tasks)." msgstr "" -#: ../../library/asyncio-task.rst:474 +#: ../../library/asyncio-task.rst:553 msgid "" "import asyncio\n" "\n" @@ -730,7 +831,7 @@ msgid "" "# [2, 6, 24]" msgstr "" -#: ../../library/asyncio-task.rst:510 +#: ../../library/asyncio-task.rst:589 msgid "" "If *return_exceptions* is false, cancelling gather() after it has been " "marked done won't cancel any submitted awaitables. For instance, gather can " @@ -739,44 +840,44 @@ msgid "" "the awaitables) from gather won't cancel any other awaitables." msgstr "" -#: ../../library/asyncio-task.rst:517 +#: ../../library/asyncio-task.rst:596 msgid "" "If the *gather* itself is cancelled, the cancellation is propagated " "regardless of *return_exceptions*." msgstr "" -#: ../../library/asyncio-task.rst:524 +#: ../../library/asyncio-task.rst:603 msgid "" "Deprecation warning is emitted if no positional arguments are provided or " "not all positional arguments are Future-like objects and there is no running " "event loop." msgstr "" -#: ../../library/asyncio-task.rst:533 +#: ../../library/asyncio-task.rst:612 msgid "Eager Task Factory" msgstr "" -#: ../../library/asyncio-task.rst:537 +#: ../../library/asyncio-task.rst:616 msgid "A task factory for eager task execution." msgstr "" -#: ../../library/asyncio-task.rst:539 +#: ../../library/asyncio-task.rst:618 msgid "" -"When using this factory (via :meth:`loop.set_task_factory(asyncio." -"eager_task_factory) `), coroutines begin execution " -"synchronously during :class:`Task` 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." +"When using this factory " +"(via :meth:`loop.set_task_factory(asyncio.eager_task_factory) " +"`), coroutines begin execution synchronously " +"during :class:`Task` 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." msgstr "" -#: ../../library/asyncio-task.rst:545 +#: ../../library/asyncio-task.rst:624 msgid "" "A common example where this is beneficial is coroutines which employ caching " "or memoization to avoid actual I/O when possible." msgstr "" -#: ../../library/asyncio-task.rst:550 +#: ../../library/asyncio-task.rst:629 msgid "" "Immediate execution of the coroutine is a semantic change. If the coroutine " "returns or raises, the task is never scheduled to the event loop. If the " @@ -785,46 +886,46 @@ msgid "" "the application's task execution order is likely to change." msgstr "" -#: ../../library/asyncio-task.rst:561 +#: ../../library/asyncio-task.rst:640 msgid "" "Create an eager task factory, similar to :func:`eager_task_factory`, using " "the provided *custom_task_constructor* when creating a new task instead of " "the default :class:`Task`." msgstr "" -#: ../../library/asyncio-task.rst:565 +#: ../../library/asyncio-task.rst:644 msgid "" "*custom_task_constructor* must be a *callable* with the signature matching " -"the signature of :class:`Task.__init__ `. The callable must return a :" -"class:`asyncio.Task`-compatible object." +"the signature of :class:`Task.__init__ `. The callable must return " +"a :class:`asyncio.Task`-compatible object." msgstr "" -#: ../../library/asyncio-task.rst:569 +#: ../../library/asyncio-task.rst:648 msgid "" "This function returns a *callable* intended to be used as a task factory of " -"an event loop via :meth:`loop.set_task_factory(factory) `)." +"an event loop via :meth:`loop.set_task_factory(factory) " +"`)." msgstr "" -#: ../../library/asyncio-task.rst:576 +#: ../../library/asyncio-task.rst:655 msgid "Shielding From Cancellation" msgstr "" -#: ../../library/asyncio-task.rst:580 +#: ../../library/asyncio-task.rst:659 msgid "" -"Protect an :ref:`awaitable object ` from being :meth:" -"`cancelled `." +"Protect an :ref:`awaitable object ` from " +"being :meth:`cancelled `." msgstr "" -#: ../../library/asyncio-task.rst:583 ../../library/asyncio-task.rst:749 +#: ../../library/asyncio-task.rst:662 ../../library/asyncio-task.rst:829 msgid "If *aw* is a coroutine it is automatically scheduled as a Task." msgstr "" -#: ../../library/asyncio-task.rst:585 +#: ../../library/asyncio-task.rst:664 msgid "The statement::" msgstr "" -#: ../../library/asyncio-task.rst:587 +#: ../../library/asyncio-task.rst:666 msgid "" "task = asyncio.create_task(something())\n" "res = await shield(task)" @@ -832,37 +933,37 @@ msgstr "" "task = asyncio.create_task(something())\n" "res = await shield(task)" -#: ../../library/asyncio-task.rst:590 +#: ../../library/asyncio-task.rst:669 msgid "is equivalent to::" msgstr "" -#: ../../library/asyncio-task.rst:592 +#: ../../library/asyncio-task.rst:671 msgid "res = await something()" msgstr "res = await something()" -#: ../../library/asyncio-task.rst:594 +#: ../../library/asyncio-task.rst:673 msgid "" "*except* that if the coroutine containing it is cancelled, the Task running " "in ``something()`` is not cancelled. From the point of view of " "``something()``, the cancellation did not happen. Although its caller is " -"still cancelled, so the \"await\" expression still raises a :exc:" -"`CancelledError`." +"still cancelled, so the \"await\" expression still raises " +"a :exc:`CancelledError`." msgstr "" -#: ../../library/asyncio-task.rst:600 +#: ../../library/asyncio-task.rst:679 msgid "" "If ``something()`` is cancelled by other means (i.e. from within itself) " "that would also cancel ``shield()``." msgstr "" -#: ../../library/asyncio-task.rst:603 +#: ../../library/asyncio-task.rst:682 msgid "" "If it is desired to completely ignore cancellation (not recommended) the " "``shield()`` function should be combined with a try/except clause, as " "follows::" msgstr "" -#: ../../library/asyncio-task.rst:607 +#: ../../library/asyncio-task.rst:686 msgid "" "task = asyncio.create_task(something())\n" "try:\n" @@ -876,7 +977,7 @@ msgstr "" "except CancelledError:\n" " res = None" -#: ../../library/asyncio-task.rst:615 +#: ../../library/asyncio-task.rst:694 msgid "" "Save a reference to tasks passed to this function, to avoid a task " "disappearing mid-execution. The event loop only keeps weak references to " @@ -884,36 +985,36 @@ msgid "" "any time, even before it's done." msgstr "" -#: ../../library/asyncio-task.rst:623 +#: ../../library/asyncio-task.rst:702 msgid "" "Deprecation warning is emitted if *aw* is not Future-like object and there " "is no running event loop." msgstr "" -#: ../../library/asyncio-task.rst:629 +#: ../../library/asyncio-task.rst:708 msgid "Timeouts" msgstr "" -#: ../../library/asyncio-task.rst:633 +#: ../../library/asyncio-task.rst:712 msgid "" "Return an :ref:`asynchronous context manager ` that " "can be used to limit the amount of time spent waiting on something." msgstr "" -#: ../../library/asyncio-task.rst:637 +#: ../../library/asyncio-task.rst:716 msgid "" "*delay* can either be ``None``, or a float/int number of seconds to wait. If " "*delay* is ``None``, no time limit will be applied; this can be useful if " "the delay is unknown when the context manager is created." msgstr "" -#: ../../library/asyncio-task.rst:642 +#: ../../library/asyncio-task.rst:721 msgid "" -"In either case, the context manager can be rescheduled after creation using :" -"meth:`Timeout.reschedule`." +"In either case, the context manager can be rescheduled after creation " +"using :meth:`Timeout.reschedule`." msgstr "" -#: ../../library/asyncio-task.rst:647 +#: ../../library/asyncio-task.rst:726 msgid "" "async def main():\n" " async with asyncio.timeout(10):\n" @@ -923,26 +1024,26 @@ msgstr "" " async with asyncio.timeout(10):\n" " await long_running_task()" -#: ../../library/asyncio-task.rst:651 +#: ../../library/asyncio-task.rst:730 msgid "" "If ``long_running_task`` takes more than 10 seconds to complete, the context " -"manager will cancel the current task and handle the resulting :exc:`asyncio." -"CancelledError` internally, transforming it into a :exc:`TimeoutError` which " -"can be caught and handled." +"manager will cancel the current task and handle the " +"resulting :exc:`asyncio.CancelledError` internally, transforming it into " +"a :exc:`TimeoutError` which can be caught and handled." msgstr "" -#: ../../library/asyncio-task.rst:658 +#: ../../library/asyncio-task.rst:737 msgid "" -"The :func:`asyncio.timeout` context manager is what transforms the :exc:" -"`asyncio.CancelledError` into a :exc:`TimeoutError`, which means the :exc:" -"`TimeoutError` can only be caught *outside* of the context manager." +"The :func:`asyncio.timeout` context manager is what transforms " +"the :exc:`asyncio.CancelledError` into a :exc:`TimeoutError`, which means " +"the :exc:`TimeoutError` can only be caught *outside* of the context manager." msgstr "" -#: ../../library/asyncio-task.rst:663 +#: ../../library/asyncio-task.rst:742 msgid "Example of catching :exc:`TimeoutError`::" msgstr "" -#: ../../library/asyncio-task.rst:665 +#: ../../library/asyncio-task.rst:744 msgid "" "async def main():\n" " try:\n" @@ -954,48 +1055,48 @@ msgid "" " print(\"This statement will run regardless.\")" msgstr "" -#: ../../library/asyncio-task.rst:674 +#: ../../library/asyncio-task.rst:753 msgid "" "The context manager produced by :func:`asyncio.timeout` can be rescheduled " "to a different deadline and inspected." msgstr "" -#: ../../library/asyncio-task.rst:679 +#: ../../library/asyncio-task.rst:758 msgid "" "An :ref:`asynchronous context manager ` for " "cancelling overdue coroutines." msgstr "" -#: ../../library/asyncio-task.rst:682 +#: ../../library/asyncio-task.rst:761 msgid "" "``when`` should be an absolute time at which the context should time out, as " "measured by the event loop's clock:" msgstr "" -#: ../../library/asyncio-task.rst:685 +#: ../../library/asyncio-task.rst:764 msgid "If ``when`` is ``None``, the timeout will never trigger." msgstr "" -#: ../../library/asyncio-task.rst:686 +#: ../../library/asyncio-task.rst:765 msgid "" "If ``when < loop.time()``, the timeout will trigger on the next iteration of " "the event loop." msgstr "" -#: ../../library/asyncio-task.rst:691 +#: ../../library/asyncio-task.rst:770 msgid "" "Return the current deadline, or ``None`` if the current deadline is not set." msgstr "" -#: ../../library/asyncio-task.rst:696 +#: ../../library/asyncio-task.rst:775 msgid "Reschedule the timeout." msgstr "" -#: ../../library/asyncio-task.rst:700 +#: ../../library/asyncio-task.rst:779 msgid "Return whether the context manager has exceeded its deadline (expired)." msgstr "" -#: ../../library/asyncio-task.rst:705 +#: ../../library/asyncio-task.rst:784 msgid "" "async def main():\n" " try:\n" @@ -1013,17 +1114,17 @@ msgid "" " print(\"Looks like we haven't finished on time.\")" msgstr "" -#: ../../library/asyncio-task.rst:720 +#: ../../library/asyncio-task.rst:799 msgid "Timeout context managers can be safely nested." msgstr "" -#: ../../library/asyncio-task.rst:726 +#: ../../library/asyncio-task.rst:805 msgid "" "Similar to :func:`asyncio.timeout`, except *when* is the absolute time to " "stop waiting, or ``None``." msgstr "" -#: ../../library/asyncio-task.rst:731 +#: ../../library/asyncio-task.rst:810 msgid "" "async def main():\n" " loop = get_running_loop()\n" @@ -1037,41 +1138,41 @@ msgid "" " print(\"This statement will run regardless.\")" msgstr "" -#: ../../library/asyncio-task.rst:746 +#: ../../library/asyncio-task.rst:826 msgid "" "Wait for the *aw* :ref:`awaitable ` to complete with a " "timeout." msgstr "" -#: ../../library/asyncio-task.rst:751 +#: ../../library/asyncio-task.rst:831 msgid "" "*timeout* can either be ``None`` or a float or int number of seconds to wait " "for. If *timeout* is ``None``, block until the future completes." msgstr "" -#: ../../library/asyncio-task.rst:755 +#: ../../library/asyncio-task.rst:835 msgid "" "If a timeout occurs, it cancels the task and raises :exc:`TimeoutError`." msgstr "" -#: ../../library/asyncio-task.rst:758 +#: ../../library/asyncio-task.rst:838 msgid "" -"To avoid the task :meth:`cancellation `, wrap it in :func:" -"`shield`." +"To avoid the task :meth:`cancellation `, wrap it " +"in :func:`shield`." msgstr "" -#: ../../library/asyncio-task.rst:761 +#: ../../library/asyncio-task.rst:841 msgid "" "The function will wait until the future is actually cancelled, so the total " "wait time may exceed the *timeout*. If an exception happens during " "cancellation, it is propagated." msgstr "" -#: ../../library/asyncio-task.rst:765 +#: ../../library/asyncio-task.rst:845 msgid "If the wait is cancelled, the future *aw* is also cancelled." msgstr "" -#: ../../library/asyncio-task.rst:771 +#: ../../library/asyncio-task.rst:851 msgid "" "async def eternity():\n" " # Sleep for one hour\n" @@ -1092,137 +1193,186 @@ msgid "" "# timeout!" msgstr "" -#: ../../library/asyncio-task.rst:789 +#: ../../library/asyncio-task.rst:869 msgid "" "When *aw* is cancelled due to a timeout, ``wait_for`` waits for *aw* to be " "cancelled. Previously, it raised :exc:`TimeoutError` immediately." msgstr "" -#: ../../library/asyncio-task.rst:797 +#: ../../library/asyncio-task.rst:877 msgid "Raises :exc:`TimeoutError` instead of :exc:`asyncio.TimeoutError`." msgstr "引發 :exc:`TimeoutError` 而不是 :exc:`asyncio.TimeoutError`。" -#: ../../library/asyncio-task.rst:802 +#: ../../library/asyncio-task.rst:882 msgid "Waiting Primitives" msgstr "" -#: ../../library/asyncio-task.rst:806 +#: ../../library/asyncio-task.rst:887 msgid "" "Run :class:`~asyncio.Future` and :class:`~asyncio.Task` instances in the " "*aws* iterable concurrently and block until the condition specified by " "*return_when*." msgstr "" -#: ../../library/asyncio-task.rst:810 +#: ../../library/asyncio-task.rst:891 msgid "The *aws* iterable must not be empty." msgstr "" -#: ../../library/asyncio-task.rst:812 +#: ../../library/asyncio-task.rst:893 msgid "Returns two sets of Tasks/Futures: ``(done, pending)``." msgstr "" -#: ../../library/asyncio-task.rst:814 +#: ../../library/asyncio-task.rst:895 msgid "Usage::" msgstr "用法: ::" -#: ../../library/asyncio-task.rst:816 +#: ../../library/asyncio-task.rst:897 msgid "done, pending = await asyncio.wait(aws)" msgstr "done, pending = await asyncio.wait(aws)" -#: ../../library/asyncio-task.rst:818 +#: ../../library/asyncio-task.rst:899 msgid "" "*timeout* (a float or int), if specified, can be used to control the maximum " "number of seconds to wait before returning." msgstr "" -#: ../../library/asyncio-task.rst:821 +#: ../../library/asyncio-task.rst:902 msgid "" "Note that this function does not raise :exc:`TimeoutError`. Futures or Tasks " "that aren't done when the timeout occurs are simply returned in the second " "set." msgstr "" -#: ../../library/asyncio-task.rst:825 +#: ../../library/asyncio-task.rst:906 msgid "" "*return_when* indicates when this function should return. It must be one of " "the following constants:" msgstr "" -#: ../../library/asyncio-task.rst:831 +#: ../../library/asyncio-task.rst:912 msgid "Constant" msgstr "常數" -#: ../../library/asyncio-task.rst:832 +#: ../../library/asyncio-task.rst:913 msgid "Description" msgstr "描述" -#: ../../library/asyncio-task.rst:835 +#: ../../library/asyncio-task.rst:916 msgid "The function will return when any future finishes or is cancelled." msgstr "" -#: ../../library/asyncio-task.rst:838 +#: ../../library/asyncio-task.rst:919 msgid "" "The function will return when any future finishes by raising an exception. " -"If no future raises an exception then it is equivalent to :const:" -"`ALL_COMPLETED`." +"If no future raises an exception then it is equivalent " +"to :const:`ALL_COMPLETED`." msgstr "" -#: ../../library/asyncio-task.rst:843 +#: ../../library/asyncio-task.rst:924 msgid "The function will return when all futures finish or are cancelled." msgstr "" -#: ../../library/asyncio-task.rst:845 +#: ../../library/asyncio-task.rst:926 msgid "" "Unlike :func:`~asyncio.wait_for`, ``wait()`` does not cancel the futures " "when a timeout occurs." msgstr "" -#: ../../library/asyncio-task.rst:851 +#: ../../library/asyncio-task.rst:932 msgid "Passing coroutine objects to ``wait()`` directly is forbidden." msgstr "" -#: ../../library/asyncio-task.rst:854 ../../library/asyncio-task.rst:881 +#: ../../library/asyncio-task.rst:935 ../../library/asyncio-task.rst:993 msgid "Added support for generators yielding tasks." msgstr "" -#: ../../library/asyncio-task.rst:860 +#: ../../library/asyncio-task.rst:941 msgid "" "Run :ref:`awaitable objects ` in the *aws* iterable " -"concurrently. Return an iterator of coroutines. Each coroutine returned can " -"be awaited to get the earliest next result from the iterable of the " -"remaining awaitables." +"concurrently. The returned object can be iterated to obtain the results of " +"the awaitables as they finish." +msgstr "" + +#: ../../library/asyncio-task.rst:945 +msgid "" +"The object returned by ``as_completed()`` can be iterated as " +"an :term:`asynchronous iterator` or a plain :term:`iterator`. 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::" msgstr "" -#: ../../library/asyncio-task.rst:865 +#: ../../library/asyncio-task.rst:951 msgid "" -"Raises :exc:`TimeoutError` if the timeout occurs before all Futures are done." +"ipv4_connect = create_task(open_connection(\"127.0.0.1\", 80))\n" +"ipv6_connect = create_task(open_connection(\"::1\", 80))\n" +"tasks = [ipv4_connect, ipv6_connect]\n" +"\n" +"async for earliest_connect in as_completed(tasks):\n" +" # earliest_connect is done. The result can be obtained by\n" +" # awaiting it or calling earliest_connect.result()\n" +" reader, writer = await earliest_connect\n" +"\n" +" if earliest_connect is ipv6_connect:\n" +" print(\"IPv6 connection established.\")\n" +" else:\n" +" print(\"IPv4 connection established.\")" msgstr "" -#: ../../library/asyncio-task.rst:870 +#: ../../library/asyncio-task.rst:965 msgid "" -"for coro in as_completed(aws):\n" -" earliest_result = await coro\n" -" # ..." +"During asynchronous iteration, implicitly-created tasks will be yielded for " +"supplied awaitables that aren't tasks or futures." msgstr "" -"for coro in as_completed(aws):\n" -" earliest_result = await coro\n" -" # ..." -#: ../../library/asyncio-task.rst:877 +#: ../../library/asyncio-task.rst:968 +msgid "" +"When used as a plain iterator, each iteration yields a new coroutine that " +"returns the result or raises the exception of the next completed awaitable. " +"This pattern is compatible with Python versions older than 3.13::" +msgstr "" + +#: ../../library/asyncio-task.rst:972 +msgid "" +"ipv4_connect = create_task(open_connection(\"127.0.0.1\", 80))\n" +"ipv6_connect = create_task(open_connection(\"::1\", 80))\n" +"tasks = [ipv4_connect, ipv6_connect]\n" +"\n" +"for next_connect in as_completed(tasks):\n" +" # next_connect is not one of the original task objects. It must be\n" +" # awaited to obtain the result value or raise the exception of the\n" +" # awaitable that finishes next.\n" +" reader, writer = await next_connect" +msgstr "" + +#: ../../library/asyncio-task.rst:982 +msgid "" +"A :exc:`TimeoutError` is raised if the timeout occurs before all awaitables " +"are done. This is raised by the ``async for`` loop during asynchronous " +"iteration or by the coroutines yielded during plain iteration." +msgstr "" + +#: ../../library/asyncio-task.rst:989 msgid "" "Deprecation warning is emitted if not all awaitable objects in the *aws* " "iterable are Future-like objects and there is no running event loop." msgstr "" -#: ../../library/asyncio-task.rst:886 +#: ../../library/asyncio-task.rst:996 +msgid "" +"The result can now be used as either an :term:`asynchronous iterator` or as " +"a plain :term:`iterator` (previously it was only a plain iterator)." +msgstr "" + +#: ../../library/asyncio-task.rst:1002 msgid "Running in Threads" msgstr "" -#: ../../library/asyncio-task.rst:890 +#: ../../library/asyncio-task.rst:1007 msgid "Asynchronously run function *func* in a separate thread." msgstr "" -#: ../../library/asyncio-task.rst:892 +#: ../../library/asyncio-task.rst:1009 msgid "" "Any \\*args and \\*\\*kwargs supplied for this function are directly passed " "to *func*. Also, the current :class:`contextvars.Context` is propagated, " @@ -1230,19 +1380,19 @@ msgid "" "separate thread." msgstr "" -#: ../../library/asyncio-task.rst:897 +#: ../../library/asyncio-task.rst:1014 msgid "" "Return a coroutine that can be awaited to get the eventual result of *func*." msgstr "" -#: ../../library/asyncio-task.rst:899 +#: ../../library/asyncio-task.rst:1016 msgid "" "This coroutine function is primarily intended to be used for executing IO-" "bound functions/methods that would otherwise block the event loop if they " "were run in the main thread. For example::" msgstr "" -#: ../../library/asyncio-task.rst:903 +#: ../../library/asyncio-task.rst:1020 msgid "" "def blocking_io():\n" " print(f\"start blocking_io at {time.strftime('%X')}\")\n" @@ -1271,7 +1421,7 @@ msgid "" "# finished main at 19:50:54" msgstr "" -#: ../../library/asyncio-task.rst:929 +#: ../../library/asyncio-task.rst:1046 msgid "" "Directly calling ``blocking_io()`` in any coroutine would block the event " "loop for its duration, resulting in an additional 1 second of run time. " @@ -1279,7 +1429,7 @@ msgid "" "thread without blocking the event loop." msgstr "" -#: ../../library/asyncio-task.rst:936 +#: ../../library/asyncio-task.rst:1053 msgid "" "Due to the :term:`GIL`, ``asyncio.to_thread()`` can typically only be used " "to make IO-bound functions non-blocking. However, for extension modules that " @@ -1287,27 +1437,27 @@ msgid "" "``asyncio.to_thread()`` can also be used for CPU-bound functions." msgstr "" -#: ../../library/asyncio-task.rst:945 +#: ../../library/asyncio-task.rst:1062 msgid "Scheduling From Other Threads" msgstr "" -#: ../../library/asyncio-task.rst:949 +#: ../../library/asyncio-task.rst:1066 msgid "Submit a coroutine to the given event loop. Thread-safe." msgstr "" -#: ../../library/asyncio-task.rst:951 +#: ../../library/asyncio-task.rst:1068 msgid "" "Return a :class:`concurrent.futures.Future` to wait for the result from " "another OS thread." msgstr "" -#: ../../library/asyncio-task.rst:954 +#: ../../library/asyncio-task.rst:1071 msgid "" "This function is meant to be called from a different OS thread than the one " "where the event loop is running. Example::" msgstr "" -#: ../../library/asyncio-task.rst:957 +#: ../../library/asyncio-task.rst:1074 msgid "" "# Create a coroutine\n" "coro = asyncio.sleep(1, result=3)\n" @@ -1319,13 +1469,13 @@ msgid "" "assert future.result(timeout) == 3" msgstr "" -#: ../../library/asyncio-task.rst:966 +#: ../../library/asyncio-task.rst:1083 msgid "" "If an exception is raised in the coroutine, the returned Future will be " "notified. It can also be used to cancel the task in the event loop::" msgstr "" -#: ../../library/asyncio-task.rst:970 +#: ../../library/asyncio-task.rst:1087 msgid "" "try:\n" " result = future.result(timeout)\n" @@ -1338,59 +1488,59 @@ msgid "" " print(f'The coroutine returned: {result!r}')" msgstr "" -#: ../../library/asyncio-task.rst:980 +#: ../../library/asyncio-task.rst:1097 msgid "" "See the :ref:`concurrency and multithreading ` " "section of the documentation." msgstr "" -#: ../../library/asyncio-task.rst:983 +#: ../../library/asyncio-task.rst:1100 msgid "" "Unlike other asyncio functions this function requires the *loop* argument to " "be passed explicitly." msgstr "" -#: ../../library/asyncio-task.rst:990 +#: ../../library/asyncio-task.rst:1107 msgid "Introspection" msgstr "" -#: ../../library/asyncio-task.rst:995 +#: ../../library/asyncio-task.rst:1112 msgid "" "Return the currently running :class:`Task` instance, or ``None`` if no task " "is running." msgstr "" -#: ../../library/asyncio-task.rst:998 +#: ../../library/asyncio-task.rst:1115 msgid "" "If *loop* is ``None`` :func:`get_running_loop` is used to get the current " "loop." msgstr "" -#: ../../library/asyncio-task.rst:1006 +#: ../../library/asyncio-task.rst:1123 msgid "Return a set of not yet finished :class:`Task` objects run by the loop." msgstr "" -#: ../../library/asyncio-task.rst:1009 +#: ../../library/asyncio-task.rst:1126 msgid "" "If *loop* is ``None``, :func:`get_running_loop` is used for getting current " "loop." msgstr "" -#: ../../library/asyncio-task.rst:1017 +#: ../../library/asyncio-task.rst:1134 msgid "Return ``True`` if *obj* is a coroutine object." msgstr "" -#: ../../library/asyncio-task.rst:1023 +#: ../../library/asyncio-task.rst:1140 msgid "Task Object" -msgstr "" +msgstr "Task 物件" -#: ../../library/asyncio-task.rst:1027 +#: ../../library/asyncio-task.rst:1144 msgid "" "A :class:`Future-like ` object that runs a Python :ref:`coroutine " "`. Not thread-safe." msgstr "" -#: ../../library/asyncio-task.rst:1030 +#: ../../library/asyncio-task.rst:1147 msgid "" "Tasks are used to run coroutines in event loops. If a coroutine awaits on a " "Future, the Task suspends the execution of the coroutine and waits for the " @@ -1398,21 +1548,21 @@ msgid "" "wrapped coroutine resumes." msgstr "" -#: ../../library/asyncio-task.rst:1036 +#: ../../library/asyncio-task.rst:1153 msgid "" "Event loops use cooperative scheduling: an event loop runs one Task at a " "time. While a Task awaits for the completion of a Future, the event loop " "runs other Tasks, callbacks, or performs IO operations." msgstr "" -#: ../../library/asyncio-task.rst:1041 +#: ../../library/asyncio-task.rst:1158 msgid "" "Use the high-level :func:`asyncio.create_task` function to create Tasks, or " "the low-level :meth:`loop.create_task` or :func:`ensure_future` functions. " "Manual instantiation of Tasks is discouraged." msgstr "" -#: ../../library/asyncio-task.rst:1046 +#: ../../library/asyncio-task.rst:1163 msgid "" "To cancel a running Task use the :meth:`cancel` method. Calling it will " "cause the Task to throw a :exc:`CancelledError` exception into the wrapped " @@ -1420,28 +1570,28 @@ msgid "" "cancellation, the Future object will be cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1051 +#: ../../library/asyncio-task.rst:1168 msgid "" ":meth:`cancelled` can be used to check if the Task was cancelled. The method " -"returns ``True`` if the wrapped coroutine did not suppress the :exc:" -"`CancelledError` exception and was actually cancelled." +"returns ``True`` if the wrapped coroutine did not suppress " +"the :exc:`CancelledError` exception and was actually cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1056 +#: ../../library/asyncio-task.rst:1173 msgid "" -":class:`asyncio.Task` inherits from :class:`Future` all of its APIs except :" -"meth:`Future.set_result` and :meth:`Future.set_exception`." +":class:`asyncio.Task` inherits from :class:`Future` all of its APIs " +"except :meth:`Future.set_result` and :meth:`Future.set_exception`." msgstr "" -#: ../../library/asyncio-task.rst:1060 +#: ../../library/asyncio-task.rst:1177 msgid "" -"An optional keyword-only *context* argument allows specifying a custom :" -"class:`contextvars.Context` for the *coro* to run in. If no *context* is " -"provided, the Task copies the current context and later runs its coroutine " -"in the copied context." +"An optional keyword-only *context* argument allows specifying a " +"custom :class:`contextvars.Context` for the *coro* to run in. If no " +"*context* is provided, the Task copies the current context and later runs " +"its coroutine in the copied context." msgstr "" -#: ../../library/asyncio-task.rst:1065 +#: ../../library/asyncio-task.rst:1182 msgid "" "An optional keyword-only *eager_start* argument allows eagerly starting the " "execution of the :class:`asyncio.Task` at task creation time. If set to " @@ -1451,96 +1601,96 @@ msgid "" "eagerly and will skip scheduling to the event loop." msgstr "" -#: ../../library/asyncio-task.rst:1072 +#: ../../library/asyncio-task.rst:1189 msgid "Added support for the :mod:`contextvars` module." -msgstr "" +msgstr "新增對 :mod:`contextvars` 模組的支援。" -#: ../../library/asyncio-task.rst:1078 +#: ../../library/asyncio-task.rst:1195 msgid "" "Deprecation warning is emitted if *loop* is not specified and there is no " "running event loop." msgstr "" -#: ../../library/asyncio-task.rst:1085 +#: ../../library/asyncio-task.rst:1202 msgid "Added the *eager_start* parameter." msgstr "新增 *eager_start* 參數。" -#: ../../library/asyncio-task.rst:1090 +#: ../../library/asyncio-task.rst:1207 msgid "Return ``True`` if the Task is *done*." msgstr "" -#: ../../library/asyncio-task.rst:1092 +#: ../../library/asyncio-task.rst:1209 msgid "" "A Task is *done* when the wrapped coroutine either returned a value, raised " "an exception, or the Task was cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1097 +#: ../../library/asyncio-task.rst:1214 msgid "Return the result of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1099 +#: ../../library/asyncio-task.rst:1216 msgid "" "If the Task is *done*, the result of the wrapped coroutine is returned (or " "if the coroutine raised an exception, that exception is re-raised.)" msgstr "" -#: ../../library/asyncio-task.rst:1103 ../../library/asyncio-task.rst:1117 +#: ../../library/asyncio-task.rst:1220 ../../library/asyncio-task.rst:1234 msgid "" "If the Task has been *cancelled*, this method raises a :exc:`CancelledError` " "exception." msgstr "" -#: ../../library/asyncio-task.rst:1106 +#: ../../library/asyncio-task.rst:1223 msgid "" -"If the Task's result isn't yet available, this method raises an :exc:" -"`InvalidStateError` exception." +"If the Task's result isn't yet available, this method raises " +"an :exc:`InvalidStateError` exception." msgstr "" -#: ../../library/asyncio-task.rst:1111 +#: ../../library/asyncio-task.rst:1228 msgid "Return the exception of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1113 +#: ../../library/asyncio-task.rst:1230 msgid "" "If the wrapped coroutine raised an exception that exception is returned. If " "the wrapped coroutine returned normally this method returns ``None``." msgstr "" -#: ../../library/asyncio-task.rst:1120 +#: ../../library/asyncio-task.rst:1237 msgid "" "If the Task isn't *done* yet, this method raises an :exc:`InvalidStateError` " "exception." msgstr "" -#: ../../library/asyncio-task.rst:1125 +#: ../../library/asyncio-task.rst:1242 msgid "Add a callback to be run when the Task is *done*." msgstr "" -#: ../../library/asyncio-task.rst:1127 ../../library/asyncio-task.rst:1136 +#: ../../library/asyncio-task.rst:1244 ../../library/asyncio-task.rst:1253 msgid "This method should only be used in low-level callback-based code." msgstr "" -#: ../../library/asyncio-task.rst:1129 +#: ../../library/asyncio-task.rst:1246 msgid "" "See the documentation of :meth:`Future.add_done_callback` for more details." msgstr "" -#: ../../library/asyncio-task.rst:1134 +#: ../../library/asyncio-task.rst:1251 msgid "Remove *callback* from the callbacks list." msgstr "" -#: ../../library/asyncio-task.rst:1138 +#: ../../library/asyncio-task.rst:1255 msgid "" "See the documentation of :meth:`Future.remove_done_callback` for more " "details." msgstr "" -#: ../../library/asyncio-task.rst:1143 +#: ../../library/asyncio-task.rst:1260 msgid "Return the list of stack frames for this Task." msgstr "" -#: ../../library/asyncio-task.rst:1145 +#: ../../library/asyncio-task.rst:1262 msgid "" "If the wrapped coroutine is not done, this returns the stack where it is " "suspended. If the coroutine has completed successfully or was cancelled, " @@ -1548,15 +1698,15 @@ msgid "" "this returns the list of traceback frames." msgstr "" -#: ../../library/asyncio-task.rst:1151 +#: ../../library/asyncio-task.rst:1268 msgid "The frames are always ordered from oldest to newest." msgstr "" -#: ../../library/asyncio-task.rst:1153 +#: ../../library/asyncio-task.rst:1270 msgid "Only one stack frame is returned for a suspended coroutine." msgstr "" -#: ../../library/asyncio-task.rst:1155 +#: ../../library/asyncio-task.rst:1272 msgid "" "The optional *limit* argument sets the maximum number of frames to return; " "by default all available frames are returned. The ordering of the returned " @@ -1565,107 +1715,113 @@ msgid "" "are returned. (This matches the behavior of the traceback module.)" msgstr "" -#: ../../library/asyncio-task.rst:1164 +#: ../../library/asyncio-task.rst:1281 msgid "Print the stack or traceback for this Task." msgstr "" -#: ../../library/asyncio-task.rst:1166 +#: ../../library/asyncio-task.rst:1283 msgid "" "This produces output similar to that of the traceback module for the frames " "retrieved by :meth:`get_stack`." msgstr "" -#: ../../library/asyncio-task.rst:1169 +#: ../../library/asyncio-task.rst:1286 msgid "The *limit* argument is passed to :meth:`get_stack` directly." msgstr "" -#: ../../library/asyncio-task.rst:1171 +#: ../../library/asyncio-task.rst:1288 msgid "" "The *file* argument is an I/O stream to which the output is written; by " "default output is written to :data:`sys.stdout`." msgstr "" -#: ../../library/asyncio-task.rst:1176 +#: ../../library/asyncio-task.rst:1293 msgid "Return the coroutine object wrapped by the :class:`Task`." msgstr "" -#: ../../library/asyncio-task.rst:1180 +#: ../../library/asyncio-task.rst:1297 msgid "" "This will return ``None`` for Tasks which have already completed eagerly. " "See the :ref:`Eager Task Factory `." msgstr "" -#: ../../library/asyncio-task.rst:1187 +#: ../../library/asyncio-task.rst:1304 msgid "Newly added eager task execution means result may be ``None``." msgstr "" -#: ../../library/asyncio-task.rst:1191 +#: ../../library/asyncio-task.rst:1308 msgid "" "Return the :class:`contextvars.Context` object associated with the task." msgstr "" -#: ../../library/asyncio-task.rst:1198 +#: ../../library/asyncio-task.rst:1315 msgid "Return the name of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1200 +#: ../../library/asyncio-task.rst:1317 msgid "" "If no name has been explicitly assigned to the Task, the default asyncio " "Task implementation generates a default name during instantiation." msgstr "" -#: ../../library/asyncio-task.rst:1208 +#: ../../library/asyncio-task.rst:1325 msgid "Set the name of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1210 +#: ../../library/asyncio-task.rst:1327 msgid "" "The *value* argument can be any object, which is then converted to a string." msgstr "" -#: ../../library/asyncio-task.rst:1213 +#: ../../library/asyncio-task.rst:1330 msgid "" -"In the default Task implementation, the name will be visible in the :func:" -"`repr` output of a task object." +"In the default Task implementation, the name will be visible in " +"the :func:`repr` output of a task object." msgstr "" -#: ../../library/asyncio-task.rst:1220 +#: ../../library/asyncio-task.rst:1337 msgid "Request the Task to be cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1222 +#: ../../library/asyncio-task.rst:1339 msgid "" -"This arranges for a :exc:`CancelledError` exception to be thrown into the " -"wrapped coroutine on the next cycle of the event loop." +"If the Task is already *done* or *cancelled*, return ``False``, otherwise, " +"return ``True``." msgstr "" -#: ../../library/asyncio-task.rst:1225 +#: ../../library/asyncio-task.rst:1342 +msgid "" +"The method arranges for a :exc:`CancelledError` exception to be thrown into " +"the wrapped coroutine on the next cycle of the event loop." +msgstr "" + +#: ../../library/asyncio-task.rst:1345 msgid "" "The coroutine then has a chance to clean up or even deny the request by " "suppressing the exception with a :keyword:`try` ... ... ``except " -"CancelledError`` ... :keyword:`finally` block. Therefore, unlike :meth:" -"`Future.cancel`, :meth:`Task.cancel` 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 :meth:`Task.uncancel` in " -"addition to catching the exception." +"CancelledError`` ... :keyword:`finally` block. Therefore, " +"unlike :meth:`Future.cancel`, :meth:`Task.cancel` 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 :meth:`Task.uncancel` " +"in addition to catching the exception." msgstr "" -#: ../../library/asyncio-task.rst:1235 +#: ../../library/asyncio-task.rst:1355 msgid "Added the *msg* parameter." msgstr "新增 *msg* 參數。" -#: ../../library/asyncio-task.rst:1238 +#: ../../library/asyncio-task.rst:1358 msgid "The ``msg`` parameter is propagated from cancelled task to its awaiter." msgstr "" -#: ../../library/asyncio-task.rst:1243 +#: ../../library/asyncio-task.rst:1363 msgid "" "The following example illustrates how coroutines can intercept the " "cancellation request::" msgstr "" -#: ../../library/asyncio-task.rst:1246 +#: ../../library/asyncio-task.rst:1366 msgid "" "async def cancel_me():\n" " print('cancel_me(): before sleep')\n" @@ -1702,41 +1858,41 @@ msgid "" "# main(): cancel_me is cancelled now" msgstr "" -#: ../../library/asyncio-task.rst:1282 +#: ../../library/asyncio-task.rst:1402 msgid "Return ``True`` if the Task is *cancelled*." msgstr "" -#: ../../library/asyncio-task.rst:1284 +#: ../../library/asyncio-task.rst:1404 msgid "" -"The Task is *cancelled* when the cancellation was requested with :meth:" -"`cancel` and the wrapped coroutine propagated the :exc:`CancelledError` " -"exception thrown into it." +"The Task is *cancelled* when the cancellation was requested " +"with :meth:`cancel` and the wrapped coroutine propagated " +"the :exc:`CancelledError` exception thrown into it." msgstr "" -#: ../../library/asyncio-task.rst:1290 +#: ../../library/asyncio-task.rst:1410 msgid "Decrement the count of cancellation requests to this Task." msgstr "" -#: ../../library/asyncio-task.rst:1292 +#: ../../library/asyncio-task.rst:1412 msgid "Returns the remaining number of cancellation requests." msgstr "" -#: ../../library/asyncio-task.rst:1294 +#: ../../library/asyncio-task.rst:1414 msgid "" -"Note that once execution of a cancelled task completed, further calls to :" -"meth:`uncancel` are ineffective." +"Note that once execution of a cancelled task completed, further calls " +"to :meth:`uncancel` are ineffective." msgstr "" -#: ../../library/asyncio-task.rst:1299 +#: ../../library/asyncio-task.rst:1419 msgid "" "This method is used by asyncio's internals and isn't expected to be used by " "end-user code. In particular, if a Task gets successfully uncancelled, this " -"allows for elements of structured concurrency like :ref:`taskgroups` and :" -"func:`asyncio.timeout` to continue running, isolating cancellation to the " -"respective structured block. For example::" +"allows for elements of structured concurrency like :ref:`taskgroups` " +"and :func:`asyncio.timeout` to continue running, isolating cancellation to " +"the respective structured block. For example::" msgstr "" -#: ../../library/asyncio-task.rst:1306 +#: ../../library/asyncio-task.rst:1426 msgid "" "async def make_request_with_timeout():\n" " try:\n" @@ -1750,29 +1906,42 @@ msgid "" " await unrelated_code()" msgstr "" -#: ../../library/asyncio-task.rst:1317 +#: ../../library/asyncio-task.rst:1437 msgid "" "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 :meth:" -"`uncancel`. :class:`TaskGroup` context managers use :func:`uncancel` in a " -"similar fashion." +"running even in case of the timeout. This is implemented " +"with :meth:`uncancel`. :class:`TaskGroup` context managers " +"use :func:`uncancel` in a similar fashion." msgstr "" -#: ../../library/asyncio-task.rst:1323 +#: ../../library/asyncio-task.rst:1443 msgid "" -"If end-user code is, for some reason, suppressing cancellation by catching :" -"exc:`CancelledError`, it needs to call this method to remove the " +"If end-user code is, for some reason, suppressing cancellation by " +"catching :exc:`CancelledError`, it needs to call this method to remove the " "cancellation state." msgstr "" -#: ../../library/asyncio-task.rst:1329 +#: ../../library/asyncio-task.rst:1447 +msgid "" +"When this method decrements the cancellation count to zero, the method " +"checks if a previous :meth:`cancel` call had arranged " +"for :exc:`CancelledError` 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)." +msgstr "" + +#: ../../library/asyncio-task.rst:1453 +msgid "Changed to rescind pending cancellation requests upon reaching zero." +msgstr "" + +#: ../../library/asyncio-task.rst:1458 msgid "" "Return the number of pending cancellation requests to this Task, i.e., the " "number of calls to :meth:`cancel` less the number of :meth:`uncancel` calls." msgstr "" -#: ../../library/asyncio-task.rst:1333 +#: ../../library/asyncio-task.rst:1462 msgid "" "Note that if this number is greater than zero but the Task is still " "executing, :meth:`cancelled` will still return ``False``. This is because " @@ -1781,12 +1950,21 @@ msgid "" "to zero." msgstr "" -#: ../../library/asyncio-task.rst:1339 +#: ../../library/asyncio-task.rst:1468 msgid "" "This method is used by asyncio's internals and isn't expected to be used by " "end-user code. See :meth:`uncancel` for more details." msgstr "" +#~ msgid "" +#~ "for coro in as_completed(aws):\n" +#~ " earliest_result = await coro\n" +#~ " # ..." +#~ msgstr "" +#~ "for coro in as_completed(aws):\n" +#~ " earliest_result = await coro\n" +#~ " # ..." + #~ msgid ":const:`FIRST_COMPLETED`" #~ msgstr ":const:`FIRST_COMPLETED`" diff --git a/library/asyncio.po b/library/asyncio.po index 6fd394fb11..1d0919783b 100644 --- a/library/asyncio.po +++ b/library/asyncio.po @@ -5,13 +5,14 @@ # Adrian Liaw , 2018 # Matt Wang , 2021 # Leo Wang , 2023 +# Weilin Du, 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" -"PO-Revision-Date: 2021-11-23 12:40+0800\n" -"Last-Translator: Matt Wang \n" +"POT-Creation-Date: 2024-10-11 00:13+0000\n" +"PO-Revision-Date: 2025-07-06 17:13+0800\n" +"Last-Translator: Weilin Du\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -19,17 +20,16 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Poedit 3.0\n" -#: ../../library/asyncio.rst:87 +#: ../../library/asyncio.rst:91 msgid "High-level APIs" msgstr "高階 API" -#: ../../library/asyncio.rst:99 +#: ../../library/asyncio.rst:103 msgid "Low-level APIs" msgstr "低階 API" -#: ../../library/asyncio.rst:110 +#: ../../library/asyncio.rst:114 msgid "Guides and Tutorials" msgstr "指南與教學" @@ -122,9 +122,9 @@ msgstr "" #: ../../library/asyncio.rst:48 msgid "" "create and manage :ref:`event loops `, which provide " -"asynchronous APIs for :ref:`networking `, running :ref:" -"`subprocesses `, handling :ref:`OS signals " -"`, etc;" +"asynchronous APIs for :ref:`networking `, " +"running :ref:`subprocesses `, handling :ref:`OS " +"signals `, etc;" msgstr "" "建立與管理 :ref:`event loops(事件迴圈) `,它提供了能被" "用於\\ :ref:`網路 `、執行\\ :ref:`子行程 " @@ -148,25 +148,27 @@ msgstr "" "based) 的函式庫與程式碼。" #: ../../includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not Emscripten, not WASI." -msgstr ":ref:`適用 `:非 Emscripten、非 WASI。" +msgid "Availability" +msgstr "可用性" #: ../../includes/wasm-notavail.rst:5 msgid "" -"This module does not work or is not available on WebAssembly platforms " -"``wasm32-emscripten`` and ``wasm32-wasi``. See :ref:`wasm-availability` for " -"more information." +"This module does not work or is not available on WebAssembly. See :ref:`wasm-" +"availability` for more information." msgstr "" -"此模組在 WebAssembly 平台 ``wasm32-emscripten`` 和 ``wasm32-wasi`` 上不起作用" -"或無法使用。有關更多資訊,請參閱 :ref:`wasm-availability`。" +"此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" +"availability`。" #: ../../library/asyncio.rst:64 msgid "asyncio REPL" -msgstr "" +msgstr "asyncio REPL" #: ../../library/asyncio.rst:65 -msgid "You can experiment with an ``asyncio`` concurrent context in the REPL:" -msgstr "你能在 REPL 中對一個 ``asyncio`` 的並行情境 (context) 進行實驗:" +msgid "" +"You can experiment with an ``asyncio`` concurrent context in " +"the :term:`REPL`:" +msgstr "" +"你能在 :term:`REPL` 中對一個 ``asyncio`` 的並行情境 (context) 進行實驗:" #: ../../library/asyncio.rst:67 msgid "" @@ -192,16 +194,24 @@ msgstr "" msgid "" "Raises an :ref:`auditing event ` ``cpython.run_stdin`` with no " "arguments." -msgstr "" +msgstr "產生一個 :ref:`稽核事件 ` ``cpython.run_stdin`` 且沒有引數。" #: ../../library/asyncio.rst:79 msgid "(also 3.11.10, 3.10.15, 3.9.20, and 3.8.20) Emits audit events." +msgstr "(也包括 3.11.10、3.10.15、3.9.20 及 3.8.20)發出稽核事件。" + +#: ../../library/asyncio.rst:82 +msgid "" +"Uses PyREPL if possible, in which case :envvar:`PYTHONSTARTUP` is also " +"executed. Emits audit events." msgstr "" +"可能的話使用 PyREPL,在這種情況下 :envvar:`PYTHONSTARTUP` 也會被執行。發出稽核" +"事件。" -#: ../../library/asyncio.rst:86 +#: ../../library/asyncio.rst:90 msgid "Reference" msgstr "參閱" -#: ../../library/asyncio.rst:119 +#: ../../library/asyncio.rst:123 msgid "The source code for asyncio can be found in :source:`Lib/asyncio/`." msgstr "asyncio 的原始碼可以在 :source:`Lib/asyncio/` 中找到。" diff --git a/library/asyncore.po b/library/asyncore.po new file mode 100644 index 0000000000..98419d8bc4 --- /dev/null +++ b/library/asyncore.po @@ -0,0 +1,43 @@ +# Copyright (C) 2001-2024, Python Software Foundation +# This file is distributed under the same license as the Python package. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.13\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-18 00:15+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" +"Language: zh_TW\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../../library/asyncore.rst:2 +msgid ":mod:`!asyncore` --- Asynchronous socket handler" +msgstr ":mod:`!asyncore` --- 非同步 socket 處理函式" + +#: ../../library/asyncore.rst:10 +msgid "" +"This module is no longer part of the Python standard library. It was :ref:" +"`removed in Python 3.12 ` after being deprecated in " +"Python 3.6. The removal was decided in :pep:`594`." +msgstr "" +"這個模組已不再是 Python 標準函式庫的一部分。它在 Python 3.6 中被棄用,並\\ :" +"ref:`已在 Python 3.12 中被移除 `。它的移除是在 :pep:" +"`594` 中決定的。" + +#: ../../library/asyncore.rst:14 +msgid "Applications should use the :mod:`asyncio` module instead." +msgstr "應用程式應改用 :mod:`asyncio` 模組。" + +#: ../../library/asyncore.rst:16 +msgid "" +"The last version of Python that provided the :mod:`!asyncore` module was " +"`Python 3.11 `_." +msgstr "" +"最後提供 :mod:`!asyncore` 模組的 Python 版本是 `Python 3.11 `_。" diff --git a/library/atexit.po b/library/atexit.po index de07b4ee11..d671623db5 100644 --- a/library/atexit.po +++ b/library/atexit.po @@ -5,7 +5,7 @@ # Matt Wang , 2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2016-01-31 07:13+0000\n" diff --git a/library/audioop.po b/library/audioop.po index c835baaa18..7e17882da9 100644 --- a/library/audioop.po +++ b/library/audioop.po @@ -1,367 +1,39 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # -# Translators: +#, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" -"PO-Revision-Date: 2022-05-22 02:00+0800\n" -"Last-Translator: Liang-Bo Wang \n" +"POT-Creation-Date: 2024-11-18 00:15+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Poedit 3.0.1\n" #: ../../library/audioop.rst:2 -msgid ":mod:`audioop` --- Manipulate raw audio data" -msgstr ":mod:`audioop` --- 操作原始聲音檔案" +msgid ":mod:`!audioop` --- Manipulate raw audio data" +msgstr ":mod:`!audioop` --- 操作原始聲音檔案" -#: ../../library/audioop.rst:8 +#: ../../library/audioop.rst:10 msgid "" -"The :mod:`audioop` module is deprecated (see :pep:`PEP 594 <594#audioop>` " -"for details)." +"This module is no longer part of the Python standard library. It was :ref:" +"`removed in Python 3.13 ` after being deprecated in " +"Python 3.11. The removal was decided in :pep:`594`." msgstr "" -":mod:`audioop` 模組 (module) 即將被棄用(詳見 :pep:`PEP 594 " -"<594#audioop>`\\ )。" +"這個模組已不再是 Python 標準函式庫的一部分。它在 Python 3.11 中被棄用,並\\ :" +"ref:`已在 Python 3.13 中被移除 `。它的移除是在 :pep:" +"`594` 中決定的。" #: ../../library/audioop.rst:14 msgid "" -"The :mod:`audioop` module contains some useful operations on sound " -"fragments. It operates on sound fragments consisting of signed integer " -"samples 8, 16, 24 or 32 bits wide, stored in :term:`bytes-like objects " -"`. All scalar items are integers, unless specified " -"otherwise." +"The last version of Python that provided the :mod:`!audioop` module was " +"`Python 3.12 `_." msgstr "" - -#: ../../library/audioop.rst:19 -msgid "" -"Support for 24-bit samples was added. All functions now accept any :term:" -"`bytes-like object`. String input now results in an immediate error." -msgstr "" - -#: ../../library/audioop.rst:30 -msgid "" -"This module provides support for a-LAW, u-LAW and Intel/DVI ADPCM encodings." -msgstr "" - -#: ../../library/audioop.rst:34 -msgid "" -"A few of the more complicated operations only take 16-bit samples, otherwise " -"the sample size (in bytes) is always a parameter of the operation." -msgstr "" - -#: ../../library/audioop.rst:37 -msgid "The module defines the following variables and functions:" -msgstr "" - -#: ../../library/audioop.rst:42 -msgid "" -"This exception is raised on all errors, such as unknown number of bytes per " -"sample, etc." -msgstr "" - -#: ../../library/audioop.rst:48 -msgid "" -"Return a fragment which is the addition of the two samples passed as " -"parameters. *width* is the sample width in bytes, either ``1``, ``2``, ``3`` " -"or ``4``. Both fragments should have the same length. Samples are " -"truncated in case of overflow." -msgstr "" - -#: ../../library/audioop.rst:55 -msgid "" -"Decode an Intel/DVI ADPCM coded fragment to a linear fragment. See the " -"description of :func:`lin2adpcm` for details on ADPCM coding. Return a tuple " -"``(sample, newstate)`` where the sample has the width specified in *width*." -msgstr "" - -#: ../../library/audioop.rst:62 -msgid "" -"Convert sound fragments in a-LAW encoding to linearly encoded sound " -"fragments. a-LAW encoding always uses 8 bits samples, so *width* refers only " -"to the sample width of the output fragment here." -msgstr "" - -#: ../../library/audioop.rst:69 -msgid "Return the average over all samples in the fragment." -msgstr "" - -#: ../../library/audioop.rst:74 -msgid "" -"Return the average peak-peak value over all samples in the fragment. No " -"filtering is done, so the usefulness of this routine is questionable." -msgstr "" - -#: ../../library/audioop.rst:80 -msgid "" -"Return a fragment that is the original fragment with a bias added to each " -"sample. Samples wrap around in case of overflow." -msgstr "" - -#: ../../library/audioop.rst:86 -msgid "" -"\"Byteswap\" all samples in a fragment and returns the modified fragment. " -"Converts big-endian samples to little-endian and vice versa." -msgstr "" - -#: ../../library/audioop.rst:94 -msgid "" -"Return the number of zero crossings in the fragment passed as an argument." -msgstr "" - -#: ../../library/audioop.rst:99 -msgid "" -"Return a factor *F* such that ``rms(add(fragment, mul(reference, -F)))`` is " -"minimal, i.e., return the factor with which you should multiply *reference* " -"to make it match as well as possible to *fragment*. The fragments should " -"both contain 2-byte samples." -msgstr "" - -#: ../../library/audioop.rst:104 -msgid "The time taken by this routine is proportional to ``len(fragment)``." -msgstr "" - -#: ../../library/audioop.rst:109 -msgid "" -"Try to match *reference* as well as possible to a portion of *fragment* " -"(which should be the longer fragment). This is (conceptually) done by " -"taking slices out of *fragment*, using :func:`findfactor` to compute the " -"best match, and minimizing the result. The fragments should both contain 2-" -"byte samples. Return a tuple ``(offset, factor)`` where *offset* is the " -"(integer) offset into *fragment* where the optimal match started and " -"*factor* is the (floating-point) factor as per :func:`findfactor`." -msgstr "" - -#: ../../library/audioop.rst:120 -msgid "" -"Search *fragment* for a slice of length *length* samples (not bytes!) with " -"maximum energy, i.e., return *i* for which ``rms(fragment[i*2:" -"(i+length)*2])`` is maximal. The fragments should both contain 2-byte " -"samples." -msgstr "" - -#: ../../library/audioop.rst:124 -msgid "The routine takes time proportional to ``len(fragment)``." -msgstr "" - -#: ../../library/audioop.rst:129 -msgid "Return the value of sample *index* from the fragment." -msgstr "" - -#: ../../library/audioop.rst:134 -msgid "" -"Convert samples to 4 bit Intel/DVI ADPCM encoding. ADPCM coding is an " -"adaptive coding scheme, whereby each 4 bit number is the difference between " -"one sample and the next, divided by a (varying) step. The Intel/DVI ADPCM " -"algorithm has been selected for use by the IMA, so it may well become a " -"standard." -msgstr "" - -#: ../../library/audioop.rst:139 -msgid "" -"*state* is a tuple containing the state of the coder. The coder returns a " -"tuple ``(adpcmfrag, newstate)``, and the *newstate* should be passed to the " -"next call of :func:`lin2adpcm`. In the initial call, ``None`` can be passed " -"as the state. *adpcmfrag* is the ADPCM coded fragment packed 2 4-bit values " -"per byte." -msgstr "" - -#: ../../library/audioop.rst:147 -msgid "" -"Convert samples in the audio fragment to a-LAW encoding and return this as a " -"bytes object. a-LAW is an audio encoding format whereby you get a dynamic " -"range of about 13 bits using only 8 bit samples. It is used by the Sun " -"audio hardware, among others." -msgstr "" - -#: ../../library/audioop.rst:155 -msgid "Convert samples between 1-, 2-, 3- and 4-byte formats." -msgstr "" - -#: ../../library/audioop.rst:159 -msgid "" -"In some audio formats, such as .WAV files, 16, 24 and 32 bit samples are " -"signed, but 8 bit samples are unsigned. So when converting to 8 bit wide " -"samples for these formats, you need to also add 128 to the result::" -msgstr "" - -#: ../../library/audioop.rst:163 -msgid "" -"new_frames = audioop.lin2lin(frames, old_width, 1)\n" -"new_frames = audioop.bias(new_frames, 1, 128)" -msgstr "" - -#: ../../library/audioop.rst:166 -msgid "" -"The same, in reverse, has to be applied when converting from 8 to 16, 24 or " -"32 bit width samples." -msgstr "" - -#: ../../library/audioop.rst:172 -msgid "" -"Convert samples in the audio fragment to u-LAW encoding and return this as a " -"bytes object. u-LAW is an audio encoding format whereby you get a dynamic " -"range of about 14 bits using only 8 bit samples. It is used by the Sun " -"audio hardware, among others." -msgstr "" - -#: ../../library/audioop.rst:180 -msgid "" -"Return the maximum of the *absolute value* of all samples in a fragment." -msgstr "" - -#: ../../library/audioop.rst:185 -msgid "Return the maximum peak-peak value in the sound fragment." -msgstr "" - -#: ../../library/audioop.rst:190 -msgid "" -"Return a tuple consisting of the minimum and maximum values of all samples " -"in the sound fragment." -msgstr "" - -#: ../../library/audioop.rst:196 -msgid "" -"Return a fragment that has all samples in the original fragment multiplied " -"by the floating-point value *factor*. Samples are truncated in case of " -"overflow." -msgstr "" - -#: ../../library/audioop.rst:202 -msgid "Convert the frame rate of the input fragment." -msgstr "" - -#: ../../library/audioop.rst:204 -msgid "" -"*state* is a tuple containing the state of the converter. The converter " -"returns a tuple ``(newfragment, newstate)``, and *newstate* should be passed " -"to the next call of :func:`ratecv`. The initial call should pass ``None`` " -"as the state." -msgstr "" - -#: ../../library/audioop.rst:208 -msgid "" -"The *weightA* and *weightB* arguments are parameters for a simple digital " -"filter and default to ``1`` and ``0`` respectively." -msgstr "" - -#: ../../library/audioop.rst:214 -msgid "Reverse the samples in a fragment and returns the modified fragment." -msgstr "" - -#: ../../library/audioop.rst:219 -msgid "" -"Return the root-mean-square of the fragment, i.e. ``sqrt(sum(S_i^2)/n)``." -msgstr "" - -#: ../../library/audioop.rst:221 -msgid "This is a measure of the power in an audio signal." -msgstr "" - -#: ../../library/audioop.rst:226 -msgid "" -"Convert a stereo fragment to a mono fragment. The left channel is " -"multiplied by *lfactor* and the right channel by *rfactor* before adding the " -"two channels to give a mono signal." -msgstr "" - -#: ../../library/audioop.rst:233 -msgid "" -"Generate a stereo fragment from a mono fragment. Each pair of samples in " -"the stereo fragment are computed from the mono sample, whereby left channel " -"samples are multiplied by *lfactor* and right channel samples by *rfactor*." -msgstr "" - -#: ../../library/audioop.rst:240 -msgid "" -"Convert sound fragments in u-LAW encoding to linearly encoded sound " -"fragments. u-LAW encoding always uses 8 bits samples, so *width* refers only " -"to the sample width of the output fragment here." -msgstr "" - -#: ../../library/audioop.rst:244 -msgid "" -"Note that operations such as :func:`.mul` or :func:`.max` make no " -"distinction between mono and stereo fragments, i.e. all samples are treated " -"equal. If this is a problem the stereo fragment should be split into two " -"mono fragments first and recombined later. Here is an example of how to do " -"that::" -msgstr "" - -#: ../../library/audioop.rst:249 -msgid "" -"def mul_stereo(sample, width, lfactor, rfactor):\n" -" lsample = audioop.tomono(sample, width, 1, 0)\n" -" rsample = audioop.tomono(sample, width, 0, 1)\n" -" lsample = audioop.mul(lsample, width, lfactor)\n" -" rsample = audioop.mul(rsample, width, rfactor)\n" -" lsample = audioop.tostereo(lsample, width, 1, 0)\n" -" rsample = audioop.tostereo(rsample, width, 0, 1)\n" -" return audioop.add(lsample, rsample, width)" -msgstr "" - -#: ../../library/audioop.rst:258 -msgid "" -"If you use the ADPCM coder to build network packets and you want your " -"protocol to be stateless (i.e. to be able to tolerate packet loss) you " -"should not only transmit the data but also the state. Note that you should " -"send the *initial* state (the one you passed to :func:`lin2adpcm`) along to " -"the decoder, not the final state (as returned by the coder). If you want to " -"use :class:`struct.Struct` to store the state in binary you can code the " -"first element (the predicted value) in 16 bits and the second (the delta " -"index) in 8." -msgstr "" - -#: ../../library/audioop.rst:266 -msgid "" -"The ADPCM coders have never been tried against other ADPCM coders, only " -"against themselves. It could well be that I misinterpreted the standards in " -"which case they will not be interoperable with the respective standards." -msgstr "" - -#: ../../library/audioop.rst:270 -msgid "" -"The :func:`find\\*` routines might look a bit funny at first sight. They are " -"primarily meant to do echo cancellation. A reasonably fast way to do this " -"is to pick the most energetic piece of the output sample, locate that in the " -"input sample and subtract the whole output sample from the input sample::" -msgstr "" - -#: ../../library/audioop.rst:275 -msgid "" -"def echocancel(outputdata, inputdata):\n" -" pos = audioop.findmax(outputdata, 800) # one tenth second\n" -" out_test = outputdata[pos*2:]\n" -" in_test = inputdata[pos*2:]\n" -" ipos, factor = audioop.findfit(in_test, out_test)\n" -" # Optional (for better cancellation):\n" -" # factor = audioop.findfactor(in_test[ipos*2:ipos*2+len(out_test)],\n" -" # out_test)\n" -" prefill = '\\0'*(pos+ipos)*2\n" -" postfill = '\\0'*(len(inputdata)-len(prefill)-len(outputdata))\n" -" outputdata = prefill + audioop.mul(outputdata, 2, -factor) + postfill\n" -" return audioop.add(inputdata, outputdata, 2)" -msgstr "" - -#: ../../library/audioop.rst:24 -msgid "Intel/DVI ADPCM" -msgstr "Intel/DVI ADPCM" - -#: ../../library/audioop.rst:24 -msgid "ADPCM, Intel/DVI" -msgstr "ADPCM, Intel/DVI" - -#: ../../library/audioop.rst:24 -msgid "a-LAW" -msgstr "a-LAW" - -#: ../../library/audioop.rst:24 -msgid "u-LAW" -msgstr "u-LAW" +"最後提供 :mod:`!audioop` 模組的 Python 版本是 `Python 3.12 `_。" diff --git a/library/audit_events.po b/library/audit_events.po index 935f0dbc57..46114bbe00 100644 --- a/library/audit_events.po +++ b/library/audit_events.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-03-06 00:03+0000\n" "PO-Revision-Date: 2021-12-06 21:50+0800\n" diff --git a/library/base64.po b/library/base64.po index d386fecf1f..59e5ded526 100644 --- a/library/base64.po +++ b/library/base64.po @@ -6,9 +6,9 @@ # Inndy, 2016 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-29 00:03+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 14:39+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -30,27 +30,17 @@ msgstr "**原始碼:** :source:`Lib/base64.py`" #: ../../library/base64.rst:16 msgid "" "This module provides functions for encoding binary data to printable ASCII " -"characters and decoding such encodings back to binary data. It provides " -"encoding and decoding functions for the encodings specified in :rfc:`4648`, " -"which defines the Base16, Base32, and Base64 algorithms, and for the de-" -"facto standard Ascii85 and Base85 encodings." +"characters and decoding such encodings back to binary data. This includes " +"the :ref:`encodings specified in ` :rfc:`4648` (Base64, " +"Base32 and Base16) and the non-standard :ref:`Base85 encodings `." msgstr "" -"這個模組提供將二進位資料編碼成可顯示 ASCII 字元以及解碼回原始資料的功能,包括" -"了 :rfc:`4648` 中的 Base16、Base32、Base64 等編碼方式,以及標準 Ascii85、" -"Base85 編碼等。" +"這個模組提供將二進位資料編碼成可顯示 ASCII 字元以及解碼回原始資料的功能。這包括" +"了 :rfc:`4648` 中\\ :ref:`指定的編碼 `\\ (Base64、Base32 " +"和 Base16)和非標準的 :ref:`Base85 編碼 `。" #: ../../library/base64.rst:22 msgid "" -"The :rfc:`4648` encodings are suitable for encoding binary data so that it " -"can be safely sent by email, used as parts of URLs, or included as part of " -"an HTTP POST request. The encoding algorithm is not the same as the :" -"program:`uuencode` program." -msgstr "" -":rfc:`4648` 編碼適合對二進位資料進行編碼來使得電子郵件、URL 或是 HTTP POST 內" -"容等傳輸管道安全地傳遞資料。這些編碼演算法與 :program:`uuencode` 並不相同。" - -#: ../../library/base64.rst:27 -msgid "" "There are two interfaces provided by this module. The modern interface " "supports encoding :term:`bytes-like objects ` to ASCII :" "class:`bytes`, and decoding :term:`bytes-like objects ` " @@ -63,27 +53,27 @@ msgstr "" "義的兩種 base-64 字母表(常見和 URL 安全 (URL-safe) 及檔案系統安全 " "(filesystem-safe) 字母表)。" -#: ../../library/base64.rst:33 +#: ../../library/base64.rst:28 msgid "" -"The legacy interface does not support decoding from strings, but it does " -"provide functions for encoding and decoding to and from :term:`file objects " -"`. It only supports the Base64 standard alphabet, and it adds " -"newlines every 76 characters as per :rfc:`2045`. Note that if you are " -"looking for :rfc:`2045` support you probably want to be looking at the :mod:" -"`email` package instead." +"The :ref:`legacy interface ` does not support decoding from " +"strings, but it does provide functions for encoding and decoding to and " +"from :term:`file objects `. It only supports the Base64 " +"standard alphabet, and it adds newlines every 76 characters as per :rfc:" +"`2045`. Note that if you are looking for :rfc:`2045` support you probably " +"want to be looking at the :mod:`email` package instead." msgstr "" -"舊版介面不支援從字串解碼,但它提供對\\ :term:`檔案物件 `\\ 進行" +":ref:`舊版介面 `\\ 不支援從字串解碼,但它提供對\\ :term:`檔案物件 `\\ 進行" "編碼和解碼的函式。它僅支援 Base64 標準字母表,並且按照 :rfc:`2045` 每 76 個字" "元添加換行字元。請注意,如果你需要 :rfc:`2045` 的支援,你可能會需要 :mod:" "`email` 函式庫。" -#: ../../library/base64.rst:41 +#: ../../library/base64.rst:36 msgid "" "ASCII-only Unicode strings are now accepted by the decoding functions of the " "modern interface." msgstr "新介面的解碼功能現在接受 ASCII-only 的 Unicode 字串。" -#: ../../library/base64.rst:45 +#: ../../library/base64.rst:40 msgid "" "Any :term:`bytes-like objects ` are now accepted by all " "encoding and decoding functions in this module. Ascii85/Base85 support " @@ -92,11 +82,20 @@ msgstr "" "任何\\ :term:`類位元組物件 `\\ 現在被該模組中的所有編碼和" "解碼函式接受。新增了對 Ascii85/Base85 的支援。" -#: ../../library/base64.rst:49 -msgid "The modern interface provides:" -msgstr "新介面提供:" +#: ../../library/base64.rst:48 +msgid "RFC 4648 Encodings" +msgstr "RFC 4648 編碼" + +#: ../../library/base64.rst:50 +msgid "" +"The :rfc:`4648` encodings are suitable for encoding binary data so that it " +"can be safely sent by email, used as parts of URLs, or included as part of " +"an HTTP POST request." +msgstr "" +":rfc:`4648` 編碼適合對二進位資料進行編碼來使得電子郵件、URL 或是 HTTP POST 內" +"容等傳輸管道能夠安全地傳遞資料。" -#: ../../library/base64.rst:53 +#: ../../library/base64.rst:56 msgid "" "Encode the :term:`bytes-like object` *s* using Base64 and return the " "encoded :class:`bytes`." @@ -104,7 +103,7 @@ msgstr "" "使用 Base64 對\\ :term:`類位元組物件 ` *s* 進行編碼並回傳" "編碼過的 :class:`bytes`。" -#: ../../library/base64.rst:56 +#: ../../library/base64.rst:59 msgid "" "Optional *altchars* must be a :term:`bytes-like object` of length 2 which " "specifies an alternative alphabet for the ``+`` and ``/`` characters. This " @@ -117,7 +116,7 @@ msgstr "" "以生成對 URL 或檔案系統安全的 Base64 字串。預設值為 ``None``,即使用標準的 " "Base64 字母表。" -#: ../../library/base64.rst:61 +#: ../../library/base64.rst:64 msgid "" "May assert or raise a :exc:`ValueError` if the length of *altchars* is not " "2. Raises a :exc:`TypeError` if *altchars* is not a :term:`bytes-like " @@ -127,7 +126,7 @@ msgstr "" "*altchars* 不是\\ :term:`類位元組物件 `,則會引發 :exc:" "`TypeError`。" -#: ../../library/base64.rst:67 +#: ../../library/base64.rst:70 msgid "" "Decode the Base64 encoded :term:`bytes-like object` or ASCII string *s* and " "return the decoded :class:`bytes`." @@ -135,7 +134,7 @@ msgstr "" "將經過 Base64 編碼的\\ :term:`類位元組物件 `\\ 或 ASCII 字" "串 *s* 解碼,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:70 +#: ../../library/base64.rst:73 msgid "" "Optional *altchars* must be a :term:`bytes-like object` or ASCII string of " "length 2 which specifies the alternative alphabet used instead of the ``+`` " @@ -144,12 +143,12 @@ msgstr "" "可選的 *altchars* 必須是長度為 2 的\\ :term:`類位元組物件 `\\ 或 ASCII 字串,用於指定替代字母表,取代 ``+`` 和 ``/`` 字元。" -#: ../../library/base64.rst:74 +#: ../../library/base64.rst:77 msgid "" "A :exc:`binascii.Error` exception is raised if *s* is incorrectly padded." msgstr "如果 *s* 填充 (pad) 不正確,將引發 :exc:`binascii.Error` 例外。" -#: ../../library/base64.rst:77 +#: ../../library/base64.rst:80 msgid "" "If *validate* is ``False`` (the default), characters that are neither in the " "normal base-64 alphabet nor the alternative alphabet are discarded prior to " @@ -160,18 +159,18 @@ msgstr "" "不屬於標準 base-64 字母表和替代字母表的字元將被丟棄。如果 *validate* 為 " "``True``,輸入中的這些非字母表字元將導致引發 :exc:`binascii.Error`。" -#: ../../library/base64.rst:83 +#: ../../library/base64.rst:86 msgid "" "For more information about the strict base64 check, see :func:`binascii." "a2b_base64`" msgstr "有關嚴格的 base64 檢查的更多資訊,請參閱 :func:`binascii.a2b_base64`。" -#: ../../library/base64.rst:85 +#: ../../library/base64.rst:88 msgid "" "May assert or raise a :exc:`ValueError` if the length of *altchars* is not 2." msgstr "如果 *altchars* 的長度不是 2,可能會斷言或引發 :exc:`ValueError`。" -#: ../../library/base64.rst:89 +#: ../../library/base64.rst:92 msgid "" "Encode :term:`bytes-like object` *s* using the standard Base64 alphabet and " "return the encoded :class:`bytes`." @@ -179,7 +178,7 @@ msgstr "" "使用標準 Base64 字母表對\\ :term:`類位元組物件 ` *s* 進行" "編碼,並回傳編碼後的 :class:`bytes`。" -#: ../../library/base64.rst:95 +#: ../../library/base64.rst:98 msgid "" "Decode :term:`bytes-like object` or ASCII string *s* using the standard " "Base64 alphabet and return the decoded :class:`bytes`." @@ -187,7 +186,7 @@ msgstr "" "使用標準 Base64 字母表對\\ :term:`類位元組物件 `\\ 或 " "ASCII 字串 *s* 進行解碼,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:101 +#: ../../library/base64.rst:104 msgid "" "Encode :term:`bytes-like object` *s* using the URL- and filesystem-safe " "alphabet, which substitutes ``-`` instead of ``+`` and ``_`` instead of ``/" @@ -198,7 +197,7 @@ msgstr "" "object>` *s* 進行編碼,該字母表將標準 Base64 字母表中的 ``+`` 替換為 ``-``," "``/`` 替換為 ``_``,並回傳編碼後的 :class:`bytes`。結果仍可能包含 ``=``。" -#: ../../library/base64.rst:110 +#: ../../library/base64.rst:113 msgid "" "Decode :term:`bytes-like object` or ASCII string *s* using the URL- and " "filesystem-safe alphabet, which substitutes ``-`` instead of ``+`` and ``_`` " @@ -209,7 +208,7 @@ msgstr "" "object>`\\ 或 ASCII 字串 *s* 進行解碼,該字母表將標準 Base64 字母表中的 " "``+`` 替換為 ``-``,``/`` 替換為 ``_``,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:119 +#: ../../library/base64.rst:122 msgid "" "Encode the :term:`bytes-like object` *s* using Base32 and return the " "encoded :class:`bytes`." @@ -217,7 +216,7 @@ msgstr "" "使用 Base32 對\\ :term:`類位元組物件 ` *s* 進行編碼,並回" "傳編碼後的 :class:`bytes`。" -#: ../../library/base64.rst:125 +#: ../../library/base64.rst:128 msgid "" "Decode the Base32 encoded :term:`bytes-like object` or ASCII string *s* and " "return the decoded :class:`bytes`." @@ -225,7 +224,7 @@ msgstr "" "解碼經過 Base32 編碼的\\ :term:`類位元組物件 `\\ 或 ASCII " "字串 *s*,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:128 ../../library/base64.rst:176 +#: ../../library/base64.rst:131 ../../library/base64.rst:179 msgid "" "Optional *casefold* is a flag specifying whether a lowercase alphabet is " "acceptable as input. For security purposes, the default is ``False``." @@ -233,7 +232,7 @@ msgstr "" "可選的 *casefold* 是一個是否接受小寫字母表作為輸入的旗標。出於安全性考量,預" "設值為 ``False``。" -#: ../../library/base64.rst:132 +#: ../../library/base64.rst:135 msgid "" ":rfc:`4648` allows for optional mapping of the digit 0 (zero) to the letter " "O (oh), and for optional mapping of the digit 1 (one) to either the letter I " @@ -248,14 +247,14 @@ msgstr "" "對映為哪個字母(當 *map01* 不為 ``None`` 時,數字 0 總是對映為字母 O)。出於" "安全性考量,預設值為 ``None``,因此不允許在輸入中使用數字 0 和 1。" -#: ../../library/base64.rst:139 ../../library/base64.rst:180 +#: ../../library/base64.rst:142 ../../library/base64.rst:183 msgid "" "A :exc:`binascii.Error` is raised if *s* is incorrectly padded or if there " "are non-alphabet characters present in the input." msgstr "" "如果 *s* 的填充不正確或輸入中存在非字母表字元,將引發 :exc:`binascii.Error`。" -#: ../../library/base64.rst:146 +#: ../../library/base64.rst:149 msgid "" "Similar to :func:`b32encode` but uses the Extended Hex Alphabet, as defined " "in :rfc:`4648`." @@ -263,14 +262,14 @@ msgstr "" "類似於 :func:`b32encode`,但使用在 :rfc:`4648` 中定義的擴展十六進位字母表 " "(Extended Hex Alphabet)。" -#: ../../library/base64.rst:154 +#: ../../library/base64.rst:157 msgid "" "Similar to :func:`b32decode` but uses the Extended Hex Alphabet, as defined " "in :rfc:`4648`." msgstr "" "類似於 :func:`b32encode`,但使用在 :rfc:`4648` 中定義的擴展十六進位字母表。" -#: ../../library/base64.rst:157 +#: ../../library/base64.rst:160 msgid "" "This version does not allow the digit 0 (zero) to the letter O (oh) and " "digit 1 (one) to either the letter I (eye) or letter L (el) mappings, all " @@ -280,7 +279,7 @@ msgstr "" "這個版本不允許將數字 0 對映為字母 O ,以及將數字 1 對映為字母 I 或字母 L,所" "有這些字元都包含在擴展十六進位字母表中,並且不能互換使用。" -#: ../../library/base64.rst:167 +#: ../../library/base64.rst:170 msgid "" "Encode the :term:`bytes-like object` *s* using Base16 and return the " "encoded :class:`bytes`." @@ -288,7 +287,7 @@ msgstr "" "使用 Base16 對\\ :term:`類位元組物件 ` *s* 進行編碼,並回" "傳編碼後的 :class:`bytes`。" -#: ../../library/base64.rst:173 +#: ../../library/base64.rst:176 msgid "" "Decode the Base16 encoded :term:`bytes-like object` or ASCII string *s* and " "return the decoded :class:`bytes`." @@ -296,7 +295,51 @@ msgstr "" "解碼經過 Base16 編碼的\\ :term:`類位元組物件 `\\ 或 ASCII " "字串 *s*,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:187 +#: ../../library/base64.rst:190 +msgid "Base85 Encodings" +msgstr "Base85 編碼" + +#: ../../library/base64.rst:192 +msgid "" +"Base85 encoding is not formally specified but rather a de facto standard, " +"thus different systems perform the encoding differently." +msgstr "" + +#: ../../library/base64.rst:195 +msgid "" +"The :func:`a85encode` and :func:`b85encode` functions in this module are two " +"implementations of the de facto standard. You should call the function with " +"the Base85 implementation used by the software you intend to work with." +msgstr "" + +#: ../../library/base64.rst:199 +msgid "" +"The two functions present in this module differ in how they handle the " +"following:" +msgstr "" + +#: ../../library/base64.rst:201 +msgid "Whether to include enclosing ``<~`` and ``~>`` markers" +msgstr "" + +#: ../../library/base64.rst:202 +msgid "Whether to include newline characters" +msgstr "" + +#: ../../library/base64.rst:203 +msgid "The set of ASCII characters used for encoding" +msgstr "" + +#: ../../library/base64.rst:204 +msgid "Handling of null bytes" +msgstr "" + +#: ../../library/base64.rst:206 +msgid "" +"Refer to the documentation of the individual functions for more information." +msgstr "" + +#: ../../library/base64.rst:210 msgid "" "Encode the :term:`bytes-like object` *b* using Ascii85 and return the " "encoded :class:`bytes`." @@ -304,7 +347,7 @@ msgstr "" "使用 Ascii85 對\\ :term:`類位元組物件 ` *b* 進行編碼,並回" "傳編碼後的 :class:`bytes`。" -#: ../../library/base64.rst:190 +#: ../../library/base64.rst:213 msgid "" "*foldspaces* is an optional flag that uses the special short sequence 'y' " "instead of 4 consecutive spaces (ASCII 0x20) as supported by 'btoa'. This " @@ -314,7 +357,7 @@ msgstr "" "(ASCII 0x20),這是由 'btoa' 支援的功能。這個特性不被「標準」的 Ascii85 編碼所" "支援。" -#: ../../library/base64.rst:194 +#: ../../library/base64.rst:217 msgid "" "*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 " @@ -323,7 +366,7 @@ msgstr "" "*wrapcol* 控制輸出是否應該包含換行字元 (``b'\\n'``) 。如果這個值不為零,每行" "輸出的長度將不超過這個字元長度(不包含後面的換行符號)。" -#: ../../library/base64.rst:198 +#: ../../library/base64.rst:221 msgid "" "*pad* controls whether the input is padded to a multiple of 4 before " "encoding. Note that the ``btoa`` implementation always pads." @@ -331,7 +374,7 @@ msgstr "" "*pad* 控制是否在編碼之前將輸入填充為 4 的倍數。請注意,``btoa`` 實作始終會填" "充。" -#: ../../library/base64.rst:201 +#: ../../library/base64.rst:224 msgid "" "*adobe* controls whether the encoded byte sequence is framed with ``<~`` and " "``~>``, which is used by the Adobe implementation." @@ -339,7 +382,7 @@ msgstr "" "*adobe* 控制編碼的位元組序列前後是否加上 ``<~`` 和 ``~>``,這是 Adobe 實作中" "使用的。" -#: ../../library/base64.rst:209 +#: ../../library/base64.rst:232 msgid "" "Decode the Ascii85 encoded :term:`bytes-like object` or ASCII string *b* and " "return the decoded :class:`bytes`." @@ -347,7 +390,7 @@ msgstr "" "解碼經過 Ascii85 編碼的\\ :term:`類位元組物件 `\\ 或 " "ASCII 字串 *b*,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:212 +#: ../../library/base64.rst:235 msgid "" "*foldspaces* is a flag that specifies whether the 'y' short sequence should " "be accepted as shorthand for 4 consecutive spaces (ASCII 0x20). This feature " @@ -356,7 +399,7 @@ msgstr "" "*foldspaces* 是一個旗標,指定是否應該將短序列 'y' 視為 4 個連續的空格 (ASCII " "0x20) 的簡寫。這個功能不受「標準」Ascii85 編碼的支援。" -#: ../../library/base64.rst:216 +#: ../../library/base64.rst:239 msgid "" "*adobe* controls whether the input sequence is in Adobe Ascii85 format (i.e. " "is framed with <~ and ~>)." @@ -364,7 +407,7 @@ msgstr "" "*adobe* 控制輸入序列是否符合 Adobe Ascii85 格式(即前後加上 ``<~`` 和 " "``~>``)。" -#: ../../library/base64.rst:219 +#: ../../library/base64.rst:242 msgid "" "*ignorechars* should be a :term:`bytes-like object` or ASCII string " "containing characters to ignore from the input. This should only contain " @@ -375,7 +418,7 @@ msgstr "" "like object>`\\ 或 ASCII 字串。這只包含空格字元,預設情況下包含 ASCII 中的所" "有空格字元。" -#: ../../library/base64.rst:229 +#: ../../library/base64.rst:252 msgid "" "Encode the :term:`bytes-like object` *b* using base85 (as used in e.g. git-" "style binary diffs) and return the encoded :class:`bytes`." @@ -383,7 +426,7 @@ msgstr "" "使用 Base85(例如,git 風格的二進位差異 (binary diff))對\\ :term:`類位元組物" "件 ` *b* 進行編碼,並回傳編碼後的 :class:`bytes`。" -#: ../../library/base64.rst:232 +#: ../../library/base64.rst:255 msgid "" "If *pad* is true, the input is padded with ``b'\\0'`` so its length is a " "multiple of 4 bytes before encoding." @@ -391,7 +434,7 @@ msgstr "" "如果 *pad* 為 true,則在編碼之前,輸入將使用 ``b'\\0'`` 進行填充,以使其長度" "為 4 的倍數。" -#: ../../library/base64.rst:240 +#: ../../library/base64.rst:263 msgid "" "Decode the base85-encoded :term:`bytes-like object` or ASCII string *b* and " "return the decoded :class:`bytes`. Padding is implicitly removed, if " @@ -400,11 +443,29 @@ msgstr "" "解碼經過 base85 編碼的\\ :term:`類位元組物件 `\\ 或 ASCII " "字串 *b*,並回傳解碼後的 :class:`bytes`。必要時會隱式移除填充。" -#: ../../library/base64.rst:247 -msgid "The legacy interface:" -msgstr "舊版介面:" +#: ../../library/base64.rst:272 +msgid "" +"Encode the :term:`bytes-like object` *s* using Z85 (as used in ZeroMQ) and " +"return the encoded :class:`bytes`. See `Z85 specification `_ for more information." +msgstr "" +"使用 Z85(如用於 ZeroMQ)對\\ :term:`類位元組物件 ` *s* 進行編碼,並回傳" +"編碼後的 :class:`bytes`。有關更多資訊,請參閱 `Z85 規格 `_。" + +#: ../../library/base64.rst:281 +msgid "" +"Decode the Z85-encoded :term:`bytes-like object` or ASCII string *s* and " +"return the decoded :class:`bytes`. See `Z85 specification `_ for more information." +msgstr "" +"解碼經 Z85 編碼的\\ :term:`類位元組物件 `\\ 或 ASCII " +"字串 *s*,並回傳解碼後的 :class:`bytes`。有關更多資訊,請參閱 `Z85 規格 `_。" + +#: ../../library/base64.rst:291 +msgid "Legacy Interface" +msgstr "舊版介面" -#: ../../library/base64.rst:251 +#: ../../library/base64.rst:295 msgid "" "Decode the contents of the binary *input* file and write the resulting " "binary data to the *output* file. *input* and *output* must be :term:`file " @@ -415,7 +476,7 @@ msgstr "" "*input* 和 *output* 必須是\\ :term:`檔案物件 `。*input* 將被讀" "取,直到 ``input.readline()`` 回傳一個空的 bytes 物件為止。" -#: ../../library/base64.rst:259 +#: ../../library/base64.rst:303 msgid "" "Decode the :term:`bytes-like object` *s*, which must contain one or more " "lines of base64 encoded data, and return the decoded :class:`bytes`." @@ -423,7 +484,7 @@ msgstr "" "解碼必須包含一行或多行的 base64 編碼資料\\ :term:`類位元組物件 ` *s*,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:267 +#: ../../library/base64.rst:311 msgid "" "Encode the contents of the binary *input* file and write the resulting " "base64 encoded data to the *output* file. *input* and *output* must be :term:" @@ -438,7 +499,7 @@ msgstr "" "出的每 76 個位元組之後插入一個換行字元 (``b'\\n'``),並確保輸出始終以換行字元" "結尾,符合 :rfc:`2045` (MIME) 的規定。" -#: ../../library/base64.rst:277 +#: ../../library/base64.rst:321 msgid "" "Encode the :term:`bytes-like object` *s*, which can contain arbitrary binary " "data, and return :class:`bytes` containing the base64-encoded data, with " @@ -449,15 +510,15 @@ msgstr "" "碼,並回傳包含 base64 編碼資料 :class:`bytes`,在每 76 個輸出位元組後插入換行" "字元 (``b'\\n'``) ,並確保有尾隨換行字元,符合 :rfc:`2045` (MIME) 的規定。" -#: ../../library/base64.rst:285 +#: ../../library/base64.rst:329 msgid "An example usage of the module:" msgstr "模組的一個範例用法:" -#: ../../library/base64.rst:298 +#: ../../library/base64.rst:342 msgid "Security Considerations" msgstr "安全性注意事項" -#: ../../library/base64.rst:300 +#: ../../library/base64.rst:344 msgid "" "A new security considerations section was added to :rfc:`4648` (section 12); " "it's recommended to review the security section for any code deployed to " @@ -466,18 +527,18 @@ msgstr "" ":rfc:`4648`\\ (第 12 節)中添加了一個新的安全性考量部分;建議對部署到正式環" "境的任何程式碼進行安全性部分的審查。" -#: ../../library/base64.rst:305 +#: ../../library/base64.rst:349 msgid "Module :mod:`binascii`" msgstr ":mod:`binascii` 模組" -#: ../../library/base64.rst:306 +#: ../../library/base64.rst:350 msgid "" "Support module containing ASCII-to-binary and binary-to-ASCII conversions." msgstr "" "支援模組中包含 ASCII 到二進位 (ASCII-to-binary) 和二進位到 ASCII (binary-to-" "ASCII) 的轉換功能。" -#: ../../library/base64.rst:308 +#: ../../library/base64.rst:352 msgid "" ":rfc:`1521` - MIME (Multipurpose Internet Mail Extensions) Part One: " "Mechanisms for Specifying and Describing the Format of Internet Message " @@ -486,7 +547,7 @@ msgstr "" ":rfc:`1521` - MIME(多用途網際網路郵件擴展)第一部分:指定和描述網際網路主體" "格式的機制。" -#: ../../library/base64.rst:309 +#: ../../library/base64.rst:353 msgid "" "Section 5.2, \"Base64 Content-Transfer-Encoding,\" provides the definition " "of the base64 encoding." diff --git a/library/bdb.po b/library/bdb.po index dc99fb79d8..c188b1f102 100644 --- a/library/bdb.po +++ b/library/bdb.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-09 00:03+0000\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2018-05-23 14:39+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -124,11 +124,11 @@ msgstr "" #: ../../library/bdb.rst:77 msgid ":class:`Breakpoint` instances have the following attributes:" -msgstr "" +msgstr ":class:`Breakpoint` 實例有以下屬性:" #: ../../library/bdb.rst:81 msgid "File name of the :class:`Breakpoint`." -msgstr "" +msgstr ":class:`Breakpoint` 的檔案名稱。" #: ../../library/bdb.rst:85 msgid "Line number of the :class:`Breakpoint` within :attr:`file`." @@ -415,57 +415,63 @@ msgid "" "from caller's frame." msgstr "" -#: ../../library/bdb.rst:294 +#: ../../library/bdb.rst:292 +msgid "" +":func:`set_trace` will enter the debugger immediately, rather than on the " +"next line of code to be executed." +msgstr "" + +#: ../../library/bdb.rst:298 msgid "" "Stop only at breakpoints or when finished. If there are no breakpoints, set " "the system trace function to ``None``." msgstr "" -#: ../../library/bdb.rst:301 +#: ../../library/bdb.rst:305 msgid "" "Set the :attr:`!quitting` attribute to ``True``. This raises :exc:`BdbQuit` " "in the next call to one of the :meth:`!dispatch_\\*` methods." msgstr "" -#: ../../library/bdb.rst:305 +#: ../../library/bdb.rst:309 msgid "" "Derived classes and clients can call the following methods to manipulate " "breakpoints. These methods return a string containing an error message if " "something went wrong, or ``None`` if all is well." msgstr "" -#: ../../library/bdb.rst:311 +#: ../../library/bdb.rst:315 msgid "" "Set a new breakpoint. If the *lineno* line doesn't exist for the *filename* " "passed as argument, return an error message. The *filename* should be in " "canonical form, as described in the :meth:`canonic` method." msgstr "" -#: ../../library/bdb.rst:317 +#: ../../library/bdb.rst:321 msgid "" "Delete the breakpoints in *filename* and *lineno*. If none were set, return " "an error message." msgstr "" -#: ../../library/bdb.rst:322 +#: ../../library/bdb.rst:326 msgid "" "Delete the breakpoint which has the index *arg* in the :attr:`Breakpoint." "bpbynumber`. If *arg* is not numeric or out of range, return an error " "message." msgstr "" -#: ../../library/bdb.rst:328 +#: ../../library/bdb.rst:332 msgid "" "Delete all breakpoints in *filename*. If none were set, return an error " "message." msgstr "" -#: ../../library/bdb.rst:333 +#: ../../library/bdb.rst:337 msgid "" "Delete all existing breakpoints. If none were set, return an error message." msgstr "" -#: ../../library/bdb.rst:338 +#: ../../library/bdb.rst:342 msgid "" "Return a breakpoint specified by the given number. If *arg* is a string, it " "will be converted to a number. If *arg* is a non-numeric string, if the " @@ -473,103 +479,103 @@ msgid "" "raised." msgstr "" -#: ../../library/bdb.rst:347 +#: ../../library/bdb.rst:351 msgid "Return ``True`` if there is a breakpoint for *lineno* in *filename*." msgstr "" -#: ../../library/bdb.rst:351 +#: ../../library/bdb.rst:355 msgid "" "Return all breakpoints for *lineno* in *filename*, or an empty list if none " "are set." msgstr "" -#: ../../library/bdb.rst:356 +#: ../../library/bdb.rst:360 msgid "Return all breakpoints in *filename*, or an empty list if none are set." msgstr "" -#: ../../library/bdb.rst:360 +#: ../../library/bdb.rst:364 msgid "Return all breakpoints that are set." msgstr "" -#: ../../library/bdb.rst:363 +#: ../../library/bdb.rst:367 msgid "" "Derived classes and clients can call the following methods to get a data " "structure representing a stack trace." msgstr "" -#: ../../library/bdb.rst:368 +#: ../../library/bdb.rst:372 msgid "Return a list of (frame, lineno) tuples in a stack trace, and a size." msgstr "" -#: ../../library/bdb.rst:370 +#: ../../library/bdb.rst:374 msgid "" "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." msgstr "" -#: ../../library/bdb.rst:375 +#: ../../library/bdb.rst:379 msgid "" "Return a string with information about a stack entry, which is a ``(frame, " "lineno)`` tuple. The return string contains:" msgstr "" -#: ../../library/bdb.rst:378 +#: ../../library/bdb.rst:382 msgid "The canonical filename which contains the frame." msgstr "" -#: ../../library/bdb.rst:379 +#: ../../library/bdb.rst:383 msgid "The function name or ``\"\"``." msgstr "函式名稱或 ``\"\"``。" -#: ../../library/bdb.rst:380 +#: ../../library/bdb.rst:384 msgid "The input arguments." msgstr "輸入引數。" -#: ../../library/bdb.rst:381 +#: ../../library/bdb.rst:385 msgid "The return value." msgstr "回傳值。" -#: ../../library/bdb.rst:382 +#: ../../library/bdb.rst:386 msgid "The line of code (if it exists)." msgstr "" -#: ../../library/bdb.rst:385 +#: ../../library/bdb.rst:389 msgid "" "The following two methods can be called by clients to use a debugger to " "debug a :term:`statement`, given as a string." msgstr "" -#: ../../library/bdb.rst:390 +#: ../../library/bdb.rst:394 msgid "" "Debug a statement executed via the :func:`exec` function. *globals* " "defaults to :attr:`!__main__.__dict__`, *locals* defaults to *globals*." msgstr "" -#: ../../library/bdb.rst:395 +#: ../../library/bdb.rst:399 msgid "" "Debug an expression executed via the :func:`eval` function. *globals* and " "*locals* have the same meaning as in :meth:`run`." msgstr "" -#: ../../library/bdb.rst:400 +#: ../../library/bdb.rst:404 msgid "For backwards compatibility. Calls the :meth:`run` method." msgstr "" -#: ../../library/bdb.rst:404 +#: ../../library/bdb.rst:408 msgid "Debug a single function call, and return its result." msgstr "" -#: ../../library/bdb.rst:407 +#: ../../library/bdb.rst:411 msgid "Finally, the module defines the following functions:" -msgstr "" +msgstr "最後,這個模組定義了以下函式:" -#: ../../library/bdb.rst:411 +#: ../../library/bdb.rst:415 msgid "" "Return ``True`` if we should break here, depending on the way the :class:" "`Breakpoint` *b* was set." msgstr "" -#: ../../library/bdb.rst:414 +#: ../../library/bdb.rst:418 msgid "" "If it was set via line number, it checks if :attr:`b.line ` is the same as the one in *frame*. If the breakpoint was set via :" @@ -578,13 +584,13 @@ msgid "" "line." msgstr "" -#: ../../library/bdb.rst:423 +#: ../../library/bdb.rst:427 msgid "" "Return ``(active breakpoint, delete temporary flag)`` or ``(None, None)`` as " "the breakpoint to act upon." msgstr "" -#: ../../library/bdb.rst:426 +#: ../../library/bdb.rst:430 msgid "" "The *active breakpoint* is the first entry in :attr:`bplist ` for the (:attr:`file `, :attr:`line ` count is ignored)." msgstr "" -#: ../../library/bdb.rst:437 +#: ../../library/bdb.rst:441 msgid "If no such entry exists, then ``(None, None)`` is returned." msgstr "" -#: ../../library/bdb.rst:442 +#: ../../library/bdb.rst:446 msgid "Start debugging with a :class:`Bdb` instance from caller's frame." msgstr "" -#: ../../library/bdb.rst:299 +#: ../../library/bdb.rst:303 msgid "quitting (bdb.Bdb attribute)" msgstr "" diff --git a/library/binary.po b/library/binary.po index edeb5839ed..5c36e1bf9c 100644 --- a/library/binary.po +++ b/library/binary.po @@ -5,7 +5,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2015-12-09 17:51+0000\n" diff --git a/library/binascii.po b/library/binascii.po index ecfcd38b8d..48302802ab 100644 --- a/library/binascii.po +++ b/library/binascii.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2018-05-23 14:39+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,17 +22,16 @@ msgstr "" msgid ":mod:`!binascii` --- Convert between binary and ASCII" msgstr ":mod:`!binascii` --- 在二進位制和 ASCII 之間轉換" -#: ../../library/binascii.rst:14 +#: ../../library/binascii.rst:13 msgid "" "The :mod:`binascii` module contains a number of methods to convert between " "binary and various ASCII-encoded binary representations. Normally, you will " -"not use these functions directly but use wrapper modules like :mod:`uu` or :" -"mod:`base64` instead. The :mod:`binascii` module contains low-level " -"functions written in C for greater speed that are used by the higher-level " -"modules." +"not use these functions directly but use wrapper modules like :mod:`base64` " +"instead. The :mod:`binascii` module contains low-level functions written in " +"C for greater speed that are used by the higher-level modules." msgstr "" -#: ../../library/binascii.rst:23 +#: ../../library/binascii.rst:22 msgid "" "``a2b_*`` functions accept Unicode strings containing only ASCII characters. " "Other functions only accept :term:`bytes-like objects ` " @@ -40,22 +39,22 @@ msgid "" "the buffer protocol)." msgstr "" -#: ../../library/binascii.rst:28 +#: ../../library/binascii.rst:27 msgid "ASCII-only unicode strings are now accepted by the ``a2b_*`` functions." msgstr "" -#: ../../library/binascii.rst:32 +#: ../../library/binascii.rst:31 msgid "The :mod:`binascii` module defines the following functions:" -msgstr "" +msgstr ":mod:`binascii` 模組定義了以下函式:" -#: ../../library/binascii.rst:37 +#: ../../library/binascii.rst:36 msgid "" "Convert a single line of uuencoded data back to binary and return the binary " "data. Lines normally contain 45 (binary) bytes, except for the last line. " "Line data may be followed by whitespace." msgstr "" -#: ../../library/binascii.rst:44 +#: ../../library/binascii.rst:43 msgid "" "Convert binary data to a line of ASCII characters, the return value is the " "converted line, including a newline char. The length of *data* should be at " @@ -63,67 +62,67 @@ msgid "" "spaces." msgstr "" -#: ../../library/binascii.rst:48 +#: ../../library/binascii.rst:47 msgid "Added the *backtick* parameter." msgstr "新增 *backtick* 參數。" -#: ../../library/binascii.rst:54 +#: ../../library/binascii.rst:53 msgid "" "Convert a block of base64 data back to binary and return the binary data. " "More than one line may be passed at a time." msgstr "" -#: ../../library/binascii.rst:57 +#: ../../library/binascii.rst:56 msgid "" "If *strict_mode* is true, only valid base64 data will be converted. Invalid " "base64 data will raise :exc:`binascii.Error`." msgstr "" -#: ../../library/binascii.rst:60 +#: ../../library/binascii.rst:59 msgid "Valid base64:" msgstr "" -#: ../../library/binascii.rst:62 +#: ../../library/binascii.rst:61 msgid "Conforms to :rfc:`3548`." msgstr "" -#: ../../library/binascii.rst:63 +#: ../../library/binascii.rst:62 msgid "Contains only characters from the base64 alphabet." msgstr "" -#: ../../library/binascii.rst:64 +#: ../../library/binascii.rst:63 msgid "" "Contains no excess data after padding (including excess padding, newlines, " "etc.)." msgstr "" -#: ../../library/binascii.rst:65 +#: ../../library/binascii.rst:64 msgid "Does not start with a padding." msgstr "" -#: ../../library/binascii.rst:67 +#: ../../library/binascii.rst:66 msgid "Added the *strict_mode* parameter." msgstr "新增 *strict_mode* 參數。" -#: ../../library/binascii.rst:73 +#: ../../library/binascii.rst:72 msgid "" "Convert binary data to a line of ASCII characters in base64 coding. The " "return value is the converted line, including a newline char if *newline* is " "true. The output of this function conforms to :rfc:`3548`." msgstr "" -#: ../../library/binascii.rst:77 +#: ../../library/binascii.rst:76 msgid "Added the *newline* parameter." msgstr "新增 *newline* 參數。" -#: ../../library/binascii.rst:83 +#: ../../library/binascii.rst:82 msgid "" "Convert a block of quoted-printable data back to binary and return the " "binary data. More than one line may be passed at a time. If the optional " "argument *header* is present and true, underscores will be decoded as spaces." msgstr "" -#: ../../library/binascii.rst:90 +#: ../../library/binascii.rst:89 msgid "" "Convert binary data to a line(s) of ASCII characters in quoted-printable " "encoding. The return value is the converted line(s). If the optional " @@ -136,7 +135,7 @@ msgid "" "might corrupt the binary data stream." msgstr "" -#: ../../library/binascii.rst:103 +#: ../../library/binascii.rst:102 msgid "" "Compute a 16-bit CRC value of *data*, starting with *value* as the initial " "CRC, and return the result. This uses the CRC-CCITT polynomial *x*:sup:`16` " @@ -144,7 +143,7 @@ msgid "" "used in the binhex4 format." msgstr "" -#: ../../library/binascii.rst:111 +#: ../../library/binascii.rst:110 msgid "" "Compute CRC-32, the unsigned 32-bit checksum of *data*, starting with an " "initial CRC of *value*. The default initial CRC is zero. The algorithm is " @@ -153,7 +152,7 @@ msgid "" "algorithm. Use as follows::" msgstr "" -#: ../../library/binascii.rst:117 +#: ../../library/binascii.rst:116 msgid "" "print(binascii.crc32(b\"hello world\"))\n" "# Or, in two pieces:\n" @@ -162,24 +161,24 @@ msgid "" "print('crc32 = {:#010x}'.format(crc))" msgstr "" -#: ../../library/binascii.rst:123 +#: ../../library/binascii.rst:122 msgid "The result is always unsigned." msgstr "" -#: ../../library/binascii.rst:129 +#: ../../library/binascii.rst:128 msgid "" "Return the hexadecimal representation of the binary *data*. Every byte of " "*data* is converted into the corresponding 2-digit hex representation. The " "returned bytes object is therefore twice as long as the length of *data*." msgstr "" -#: ../../library/binascii.rst:133 +#: ../../library/binascii.rst:132 msgid "" "Similar functionality (but returning a text string) is also conveniently " "accessible using the :meth:`bytes.hex` method." msgstr "" -#: ../../library/binascii.rst:136 +#: ../../library/binascii.rst:135 msgid "" "If *sep* is specified, it must be a single character str or bytes object. It " "will be inserted in the output after every *bytes_per_sep* input bytes. " @@ -187,11 +186,11 @@ msgid "" "if you wish to count from the left, supply a negative *bytes_per_sep* value." msgstr "" -#: ../../library/binascii.rst:151 +#: ../../library/binascii.rst:150 msgid "The *sep* and *bytes_per_sep* parameters were added." msgstr "新增 *sep* 與 *bytes_per_sep* 參數。" -#: ../../library/binascii.rst:157 +#: ../../library/binascii.rst:156 msgid "" "Return the binary data represented by the hexadecimal string *hexstr*. This " "function is the inverse of :func:`b2a_hex`. *hexstr* must contain an even " @@ -199,45 +198,37 @@ msgid "" "an :exc:`Error` exception is raised." msgstr "" -#: ../../library/binascii.rst:162 +#: ../../library/binascii.rst:161 msgid "" "Similar functionality (accepting only text string arguments, but more " "liberal towards whitespace) is also accessible using the :meth:`bytes." "fromhex` class method." msgstr "" -#: ../../library/binascii.rst:168 +#: ../../library/binascii.rst:167 msgid "Exception raised on errors. These are usually programming errors." msgstr "" -#: ../../library/binascii.rst:173 +#: ../../library/binascii.rst:172 msgid "" "Exception raised on incomplete data. These are usually not programming " "errors, but may be handled by reading a little more data and trying again." msgstr "" -#: ../../library/binascii.rst:179 +#: ../../library/binascii.rst:178 msgid "Module :mod:`base64`" msgstr ":mod:`base64` 模組" -#: ../../library/binascii.rst:180 +#: ../../library/binascii.rst:179 msgid "" "Support for RFC compliant base64-style encoding in base 16, 32, 64, and 85." msgstr "" -#: ../../library/binascii.rst:183 -msgid "Module :mod:`uu`" -msgstr ":mod:`uu` 模組" - -#: ../../library/binascii.rst:184 -msgid "Support for UU encoding used on Unix." -msgstr "" - -#: ../../library/binascii.rst:186 +#: ../../library/binascii.rst:182 msgid "Module :mod:`quopri`" msgstr ":mod:`quopri` 模組" -#: ../../library/binascii.rst:187 +#: ../../library/binascii.rst:183 msgid "Support for quoted-printable encoding used in MIME email messages." msgstr "" @@ -245,10 +236,12 @@ msgstr "" msgid "module" msgstr "module(模組)" -#: ../../library/binascii.rst:8 -msgid "uu" -msgstr "uu" - #: ../../library/binascii.rst:8 msgid "base64" msgstr "base64" + +#~ msgid "Module :mod:`uu`" +#~ msgstr ":mod:`uu` 模組" + +#~ msgid "uu" +#~ msgstr "uu" diff --git a/library/bisect.po b/library/bisect.po index d5aae2fa8c..c423cc4f89 100644 --- a/library/bisect.po +++ b/library/bisect.po @@ -8,7 +8,7 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2023-08-01 12:53+0800\n" @@ -38,7 +38,7 @@ msgid "" "searches or frequent resorting." msgstr "" "這個模組維護一個已經排序過的 list ,當我們每次做完插入後不需要再次排序整個 " -"list 。一個很長的 list 的比較操作很花費時間,可以透過線性搜索或頻繁地詢問來改" +"list 。一個很長的 list 的比較操作很花費時間,可以透過線性搜尋或頻繁地詢問來改" "善。" #: ../../library/bisect.rst:19 @@ -135,21 +135,21 @@ msgid "" "insertion point. Next, it runs the :meth:`!insert` method on *a* to insert " "*x* at the appropriate position to maintain sort order." msgstr "" -"此函式先使用 :py:func:`~bisect.bisect_left` 搜索插入位置,接著用 :meth:`!" +"此函式先使用 :py:func:`~bisect.bisect_left` 搜尋插入位置,接著用 :meth:`!" "insert` 於 *a* 以將 *x* 插入,並維持添加元素後的順序。" #: ../../library/bisect.rst:79 ../../library/bisect.rst:99 msgid "" "To support inserting records in a table, the *key* function (if any) is " "applied to *x* for the search step but not for the insertion step." -msgstr "此函式只有在搜索時會使用 *key* 函式,插入時不會。" +msgstr "此函式只有在搜尋時會使用 *key* 函式,插入時不會。" #: ../../library/bisect.rst:82 ../../library/bisect.rst:102 msgid "" "Keep in mind that the *O*\\ (log *n*) search is dominated by the slow *O*\\ " "(*n*) insertion step." msgstr "" -"注意雖然搜索是 *O*\\ (log *n*),但插入是 *O*\\ (*n*),因此此函式整體時間複雜" +"注意雖然搜尋是 *O*\\ (log *n*),但插入是 *O*\\ (*n*),因此此函式整體時間複雜" "度是 *O*\\ (*n*)。" #: ../../library/bisect.rst:92 @@ -166,7 +166,7 @@ msgid "" "insertion point. Next, it runs the :meth:`!insert` method on *a* to insert " "*x* at the appropriate position to maintain sort order." msgstr "" -"此函式先使用 :py:func:`~bisect.bisect_right` 搜索插入位置,接著用 :meth:`!" +"此函式先使用 :py:func:`~bisect.bisect_right` 搜尋插入位置,接著用 :meth:`!" "insert` 於 *a* 以將 *x* 插入,並維持添加元素後的順序。" #: ../../library/bisect.rst:110 @@ -186,7 +186,7 @@ msgid "" "Bisection is effective for searching ranges of values. For locating specific " "values, dictionaries are more performant." msgstr "" -"二分法在一段範圍的數值中做搜索的效率較佳,但若是要存取特定數值,使用字典的表" +"二分法在一段範圍的數值中做搜尋的效率較佳,但若是要存取特定數值,使用字典的表" "現還是比較好。" #: ../../library/bisect.rst:118 @@ -207,7 +207,7 @@ msgid "" "searching an array of precomputed keys to locate the insertion point (as " "shown in the examples section below)." msgstr "" -"搜索函式為無狀態的 (stateless),且鍵函式會在使用過後被丟棄。因此,如果搜索函" +"搜尋函式為無狀態的 (stateless),且鍵函式會在使用過後被丟棄。因此,如果搜尋函" "式被使用於迴圈當中,鍵函式會不斷被重複呼叫於相同的 list 元素。如果鍵函式執行" "速度不快,請考慮將其以 :py:func:`functools.cache` 包裝起來以減少重複的計算。" "另外,也可以透過搜尋預先計算好的鍵列表 (array of precomputed keys) 來定位插入" @@ -232,8 +232,8 @@ msgid "" msgstr "" "`SortedCollection recipe `_ 使用二分法來建立一個功能完整的集合類別 (collection " -"class) 並帶有符合直覺的搜索方法 (search methods) 與支援鍵函式。鍵會預先被計算" -"好,以減少搜索過程中多餘的鍵函式呼叫。" +"class) 並帶有符合直覺的搜尋方法 (search methods) 與支援鍵函式。鍵會預先被計算" +"好,以減少搜尋過程中多餘的鍵函式呼叫。" #: ../../library/bisect.rst:143 msgid "Searching Sorted Lists" @@ -366,7 +366,7 @@ msgid "" "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::" msgstr "" -"如果鍵函式會消耗較多運算資源,那可以在預先計算好的鍵列表中搜索該紀錄的索引" +"如果鍵函式會消耗較多運算資源,那可以在預先計算好的鍵列表中搜尋該紀錄的索引" "值,以減少重複的函式呼叫: ::" #: ../../library/bisect.rst:240 diff --git a/library/builtins.po b/library/builtins.po index ef5628bb84..ab36c9d83d 100644 --- a/library/builtins.po +++ b/library/builtins.po @@ -1,14 +1,14 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Adrian Liaw , 2018 -# Matt Wang , 2022 +# Matt Wang , 2022-2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-10-22 00:13+0000\n" "PO-Revision-Date: 2022-02-15 20:55+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -28,14 +28,12 @@ msgstr ":mod:`!builtins` --- 內建物件" msgid "" "This module provides direct access to all 'built-in' identifiers of Python; " "for example, ``builtins.open`` is the full name for the built-in function :" -"func:`open`. See :ref:`built-in-funcs` and :ref:`built-in-consts` for " -"documentation." +"func:`open`." msgstr "" "該模組提供對 Python 所有'內建'識別符號的直接存取;例如 ``builtins.open`` 是內" -"建函式 :func:`open` 的全名。請參閱\\ :ref:`built-in-funcs`\\ 和\\ :ref:" -"`built-in-consts`\\ 的文件。" +"建函式 :func:`open` 的全名。" -#: ../../library/builtins.rst:15 +#: ../../library/builtins.rst:12 msgid "" "This module is not normally accessed explicitly by most applications, but " "can be useful in modules that provide objects with the same name as a built-" @@ -47,7 +45,7 @@ msgstr "" "能很有用,不過其中還會需要內建該名稱。例如,在一個將內建 :func:`open` 包裝起" "來以實現另一版本 :func:`open` 函式的模組中,這個模組可以直接被使用: ::" -#: ../../library/builtins.rst:21 +#: ../../library/builtins.rst:18 msgid "" "import builtins\n" "\n" @@ -66,8 +64,24 @@ msgid "" "\n" " # ..." msgstr "" +"import builtins\n" +"\n" +"def open(path):\n" +" f = builtins.open(path, 'r')\n" +" return UpperCaser(f)\n" +"\n" +"class UpperCaser:\n" +" '''將輸出轉換成大寫的檔案包裝器'''\n" +"\n" +" def __init__(self, f):\n" +" self._f = f\n" +"\n" +" def read(self, count=-1):\n" +" return self._f.read(count).upper()\n" +"\n" +" # ..." -#: ../../library/builtins.rst:38 +#: ../../library/builtins.rst:35 msgid "" "As an implementation detail, most modules have the name ``__builtins__`` " "made available as part of their globals. The value of ``__builtins__`` is " @@ -79,3 +93,19 @@ msgstr "" "以提使用。``__builtins__`` 的值通常是這個模組或者這個模組的 :attr:`~object." "__dict__` 屬性值。由於這是一個實作細節,因此 Python 的其他實作可能不會使用" "它。" + +#: ../../library/builtins.rst:43 +msgid ":ref:`built-in-consts`" +msgstr ":ref:`built-in-consts`" + +#: ../../library/builtins.rst:44 +msgid ":ref:`bltin-exceptions`" +msgstr ":ref:`bltin-exceptions`" + +#: ../../library/builtins.rst:45 +msgid ":ref:`built-in-funcs`" +msgstr ":ref:`built-in-funcs`" + +#: ../../library/builtins.rst:46 +msgid ":ref:`bltin-types`" +msgstr ":ref:`bltin-types`" diff --git a/library/bz2.po b/library/bz2.po index 94b9f0a99f..f0ec58fb6a 100644 --- a/library/bz2.po +++ b/library/bz2.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-09 00:03+0000\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2018-05-23 14:40+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -99,11 +99,11 @@ msgid "" "handling behavior, and line ending(s)." msgstr "" -#: ../../library/bz2.rst:59 ../../library/bz2.rst:162 +#: ../../library/bz2.rst:59 ../../library/bz2.rst:175 msgid "The ``'x'`` (exclusive creation) mode was added." msgstr "" -#: ../../library/bz2.rst:62 ../../library/bz2.rst:169 +#: ../../library/bz2.rst:62 ../../library/bz2.rst:182 msgid "Accepts a :term:`path-like object`." msgstr "" @@ -153,8 +153,8 @@ msgid "" msgstr "" #: ../../library/bz2.rst:94 -msgid ":class:`BZ2File` also provides the following methods:" -msgstr "" +msgid ":class:`BZ2File` also provides the following methods and attributes:" +msgstr ":class:`BZ2File` 也提供了以下方法和屬性:" #: ../../library/bz2.rst:98 msgid "" @@ -206,93 +206,103 @@ msgstr "" msgid "Returns the number of bytes read (0 for EOF)." msgstr "" -#: ../../library/bz2.rst:152 +#: ../../library/bz2.rst:153 +msgid "``'rb'`` for reading and ``'wb'`` for writing." +msgstr "" + +#: ../../library/bz2.rst:159 +msgid "" +"The bzip2 file name. Equivalent to the :attr:`~io.FileIO.name` attribute of " +"the underlying :term:`file object`." +msgstr "" + +#: ../../library/bz2.rst:165 msgid "Support for the :keyword:`with` statement was added." msgstr "" -#: ../../library/bz2.rst:155 +#: ../../library/bz2.rst:168 msgid "" "Support was added for *filename* being a :term:`file object` instead of an " "actual filename." msgstr "" -#: ../../library/bz2.rst:159 +#: ../../library/bz2.rst:172 msgid "" "The ``'a'`` (append) mode was added, along with support for reading multi-" "stream files." msgstr "" -#: ../../library/bz2.rst:165 +#: ../../library/bz2.rst:178 msgid "" "The :meth:`~io.BufferedIOBase.read` method now accepts an argument of " "``None``." msgstr "" -#: ../../library/bz2.rst:172 +#: ../../library/bz2.rst:185 msgid "" "The *buffering* parameter has been removed. It was ignored and deprecated " "since Python 3.0. Pass an open file object to control how the file is opened." msgstr "" -#: ../../library/bz2.rst:177 +#: ../../library/bz2.rst:190 msgid "The *compresslevel* parameter became keyword-only." msgstr "" -#: ../../library/bz2.rst:179 +#: ../../library/bz2.rst:192 msgid "" "This class is thread unsafe in the face of multiple simultaneous readers or " "writers, just like its equivalent classes in :mod:`gzip` and :mod:`lzma` " "have always been." msgstr "" -#: ../../library/bz2.rst:186 +#: ../../library/bz2.rst:199 msgid "Incremental (de)compression" msgstr "" -#: ../../library/bz2.rst:190 +#: ../../library/bz2.rst:203 msgid "" "Create a new compressor object. This object may be used to compress data " "incrementally. For one-shot compression, use the :func:`compress` function " "instead." msgstr "" -#: ../../library/bz2.rst:194 ../../library/bz2.rst:282 +#: ../../library/bz2.rst:207 ../../library/bz2.rst:295 msgid "" "*compresslevel*, if given, must be an integer between ``1`` and ``9``. The " "default is ``9``." msgstr "" -#: ../../library/bz2.rst:199 +#: ../../library/bz2.rst:212 msgid "" "Provide data to the compressor object. Returns a chunk of compressed data if " "possible, or an empty byte string otherwise." msgstr "" -#: ../../library/bz2.rst:202 +#: ../../library/bz2.rst:215 msgid "" "When you have finished providing data to the compressor, call the :meth:" "`flush` method to finish the compression process." msgstr "" -#: ../../library/bz2.rst:208 +#: ../../library/bz2.rst:221 msgid "" "Finish the compression process. Returns the compressed data left in internal " "buffers." msgstr "" -#: ../../library/bz2.rst:211 +#: ../../library/bz2.rst:224 msgid "" "The compressor object may not be used after this method has been called." msgstr "" -#: ../../library/bz2.rst:216 +#: ../../library/bz2.rst:229 msgid "" "Create a new decompressor object. This object may be used to decompress data " "incrementally. For one-shot compression, use the :func:`decompress` function " "instead." msgstr "" -#: ../../library/bz2.rst:221 +#: ../../library/bz2.rst:234 msgid "" "This class does not transparently handle inputs containing multiple " "compressed streams, unlike :func:`decompress` and :class:`BZ2File`. If you " @@ -300,7 +310,7 @@ msgid "" "must use a new decompressor for each stream." msgstr "" -#: ../../library/bz2.rst:228 +#: ../../library/bz2.rst:241 msgid "" "Decompress *data* (a :term:`bytes-like object`), returning uncompressed data " "as bytes. Some of *data* may be buffered internally, for use in later calls " @@ -308,7 +318,7 @@ msgid "" "output of any previous calls to :meth:`decompress`." msgstr "" -#: ../../library/bz2.rst:234 +#: ../../library/bz2.rst:247 msgid "" "If *max_length* is nonnegative, returns at most *max_length* bytes of " "decompressed data. If this limit is reached and further output can be " @@ -317,99 +327,99 @@ msgid "" "``b''`` to obtain more of the output." msgstr "" -#: ../../library/bz2.rst:241 +#: ../../library/bz2.rst:254 msgid "" "If all of the input data was decompressed and returned (either because this " "was less than *max_length* bytes, or because *max_length* was negative), " "the :attr:`~.needs_input` attribute will be set to ``True``." msgstr "" -#: ../../library/bz2.rst:246 +#: ../../library/bz2.rst:259 msgid "" "Attempting to decompress data after the end of stream is reached raises an :" "exc:`EOFError`. Any data found after the end of the stream is ignored and " "saved in the :attr:`~.unused_data` attribute." msgstr "" -#: ../../library/bz2.rst:250 +#: ../../library/bz2.rst:263 msgid "Added the *max_length* parameter." msgstr "新增 *max_length* 參數。" -#: ../../library/bz2.rst:255 +#: ../../library/bz2.rst:268 msgid "``True`` if the end-of-stream marker has been reached." msgstr "" -#: ../../library/bz2.rst:262 +#: ../../library/bz2.rst:275 msgid "Data found after the end of the compressed stream." msgstr "" -#: ../../library/bz2.rst:264 +#: ../../library/bz2.rst:277 msgid "" "If this attribute is accessed before the end of the stream has been reached, " "its value will be ``b''``." msgstr "" -#: ../../library/bz2.rst:269 +#: ../../library/bz2.rst:282 msgid "" "``False`` if the :meth:`.decompress` method can provide more decompressed " "data before requiring new uncompressed input." msgstr "" -#: ../../library/bz2.rst:276 +#: ../../library/bz2.rst:289 msgid "One-shot (de)compression" msgstr "" -#: ../../library/bz2.rst:280 +#: ../../library/bz2.rst:293 msgid "Compress *data*, a :term:`bytes-like object `." msgstr "" -#: ../../library/bz2.rst:285 +#: ../../library/bz2.rst:298 msgid "For incremental compression, use a :class:`BZ2Compressor` instead." msgstr "" -#: ../../library/bz2.rst:290 +#: ../../library/bz2.rst:303 msgid "Decompress *data*, a :term:`bytes-like object `." msgstr "" -#: ../../library/bz2.rst:292 +#: ../../library/bz2.rst:305 msgid "" "If *data* is the concatenation of multiple compressed streams, decompress " "all of the streams." msgstr "" -#: ../../library/bz2.rst:295 +#: ../../library/bz2.rst:308 msgid "For incremental decompression, use a :class:`BZ2Decompressor` instead." msgstr "" -#: ../../library/bz2.rst:297 +#: ../../library/bz2.rst:310 msgid "Support for multi-stream inputs was added." msgstr "" -#: ../../library/bz2.rst:303 +#: ../../library/bz2.rst:316 msgid "Examples of usage" msgstr "用法範例" -#: ../../library/bz2.rst:305 +#: ../../library/bz2.rst:318 msgid "Below are some examples of typical usage of the :mod:`bz2` module." msgstr "" -#: ../../library/bz2.rst:307 +#: ../../library/bz2.rst:320 msgid "" "Using :func:`compress` and :func:`decompress` to demonstrate round-trip " "compression:" msgstr "" -#: ../../library/bz2.rst:325 +#: ../../library/bz2.rst:338 msgid "Using :class:`BZ2Compressor` for incremental compression:" msgstr "" -#: ../../library/bz2.rst:343 +#: ../../library/bz2.rst:356 msgid "" "The example above uses a very \"nonrandom\" stream of data (a stream of " "``b\"z\"`` chunks). Random data tends to compress poorly, while ordered, " "repetitive data usually yields a high compression ratio." msgstr "" -#: ../../library/bz2.rst:347 +#: ../../library/bz2.rst:360 msgid "Writing and reading a bzip2-compressed file in binary mode:" msgstr "" diff --git a/library/calendar.po b/library/calendar.po index 7ed55e4591..59c409fce5 100644 --- a/library/calendar.po +++ b/library/calendar.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-01-08 00:13+0000\n" "PO-Revision-Date: 2018-05-23 14:40+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -38,8 +38,8 @@ msgstr "" "這個模組讓你可以像 Unix 的 :program:`cal` 程式一樣輸出日曆,並額外提供有用的" "日曆相關函式。這些日曆預設把週一當作一週的第一天,而週日當作最後一天(歐洲的" "慣例)。可以使用 :func:`setfirstweekday` 設定一週的第一天為週日 (6) 或一週的" -"其它任一天,其中指定日期的參數是整數。相關功能參考 :mod:`datetime` 和 :mod:" -"`time` 模組。" +"其它任一天,其中指定日期的參數是整數。相關功能參考 :mod:`datetime` " +"和 :mod:`time` 模組。" #: ../../library/calendar.rst:22 msgid "" @@ -60,11 +60,11 @@ msgstr "" #: ../../library/calendar.rst:33 msgid "" "Creates a :class:`Calendar` object. *firstweekday* is an integer specifying " -"the first day of the week. :const:`MONDAY` is ``0`` (the default), :const:" -"`SUNDAY` is ``6``." +"the first day of the week. :const:`MONDAY` is ``0`` (the " +"default), :const:`SUNDAY` is ``6``." msgstr "" -"建立 :class:`Calendar` 物件。*firstweekday* 是一個指定一週第一天的整數,:" -"const:`MONDAY` 是 ``0``\\ (預設值),:const:`SUNDAY` 是 ``6``。" +"建立 :class:`Calendar` 物件。*firstweekday* 是一個指定一週第一天的整" +"數,:const:`MONDAY` 是 ``0``\\ (預設值),:const:`SUNDAY` 是 ``6``。" #: ../../library/calendar.rst:36 msgid "" @@ -76,19 +76,47 @@ msgstr "" "做任何格式化,這是子類別的工作。" #: ../../library/calendar.rst:41 -msgid ":class:`Calendar` instances have the following methods:" -msgstr ":class:`Calendar` 實例有以下方法:" +msgid ":class:`Calendar` instances have the following methods and attributes:" +msgstr ":class:`Calendar` 實例有以下方法與屬性:" #: ../../library/calendar.rst:45 +msgid "The first weekday as an integer (0--6)." +msgstr "" + +#: ../../library/calendar.rst:47 +msgid "" +"This property can also be set and read " +"using :meth:`~Calendar.setfirstweekday` " +"and :meth:`~Calendar.getfirstweekday` respectively." +msgstr "" + +#: ../../library/calendar.rst:53 +msgid "Return an :class:`int` for the current first weekday (0--6)." +msgstr "" + +#: ../../library/calendar.rst:55 +msgid "Identical to reading the :attr:`~Calendar.firstweekday` property." +msgstr "" + +#: ../../library/calendar.rst:59 +msgid "" +"Set the first weekday to *firstweekday*, passed as an :class:`int` (0--6)" +msgstr "" + +#: ../../library/calendar.rst:61 +msgid "Identical to setting the :attr:`~Calendar.firstweekday` property." +msgstr "" + +#: ../../library/calendar.rst:65 msgid "" "Return an iterator for the week day numbers that will be used for one week. " -"The first value from the iterator will be the same as the value of the :attr:" -"`firstweekday` property." +"The first value from the iterator will be the same as the value of " +"the :attr:`~Calendar.firstweekday` property." msgstr "" -"回傳一個以數字代表一週的每一天的疊代器 (iterator)。疊代器的第一個值和 :attr:" -"`firstweekday` 屬性的值一樣。" +"回傳一個以數字代表一週的每一天的疊代器 (iterator)。疊代器的第一個值" +"和 :attr:`~Calendar.firstweekday` 屬性的值一樣。" -#: ../../library/calendar.rst:52 +#: ../../library/calendar.rst:72 msgid "" "Return an iterator for the month *month* (1--12) in the year *year*. This " "iterator will return all days (as :class:`datetime.date` objects) for the " @@ -98,59 +126,59 @@ msgstr "" "回傳一個在 *year* 年 *month* (1--12) 月的疊代器。這個疊代器會回傳該月的所有日" "期(:class:`datetime.date` 物件)以及在該月之前及之後用來組成完整一週的日期。" -#: ../../library/calendar.rst:60 +#: ../../library/calendar.rst:80 msgid "" -"Return an iterator for the month *month* in the year *year* similar to :meth:" -"`itermonthdates`, but not restricted by the :class:`datetime.date` range. " -"Days returned will simply be day of the month numbers. For the days outside " -"of the specified month, the day number is ``0``." +"Return an iterator for the month *month* in the year *year* similar " +"to :meth:`itermonthdates`, but not restricted by the :class:`datetime.date` " +"range. Days returned will simply be day of the month numbers. For the days " +"outside of the specified month, the day number is ``0``." msgstr "" "類似 :meth:`itermonthdates`,回傳一個在 *year* 年 *month* 月的疊代器,但不受" "限於 :class:`datetime.date` 的範圍。回傳的日期單純是該月當日的數字,對於該月" "之外的日期數字會是 ``0``。" -#: ../../library/calendar.rst:68 +#: ../../library/calendar.rst:88 msgid "" -"Return an iterator for the month *month* in the year *year* similar to :meth:" -"`itermonthdates`, but not restricted by the :class:`datetime.date` range. " -"Days returned will be tuples consisting of a day of the month number and a " -"week day number." +"Return an iterator for the month *month* in the year *year* similar " +"to :meth:`itermonthdates`, but not restricted by the :class:`datetime.date` " +"range. Days returned will be tuples consisting of a day of the month number " +"and a week day number." msgstr "" "類似 :meth:`itermonthdates`,回傳一個在 *year* 年 *month* 月的疊代器,但不受" "限於 :class:`datetime.date` 的範圍。回傳的日期是一個由該月當日的數字及代表週" "幾的數字組成的元組。" -#: ../../library/calendar.rst:76 +#: ../../library/calendar.rst:96 msgid "" -"Return an iterator for the month *month* in the year *year* similar to :meth:" -"`itermonthdates`, but not restricted by the :class:`datetime.date` range. " -"Days returned will be tuples consisting of a year, a month and a day of the " -"month numbers." +"Return an iterator for the month *month* in the year *year* similar " +"to :meth:`itermonthdates`, but not restricted by the :class:`datetime.date` " +"range. Days returned will be tuples consisting of a year, a month and a day " +"of the month numbers." msgstr "" "類似 :meth:`itermonthdates`,回傳一個在 *year* 年 *month* 月的疊代器,但不受" "限於 :class:`datetime.date` 的範圍。回傳的日期是一個由年、月、日的數字組成的" "元組。" -#: ../../library/calendar.rst:86 +#: ../../library/calendar.rst:106 msgid "" -"Return an iterator for the month *month* in the year *year* similar to :meth:" -"`itermonthdates`, but not restricted by the :class:`datetime.date` range. " -"Days returned will be tuples consisting of a year, a month, a day of the " -"month, and a day of the week numbers." +"Return an iterator for the month *month* in the year *year* similar " +"to :meth:`itermonthdates`, but not restricted by the :class:`datetime.date` " +"range. Days returned will be tuples consisting of a year, a month, a day of " +"the month, and a day of the week numbers." msgstr "" "類似 :meth:`itermonthdates`,回傳一個在 *year* 年 *month* 月的疊代器,但不受" "限於 :class:`datetime.date` 的範圍。回傳的日期是一個由年、月、日及代表週幾的" "數字組成的元組。" -#: ../../library/calendar.rst:96 +#: ../../library/calendar.rst:116 msgid "" "Return a list of the weeks in the month *month* of the *year* as full " "weeks. Weeks are lists of seven :class:`datetime.date` objects." msgstr "" -"回傳一個在 *year* 年 *month* 月每一週組成的串列。每一週是一個串列,包含七個 :" -"class:`datetime.date` 物件。" +"回傳一個在 *year* 年 *month* 月每一週組成的串列。每一週是一個串列,包含七" +"個 :class:`datetime.date` 物件。" -#: ../../library/calendar.rst:102 +#: ../../library/calendar.rst:122 msgid "" "Return a list of the weeks in the month *month* of the *year* as full " "weeks. Weeks are lists of seven tuples of day numbers and weekday numbers." @@ -158,7 +186,7 @@ msgstr "" "回傳一個在 *year* 年 *month* 月每一週組成的串列。每一週是一個串列,包含七個該" "月當日的數字及代表週幾的數字組成的元組。" -#: ../../library/calendar.rst:109 +#: ../../library/calendar.rst:129 msgid "" "Return a list of the weeks in the month *month* of the *year* as full " "weeks. Weeks are lists of seven day numbers." @@ -166,7 +194,7 @@ msgstr "" "回傳一個在 *year* 年 *month* 月每一週組成的串列。每一週是一個串列,包含七個該" "月當日的數字。" -#: ../../library/calendar.rst:115 +#: ../../library/calendar.rst:135 msgid "" "Return the data for the specified year ready for formatting. The return " "value is a list of month rows. Each month row contains up to *width* months " @@ -177,76 +205,113 @@ msgstr "" "*width* 個月份組成(預設為 3)。每個月份包含四到六週,每一週包含一到七天,每" "一天則是一個 :class:`datetime.date` 物件。" -#: ../../library/calendar.rst:123 +#: ../../library/calendar.rst:143 msgid "" -"Return the data for the specified year ready for formatting (similar to :" -"meth:`yeardatescalendar`). Entries in the week lists are tuples of day " +"Return the data for the specified year ready for formatting (similar " +"to :meth:`yeardatescalendar`). Entries in the week lists are tuples of day " "numbers and weekday numbers. Day numbers outside this month are zero." msgstr "" "回傳用來格式化的指定年份的資料(類似 :meth:`yeardatescalendar`)。每一天是一" "個該月當日的數字及代表週幾的數字組成的元組,該月外的日期的該月當日數字為 0。" -#: ../../library/calendar.rst:130 +#: ../../library/calendar.rst:150 msgid "" -"Return the data for the specified year ready for formatting (similar to :" -"meth:`yeardatescalendar`). Entries in the week lists are day numbers. Day " -"numbers outside this month are zero." +"Return the data for the specified year ready for formatting (similar " +"to :meth:`yeardatescalendar`). Entries in the week lists are day numbers. " +"Day numbers outside this month are zero." msgstr "" "回傳用來格式化的指定年份的資料(類似 :meth:`yeardatescalendar`)。每一天是一" "個該月當日的數字,該月外的日期的該月當日數字為 0。" -#: ../../library/calendar.rst:137 +#: ../../library/calendar.rst:157 msgid "This class can be used to generate plain text calendars." msgstr "這個類別用來產生純文字的日曆。" -#: ../../library/calendar.rst:139 +#: ../../library/calendar.rst:159 msgid ":class:`TextCalendar` instances have the following methods:" msgstr ":class:`TextCalendar` 實例有以下方法:" -#: ../../library/calendar.rst:143 +#: ../../library/calendar.rst:164 +msgid "" +"Return a string representing a single day formatted with the given *width*. " +"If *theday* is ``0``, return a string of spaces of the specified width, " +"representing an empty day. The *weekday* parameter is unused." +msgstr "" + +#: ../../library/calendar.rst:171 +msgid "" +"Return a single week in a string with no newline. If *w* is provided, it " +"specifies the width of the date columns, which are centered. Depends on the " +"first weekday as specified in the constructor or set by " +"the :meth:`setfirstweekday` method." +msgstr "" + +#: ../../library/calendar.rst:178 +msgid "" +"Return a string representing the name of a single weekday formatted to the " +"specified *width*. The *weekday* parameter is an integer representing the " +"day of the week, where ``0`` is Monday and ``6`` is Sunday." +msgstr "" + +#: ../../library/calendar.rst:184 +msgid "" +"Return a string containing the header row of weekday names, formatted with " +"the given *width* for each column. The names depend on the locale settings " +"and are padded to the specified width." +msgstr "" + +#: ../../library/calendar.rst:190 msgid "" "Return a month's calendar in a multi-line string. If *w* is provided, it " "specifies the width of the date columns, which are centered. If *l* is " "given, it specifies the number of lines that each week will use. Depends on " -"the first weekday as specified in the constructor or set by the :meth:" -"`setfirstweekday` method." +"the first weekday as specified in the constructor or set by " +"the :meth:`setfirstweekday` method." msgstr "" "以多行字串的形式回傳一個月份的日曆。如果給定 *w*,它會指定置中的日期欄的寬" "度。如果給定 *l*,它會指定每一週使用的行數。這個日曆會依據在建構函式中指定或" "者透過 :meth:`setfirstweekday` 方法設定的一週的第一天來輸出。" -#: ../../library/calendar.rst:152 +#: ../../library/calendar.rst:198 +msgid "" +"Return a string representing the month's name centered within the specified " +"*width*. If *withyear* is ``True``, include the year in the output. The " +"*theyear* and *themonth* parameters specify the year and month for the name " +"to be formatted respectively." +msgstr "" + +#: ../../library/calendar.rst:205 msgid "Print a month's calendar as returned by :meth:`formatmonth`." msgstr "印出一個月份的日曆,內容和 :meth:`formatmonth` 回傳的一樣。" -#: ../../library/calendar.rst:157 +#: ../../library/calendar.rst:210 msgid "" "Return a *m*-column calendar for an entire year as a multi-line string. " "Optional parameters *w*, *l*, and *c* are for date column width, lines per " "week, and number of spaces between month columns, respectively. Depends on " -"the first weekday as specified in the constructor or set by the :meth:" -"`setfirstweekday` method. The earliest year for which a calendar can be " -"generated is platform-dependent." +"the first weekday as specified in the constructor or set by " +"the :meth:`setfirstweekday` method. The earliest year for which a calendar " +"can be generated is platform-dependent." msgstr "" "以多行字串的形式回傳有 *m* 欄的一整年的日曆。可選的參數 *w*、*l* 及 *c* 分別" "是日期欄寬度、每週行數及月份欄中間的空白數。這個日曆會依據在建構函式中指定或" "者透過 :meth:`setfirstweekday` 方法設定的一週的第一天來輸出。最早可以產生日曆" "的年份會依據平台而不同。" -#: ../../library/calendar.rst:167 +#: ../../library/calendar.rst:220 msgid "" "Print the calendar for an entire year as returned by :meth:`formatyear`." msgstr "印出一整年的日曆,內容和 :meth:`formatyear` 回傳的一樣。" -#: ../../library/calendar.rst:172 +#: ../../library/calendar.rst:225 msgid "This class can be used to generate HTML calendars." msgstr "這個類別用來產生 HTML 日曆。" -#: ../../library/calendar.rst:175 +#: ../../library/calendar.rst:228 msgid ":class:`!HTMLCalendar` instances have the following methods:" msgstr ":class:`!HTMLCalendar` 實例有以下方法:" -#: ../../library/calendar.rst:179 +#: ../../library/calendar.rst:232 msgid "" "Return a month's calendar as an HTML table. If *withyear* is true the year " "will be included in the header, otherwise just the month name will be used." @@ -254,14 +319,14 @@ msgstr "" "以 HTML 表格的形式回傳一個月份的日曆。如果 *withyear* 是 true 則標題會包含年" "份,否則只會有月份名稱。" -#: ../../library/calendar.rst:186 +#: ../../library/calendar.rst:239 msgid "" "Return a year's calendar as an HTML table. *width* (defaulting to 3) " "specifies the number of months per row." msgstr "" "以 HTML 表格的形式回傳一整年的日曆。*width*\\ (預設為 3)指定一列有幾個月。" -#: ../../library/calendar.rst:192 +#: ../../library/calendar.rst:245 msgid "" "Return a year's calendar as a complete HTML page. *width* (defaulting to 3) " "specifies the number of months per row. *css* is the name for the cascading " @@ -273,7 +338,7 @@ msgstr "" "月。*css* 是要使用的 CSS (cascading style sheet) 名稱,可以給 :const:`None` " "表示不使用任何 CSS。*encoding* 指定輸出使用的編碼(預設使用系統預設編碼)。" -#: ../../library/calendar.rst:201 +#: ../../library/calendar.rst:254 msgid "" "Return a month name as an HTML table row. If *withyear* is true the year " "will be included in the row, otherwise just the month name will be used." @@ -281,28 +346,28 @@ msgstr "" "以 HTML 表列的形式回傳一個月份的名稱。如果 *withyear* 是 true 則該列會包含年" "份,否則只會有月份名稱。" -#: ../../library/calendar.rst:206 +#: ../../library/calendar.rst:259 msgid "" ":class:`!HTMLCalendar` has the following attributes you can override to " "customize the CSS classes used by the calendar:" msgstr ":class:`!HTMLCalendar` 可以覆寫以下屬性來客製日曆所使用的 CSS 類別:" -#: ../../library/calendar.rst:211 +#: ../../library/calendar.rst:264 msgid "" "A list of CSS classes used for each weekday. The default class list is::" msgstr "對應一週每一天 CSS 類別的串列。預設的串列內容為: ::" -#: ../../library/calendar.rst:213 +#: ../../library/calendar.rst:266 msgid "" "cssclasses = [\"mon\", \"tue\", \"wed\", \"thu\", \"fri\", \"sat\", \"sun\"]" msgstr "" "cssclasses = [\"mon\", \"tue\", \"wed\", \"thu\", \"fri\", \"sat\", \"sun\"]" -#: ../../library/calendar.rst:215 +#: ../../library/calendar.rst:268 msgid "more styles can be added for each day::" msgstr "可以針對每一天增加更多樣式: ::" -#: ../../library/calendar.rst:217 +#: ../../library/calendar.rst:270 msgid "" "cssclasses = [\"mon text-bold\", \"tue\", \"wed\", \"thu\", \"fri\", " "\"sat\", \"sun red\"]" @@ -310,15 +375,15 @@ msgstr "" "cssclasses = [\"mon text-bold\", \"tue\", \"wed\", \"thu\", \"fri\", " "\"sat\", \"sun red\"]" -#: ../../library/calendar.rst:219 +#: ../../library/calendar.rst:272 msgid "Note that the length of this list must be seven items." msgstr "注意這個串列的長度必須是七個項目。" -#: ../../library/calendar.rst:224 +#: ../../library/calendar.rst:277 msgid "The CSS class for a weekday occurring in the previous or coming month." msgstr "跟當月為同一週且屬於前一個或下一個月份的日期使用的 CSS 類別。" -#: ../../library/calendar.rst:231 +#: ../../library/calendar.rst:284 msgid "" "A list of CSS classes used for weekday names in the header row. The default " "is the same as :attr:`cssclasses`." @@ -326,7 +391,7 @@ msgstr "" "在標題列中一週每一天名稱的 CSS 類別的串列。預設內容和 :attr:`cssclasses` 相" "同。" -#: ../../library/calendar.rst:239 +#: ../../library/calendar.rst:292 msgid "" "The month's head CSS class (used by :meth:`formatmonthname`). The default " "value is ``\"month\"``." @@ -334,7 +399,7 @@ msgstr "" "月份標題的 CSS 類別(由 :meth:`formatmonthname` 所使用),預設值是 " "``\"month\"``。" -#: ../../library/calendar.rst:247 +#: ../../library/calendar.rst:300 msgid "" "The CSS class for the whole month's table (used by :meth:`formatmonth`). The " "default value is ``\"month\"``." @@ -342,22 +407,22 @@ msgstr "" "整個月份表格的 CSS 類別(由 :meth:`formatmonth` 所使用),預設值是 " "``\"month\"``。" -#: ../../library/calendar.rst:255 +#: ../../library/calendar.rst:308 msgid "" -"The CSS class for the whole year's table of tables (used by :meth:" -"`formatyear`). The default value is ``\"year\"``." +"The CSS class for the whole year's table of tables (used " +"by :meth:`formatyear`). The default value is ``\"year\"``." msgstr "" "整年表格的 CSS 類別(由 :meth:`formatyear` 所使用),預設值是 ``\"year\"``。" -#: ../../library/calendar.rst:263 +#: ../../library/calendar.rst:316 msgid "" -"The CSS class for the table head for the whole year (used by :meth:" -"`formatyear`). The default value is ``\"year\"``." +"The CSS class for the table head for the whole year (used " +"by :meth:`formatyear`). The default value is ``\"year\"``." msgstr "" "整年表格標題的 CSS 類別(由 :meth:`formatyear` 所使用),預設值是 " "``\"year\"``。" -#: ../../library/calendar.rst:269 +#: ../../library/calendar.rst:322 msgid "" "Note that although the naming for the above described class attributes is " "singular (e.g. ``cssclass_month`` ``cssclass_noday``), one can replace the " @@ -367,15 +432,15 @@ msgstr "" "``cssclass_noday``),你可以使用多個以空格隔開的 CSS 類別取代單一 CSS 類別," "例如: ::" -#: ../../library/calendar.rst:273 +#: ../../library/calendar.rst:326 msgid "\"text-bold text-red\"" msgstr "\"text-bold text-red\"" -#: ../../library/calendar.rst:275 +#: ../../library/calendar.rst:328 msgid "Here is an example how :class:`!HTMLCalendar` can be customized::" msgstr "以下是客製化 :class:`!HTMLCalendar` 的範例: ::" -#: ../../library/calendar.rst:277 +#: ../../library/calendar.rst:330 msgid "" "class CustomHTMLCal(calendar.HTMLCalendar):\n" " cssclasses = [style + \" text-nowrap\" for style in\n" @@ -391,7 +456,7 @@ msgstr "" " cssclass_month = \"text-center month\"\n" " cssclass_year = \"text-italic lead\"" -#: ../../library/calendar.rst:287 +#: ../../library/calendar.rst:340 msgid "" "This subclass of :class:`TextCalendar` can be passed a locale name in the " "constructor and will return month and weekday names in the specified locale." @@ -399,7 +464,7 @@ msgstr "" ":class:`TextCalendar` 的子類別,可以在建構函式傳入語系名稱,它會回傳指定語系" "的月份及一週每一天的名稱。" -#: ../../library/calendar.rst:293 +#: ../../library/calendar.rst:346 msgid "" "This subclass of :class:`HTMLCalendar` can be passed a locale name in the " "constructor and will return month and weekday names in the specified locale." @@ -407,7 +472,7 @@ msgstr "" ":class:`HTMLCalendar` 的子類別,可以在建構函式傳入語系名稱,它會回傳指定語系" "的月份及一週每一天的名稱。" -#: ../../library/calendar.rst:299 +#: ../../library/calendar.rst:352 msgid "" "The constructor, :meth:`!formatweekday` and :meth:`!formatmonthname` methods " "of these two classes temporarily change the ``LC_TIME`` locale to the given " @@ -418,22 +483,22 @@ msgstr "" "會把 ``LC_TIME`` 語系暫時改成給定的 *locale*。因為目前的語系是屬於整個行程 " "(process-wide) 的設定,它們不是執行緒安全的。" -#: ../../library/calendar.rst:305 +#: ../../library/calendar.rst:358 msgid "For simple text calendars this module provides the following functions." msgstr "這個模組提供以下函式給單純的文字日曆使用。" -#: ../../library/calendar.rst:309 +#: ../../library/calendar.rst:362 msgid "" "Sets the weekday (``0`` is Monday, ``6`` is Sunday) to start each week. The " -"values :const:`MONDAY`, :const:`TUESDAY`, :const:`WEDNESDAY`, :const:" -"`THURSDAY`, :const:`FRIDAY`, :const:`SATURDAY`, and :const:`SUNDAY` are " -"provided for convenience. For example, to set the first weekday to Sunday::" +"values :const:`MONDAY`, :const:`TUESDAY`, :const:`WEDNESDAY`, :const:`THURSDAY`, :const:`FRIDAY`, :const:`SATURDAY`, " +"and :const:`SUNDAY` are provided for convenience. For example, to set the " +"first weekday to Sunday::" msgstr "" -"設定一週的第一天(``0`` 是週一、``6`` 是週日)。提供 :const:`MONDAY`、:const:" -"`TUESDAY`、:const:`WEDNESDAY`、:const:`THURSDAY`、:const:`FRIDAY`、:const:" -"`SATURDAY` 及 :const:`SUNDAY` 可以方便設定。例如設定一週的第一天為週日: ::" +"設定一週的第一天(``0`` 是週一、``6`` 是週日)。提" +"供 :const:`MONDAY`、:const:`TUESDAY`、:const:`WEDNESDAY`、:const:`THURSDAY`、:const:`FRIDAY`、:const:`SATURDAY` " +"及 :const:`SUNDAY` 可以方便設定。例如設定一週的第一天為週日: ::" -#: ../../library/calendar.rst:314 +#: ../../library/calendar.rst:367 msgid "" "import calendar\n" "calendar.setfirstweekday(calendar.SUNDAY)" @@ -441,27 +506,27 @@ msgstr "" "import calendar\n" "calendar.setfirstweekday(calendar.SUNDAY)" -#: ../../library/calendar.rst:320 +#: ../../library/calendar.rst:373 msgid "Returns the current setting for the weekday to start each week." msgstr "回傳目前設定的一週的第一天。" -#: ../../library/calendar.rst:325 +#: ../../library/calendar.rst:378 msgid "" "Returns :const:`True` if *year* is a leap year, otherwise :const:`False`." msgstr "如果 *year* 是閏年回傳 :const:`True`,否則回傳 :const:`False`。" -#: ../../library/calendar.rst:330 +#: ../../library/calendar.rst:383 msgid "" "Returns the number of leap years in the range from *y1* to *y2* (exclusive), " "where *y1* and *y2* are years." msgstr "" "回傳從 *y1* 到 *y2*\\ (不包含)間有幾個閏年,其中 *y1* 和 *y2* 是年份。" -#: ../../library/calendar.rst:333 +#: ../../library/calendar.rst:386 msgid "This function works for ranges spanning a century change." msgstr "這個函式也適用在跨越世紀的時間範圍。" -#: ../../library/calendar.rst:338 +#: ../../library/calendar.rst:391 msgid "" "Returns the day of the week (``0`` is Monday) for *year* (``1970``--...), " "*month* (``1``--``12``), *day* (``1``--``31``)." @@ -469,19 +534,19 @@ msgstr "" "回傳 *year* 年 (``1970``--...) *month* 月 (``1``--``12``) *day* 日 (``1``--" "``31``) 是週幾(``0`` 是星期一)。" -#: ../../library/calendar.rst:344 +#: ../../library/calendar.rst:397 msgid "" "Return a header containing abbreviated weekday names. *n* specifies the " "width in characters for one weekday." msgstr "回傳包含一週每一天的名稱縮寫的標題。*n* 指定每一天的字元寬度。" -#: ../../library/calendar.rst:350 +#: ../../library/calendar.rst:403 msgid "" "Returns weekday of first day of the month and number of days in month, for " "the specified *year* and *month*." msgstr "回傳指定 *year* 年 *month* 月該月第一天代表週幾的數字及該月有多少天。" -#: ../../library/calendar.rst:356 +#: ../../library/calendar.rst:409 msgid "" "Returns a matrix representing a month's calendar. Each row represents a " "week; days outside of the month are represented by zeros. Each week begins " @@ -490,32 +555,32 @@ msgstr "" "回傳代表一個月份日曆的矩陣。每一列為一週;該月以外的日期以 0 表示。每一週以週" "一開始,除非有使用 :func:`setfirstweekday` 改變設定。" -#: ../../library/calendar.rst:363 +#: ../../library/calendar.rst:416 msgid "Prints a month's calendar as returned by :func:`month`." msgstr "印出一個月份的日曆,跟 :func:`month` 回傳的內容一樣。" -#: ../../library/calendar.rst:368 +#: ../../library/calendar.rst:421 msgid "" -"Returns a month's calendar in a multi-line string using the :meth:" -"`~TextCalendar.formatmonth` of the :class:`TextCalendar` class." +"Returns a month's calendar in a multi-line string using " +"the :meth:`~TextCalendar.formatmonth` of the :class:`TextCalendar` class." msgstr "" -"以多行字串的形式回傳一個月的日曆,使用 :class:`TextCalendar` 類別的 :meth:" -"`~TextCalendar.formatmonth`。" +"以多行字串的形式回傳一個月的日曆,使用 :class:`TextCalendar` 類別" +"的 :meth:`~TextCalendar.formatmonth`。" -#: ../../library/calendar.rst:374 +#: ../../library/calendar.rst:427 msgid "" "Prints the calendar for an entire year as returned by :func:`calendar`." msgstr "印出一整年的日曆,跟 :func:`calendar` 回傳的內容一樣。" -#: ../../library/calendar.rst:379 +#: ../../library/calendar.rst:432 msgid "" "Returns a 3-column calendar for an entire year as a multi-line string using " "the :meth:`~TextCalendar.formatyear` of the :class:`TextCalendar` class." msgstr "" -"以多行字串回傳三欄形式的一整年日曆,使用 :class:`TextCalendar` 類別的 :meth:" -"`~TextCalendar.formatyear`。" +"以多行字串回傳三欄形式的一整年日曆,使用 :class:`TextCalendar` 類別" +"的 :meth:`~TextCalendar.formatyear`。" -#: ../../library/calendar.rst:385 +#: ../../library/calendar.rst:438 msgid "" "An unrelated but handy function that takes a time tuple such as returned by " "the :func:`~time.gmtime` function in the :mod:`time` module, and returns the " @@ -523,142 +588,145 @@ msgid "" "encoding. In fact, :func:`time.gmtime` and :func:`timegm` are each others' " "inverse." msgstr "" -"一個跟日曆無關但方便的函式,它接受一個像 :mod:`time` 模組裡的 :func:`~time." -"gmtime` 函式回傳的元組,並回傳對應的 Unix 時間戳,假設從 1970 開始及 POSIX 編" -"碼。事實上,:func:`time.gmtime` 和 :func:`timegm` 是彼此相反的。" +"一個跟日曆無關但方便的函式,它接受一個像 :mod:`time` 模組裡" +"的 :func:`~time.gmtime` 函式回傳的元組,並回傳對應的 Unix 時間戳,假設從 " +"1970 開始及 POSIX 編碼。事實上,:func:`time.gmtime` 和 :func:`timegm` 是彼此" +"相反的。" -#: ../../library/calendar.rst:392 +#: ../../library/calendar.rst:445 msgid "The :mod:`calendar` module exports the following data attributes:" msgstr ":mod:`calendar` 模組匯出以下資料屬性:" -#: ../../library/calendar.rst:396 -msgid "An array that represents the days of the week in the current locale." -msgstr "以目前語系來表示的一週每一天名稱的陣列。" +#: ../../library/calendar.rst:449 +msgid "" +"A sequence that represents the days of the week in the current locale, where " +"Monday is day number 0." +msgstr "以目前語系來表示的一週每一天名稱的序列,其中週一是第 0 天。" -#: ../../library/calendar.rst:401 +#: ../../library/calendar.rst:459 msgid "" -"An array that represents the abbreviated days of the week in the current " -"locale." -msgstr "以目前語系來表示的一週每一天縮寫名稱的陣列。" +"A sequence that represents the abbreviated days of the week in the current " +"locale, where Mon is day number 0." +msgstr "以目前語系來表示的一週每一天縮寫名稱的序列,其中 Mon 是第 0 天。" -#: ../../library/calendar.rst:412 +#: ../../library/calendar.rst:474 msgid "" "Aliases for the days of the week, where ``MONDAY`` is ``0`` and ``SUNDAY`` " "is ``6``." msgstr "一週每一天的別名,其中 ``MONDAY`` 是 ``0`` 而 ``SUNDAY`` 是 ``6``。" -#: ../../library/calendar.rst:420 +#: ../../library/calendar.rst:482 msgid "" "Enumeration defining days of the week as integer constants. The members of " -"this enumeration are exported to the module scope as :data:`MONDAY` through :" -"data:`SUNDAY`." +"this enumeration are exported to the module scope as :data:`MONDAY` " +"through :data:`SUNDAY`." msgstr "" -"將一週中的幾天定義為整數常數的列舉。此列舉的成員將作為 :data:`MONDAY` 到 :" -"data:`SUNDAY` 匯出到模組作用域。" +"將一週中的幾天定義為整數常數的列舉。此列舉的成員將作為 :data:`MONDAY` " +"到 :data:`SUNDAY` 匯出到模組作用域。" -#: ../../library/calendar.rst:429 +#: ../../library/calendar.rst:491 msgid "" -"An array 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." +"A sequence that represents the months of the year in the current locale. " +"This follows normal convention of January being month number 1, so it has a " +"length of 13 and ``month_name[0]`` is the empty string." msgstr "" -"以目前語系來表示的一年每個月份名稱的陣列。它按照一般慣例以數字 1 代表一月,因" +"以目前語系來表示的一年每個月份名稱的序列。它按照一般慣例以數字 1 代表一月,因" "此它的長度為 13,而 ``month_name[0]`` 是空字串。" -#: ../../library/calendar.rst:436 +#: ../../library/calendar.rst:502 msgid "" -"An array that represents the abbreviated months of the year in the current " +"A sequence that represents the abbreviated months of the year in the current " "locale. This follows normal convention of January being month number 1, so " "it has a length of 13 and ``month_abbr[0]`` is the empty string." msgstr "" -"以目前語系來表示的一年每個月份縮寫名稱的陣列。它按照一般慣例以數字 1 代表一" +"以目前語系來表示的一年每個月份縮寫名稱的序列。它按照一般慣例以數字 1 代表一" "月,因此它的長度為 13,而 ``month_abbr[0]`` 是空字串。" -#: ../../library/calendar.rst:454 +#: ../../library/calendar.rst:523 msgid "" "Aliases for the months of the year, where ``JANUARY`` is ``1`` and " "``DECEMBER`` is ``12``." msgstr "" -"一年內每個月的別名,其中 ``JANUARY`` 是 ``ㄅ`` 而 ``DECEMBER`` 是 ``12``。" +"一年內每個月的別名,其中 ``JANUARY`` 是 ``1`` 而 ``DECEMBER`` 是 ``12``。" -#: ../../library/calendar.rst:462 +#: ../../library/calendar.rst:531 msgid "" "Enumeration defining months of the year as integer constants. The members of " "this enumeration are exported to the module scope as :data:`JANUARY` " "through :data:`DECEMBER`." msgstr "" -"將一年中的月份定義為整數常數的列舉。此列舉的成員將作為 :data:`JANUARY` 到 :" -"data:`DECEMBER` 匯出到模組作用域。" +"將一年中的月份定義為整數常數的列舉。此列舉的成員將作為 :data:`JANUARY` " +"到 :data:`DECEMBER` 匯出到模組作用域。" -#: ../../library/calendar.rst:469 +#: ../../library/calendar.rst:538 msgid "The :mod:`calendar` module defines the following exceptions:" msgstr ":mod:`calendar` 模組定義了以下例外:" -#: ../../library/calendar.rst:473 +#: ../../library/calendar.rst:542 msgid "" "A subclass of :exc:`ValueError`, raised when the given month number is " "outside of the range 1-12 (inclusive)." msgstr "" ":exc:`ValueError` 的子類別,當給定的月份數字超出 1-12 範圍(含)時引發。" -#: ../../library/calendar.rst:478 +#: ../../library/calendar.rst:547 msgid "The invalid month number." msgstr "無效的月份號。" -#: ../../library/calendar.rst:483 +#: ../../library/calendar.rst:552 msgid "" "A subclass of :exc:`ValueError`, raised when the given weekday number is " "outside of the range 0-6 (inclusive)." msgstr "" ":exc:`ValueError` 的子類別,當給定的週幾的數字超出 0-6(含)範圍時引發。" -#: ../../library/calendar.rst:488 +#: ../../library/calendar.rst:557 msgid "The invalid weekday number." msgstr "無效的週幾編號。" -#: ../../library/calendar.rst:493 +#: ../../library/calendar.rst:562 msgid "Module :mod:`datetime`" msgstr ":mod:`datetime` 模組" -#: ../../library/calendar.rst:494 +#: ../../library/calendar.rst:563 msgid "" "Object-oriented interface to dates and times with similar functionality to " "the :mod:`time` module." msgstr "日期與時間的物件導向介面,和 :mod:`time` 模組有相似的功能。" -#: ../../library/calendar.rst:497 +#: ../../library/calendar.rst:566 msgid "Module :mod:`time`" msgstr ":mod:`time` 模組" -#: ../../library/calendar.rst:498 +#: ../../library/calendar.rst:567 msgid "Low-level time related functions." msgstr "底層的時間相關函式。" -#: ../../library/calendar.rst:504 +#: ../../library/calendar.rst:573 msgid "Command-Line Usage" msgstr "命令列用法" -#: ../../library/calendar.rst:508 +#: ../../library/calendar.rst:577 msgid "" "The :mod:`calendar` module can be executed as a script from the command line " "to interactively print a calendar." msgstr ":mod:`calendar` 模組可以作為腳本從命令列執行,並以互動方式列印日曆。" -#: ../../library/calendar.rst:511 +#: ../../library/calendar.rst:580 msgid "" "python -m calendar [-h] [-L LOCALE] [-e ENCODING] [-t {text,html}]\n" " [-w WIDTH] [-l LINES] [-s SPACING] [-m MONTHS] [-c CSS]\n" -" [year] [month]" +" [-f FIRST_WEEKDAY] [year] [month]" msgstr "" "python -m calendar [-h] [-L LOCALE] [-e ENCODING] [-t {text,html}]\n" " [-w WIDTH] [-l LINES] [-s SPACING] [-m MONTHS] [-c CSS]\n" -" [year] [month]" +" [-f FIRST_WEEKDAY] [year] [month]" -#: ../../library/calendar.rst:518 +#: ../../library/calendar.rst:587 msgid "For example, to print a calendar for the year 2000:" msgstr "例如,要列印 2000 年的日曆:" -#: ../../library/calendar.rst:520 +#: ../../library/calendar.rst:589 msgid "" "$ python -m calendar 2000\n" " 2000\n" @@ -736,36 +804,40 @@ msgstr "" "23 24 25 26 27 28 29 27 28 29 30 25 26 27 28 29 30 31\n" "30 31" -#: ../../library/calendar.rst:561 +#: ../../library/calendar.rst:630 msgid "The following options are accepted:" msgstr "接受以下選項:" -#: ../../library/calendar.rst:568 +#: ../../library/calendar.rst:637 msgid "Show the help message and exit." msgstr "顯示幫助訊息並退出。" -#: ../../library/calendar.rst:573 +#: ../../library/calendar.rst:642 msgid "The locale to use for month and weekday names. Defaults to English." msgstr "用於月份和週幾名稱的語系。預設為英語。" -#: ../../library/calendar.rst:579 +#: ../../library/calendar.rst:648 msgid "" -"The encoding to use for output. :option:`--encoding` is required if :option:" -"`--locale` is set." +"The encoding to use for output. :option:`--encoding` is required " +"if :option:`--locale` is set." msgstr "" "用於輸出的編碼。如有設定 :option:`--locale` 則必須給定 :option:`--encoding`。" -#: ../../library/calendar.rst:585 +#: ../../library/calendar.rst:654 msgid "Print the calendar to the terminal as text, or as an HTML document." msgstr "將日曆以文字或 HTML 文件的形式印出到終端機。" -#: ../../library/calendar.rst:591 +#: ../../library/calendar.rst:660 msgid "" -"The year to print the calendar for. Must be a number between 1 and 9999. " -"Defaults to the current year." -msgstr "印出日曆的年份。必須是 1 到 9999 之間的數字。預設為當前年份。" +"The weekday to start each week. Must be a number between 0 (Monday) and 6 " +"(Sunday). Defaults to 0." +msgstr "一週起始的日子。必須是 0(週一)到 6(週日)之間的數字。預設為 0。" + +#: ../../library/calendar.rst:668 +msgid "The year to print the calendar for. Defaults to the current year." +msgstr "印出日曆的年份。預設為目前年份。" -#: ../../library/calendar.rst:598 +#: ../../library/calendar.rst:674 msgid "" "The month of the specified :option:`year` to print the calendar for. Must be " "a number between 1 and 12, and may only be used in text mode. Defaults to " @@ -774,11 +846,11 @@ msgstr "" "要列印日曆的指定 :option:`year` 的月份。必須是 1 到 12 之間的數字,並且只能在" "文字模式下使用。預設列印全年日曆。" -#: ../../library/calendar.rst:604 +#: ../../library/calendar.rst:680 msgid "*Text-mode options:*" msgstr "*文字模式選項:*" -#: ../../library/calendar.rst:608 +#: ../../library/calendar.rst:684 msgid "" "The width of the date column in terminal columns. The date is printed " "centred in the column. Any value lower than 2 is ignored. Defaults to 2." @@ -786,7 +858,7 @@ msgstr "" "終端機行中日期行的寬度。日期印出在行的中央。任何小於 2 的值都會被忽略。預設" "為 2。" -#: ../../library/calendar.rst:616 +#: ../../library/calendar.rst:692 msgid "" "The number of lines for each week in terminal rows. The date is printed top-" "aligned. Any value lower than 1 is ignored. Defaults to 1." @@ -794,21 +866,21 @@ msgstr "" "終端機列中每週的列數。日期印出時頂部會對齊。任何小於 1 的值都會被忽略。預設" "為 1。" -#: ../../library/calendar.rst:624 +#: ../../library/calendar.rst:700 msgid "" "The space between months in columns. Any value lower than 2 is ignored. " "Defaults to 6." msgstr "行中月份之間的間距。任何小於 2 的值都會被忽略。預設為 6。" -#: ../../library/calendar.rst:631 +#: ../../library/calendar.rst:707 msgid "The number of months printed per row. Defaults to 3." msgstr "每列印出的月份數量。預設為 3。" -#: ../../library/calendar.rst:635 +#: ../../library/calendar.rst:711 msgid "*HTML-mode options:*" msgstr "*HTML 模式選項:*" -#: ../../library/calendar.rst:639 +#: ../../library/calendar.rst:715 msgid "" "The path of a CSS stylesheet to use for the calendar. This must either be " "relative to the generated HTML, or an absolute HTTP or ``file:///`` URL." diff --git a/library/cgi.po b/library/cgi.po index fcea153eae..5333d176a0 100644 --- a/library/cgi.po +++ b/library/cgi.po @@ -1,889 +1,48 @@ # Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # -# Translators: +#, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" -"PO-Revision-Date: 2022-05-22 02:01+0800\n" -"Last-Translator: Adrian Liaw \n" +"POT-Creation-Date: 2024-11-18 00:15+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Poedit 3.0.1\n" #: ../../library/cgi.rst:2 -msgid ":mod:`cgi` --- Common Gateway Interface support" -msgstr ":mod:`cgi` --- 通用閘道器介面支援" +msgid ":mod:`!cgi` --- Common Gateway Interface support" +msgstr ":mod:`!cgi` --- 通用閘道器介面支援" -#: ../../library/cgi.rst:8 -msgid "**Source code:** :source:`Lib/cgi.py`" -msgstr "**原始碼:**\\ :source:`Lib/cgi.py`" - -#: ../../library/cgi.rst:18 -msgid "" -"The :mod:`cgi` module is deprecated (see :pep:`PEP 594 <594#cgi>` for " -"details and alternatives)." -msgstr "" -":mod:`cgi` 模組 (module) 即將被棄用(詳情與替代方案請見 :pep:`PEP 594 " -"<594#cgi>`\\ )。" - -#: ../../library/cgi.rst:22 -msgid "" -"The :class:`FieldStorage` class can typically be replaced with :func:`urllib." -"parse.parse_qsl` for ``GET`` and ``HEAD`` requests, and the :mod:`email." -"message` module or :pypi:`multipart` for ``POST`` and ``PUT``. Most :ref:" -"`utility functions ` have replacements." -msgstr "" - -#: ../../library/cgi.rst:30 -msgid "Support module for Common Gateway Interface (CGI) scripts." -msgstr "" - -#: ../../library/cgi.rst:32 -msgid "" -"This module defines a number of utilities for use by CGI scripts written in " -"Python." -msgstr "" - -#: ../../library/cgi.rst:35 -msgid "" -"The global variable ``maxlen`` can be set to an integer indicating the " -"maximum size of a POST request. POST requests larger than this size will " -"result in a :exc:`ValueError` being raised during parsing. The default value " -"of this variable is ``0``, meaning the request size is unlimited." -msgstr "" - -#: ../../includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not Emscripten, not WASI." -msgstr "" - -#: ../../includes/wasm-notavail.rst:5 -msgid "" -"This module does not work or is not available on WebAssembly platforms " -"``wasm32-emscripten`` and ``wasm32-wasi``. See :ref:`wasm-availability` for " -"more information." -msgstr "" -"此模組在 WebAssembly 平台 ``wasm32-emscripten`` 和 ``wasm32-wasi`` 上無法作用" -"或無法使用。有關更多資訊,請參閱 :ref:`wasm-availability`。" - -#: ../../library/cgi.rst:43 -msgid "Introduction" -msgstr "簡介" - -#: ../../library/cgi.rst:47 -msgid "" -"A CGI script is invoked by an HTTP server, usually to process user input " -"submitted through an HTML ``
`` or ```` element." -msgstr "" - -#: ../../library/cgi.rst:50 -msgid "" -"Most often, CGI scripts live in the server's special :file:`cgi-bin` " -"directory. The HTTP server places all sorts of information about the request " -"(such as the client's hostname, the requested URL, the query string, and " -"lots of other goodies) in the script's shell environment, executes the " -"script, and sends the script's output back to the client." -msgstr "" - -#: ../../library/cgi.rst:56 -msgid "" -"The script's input is connected to the client too, and sometimes the form " -"data is read this way; at other times the form data is passed via the " -"\"query string\" part of the URL. This module is intended to take care of " -"the different cases and provide a simpler interface to the Python script. " -"It also provides a number of utilities that help in debugging scripts, and " -"the latest addition is support for file uploads from a form (if your browser " -"supports it)." -msgstr "" - -#: ../../library/cgi.rst:63 -msgid "" -"The output of a CGI script should consist of two sections, separated by a " -"blank line. The first section contains a number of headers, telling the " -"client what kind of data is following. Python code to generate a minimal " -"header section looks like this::" -msgstr "" - -#: ../../library/cgi.rst:68 -msgid "" -"print(\"Content-Type: text/html\") # HTML is following\n" -"print() # blank line, end of headers" -msgstr "" - -#: ../../library/cgi.rst:71 -msgid "" -"The second section is usually HTML, which allows the client software to " -"display nicely formatted text with header, in-line images, etc. Here's " -"Python code that prints a simple piece of HTML::" -msgstr "" - -#: ../../library/cgi.rst:75 -msgid "" -"print(\"CGI script output\")\n" -"print(\"

This is my first CGI script

\")\n" -"print(\"Hello, world!\")" -msgstr "" -"print(\"CGI script output\")\n" -"print(\"

This is my first CGI script

\")\n" -"print(\"Hello, world!\")" - -#: ../../library/cgi.rst:83 -msgid "Using the cgi module" -msgstr "使用 cgi 模組" - -#: ../../library/cgi.rst:85 -msgid "Begin by writing ``import cgi``." -msgstr "" - -#: ../../library/cgi.rst:87 -msgid "When you write a new script, consider adding these lines::" -msgstr "" - -#: ../../library/cgi.rst:89 ../../library/cgi.rst:505 -msgid "" -"import cgitb\n" -"cgitb.enable()" -msgstr "" -"import cgitb\n" -"cgitb.enable()" - -#: ../../library/cgi.rst:92 -msgid "" -"This activates a special exception handler that will display detailed " -"reports in the web browser if any errors occur. If you'd rather not show " -"the guts of your program to users of your script, you can have the reports " -"saved to files instead, with code like this::" -msgstr "" - -#: ../../library/cgi.rst:97 -msgid "" -"import cgitb\n" -"cgitb.enable(display=0, logdir=\"/path/to/logdir\")" -msgstr "" -"import cgitb\n" -"cgitb.enable(display=0, logdir=\"/path/to/logdir\")" - -#: ../../library/cgi.rst:100 -msgid "" -"It's very helpful to use this feature during script development. The reports " -"produced by :mod:`cgitb` provide information that can save you a lot of time " -"in tracking down bugs. You can always remove the ``cgitb`` line later when " -"you have tested your script and are confident that it works correctly." -msgstr "" - -#: ../../library/cgi.rst:105 -msgid "" -"To get at submitted form data, use the :class:`FieldStorage` class. If the " -"form contains non-ASCII characters, use the *encoding* keyword parameter set " -"to the value of the encoding defined for the document. It is usually " -"contained in the META tag in the HEAD section of the HTML document or by " -"the :mailheader:`Content-Type` header. This reads the form contents from " -"the standard input or the environment (depending on the value of various " -"environment variables set according to the CGI standard). Since it may " -"consume standard input, it should be instantiated only once." -msgstr "" - -#: ../../library/cgi.rst:114 -msgid "" -"The :class:`FieldStorage` instance can be indexed like a Python dictionary. " -"It allows membership testing with the :keyword:`in` operator, and also " -"supports the standard dictionary method :meth:`~dict.keys` and the built-in " -"function :func:`len`. Form fields containing empty strings are ignored and " -"do not appear in the dictionary; to keep such values, provide a true value " -"for the optional *keep_blank_values* keyword parameter when creating the :" -"class:`FieldStorage` instance." -msgstr "" - -#: ../../library/cgi.rst:122 -msgid "" -"For instance, the following code (which assumes that the :mailheader:" -"`Content-Type` header and blank line have already been printed) checks that " -"the fields ``name`` and ``addr`` are both set to a non-empty string::" -msgstr "" - -#: ../../library/cgi.rst:127 -msgid "" -"form = cgi.FieldStorage()\n" -"if \"name\" not in form or \"addr\" not in form:\n" -" print(\"

Error

\")\n" -" print(\"Please fill in the name and addr fields.\")\n" -" return\n" -"print(\"

name:\", form[\"name\"].value)\n" -"print(\"

addr:\", form[\"addr\"].value)\n" -"...further form processing here..." -msgstr "" - -#: ../../library/cgi.rst:136 -msgid "" -"Here the fields, accessed through ``form[key]``, are themselves instances " -"of :class:`FieldStorage` (or :class:`MiniFieldStorage`, depending on the " -"form encoding). The :attr:`~FieldStorage.value` attribute of the instance " -"yields the string value of the field. The :meth:`~FieldStorage.getvalue` " -"method returns this string value directly; it also accepts an optional " -"second argument as a default to return if the requested key is not present." -msgstr "" - -#: ../../library/cgi.rst:143 -msgid "" -"If the submitted form data contains more than one field with the same name, " -"the object retrieved by ``form[key]`` is not a :class:`FieldStorage` or :" -"class:`MiniFieldStorage` instance but a list of such instances. Similarly, " -"in this situation, ``form.getvalue(key)`` would return a list of strings. If " -"you expect this possibility (when your HTML form contains multiple fields " -"with the same name), use the :meth:`~FieldStorage.getlist` method, which " -"always returns a list of values (so that you do not need to special-case the " -"single item case). For example, this code concatenates any number of " -"username fields, separated by commas::" -msgstr "" - -#: ../../library/cgi.rst:153 -msgid "" -"value = form.getlist(\"username\")\n" -"usernames = \",\".join(value)" -msgstr "" -"value = form.getlist(\"username\")\n" -"usernames = \",\".join(value)" - -#: ../../library/cgi.rst:156 -msgid "" -"If a field represents an uploaded file, accessing the value via the :attr:" -"`~FieldStorage.value` attribute or the :meth:`~FieldStorage.getvalue` method " -"reads the entire file in memory as bytes. This may not be what you want. " -"You can test for an uploaded file by testing either the :attr:`~FieldStorage." -"filename` attribute or the :attr:`~FieldStorage.file` attribute. You can " -"then read the data from the :attr:`!file` attribute before it is " -"automatically closed as part of the garbage collection of the :class:" -"`FieldStorage` instance (the :func:`~io.RawIOBase.read` and :func:`~io." -"IOBase.readline` methods will return bytes)::" -msgstr "" - -#: ../../library/cgi.rst:167 -msgid "" -"fileitem = form[\"userfile\"]\n" -"if fileitem.file:\n" -" # It's an uploaded file; count lines\n" -" linecount = 0\n" -" while True:\n" -" line = fileitem.file.readline()\n" -" if not line: break\n" -" linecount = linecount + 1" -msgstr "" - -#: ../../library/cgi.rst:176 -msgid "" -":class:`FieldStorage` objects also support being used in a :keyword:`with` " -"statement, which will automatically close them when done." -msgstr "" - -#: ../../library/cgi.rst:179 -msgid "" -"If an error is encountered when obtaining the contents of an uploaded file " -"(for example, when the user interrupts the form submission by clicking on a " -"Back or Cancel button) the :attr:`~FieldStorage.done` attribute of the " -"object for the field will be set to the value -1." -msgstr "" - -#: ../../library/cgi.rst:184 -msgid "" -"The file upload draft standard entertains the possibility of uploading " -"multiple files from one field (using a recursive :mimetype:`multipart/\\*` " -"encoding). When this occurs, the item will be a dictionary-like :class:" -"`FieldStorage` item. This can be determined by testing its :attr:`!type` " -"attribute, which should be :mimetype:`multipart/form-data` (or perhaps " -"another MIME type matching :mimetype:`multipart/\\*`). In this case, it can " -"be iterated over recursively just like the top-level form object." -msgstr "" - -#: ../../library/cgi.rst:192 -msgid "" -"When a form is submitted in the \"old\" format (as the query string or as a " -"single data part of type :mimetype:`application/x-www-form-urlencoded`), the " -"items will actually be instances of the class :class:`MiniFieldStorage`. In " -"this case, the :attr:`!list`, :attr:`!file`, and :attr:`filename` attributes " -"are always ``None``." -msgstr "" - -#: ../../library/cgi.rst:197 -msgid "" -"A form submitted via POST that also has a query string will contain both :" -"class:`FieldStorage` and :class:`MiniFieldStorage` items." -msgstr "" - -#: ../../library/cgi.rst:200 -msgid "" -"The :attr:`~FieldStorage.file` attribute is automatically closed upon the " -"garbage collection of the creating :class:`FieldStorage` instance." -msgstr "" - -#: ../../library/cgi.rst:204 -msgid "" -"Added support for the context management protocol to the :class:" -"`FieldStorage` class." -msgstr "" - -#: ../../library/cgi.rst:210 -msgid "Higher Level Interface" -msgstr "" - -#: ../../library/cgi.rst:212 -msgid "" -"The previous section explains how to read CGI form data using the :class:" -"`FieldStorage` class. This section describes a higher level interface which " -"was added to this class to allow one to do it in a more readable and " -"intuitive way. The interface doesn't make the techniques described in " -"previous sections obsolete --- they are still useful to process file uploads " -"efficiently, for example." -msgstr "" - -#: ../../library/cgi.rst:221 -msgid "" -"The interface consists of two simple methods. Using the methods you can " -"process form data in a generic way, without the need to worry whether only " -"one or more values were posted under one name." -msgstr "" - -#: ../../library/cgi.rst:225 -msgid "" -"In the previous section, you learned to write following code anytime you " -"expected a user to post more than one value under one name::" -msgstr "" - -#: ../../library/cgi.rst:228 -msgid "" -"item = form.getvalue(\"item\")\n" -"if isinstance(item, list):\n" -" # The user is requesting more than one item.\n" -"else:\n" -" # The user is requesting only one item." -msgstr "" - -#: ../../library/cgi.rst:234 -msgid "" -"This situation is common for example when a form contains a group of " -"multiple checkboxes with the same name::" -msgstr "" - -#: ../../library/cgi.rst:237 -msgid "" -"\n" -"" -msgstr "" -"\n" -"" - -#: ../../library/cgi.rst:240 -msgid "" -"In most situations, however, there's only one form control with a particular " -"name in a form and then you expect and need only one value associated with " -"this name. So you write a script containing for example this code::" -msgstr "" - -#: ../../library/cgi.rst:244 -msgid "user = form.getvalue(\"user\").upper()" -msgstr "user = form.getvalue(\"user\").upper()" - -#: ../../library/cgi.rst:246 -msgid "" -"The problem with the code is that you should never expect that a client will " -"provide valid input to your scripts. For example, if a curious user appends " -"another ``user=foo`` pair to the query string, then the script would crash, " -"because in this situation the ``getvalue(\"user\")`` method call returns a " -"list instead of a string. Calling the :meth:`~str.upper` method on a list " -"is not valid (since lists do not have a method of this name) and results in " -"an :exc:`AttributeError` exception." -msgstr "" - -#: ../../library/cgi.rst:254 -msgid "" -"Therefore, the appropriate way to read form data values was to always use " -"the code which checks whether the obtained value is a single value or a list " -"of values. That's annoying and leads to less readable scripts." -msgstr "" - -#: ../../library/cgi.rst:258 -msgid "" -"A more convenient approach is to use the methods :meth:`~FieldStorage." -"getfirst` and :meth:`~FieldStorage.getlist` provided by this higher level " -"interface." -msgstr "" - -#: ../../library/cgi.rst:264 -msgid "" -"This method always returns only one value associated with form field *name*. " -"The method returns only the first value in case that more values were posted " -"under such name. Please note that the order in which the values are " -"received may vary from browser to browser and should not be counted on. " -"[#]_ If no such form field or value exists then the method returns the " -"value specified by the optional parameter *default*. This parameter " -"defaults to ``None`` if not specified." -msgstr "" - -#: ../../library/cgi.rst:275 -msgid "" -"This method always returns a list of values associated with form field " -"*name*. The method returns an empty list if no such form field or value " -"exists for *name*. It returns a list consisting of one item if only one " -"such value exists." -msgstr "" - -#: ../../library/cgi.rst:279 -msgid "Using these methods you can write nice compact code::" -msgstr "" - -#: ../../library/cgi.rst:281 -msgid "" -"import cgi\n" -"form = cgi.FieldStorage()\n" -"user = form.getfirst(\"user\", \"\").upper() # This way it's safe.\n" -"for item in form.getlist(\"item\"):\n" -" do_something(item)" -msgstr "" -"import cgi\n" -"form = cgi.FieldStorage()\n" -"user = form.getfirst(\"user\", \"\").upper() # 這是安全的方式。\n" -"for item in form.getlist(\"item\"):\n" -" do_something(item)" - -#: ../../library/cgi.rst:291 -msgid "Functions" -msgstr "函式" - -#: ../../library/cgi.rst:293 -msgid "" -"These are useful if you want more control, or if you want to employ some of " -"the algorithms implemented in this module in other circumstances." -msgstr "" - -#: ../../library/cgi.rst:299 -msgid "" -"Parse a query in the environment or from a file (the file defaults to ``sys." -"stdin``). The *keep_blank_values*, *strict_parsing* and *separator* " -"parameters are passed to :func:`urllib.parse.parse_qs` unchanged." -msgstr "" - -#: ../../library/cgi.rst:303 -msgid "" -"This function, like the rest of the :mod:`cgi` module, is deprecated. It can " -"be replaced by calling :func:`urllib.parse.parse_qs` directly on the desired " -"query string (except for ``multipart/form-data`` input, which can be handled " -"as described for :func:`parse_multipart`)." -msgstr "" - -#: ../../library/cgi.rst:312 -msgid "" -"Parse input of type :mimetype:`multipart/form-data` (for file uploads). " -"Arguments are *fp* for the input file, *pdict* for a dictionary containing " -"other parameters in the :mailheader:`Content-Type` header, and *encoding*, " -"the request encoding." -msgstr "" - -#: ../../library/cgi.rst:317 -msgid "" -"Returns a dictionary just like :func:`urllib.parse.parse_qs`: keys are the " -"field names, each value is a list of values for that field. For non-file " -"fields, the value is a list of strings." -msgstr "" - -#: ../../library/cgi.rst:321 -msgid "" -"This is easy to use but not much good if you are expecting megabytes to be " -"uploaded --- in that case, use the :class:`FieldStorage` class instead which " -"is much more flexible." -msgstr "" - -#: ../../library/cgi.rst:325 -msgid "" -"Added the *encoding* and *errors* parameters. For non-file fields, the " -"value is now a list of strings, not bytes." -msgstr "" - -#: ../../library/cgi.rst:329 -msgid "Added the *separator* parameter." -msgstr "新增 *separator* 參數。" - -#: ../../library/cgi.rst:332 -msgid "" -"This function, like the rest of the :mod:`cgi` module, is deprecated. It can " -"be replaced with the functionality in the :mod:`email` package (e.g. :class:" -"`email.message.EmailMessage`/:class:`email.message.Message`) which " -"implements the same MIME RFCs, or with the :pypi:`multipart` PyPI project." -msgstr "" - -#: ../../library/cgi.rst:342 -msgid "" -"Parse a MIME header (such as :mailheader:`Content-Type`) into a main value " -"and a dictionary of parameters." -msgstr "" - -#: ../../library/cgi.rst:345 -msgid "" -"This function, like the rest of the :mod:`cgi` module, is deprecated. It can " -"be replaced with the functionality in the :mod:`email` package, which " -"implements the same MIME RFCs." -msgstr "" - -#: ../../library/cgi.rst:350 -msgid "For example, with :class:`email.message.EmailMessage`::" -msgstr "" - -#: ../../library/cgi.rst:352 -msgid "" -"from email.message import EmailMessage\n" -"msg = EmailMessage()\n" -"msg['content-type'] = 'application/json; charset=\"utf8\"'\n" -"main, params = msg.get_content_type(), msg['content-type'].params" -msgstr "" -"from email.message import EmailMessage\n" -"msg = EmailMessage()\n" -"msg['content-type'] = 'application/json; charset=\"utf8\"'\n" -"main, params = msg.get_content_type(), msg['content-type'].params" - -#: ../../library/cgi.rst:360 -msgid "" -"Robust test CGI script, usable as main program. Writes minimal HTTP headers " -"and formats all information provided to the script in HTML format." -msgstr "" - -#: ../../library/cgi.rst:366 -msgid "Format the shell environment in HTML." -msgstr "" - -#: ../../library/cgi.rst:371 -msgid "Format a form in HTML." -msgstr "" - -#: ../../library/cgi.rst:376 -msgid "Format the current directory in HTML." -msgstr "" - -#: ../../library/cgi.rst:381 -msgid "Print a list of useful (used by CGI) environment variables in HTML." -msgstr "" - -#: ../../library/cgi.rst:387 -msgid "Caring about security" -msgstr "" - -#: ../../library/cgi.rst:391 -msgid "" -"There's one important rule: if you invoke an external program (via :func:`os." -"system`, :func:`os.popen` or other functions with similar functionality), " -"make very sure you don't pass arbitrary strings received from the client to " -"the shell. This is a well-known security hole whereby clever hackers " -"anywhere on the web can exploit a gullible CGI script to invoke arbitrary " -"shell commands. Even parts of the URL or field names cannot be trusted, " -"since the request doesn't have to come from your form!" -msgstr "" - -#: ../../library/cgi.rst:399 -msgid "" -"To be on the safe side, if you must pass a string gotten from a form to a " -"shell command, you should make sure the string contains only alphanumeric " -"characters, dashes, underscores, and periods." -msgstr "" - -#: ../../library/cgi.rst:405 -msgid "Installing your CGI script on a Unix system" -msgstr "" - -#: ../../library/cgi.rst:407 -msgid "" -"Read the documentation for your HTTP server and check with your local system " -"administrator to find the directory where CGI scripts should be installed; " -"usually this is in a directory :file:`cgi-bin` in the server tree." -msgstr "" - -#: ../../library/cgi.rst:411 -msgid "" -"Make sure that your script is readable and executable by \"others\"; the " -"Unix file mode should be ``0o755`` octal (use ``chmod 0755 filename``). " -"Make sure that the first line of the script contains ``#!`` starting in " -"column 1 followed by the pathname of the Python interpreter, for instance::" -msgstr "" - -#: ../../library/cgi.rst:416 -msgid "#!/usr/local/bin/python" -msgstr "#!/usr/local/bin/python" - -#: ../../library/cgi.rst:418 -msgid "" -"Make sure the Python interpreter exists and is executable by \"others\"." -msgstr "" - -#: ../../library/cgi.rst:420 -msgid "" -"Make sure that any files your script needs to read or write are readable or " -"writable, respectively, by \"others\" --- their mode should be ``0o644`` for " -"readable and ``0o666`` for writable. This is because, for security reasons, " -"the HTTP server executes your script as user \"nobody\", without any special " -"privileges. It can only read (write, execute) files that everybody can read " -"(write, execute). The current directory at execution time is also different " -"(it is usually the server's cgi-bin directory) and the set of environment " -"variables is also different from what you get when you log in. In " -"particular, don't count on the shell's search path for executables (:envvar:" -"`PATH`) or the Python module search path (:envvar:`PYTHONPATH`) to be set to " -"anything interesting." -msgstr "" - -#: ../../library/cgi.rst:431 -msgid "" -"If you need to load modules from a directory which is not on Python's " -"default module search path, you can change the path in your script, before " -"importing other modules. For example::" -msgstr "" - -#: ../../library/cgi.rst:435 -msgid "" -"import sys\n" -"sys.path.insert(0, \"/usr/home/joe/lib/python\")\n" -"sys.path.insert(0, \"/usr/local/lib/python\")" -msgstr "" -"import sys\n" -"sys.path.insert(0, \"/usr/home/joe/lib/python\")\n" -"sys.path.insert(0, \"/usr/local/lib/python\")" - -#: ../../library/cgi.rst:439 -msgid "(This way, the directory inserted last will be searched first!)" -msgstr "" - -#: ../../library/cgi.rst:441 -msgid "" -"Instructions for non-Unix systems will vary; check your HTTP server's " -"documentation (it will usually have a section on CGI scripts)." -msgstr "" - -#: ../../library/cgi.rst:446 -msgid "Testing your CGI script" -msgstr "" - -#: ../../library/cgi.rst:448 -msgid "" -"Unfortunately, a CGI script will generally not run when you try it from the " -"command line, and a script that works perfectly from the command line may " -"fail mysteriously when run from the server. There's one reason why you " -"should still test your script from the command line: if it contains a syntax " -"error, the Python interpreter won't execute it at all, and the HTTP server " -"will most likely send a cryptic error to the client." -msgstr "" - -#: ../../library/cgi.rst:455 -msgid "" -"Assuming your script has no syntax errors, yet it does not work, you have no " -"choice but to read the next section." -msgstr "" - -#: ../../library/cgi.rst:460 -msgid "Debugging CGI scripts" -msgstr "" - -#: ../../library/cgi.rst:464 -msgid "" -"First of all, check for trivial installation errors --- reading the section " -"above on installing your CGI script carefully can save you a lot of time. " -"If you wonder whether you have understood the installation procedure " -"correctly, try installing a copy of this module file (:file:`cgi.py`) as a " -"CGI script. When invoked as a script, the file will dump its environment " -"and the contents of the form in HTML format. Give it the right mode etc., " -"and send it a request. If it's installed in the standard :file:`cgi-bin` " -"directory, it should be possible to send it a request by entering a URL into " -"your browser of the form:" -msgstr "" - -#: ../../library/cgi.rst:473 -msgid "http://yourhostname/cgi-bin/cgi.py?name=Joe+Blow&addr=At+Home" -msgstr "http://yourhostname/cgi-bin/cgi.py?name=Joe+Blow&addr=At+Home" - -#: ../../library/cgi.rst:477 -msgid "" -"If this gives an error of type 404, the server cannot find the script -- " -"perhaps you need to install it in a different directory. If it gives " -"another error, there's an installation problem that you should fix before " -"trying to go any further. If you get a nicely formatted listing of the " -"environment and form content (in this example, the fields should be listed " -"as \"addr\" with value \"At Home\" and \"name\" with value \"Joe Blow\"), " -"the :file:`cgi.py` script has been installed correctly. If you follow the " -"same procedure for your own script, you should now be able to debug it." -msgstr "" - -#: ../../library/cgi.rst:486 -msgid "" -"The next step could be to call the :mod:`cgi` module's :func:`test` function " -"from your script: replace its main code with the single statement ::" -msgstr "" - -#: ../../library/cgi.rst:489 -msgid "cgi.test()" -msgstr "cgi.test()" - -#: ../../library/cgi.rst:491 -msgid "" -"This should produce the same results as those gotten from installing the :" -"file:`cgi.py` file itself." -msgstr "" - -#: ../../library/cgi.rst:494 -msgid "" -"When an ordinary Python script raises an unhandled exception (for whatever " -"reason: of a typo in a module name, a file that can't be opened, etc.), the " -"Python interpreter prints a nice traceback and exits. While the Python " -"interpreter will still do this when your CGI script raises an exception, " -"most likely the traceback will end up in one of the HTTP server's log files, " -"or be discarded altogether." -msgstr "" - -#: ../../library/cgi.rst:501 -msgid "" -"Fortunately, once you have managed to get your script to execute *some* " -"code, you can easily send tracebacks to the web browser using the :mod:" -"`cgitb` module. If you haven't done so already, just add the lines::" -msgstr "" - -#: ../../library/cgi.rst:508 -msgid "" -"to the top of your script. Then try running it again; when a problem " -"occurs, you should see a detailed report that will likely make apparent the " -"cause of the crash." -msgstr "" - -#: ../../library/cgi.rst:512 -msgid "" -"If you suspect that there may be a problem in importing the :mod:`cgitb` " -"module, you can use an even more robust approach (which only uses built-in " -"modules)::" -msgstr "" - -#: ../../library/cgi.rst:515 -msgid "" -"import sys\n" -"sys.stderr = sys.stdout\n" -"print(\"Content-Type: text/plain\")\n" -"print()\n" -"...your code here..." -msgstr "" - -#: ../../library/cgi.rst:521 -msgid "" -"This relies on the Python interpreter to print the traceback. The content " -"type of the output is set to plain text, which disables all HTML " -"processing. If your script works, the raw HTML will be displayed by your " -"client. If it raises an exception, most likely after the first two lines " -"have been printed, a traceback will be displayed. Because no HTML " -"interpretation is going on, the traceback will be readable." -msgstr "" - -#: ../../library/cgi.rst:530 -msgid "Common problems and solutions" -msgstr "" - -#: ../../library/cgi.rst:532 -msgid "" -"Most HTTP servers buffer the output from CGI scripts until the script is " -"completed. This means that it is not possible to display a progress report " -"on the client's display while the script is running." -msgstr "" - -#: ../../library/cgi.rst:536 -msgid "Check the installation instructions above." -msgstr "" - -#: ../../library/cgi.rst:538 -msgid "" -"Check the HTTP server's log files. (``tail -f logfile`` in a separate " -"window may be useful!)" -msgstr "" - -#: ../../library/cgi.rst:541 -msgid "" -"Always check a script for syntax errors first, by doing something like " -"``python script.py``." -msgstr "" - -#: ../../library/cgi.rst:544 -msgid "" -"If your script does not have any syntax errors, try adding ``import cgitb; " -"cgitb.enable()`` to the top of the script." -msgstr "" - -#: ../../library/cgi.rst:547 -msgid "" -"When invoking external programs, make sure they can be found. Usually, this " -"means using absolute path names --- :envvar:`PATH` is usually not set to a " -"very useful value in a CGI script." -msgstr "" - -#: ../../library/cgi.rst:551 +#: ../../library/cgi.rst:10 msgid "" -"When reading or writing external files, make sure they can be read or " -"written by the userid under which your CGI script will be running: this is " -"typically the userid under which the web server is running, or some " -"explicitly specified userid for a web server's ``suexec`` feature." +"This module is no longer part of the Python standard library. It was :ref:" +"`removed in Python 3.13 ` after being deprecated in " +"Python 3.11. The removal was decided in :pep:`594`." msgstr "" +"這個模組已不再是 Python 標準函式庫的一部分。它在 Python 3.11 中被棄用,並\\ :" +"ref:`已在 Python 3.13 中被移除 `。它的移除是在 :pep:" +"`594` 中決定的。" -#: ../../library/cgi.rst:556 +#: ../../library/cgi.rst:14 msgid "" -"Don't try to give a CGI script a set-uid mode. This doesn't work on most " -"systems, and is a security liability as well." +"A fork of the module on PyPI can be used instead: :pypi:`legacy-cgi`. This " +"is a copy of the cgi module, no longer maintained or supported by the core " +"Python team." msgstr "" +"可以改用 PyPI 上的模組 fork::pypi:`legacy-cgi`。這是 cgi 模組的一個副本,不" +"再由 Python 核心團隊維護或支援。" -#: ../../library/cgi.rst:560 -msgid "Footnotes" -msgstr "註解" - -#: ../../library/cgi.rst:561 +#: ../../library/cgi.rst:18 msgid "" -"Note that some recent versions of the HTML specification do state what order " -"the field values should be supplied in, but knowing whether a request was " -"received from a conforming browser, or even from a browser at all, is " -"tedious and error-prone." +"The last version of Python that provided the :mod:`!cgi` module was `Python " +"3.12 `_." msgstr "" - -#: ../../library/cgi.rst:10 -msgid "WWW" -msgstr "WWW" - -#: ../../library/cgi.rst:10 -msgid "server" -msgstr "server(伺服器)" - -#: ../../library/cgi.rst:10 ../../library/cgi.rst:389 ../../library/cgi.rst:462 -msgid "CGI" -msgstr "CGI" - -#: ../../library/cgi.rst:10 -msgid "protocol" -msgstr "protocol(協定)" - -#: ../../library/cgi.rst:10 -msgid "HTTP" -msgstr "HTTP" - -#: ../../library/cgi.rst:10 -msgid "MIME" -msgstr "MIME" - -#: ../../library/cgi.rst:10 -msgid "headers" -msgstr "headers(標頭)" - -#: ../../library/cgi.rst:10 -msgid "URL" -msgstr "URL(統一資源定位器)" - -#: ../../library/cgi.rst:10 -msgid "Common Gateway Interface" -msgstr "Common Gateway Interface(通用閘道器介面)" - -#: ../../library/cgi.rst:389 -msgid "security" -msgstr "security(安全)" - -#: ../../library/cgi.rst:462 -msgid "debugging" -msgstr "debugging(除錯)" +"最後提供 :mod:`!cgi` 模組的 Python 版本是 `Python 3.12 `_。" diff --git a/library/cgitb.po b/library/cgitb.po index e297a5cfee..bc357c01ba 100644 --- a/library/cgitb.po +++ b/library/cgitb.po @@ -1,137 +1,48 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # -# Translators: +#, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" -"PO-Revision-Date: 2022-05-22 02:02+0800\n" -"Last-Translator: Liang-Bo Wang \n" +"POT-Creation-Date: 2024-11-18 00:15+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Poedit 3.0.1\n" #: ../../library/cgitb.rst:2 -msgid ":mod:`cgitb` --- Traceback manager for CGI scripts" -msgstr ":mod:`cgitb` --- CGI 腳本的回溯 (traceback) 管理程式" +msgid ":mod:`!cgitb` --- Traceback manager for CGI scripts" +msgstr ":mod:`!cgitb` --- CGI 腳本的回溯管理器 (traceback manager)" -#: ../../library/cgitb.rst:11 -msgid "**Source code:** :source:`Lib/cgitb.py`" -msgstr "**原始碼:**\\ :source:`Lib/cgitb.py`" - -#: ../../library/cgitb.rst:19 -msgid "" -"The :mod:`cgitb` module is deprecated (see :pep:`PEP 594 <594#cgitb>` for " -"details)." -msgstr "" -":mod:`cgitb` 模組 (module) 即將被棄用(詳見 :pep:`PEP 594 <594#cgitb>`\\ )。" - -#: ../../library/cgitb.rst:25 -msgid "" -"The :mod:`cgitb` module provides a special exception handler for Python " -"scripts. (Its name is a bit misleading. It was originally designed to " -"display extensive traceback information in HTML for CGI scripts. It was " -"later generalized to also display this information in plain text.) After " -"this module is activated, if an uncaught exception occurs, a detailed, " -"formatted report will be displayed. The report includes a traceback showing " -"excerpts of the source code for each level, as well as the values of the " -"arguments and local variables to currently running functions, to help you " -"debug the problem. Optionally, you can save this information to a file " -"instead of sending it to the browser." -msgstr "" - -#: ../../library/cgitb.rst:35 -msgid "To enable this feature, simply add this to the top of your CGI script::" -msgstr "" - -#: ../../library/cgitb.rst:37 -msgid "" -"import cgitb\n" -"cgitb.enable()" -msgstr "" -"import cgitb\n" -"cgitb.enable()" - -#: ../../library/cgitb.rst:40 -msgid "" -"The options to the :func:`enable` function control whether the report is " -"displayed in the browser and whether the report is logged to a file for " -"later analysis." -msgstr "" - -#: ../../library/cgitb.rst:49 +#: ../../library/cgitb.rst:10 msgid "" -"This function causes the :mod:`cgitb` module to take over the interpreter's " -"default handling for exceptions by setting the value of :attr:`sys." -"excepthook`." +"This module is no longer part of the Python standard library. It was :ref:" +"`removed in Python 3.13 ` after being deprecated in " +"Python 3.11. The removal was decided in :pep:`594`." msgstr "" +"這個模組已不再是 Python 標準函式庫的一部分。它在 Python 3.11 中被棄用,並\\ :" +"ref:`已在 Python 3.13 中被移除 `。它的移除是在 :pep:" +"`594` 中決定的。" -#: ../../library/cgitb.rst:52 +#: ../../library/cgitb.rst:14 msgid "" -"The optional argument *display* defaults to ``1`` and can be set to ``0`` to " -"suppress sending the traceback to the browser. If the argument *logdir* is " -"present, the traceback reports are written to files. The value of *logdir* " -"should be a directory where these files will be placed. The optional " -"argument *context* is the number of lines of context to display around the " -"current line of source code in the traceback; this defaults to ``5``. If the " -"optional argument *format* is ``\"html\"``, the output is formatted as " -"HTML. Any other value forces plain text output. The default value is " -"``\"html\"``." +"A fork of the module on PyPI can now be used instead: :pypi:`legacy-cgi`. " +"This is a copy of the cgi module, no longer maintained or supported by the " +"core Python team." msgstr "" +"可以改用 PyPI 上的模組 fork::pypi:`legacy-cgi`。這是 cgi 模組的一個複本,不" +"再由 Python 核心團隊維護或支援。" -#: ../../library/cgitb.rst:64 +#: ../../library/cgitb.rst:18 msgid "" -"This function handles the exception described by *info* (a 3-tuple " -"containing the result of :func:`sys.exc_info`), formatting its traceback as " -"text and returning the result as a string. The optional argument *context* " -"is the number of lines of context to display around the current line of " -"source code in the traceback; this defaults to ``5``." +"The last version of Python that provided the :mod:`!cgitb` module was " +"`Python 3.12 `_." msgstr "" - -#: ../../library/cgitb.rst:73 -msgid "" -"This function handles the exception described by *info* (a 3-tuple " -"containing the result of :func:`sys.exc_info`), formatting its traceback as " -"HTML and returning the result as a string. The optional argument *context* " -"is the number of lines of context to display around the current line of " -"source code in the traceback; this defaults to ``5``." -msgstr "" - -#: ../../library/cgitb.rst:82 -msgid "" -"This function handles an exception using the default settings (that is, show " -"a report in the browser, but don't log to a file). This can be used when " -"you've caught an exception and want to report it using :mod:`cgitb`. The " -"optional *info* argument should be a 3-tuple containing an exception type, " -"exception value, and traceback object, exactly like the tuple returned by :" -"func:`sys.exc_info`. If the *info* argument is not supplied, the current " -"exception is obtained from :func:`sys.exc_info`." -msgstr "" - -#: ../../library/cgitb.rst:13 -msgid "CGI" -msgstr "CGI" - -#: ../../library/cgitb.rst:13 -msgid "exceptions" -msgstr "exceptions(例外)" - -#: ../../library/cgitb.rst:13 -msgid "tracebacks" -msgstr "tracebacks(回溯)" - -#: ../../library/cgitb.rst:13 -msgid "in CGI scripts" -msgstr "於 CGI 腳本中" - -#: ../../library/cgitb.rst:47 -msgid "excepthook() (in module sys)" -msgstr "excepthook() (sys 模組中)" +"最後提供 :mod:`!cgitb` 模組的 Python 版本是 `Python 3.12 `_。" diff --git a/library/chunk.po b/library/chunk.po index 23d9a59322..981361eca2 100644 --- a/library/chunk.po +++ b/library/chunk.po @@ -1,225 +1,39 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # -# Translators: +#, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-07-20 00:03+0000\n" -"PO-Revision-Date: 2022-05-22 02:03+0800\n" -"Last-Translator: Liang-Bo Wang \n" +"POT-Creation-Date: 2024-11-18 00:15+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Poedit 3.0.1\n" #: ../../library/chunk.rst:2 -msgid ":mod:`chunk` --- Read IFF chunked data" -msgstr ":mod:`chunk` --- 讀取 IFF 分塊資料" +msgid ":mod:`!chunk` --- Read IFF chunked data" +msgstr ":mod:`!chunk` --- 讀取 IFF 分塊資料" -#: ../../library/chunk.rst:11 -msgid "**Source code:** :source:`Lib/chunk.py`" -msgstr "**原始碼:**\\ :source:`Lib/chunk.py`" - -#: ../../library/chunk.rst:20 -msgid "" -"The :mod:`chunk` module is deprecated (see :pep:`PEP 594 <594#chunk>` for " -"details)." -msgstr "" -":mod:`chunk` 模組 (module) 即將被棄用(詳見 :pep:`PEP 594 <594#chunk>`\\ )。" - -#: ../../library/chunk.rst:26 -msgid "" -"This module provides an interface for reading files that use EA IFF 85 " -"chunks. [#]_ This format is used in at least the Audio Interchange File " -"Format (AIFF/AIFF-C) and the Real Media File Format (RMFF). The WAVE audio " -"file format is closely related and can also be read using this module." -msgstr "" - -#: ../../library/chunk.rst:31 -msgid "A chunk has the following structure:" -msgstr "" - -#: ../../library/chunk.rst:34 -msgid "Offset" -msgstr "" - -#: ../../library/chunk.rst:34 -msgid "Length" -msgstr "長度" - -#: ../../library/chunk.rst:34 -msgid "Contents" -msgstr "內容" - -#: ../../library/chunk.rst:36 -msgid "0" -msgstr "0" - -#: ../../library/chunk.rst:36 ../../library/chunk.rst:38 -msgid "4" -msgstr "4" - -#: ../../library/chunk.rst:36 -msgid "Chunk ID" -msgstr "" - -#: ../../library/chunk.rst:38 -msgid "Size of chunk in big-endian byte order, not including the header" -msgstr "" - -#: ../../library/chunk.rst:42 -msgid "8" -msgstr "8" - -#: ../../library/chunk.rst:42 -msgid "*n*" -msgstr "*n*" - -#: ../../library/chunk.rst:42 -msgid "Data bytes, where *n* is the size given in the preceding field" -msgstr "" - -#: ../../library/chunk.rst:46 -msgid "8 + *n*" -msgstr "8 + *n*" - -#: ../../library/chunk.rst:46 -msgid "0 or 1" -msgstr "0 或 1" - -#: ../../library/chunk.rst:46 -msgid "Pad byte needed if *n* is odd and chunk alignment is used" -msgstr "" - -#: ../../library/chunk.rst:50 -msgid "The ID is a 4-byte string which identifies the type of chunk." -msgstr "" - -#: ../../library/chunk.rst:52 -msgid "" -"The size field (a 32-bit value, encoded using big-endian byte order) gives " -"the size of the chunk data, not including the 8-byte header." -msgstr "" - -#: ../../library/chunk.rst:55 +#: ../../library/chunk.rst:10 msgid "" -"Usually an IFF-type file consists of one or more chunks. The proposed usage " -"of the :class:`Chunk` class defined here is to instantiate an instance at " -"the start of each chunk and read from the instance until it reaches the end, " -"after which a new instance can be instantiated. At the end of the file, " -"creating a new instance will fail with an :exc:`EOFError` exception." +"This module is no longer part of the Python standard library. It was :ref:" +"`removed in Python 3.13 ` after being deprecated in " +"Python 3.11. The removal was decided in :pep:`594`." msgstr "" +"這個模組已不再是 Python 標準函式庫的一部分。它在 Python 3.11 中被棄用,並\\ :" +"ref:`已在 Python 3.13 中被移除 `。它的移除是在 :pep:" +"`594` 中決定的。" -#: ../../library/chunk.rst:64 +#: ../../library/chunk.rst:14 msgid "" -"Class which represents a chunk. The *file* argument is expected to be a " -"file-like object. An instance of this class is specifically allowed. The " -"only method that is needed is :meth:`~io.IOBase.read`. If the methods :meth:" -"`~io.IOBase.seek` and :meth:`~io.IOBase.tell` are present and don't raise an " -"exception, they are also used. If these methods are present and raise an " -"exception, they are expected to not have altered the object. If the " -"optional argument *align* is true, chunks are assumed to be aligned on 2-" -"byte boundaries. If *align* is false, no alignment is assumed. The default " -"value is true. If the optional argument *bigendian* is false, the chunk " -"size is assumed to be in little-endian order. This is needed for WAVE audio " -"files. The default value is true. If the optional argument *inclheader* is " -"true, the size given in the chunk header includes the size of the header. " -"The default value is false." -msgstr "" - -#: ../../library/chunk.rst:78 -msgid "A :class:`Chunk` object supports the following methods:" +"The last version of Python that provided the :mod:`!chunk` module was " +"`Python 3.12 `_." msgstr "" - -#: ../../library/chunk.rst:83 -msgid "" -"Returns the name (ID) of the chunk. This is the first 4 bytes of the chunk." -msgstr "" - -#: ../../library/chunk.rst:89 -msgid "Returns the size of the chunk." -msgstr "" - -#: ../../library/chunk.rst:94 -msgid "" -"Close and skip to the end of the chunk. This does not close the underlying " -"file." -msgstr "" - -#: ../../library/chunk.rst:97 -msgid "" -"The remaining methods will raise :exc:`OSError` if called after the :meth:" -"`close` method has been called. Before Python 3.3, they used to raise :exc:" -"`IOError`, now an alias of :exc:`OSError`." -msgstr "" - -#: ../../library/chunk.rst:104 -msgid "Returns ``False``." -msgstr "" - -#: ../../library/chunk.rst:109 -msgid "" -"Set the chunk's current position. The *whence* argument is optional and " -"defaults to ``0`` (absolute file positioning); other values are ``1`` (seek " -"relative to the current position) and ``2`` (seek relative to the file's " -"end). There is no return value. If the underlying file does not allow seek, " -"only forward seeks are allowed." -msgstr "" - -#: ../../library/chunk.rst:118 -msgid "Return the current position into the chunk." -msgstr "" - -#: ../../library/chunk.rst:123 -msgid "" -"Read at most *size* bytes from the chunk (less if the read hits the end of " -"the chunk before obtaining *size* bytes). If the *size* argument is " -"negative or omitted, read all data until the end of the chunk. An empty " -"bytes object is returned when the end of the chunk is encountered " -"immediately." -msgstr "" - -#: ../../library/chunk.rst:132 -msgid "" -"Skip to the end of the chunk. All further calls to :meth:`read` for the " -"chunk will return ``b''``. If you are not interested in the contents of the " -"chunk, this method should be called so that the file points to the start of " -"the next chunk." -msgstr "" - -#: ../../library/chunk.rst:139 -msgid "Footnotes" -msgstr "註解" - -#: ../../library/chunk.rst:140 -msgid "" -"\"EA IFF 85\" Standard for Interchange Format Files, Jerry Morrison, " -"Electronic Arts, January 1985." -msgstr "" - -#: ../../library/chunk.rst:13 -msgid "Audio Interchange File Format" -msgstr "Audio Interchange File Format(音訊交換檔案格式)" - -#: ../../library/chunk.rst:13 -msgid "AIFF" -msgstr "AIFF" - -#: ../../library/chunk.rst:13 -msgid "AIFF-C" -msgstr "AIFF-C" - -#: ../../library/chunk.rst:13 -msgid "Real Media File Format" -msgstr "Real Media File Format(Real Media 檔案格式)" - -#: ../../library/chunk.rst:13 -msgid "RMFF" -msgstr "RMFF" +"最後提供 :mod:`!chunk` 模組的 Python 版本是 `Python 3.12 `_。" diff --git a/library/cmath.po b/library/cmath.po index ae115ae058..6d410bc6c9 100644 --- a/library/cmath.po +++ b/library/cmath.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-04-07 00:15+0000\n" "PO-Revision-Date: 2024-03-14 09:26+0800\n" "Last-Translator: Enkai Huang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -34,9 +33,9 @@ msgid "" "result of the conversion." msgstr "" "本模組提供一些適用於複數的數學函式。本模組中的函式接受整數、浮點數或複數作為" -"引數。它們也接受任何具有 :meth:`~object.__complex__` 或 :meth:`~object." -"__float__` 方法的 Python 物件:這些方法分別用於將物件轉換為複數或浮點數,然後" -"再將函式應用於轉換後的結果。" +"引數。它們也接受任何具有 :meth:`~object.__complex__` " +"或 :meth:`~object.__float__` 方法的 Python 物件:這些方法分別用於將物件轉換為" +"複數或浮點數,然後再將函式應用於轉換後的結果。" #: ../../library/cmath.rst:18 msgid "" @@ -88,19 +87,283 @@ msgstr "" "1.4142135623730951j" #: ../../library/cmath.rst:42 +msgid "**Conversions to and from polar coordinates**" +msgstr "**轉換到極座標和從極座標做轉換**" + +#: ../../library/cmath.rst:44 +msgid ":func:`phase(z) `" +msgstr ":func:`phase(z) `" + +#: ../../library/cmath.rst:44 +msgid "Return the phase of *z*" +msgstr "回傳 *z* 的相位角。" + +#: ../../library/cmath.rst:45 +msgid ":func:`polar(z) `" +msgstr ":func:`polar(z) `" + +#: ../../library/cmath.rst:45 +msgid "Return the representation of *z* in polar coordinates" +msgstr "回傳 *z* 在極座標中的表達方式。" + +#: ../../library/cmath.rst:46 +msgid ":func:`rect(r, phi) `" +msgstr ":func:`rect(r, phi) `" + +#: ../../library/cmath.rst:46 +msgid "Return the complex number *z* with polar coordinates *r* and *phi*" +msgstr "透過極座標 *r* 和 *phi* 回傳複數 *z*。" + +#: ../../library/cmath.rst:48 +msgid "**Power and logarithmic functions**" +msgstr "**冪函數和對數函數**" + +#: ../../library/cmath.rst:50 +msgid ":func:`exp(z) `" +msgstr ":func:`exp(z) `" + +#: ../../library/cmath.rst:50 +msgid "Return *e* raised to the power *z*" +msgstr "回傳 *e* 的 *z* 次方。" + +#: ../../library/cmath.rst:51 +msgid ":func:`log(z[, base]) `" +msgstr ":func:`log(z[, base]) `" + +#: ../../library/cmath.rst:51 +msgid "Return the logarithm of *z* to the given *base* (*e* by default)" +msgstr "回傳 *z* 以給定 *base* 為底(預設為 *e*)的對數。" + +#: ../../library/cmath.rst:52 +msgid ":func:`log10(z) `" +msgstr ":func:`log10(z) `" + +#: ../../library/cmath.rst:52 +msgid "Return the base-10 logarithm of *z*" +msgstr "回傳 *z* 以 10 為底的對數。" + +#: ../../library/cmath.rst:53 +msgid ":func:`sqrt(z) `" +msgstr ":func:`sqrt(z) `" + +#: ../../library/cmath.rst:53 +msgid "Return the square root of *z*" +msgstr "回傳 *z* 的平方根。" + +#: ../../library/cmath.rst:55 +msgid "**Trigonometric functions**" +msgstr "**三角函數**" + +#: ../../library/cmath.rst:57 +msgid ":func:`acos(z) `" +msgstr ":func:`acos(z) `" + +#: ../../library/cmath.rst:57 +msgid "Return the arc cosine of *z*" +msgstr "回傳 *z* 的反餘弦值。" + +#: ../../library/cmath.rst:58 +msgid ":func:`asin(z) `" +msgstr ":func:`asin(z) `" + +#: ../../library/cmath.rst:58 +msgid "Return the arc sine of *z*" +msgstr "回傳 *z* 的反正弦值。" + +#: ../../library/cmath.rst:59 +msgid ":func:`atan(z) `" +msgstr ":func:`atan(z) `" + +#: ../../library/cmath.rst:59 +msgid "Return the arc tangent of *z*" +msgstr "回傳 *z* 的反正切值。" + +#: ../../library/cmath.rst:60 +msgid ":func:`cos(z) `" +msgstr ":func:`cos(z) `" + +#: ../../library/cmath.rst:60 +msgid "Return the cosine of *z*" +msgstr "回傳 *z* 的餘弦值。" + +#: ../../library/cmath.rst:61 +msgid ":func:`sin(z) `" +msgstr ":func:`sin(z) `" + +#: ../../library/cmath.rst:61 +msgid "Return the sine of *z*" +msgstr "回傳 *z* 的正弦值。" + +#: ../../library/cmath.rst:62 +msgid ":func:`tan(z) `" +msgstr ":func:`tan(z) `" + +#: ../../library/cmath.rst:62 +msgid "Return the tangent of *z*" +msgstr "回傳 *z* 的正切值。" + +#: ../../library/cmath.rst:64 +msgid "**Hyperbolic functions**" +msgstr "**雙曲函數**" + +#: ../../library/cmath.rst:66 +msgid ":func:`acosh(z) `" +msgstr ":func:`acosh(z) `" + +#: ../../library/cmath.rst:66 +msgid "Return the inverse hyperbolic cosine of *z*" +msgstr "回傳 *z* 的反雙曲餘弦值。" + +#: ../../library/cmath.rst:67 +msgid ":func:`asinh(z) `" +msgstr ":func:`asinh(z) `" + +#: ../../library/cmath.rst:67 +msgid "Return the inverse hyperbolic sine of *z*" +msgstr "回傳 *z* 的反雙曲正弦值。" + +#: ../../library/cmath.rst:68 +msgid ":func:`atanh(z) `" +msgstr ":func:`atanh(z) `" + +#: ../../library/cmath.rst:68 +msgid "Return the inverse hyperbolic tangent of *z*" +msgstr "回傳 *z* 的反雙曲正切值。" + +#: ../../library/cmath.rst:69 +msgid ":func:`cosh(z) `" +msgstr ":func:`cosh(z) `" + +#: ../../library/cmath.rst:69 +msgid "Return the hyperbolic cosine of *z*" +msgstr "回傳 *z* 的雙曲餘弦值。" + +#: ../../library/cmath.rst:70 +msgid ":func:`sinh(z) `" +msgstr ":func:`sinh(z) `" + +#: ../../library/cmath.rst:70 +msgid "Return the hyperbolic sine of *z*" +msgstr "回傳 *z* 的雙曲正弦值。" + +#: ../../library/cmath.rst:71 +msgid ":func:`tanh(z) `" +msgstr ":func:`tanh(z) `" + +#: ../../library/cmath.rst:71 +msgid "Return the hyperbolic tangent of *z*" +msgstr "回傳 *z* 的雙曲正切值。" + +#: ../../library/cmath.rst:73 +msgid "**Classification functions**" +msgstr "**分類函數**" + +#: ../../library/cmath.rst:75 +msgid ":func:`isfinite(z) `" +msgstr ":func:`isfinite(z) `" + +#: ../../library/cmath.rst:75 +msgid "Check if all components of *z* are finite" +msgstr "" + +#: ../../library/cmath.rst:76 +msgid ":func:`isinf(z) `" +msgstr ":func:`isinf(z) `" + +#: ../../library/cmath.rst:76 +msgid "Check if any component of *z* is infinite" +msgstr "" + +#: ../../library/cmath.rst:77 +msgid ":func:`isnan(z) `" +msgstr ":func:`isnan(z) `" + +#: ../../library/cmath.rst:77 +msgid "Check if any component of *z* is a NaN" +msgstr "" + +#: ../../library/cmath.rst:78 +msgid ":func:`isclose(a, b, *, rel_tol, abs_tol) `" +msgstr ":func:`isclose(a, b, *, rel_tol, abs_tol) `" + +#: ../../library/cmath.rst:78 +msgid "Check if the values *a* and *b* are close to each other" +msgstr "檢查 *a* 和 *b* 的值是否接近" + +#: ../../library/cmath.rst:80 +msgid "**Constants**" +msgstr "**常數**" + +#: ../../library/cmath.rst:82 +msgid ":data:`pi`" +msgstr ":data:`pi`" + +#: ../../library/cmath.rst:82 +msgid "*π* = 3.141592..." +msgstr "*π* = 3.141592..." + +#: ../../library/cmath.rst:83 +msgid ":data:`e`" +msgstr ":data:`e`" + +#: ../../library/cmath.rst:83 +msgid "*e* = 2.718281..." +msgstr "*e* = 2.718281..." + +#: ../../library/cmath.rst:84 +msgid ":data:`tau`" +msgstr ":data:`tau`" + +#: ../../library/cmath.rst:84 +msgid "*τ* = 2\\ *π* = 6.283185..." +msgstr "*τ* = 2\\ *π* = 6.283185..." + +#: ../../library/cmath.rst:85 +msgid ":data:`inf`" +msgstr ":data:`inf`" + +#: ../../library/cmath.rst:85 +msgid "Positive infinity" +msgstr "" + +#: ../../library/cmath.rst:86 +msgid ":data:`infj`" +msgstr ":data:`infj`" + +#: ../../library/cmath.rst:86 +msgid "Pure imaginary infinity" +msgstr "" + +#: ../../library/cmath.rst:87 +msgid ":data:`nan`" +msgstr ":data:`nan`" + +#: ../../library/cmath.rst:87 +msgid "\"Not a number\" (NaN)" +msgstr "" + +#: ../../library/cmath.rst:88 +msgid ":data:`nanj`" +msgstr ":data:`nanj`" + +#: ../../library/cmath.rst:88 +msgid "Pure imaginary NaN" +msgstr "" + +#: ../../library/cmath.rst:93 msgid "Conversions to and from polar coordinates" msgstr "轉換到極座標和從極座標做轉換" -#: ../../library/cmath.rst:44 +#: ../../library/cmath.rst:95 msgid "" "A Python complex number ``z`` is stored internally using *rectangular* or " -"*Cartesian* coordinates. It is completely determined by its *real part* ``z." -"real`` and its *imaginary part* ``z.imag``." +"*Cartesian* coordinates. It is completely determined by its *real part* " +"``z.real`` and its *imaginary part* ``z.imag``." msgstr "" "Python 複數 ``z`` 是用 *直角坐標* 或 *笛卡爾坐標* 儲存在內部的。它完全是由其 " "*實部* ``z.real`` 和 *虛部* ``z.imag`` 所決定。" -#: ../../library/cmath.rst:48 +#: ../../library/cmath.rst:99 msgid "" "*Polar coordinates* give an alternative way to represent a complex number. " "In polar coordinates, a complex number *z* is defined by the modulus *r* and " @@ -113,26 +376,26 @@ msgstr "" "*r* 和相位角 (phase) *phi* 定義。絕對值 *r* 是從 *z* 到原點的距離,而相位角 " "*phi* 是從正 x 軸到連接原點到 *z* 的線段的逆時針角度(以弧度為單位)。" -#: ../../library/cmath.rst:55 +#: ../../library/cmath.rst:106 msgid "" "The following functions can be used to convert from the native rectangular " "coordinates to polar coordinates and back." msgstr "以下的函式可用於原始直角座標與極座標之間的相互轉換。" -#: ../../library/cmath.rst:60 +#: ../../library/cmath.rst:111 msgid "" -"Return the phase of *x* (also known as the *argument* of *x*), as a float. " -"``phase(x)`` is equivalent to ``math.atan2(x.imag, x.real)``. The result " +"Return the phase of *z* (also known as the *argument* of *z*), as a float. " +"``phase(z)`` is equivalent to ``math.atan2(z.imag, z.real)``. The result " "lies in the range [-\\ *π*, *π*], and the branch cut for this operation lies " "along the negative real axis. The sign of the result is the same as the " -"sign of ``x.imag``, even when ``x.imag`` is zero::" +"sign of ``z.imag``, even when ``z.imag`` is zero::" msgstr "" -"以浮點數的形式回傳 *x* 的相位角(也稱為 *x* 的 *引數* )。 ``phase(x)`` 等價" -"於 ``math.atan2(x.imag, x.real)``。結果將位於 [-\\ *π*, *π*] 的範圍內,且此操" -"作的分枝切割將位於負實軸上。結果的符號會與 ``x.imag`` 的符號相同,即使 ``x." -"imag`` 為零: ::" +"以浮點數的形式回傳 *z* 的相位角(也稱為 *z* 的 *引數* )。``phase(z)`` 等價" +"於 ``math.atan2(z.imag, z.real)``。結果將位於 [-\\ *π*, *π*] 的範圍內,且此操" +"作的分枝切割將位於負實軸上。結果的符號會與 ``z.imag`` 的符號相同,即使 " +"``z.imag`` 為零: ::" -#: ../../library/cmath.rst:66 +#: ../../library/cmath.rst:117 msgid "" ">>> phase(complex(-1.0, 0.0))\n" "3.141592653589793\n" @@ -144,276 +407,273 @@ msgstr "" ">>> phase(complex(-1.0, -0.0))\n" "-3.141592653589793" -#: ../../library/cmath.rst:74 +#: ../../library/cmath.rst:125 msgid "" -"The modulus (absolute value) of a complex number *x* can be computed using " +"The modulus (absolute value) of a complex number *z* can be computed using " "the built-in :func:`abs` function. There is no separate :mod:`cmath` module " "function for this operation." msgstr "" -"複數 *x* 的絕對值可以使用內建的 :func:`abs` 函式計算。沒有單獨的 :mod:" -"`cmath` 模組函式適用於此操作。" +"複數 *z* 的絕對值可以使用內建的 :func:`abs` 函式計算。沒有單獨" +"的 :mod:`cmath` 模組函式適用於此操作。" -#: ../../library/cmath.rst:81 +#: ../../library/cmath.rst:132 msgid "" -"Return the representation of *x* in polar coordinates. Returns a pair ``(r, " -"phi)`` where *r* is the modulus of *x* and phi is the phase of *x*. " -"``polar(x)`` is equivalent to ``(abs(x), phase(x))``." +"Return the representation of *z* in polar coordinates. Returns a pair ``(r, " +"phi)`` where *r* is the modulus of *z* and *phi* is the phase of *z*. " +"``polar(z)`` is equivalent to ``(abs(z), phase(z))``." msgstr "" -"回傳 *x* 在極座標中的表達方式。回傳一組數對 ``(r, phi)``, *r* 是 *x* 的絕對" -"值, *phi* 是 *x* 的相位角。 ``polar(x)`` 相當於 ``(abs(x), phase(x))``。" +"回傳 *z* 在極座標中的表達方式。回傳一組數對 ``(r, phi)``, *r* 是 *z* 的絕對" +"值, *phi* 是 *z* 的相位角。 ``polar(z)`` 相當於 ``(abs(z), phase(z))``。" -#: ../../library/cmath.rst:89 +#: ../../library/cmath.rst:140 msgid "" -"Return the complex number *x* with polar coordinates *r* and *phi*. " +"Return the complex number *z* with polar coordinates *r* and *phi*. " "Equivalent to ``complex(r * math.cos(phi), r * math.sin(phi))``." msgstr "" -"透過極座標 *r* 和 *phi* 回傳複數 *x*。相當於 ``complex(r * math.cos(phi), r " +"透過極座標 *r* 和 *phi* 回傳複數 *z*。相當於 ``complex(r * math.cos(phi), r " "* math.sin(phi))``。" -#: ../../library/cmath.rst:94 +#: ../../library/cmath.rst:145 msgid "Power and logarithmic functions" msgstr "冪函數和對數函數" -#: ../../library/cmath.rst:98 +#: ../../library/cmath.rst:149 msgid "" -"Return *e* raised to the power *x*, where *e* is the base of natural " +"Return *e* raised to the power *z*, where *e* is the base of natural " "logarithms." -msgstr "回傳 *e* 的 *x* 次方,其中 *e* 是自然對數的底數。" +msgstr "回傳 *e* 的 *z* 次方,其中 *e* 是自然對數的底數。" -#: ../../library/cmath.rst:104 +#: ../../library/cmath.rst:155 msgid "" -"Returns the logarithm of *x* to the given *base*. If the *base* is not " -"specified, returns the natural logarithm of *x*. There is one branch cut, " +"Return the logarithm of *z* to the given *base*. If the *base* is not " +"specified, returns the natural logarithm of *z*. There is one branch cut, " "from 0 along the negative real axis to -∞." msgstr "" -"回傳 *x* 給定 *base* 的對數。如果未指定 *base*,則傳回 *x* 的自然對數。存在一" +"回傳 *z* 給定 *base* 的對數。如果未指定 *base*,則傳回 *z* 的自然對數。存在一" "條分枝切割,從 0 沿負實數軸到 -∞。" -#: ../../library/cmath.rst:111 +#: ../../library/cmath.rst:162 msgid "" -"Return the base-10 logarithm of *x*. This has the same branch cut as :func:" -"`log`." -msgstr "回傳 *x* 以 10 為底的對數。它與 :func:`log` 具有相同的分枝切割。" +"Return the base-10 logarithm of *z*. This has the same branch cut " +"as :func:`log`." +msgstr "回傳 *z* 以 10 為底的對數。它與 :func:`log` 具有相同的分枝切割。" -#: ../../library/cmath.rst:117 +#: ../../library/cmath.rst:168 msgid "" -"Return the square root of *x*. This has the same branch cut as :func:`log`." -msgstr "回傳 *x* 的平方根。它與 :func:`log` 具有相同的分枝切割。" +"Return the square root of *z*. This has the same branch cut as :func:`log`." +msgstr "回傳 *z* 的平方根。它與 :func:`log` 具有相同的分枝切割。" -#: ../../library/cmath.rst:121 +#: ../../library/cmath.rst:172 msgid "Trigonometric functions" msgstr "三角函數" -#: ../../library/cmath.rst:125 +#: ../../library/cmath.rst:176 msgid "" -"Return the arc cosine of *x*. There are two branch cuts: One extends right " +"Return the arc cosine of *z*. There are two branch cuts: One extends right " "from 1 along the real axis to ∞. The other extends left from -1 along the " "real axis to -∞." msgstr "" -"回傳 *x* 的反餘弦值。存在兩條分枝切割:一條是從 1 沿著實數軸向右延伸到 ∞。另" +"回傳 *z* 的反餘弦值。存在兩條分枝切割:一條是從 1 沿著實數軸向右延伸到 ∞。另" "一條從 -1 沿實數軸向左延伸到 -∞。" -#: ../../library/cmath.rst:132 +#: ../../library/cmath.rst:183 msgid "" -"Return the arc sine of *x*. This has the same branch cuts as :func:`acos`." -msgstr "回傳 *x* 的反正弦值。它與 :func:`acos` 具有相同的分枝切割。" +"Return the arc sine of *z*. This has the same branch cuts as :func:`acos`." +msgstr "回傳 *z* 的反正弦值。它與 :func:`acos` 具有相同的分枝切割。" -#: ../../library/cmath.rst:137 +#: ../../library/cmath.rst:188 msgid "" -"Return the arc tangent of *x*. There are two branch cuts: One extends from " +"Return the arc tangent of *z*. There are two branch cuts: One extends from " "``1j`` along the imaginary axis to ``∞j``. The other extends from ``-1j`` " "along the imaginary axis to ``-∞j``." msgstr "" -"回傳 *x* 的反正切值。有兩條分枝切割:一條是從 ``1j`` 沿著虛軸延伸到 ``∞j``。" +"回傳 *z* 的反正切值。有兩條分枝切割:一條是從 ``1j`` 沿著虛軸延伸到 ``∞j``。" "另一條從 ``-1j`` 沿著虛軸延伸到 ``-∞j``。" -#: ../../library/cmath.rst:144 -msgid "Return the cosine of *x*." -msgstr "回傳 *x* 的餘弦值。" +#: ../../library/cmath.rst:195 +msgid "Return the cosine of *z*." +msgstr "回傳 *z* 的餘弦值。" -#: ../../library/cmath.rst:149 -msgid "Return the sine of *x*." -msgstr "回傳 *x* 的正弦值。" +#: ../../library/cmath.rst:200 +msgid "Return the sine of *z*." +msgstr "回傳 *z* 的正弦值。" -#: ../../library/cmath.rst:154 -msgid "Return the tangent of *x*." -msgstr "回傳 *x* 的正切值。" +#: ../../library/cmath.rst:205 +msgid "Return the tangent of *z*." +msgstr "回傳 *z* 的正切值。" -#: ../../library/cmath.rst:158 +#: ../../library/cmath.rst:209 msgid "Hyperbolic functions" msgstr "雙曲函數" -#: ../../library/cmath.rst:162 +#: ../../library/cmath.rst:213 msgid "" -"Return the inverse hyperbolic cosine of *x*. There is one branch cut, " +"Return the inverse hyperbolic cosine of *z*. There is one branch cut, " "extending left from 1 along the real axis to -∞." msgstr "" -"回傳 *x* 的反雙曲餘弦值。存在一條分枝切割,從 1 沿實數軸向左延伸到 -∞。" +"回傳 *z* 的反雙曲餘弦值。存在一條分枝切割,從 1 沿實數軸向左延伸到 -∞。" -#: ../../library/cmath.rst:168 +#: ../../library/cmath.rst:219 msgid "" -"Return the inverse hyperbolic sine of *x*. There are two branch cuts: One " +"Return the inverse hyperbolic sine of *z*. There are two branch cuts: One " "extends from ``1j`` along the imaginary axis to ``∞j``. The other extends " "from ``-1j`` along the imaginary axis to ``-∞j``." msgstr "" -"回傳 *x* 的反雙曲正弦值。存在兩條分枝切割:一條是從 ``1j`` 沿著虛軸延伸到 " +"回傳 *z* 的反雙曲正弦值。存在兩條分枝切割:一條是從 ``1j`` 沿著虛軸延伸到 " "``∞j``。另一條從 ``-1j`` 沿著虛軸延伸到 ``-∞j``。" -#: ../../library/cmath.rst:175 +#: ../../library/cmath.rst:226 msgid "" -"Return the inverse hyperbolic tangent of *x*. There are two branch cuts: One " +"Return the inverse hyperbolic tangent of *z*. There are two branch cuts: One " "extends from ``1`` along the real axis to ``∞``. The other extends from " "``-1`` along the real axis to ``-∞``." msgstr "" -"回傳 *x* 的反雙曲正切值。存在兩條分枝切割:一條是從 ``1`` 沿著實數軸延伸到 " +"回傳 *z* 的反雙曲正切值。存在兩條分枝切割:一條是從 ``1`` 沿著實數軸延伸到 " "``∞``。另一條從 ``-1`` 沿著實數軸延伸到 ``-∞``。" -#: ../../library/cmath.rst:182 -msgid "Return the hyperbolic cosine of *x*." -msgstr "回傳 *x* 的反雙曲餘弦值。" +#: ../../library/cmath.rst:233 +msgid "Return the hyperbolic cosine of *z*." +msgstr "回傳 *z* 的反雙曲餘弦值。" -#: ../../library/cmath.rst:187 -msgid "Return the hyperbolic sine of *x*." -msgstr "回傳 *x* 的反雙曲正弦值。" +#: ../../library/cmath.rst:238 +msgid "Return the hyperbolic sine of *z*." +msgstr "回傳 *z* 的反雙曲正弦值。" -#: ../../library/cmath.rst:192 -msgid "Return the hyperbolic tangent of *x*." -msgstr "回傳 *x* 的反雙曲正切值。" +#: ../../library/cmath.rst:243 +msgid "Return the hyperbolic tangent of *z*." +msgstr "回傳 *z* 的反雙曲正切值。" -#: ../../library/cmath.rst:196 +#: ../../library/cmath.rst:247 msgid "Classification functions" msgstr "分類函式" -#: ../../library/cmath.rst:200 +#: ../../library/cmath.rst:251 msgid "" -"Return ``True`` if both the real and imaginary parts of *x* are finite, and " +"Return ``True`` if both the real and imaginary parts of *z* are finite, and " "``False`` otherwise." -msgstr "如果 *x* 的實部和虛部都是有限的,則回傳 ``True``,否則回傳 ``False``。" +msgstr "如果 *z* 的實部和虛部都是有限的,則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/cmath.rst:208 +#: ../../library/cmath.rst:259 msgid "" -"Return ``True`` if either the real or the imaginary part of *x* is an " +"Return ``True`` if either the real or the imaginary part of *z* is an " "infinity, and ``False`` otherwise." -msgstr "如果 *x* 的實部或虛部是無窮大,則回傳 ``True``,否則回傳 ``False``。" +msgstr "如果 *z* 的實部或虛部是無窮大,則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/cmath.rst:214 +#: ../../library/cmath.rst:265 msgid "" -"Return ``True`` if either the real or the imaginary part of *x* is a NaN, " +"Return ``True`` if either the real or the imaginary part of *z* is a NaN, " "and ``False`` otherwise." -msgstr "如果 *x* 的實部或虛部為 NaN,則回傳 ``True``,否則回傳 ``False``。" +msgstr "如果 *z* 的實部或虛部為 NaN,則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/cmath.rst:220 +#: ../../library/cmath.rst:271 msgid "" "Return ``True`` if the values *a* and *b* are close to each other and " "``False`` otherwise." msgstr "如果 *a* 和 *b* 的值相互接近,則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/cmath.rst:223 +#: ../../library/cmath.rst:274 msgid "" "Whether or not two values are considered close is determined according to " -"given absolute and relative tolerances." +"given absolute and relative tolerances. If no errors occur, the result will " +"be: ``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)``." msgstr "" -"兩個值是否被認為相互接近是由給定的絕對和相對容許偏差 (tolerance) 所決定的。" +"兩數是否足夠接近取決於給定的絕對及相對容許偏差 (tolerance)。如果沒有錯誤發" +"生,結果將為:``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)``。" -#: ../../library/cmath.rst:226 +#: ../../library/cmath.rst:278 msgid "" "*rel_tol* is the relative tolerance -- it is the maximum allowed difference " "between *a* and *b*, relative to the larger absolute value of *a* or *b*. " "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 greater than zero." -msgstr "" -"*rel_tol* 是相對容許偏差 -- 它是 *a* 和 *b* 之間的最大容許偏差值,相對於 *a* " -"或 *b* 的較大絕對值。例如,要設定 5% 的容許偏差,請傳遞 ``rel_tol=0.05``。預" -"設容許偏差是 ``1e-09``,它確保兩個值在大約 9 位十進制數字內相同。 *rel_tol* " -"必須大於零。" - -#: ../../library/cmath.rst:232 -msgid "" -"*abs_tol* is the minimum absolute tolerance -- useful for comparisons near " -"zero. *abs_tol* must be at least zero." +"within about 9 decimal digits. *rel_tol* must be nonnegative and less than " +"``1.0``." msgstr "" -"*abs_tol* 是最小絕對容許偏差 -- 對於接近零的比較很有用。 *abs_tol* 必須至少為" -"零。" - -#: ../../library/cmath.rst:235 -msgid "" -"If no errors occur, the result will be: ``abs(a-b) <= max(rel_tol * " -"max(abs(a), abs(b)), abs_tol)``." +"*rel_tol* 為相對容許偏差 ── *a* 與 *b* 兩數差的最大容許值,與 *a* 及 *b* 兩數" +"的絕對值中較大者相關。例如欲設置 5% 的容許偏差,則傳入 ``rel_tol=0.05``。其預" +"設值為 ``1e-09``,該值可確保兩數於大約 9 個十進數位內相同。*rel_tol* 須不為負" +"且小於 ``1.0``。" + +#: ../../library/cmath.rst:285 +msgid "" +"*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." msgstr "" -"如果未發生錯誤,結果將為: ``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), " -"abs_tol)``。" -#: ../../library/cmath.rst:238 +#: ../../library/cmath.rst:291 msgid "" "The IEEE 754 special values of ``NaN``, ``inf``, and ``-inf`` will be " "handled according to IEEE rules. Specifically, ``NaN`` is not considered " "close to any other value, including ``NaN``. ``inf`` and ``-inf`` are only " "considered close to themselves." msgstr "" -"IEEE 754 特殊值 ``NaN`` 、 ``inf`` 和 ``-inf`` 將會根據 IEEE 規則進行處理。具" -"體來說, ``NaN`` 不被認為接近任何其他值,包括 ``NaN``。 ``inf`` 和 ``-inf`` " -"只被認為是接近它們自己的。" +"定義於 IEEE 754 浮點標準中的特殊值 ``NaN``、``inf`` 和 ``-inf`` 會根據該標準" +"處理。更明確地說,``NaN`` 不會與包含自身在內的任何數字足夠接近,而 ``inf`` " +"及 ``-inf`` 皆只與自身接近。" -#: ../../library/cmath.rst:247 +#: ../../library/cmath.rst:300 msgid ":pep:`485` -- A function for testing approximate equality" -msgstr ":pep:`485` -- 一個用來測試近似相等的函式" +msgstr ":pep:`485` ── 用於測試近似相等的函式" -#: ../../library/cmath.rst:251 +#: ../../library/cmath.rst:304 msgid "Constants" msgstr "常數" -#: ../../library/cmath.rst:255 +#: ../../library/cmath.rst:308 msgid "The mathematical constant *π*, as a float." msgstr "數學常數 *π*,作為一個浮點數。" -#: ../../library/cmath.rst:260 +#: ../../library/cmath.rst:313 msgid "The mathematical constant *e*, as a float." msgstr "數學常數 *e*,作為一個浮點數。" -#: ../../library/cmath.rst:265 +#: ../../library/cmath.rst:318 msgid "The mathematical constant *τ*, as a float." msgstr "數學常數 *τ*,作為一個浮點數。" -#: ../../library/cmath.rst:272 +#: ../../library/cmath.rst:325 msgid "Floating-point positive infinity. Equivalent to ``float('inf')``." msgstr "正無窮大的浮點數。相當於 ``float('inf')``。" -#: ../../library/cmath.rst:279 +#: ../../library/cmath.rst:332 msgid "" "Complex number with zero real part and positive infinity imaginary part. " "Equivalent to ``complex(0.0, float('inf'))``." msgstr "實部為零和虛部為正無窮的複數。相當於 ``complex(0.0, float('inf'))``。" -#: ../../library/cmath.rst:287 +#: ../../library/cmath.rst:340 msgid "" "A floating-point \"not a number\" (NaN) value. Equivalent to " "``float('nan')``." msgstr "浮點「非數字」 (NaN) 值。相當於 ``float('nan')``。" -#: ../../library/cmath.rst:295 +#: ../../library/cmath.rst:348 msgid "" "Complex number with zero real part and NaN imaginary part. Equivalent to " "``complex(0.0, float('nan'))``." msgstr "實部為零和虛部為 NaN 的複數。相當於 ``complex(0.0, float('nan'))``。" -#: ../../library/cmath.rst:303 +#: ../../library/cmath.rst:356 msgid "" "Note that the selection of functions is similar, but not identical, to that " "in module :mod:`math`. The reason for having two modules is that some users " "aren't interested in complex numbers, and perhaps don't even know what they " "are. They would rather have ``math.sqrt(-1)`` raise an exception than " -"return a complex number. Also note that the functions defined in :mod:" -"`cmath` always return a complex number, even if the answer can be expressed " -"as a real number (in which case the complex number has an imaginary part of " -"zero)." +"return a complex number. Also note that the functions defined " +"in :mod:`cmath` always return a complex number, even if the answer can be " +"expressed as a real number (in which case the complex number has an " +"imaginary part of zero)." msgstr "" "請注意,函式的選擇與模組 :mod:`math` 的類似,但並不完全相同。擁有兩個模組的原" -"因是有些用戶對複數不感興趣,甚至根本就不知道它們是什麼。他們寧願讓 ``math." -"sqrt(-1)`` 引發異常,也不願它回傳複數。另請注意, :mod:`cmath` 中所定義的函式" -"始終都會回傳複數,即使答案可以表示為實數(在這種情況下,複數的虛部為零)。" +"因是有些用戶對複數不感興趣,甚至根本就不知道它們是什麼。他們寧願讓 " +"``math.sqrt(-1)`` 引發異常,也不願它回傳複數。另請注意, :mod:`cmath` 中所定" +"義的函式始終都會回傳複數,即使答案可以表示為實數(在這種情況下,複數的虛部為" +"零)。" -#: ../../library/cmath.rst:311 +#: ../../library/cmath.rst:364 msgid "" "A note on branch cuts: They are curves along which the given function fails " "to be continuous. They are a necessary feature of many complex functions. " @@ -428,17 +688,17 @@ msgstr "" "所有關於複變函數的(不是太初級的)書籍以獲得啟發。對於如何正確地基於數值目的" "選擇分枝切割的相關訊息,以下內容應該是一個很好的參考:" -#: ../../library/cmath.rst:321 +#: ../../library/cmath.rst:374 msgid "" "Kahan, W: Branch cuts for complex elementary functions; or, Much ado about " "nothing's sign bit. In Iserles, A., and Powell, M. (eds.), The state of the " "art in numerical analysis. Clarendon Press (1987) pp165--211." msgstr "" -#: ../../library/cmath.rst:301 +#: ../../library/cmath.rst:354 msgid "module" msgstr "module(模組)" -#: ../../library/cmath.rst:301 +#: ../../library/cmath.rst:354 msgid "math" msgstr "math(數學)" diff --git a/library/cmd.po b/library/cmd.po index 5a014217df..347b67d892 100644 --- a/library/cmd.po +++ b/library/cmd.po @@ -3,13 +3,14 @@ # This file is distributed under the same license as the Python package. # # Translators: +# Dr-XYZ , 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" -"PO-Revision-Date: 2018-05-23 14:40+0000\n" -"Last-Translator: Adrian Liaw \n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"PO-Revision-Date: 2025-05-19 20:25+0800\n" +"Last-Translator: Dr-XYZ \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -20,7 +21,7 @@ msgstr "" #: ../../library/cmd.rst:2 msgid ":mod:`!cmd` --- Support for line-oriented command interpreters" -msgstr ":mod:`!cmd` --- 以列為導向的指令直譯器支援" +msgstr ":mod:`!cmd` --- 以列為導向的命令直譯器支援" #: ../../library/cmd.rst:9 msgid "**Source code:** :source:`Lib/cmd.py`" @@ -33,6 +34,8 @@ msgid "" "administrative tools, and prototypes that will later be wrapped in a more " "sophisticated interface." msgstr "" +":class:`Cmd` 類別提供了一個簡單的架構,用於撰寫列導向的命令直譯器。這類直譯器" +"常用於測試控制工具、管理工具以及日後將包裝於更高階介面的原型中。" #: ../../library/cmd.rst:20 msgid "" @@ -42,6 +45,9 @@ msgid "" "yourself in order to inherit :class:`Cmd`'s methods and encapsulate action " "methods." msgstr "" +":class:`Cmd` 實例或其子類別實例是一種列導向的直譯器架構。通常沒有必要直接實例" +"化 :class:`Cmd` 本身;它更適合作為你自定義的直譯器類別的父類別,讓你能繼承 :" +"class:`Cmd` 的方法,並封裝動作方法。" #: ../../library/cmd.rst:25 msgid "" @@ -50,44 +56,72 @@ msgid "" "`None` and :mod:`readline` is available, command completion is done " "automatically." msgstr "" +"可選引數 *completekey* 是 :mod:`readline` 模組中用於自動完成的按鍵名稱;預設" +"為 :kbd:`Tab`。若 *completekey* 不為 :const:`None` 且 :mod:`readline` 可用," +"則會自動啟用命令自動完成功能。" #: ../../library/cmd.rst:29 msgid "" +"The default, ``'tab'``, is treated specially, so that it refers to the :kbd:" +"`Tab` key on every :data:`readline.backend`. Specifically, if :data:" +"`readline.backend` 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." +msgstr "" +"預設值 ``'tab'`` 會被特殊處理,使其在所有的 :data:`readline.backend` 中皆代" +"表 :kbd:`Tab` 鍵。具體來說,若 :data:`readline.backend` 為 ``editline``,則 " +"``Cmd`` 會改用 ``'^I'`` 取代 ``'tab'``。請注意,其他值不會有此處理方式,且可" +"能僅能在特定的後端中適用。" + +#: ../../library/cmd.rst:36 +msgid "" "The optional arguments *stdin* and *stdout* specify the input and output " "file objects that the Cmd instance or subclass instance will use for input " "and output. If not specified, they will default to :data:`sys.stdin` and :" "data:`sys.stdout`." msgstr "" +"可選引數 *stdin* 與 *stdout* 用來指定 Cmd 實例或其子類別實例所使用的輸入與輸" +"出檔案物件。若未指定,預設為 :data:`sys.stdin` 與 :data:`sys.stdout`。" -#: ../../library/cmd.rst:34 +#: ../../library/cmd.rst:41 msgid "" "If you want a given *stdin* to be used, make sure to set the instance's :" "attr:`use_rawinput` attribute to ``False``, otherwise *stdin* will be " "ignored." msgstr "" +"若你希望使用指定的 *stdin*,請務必將該實例的 :attr:`use_rawinput` 屬性設為 " +"``False``,否則 *stdin* 會被忽略。" -#: ../../library/cmd.rst:42 +#: ../../library/cmd.rst:45 +msgid "``completekey='tab'`` is replaced by ``'^I'`` for ``editline``." +msgstr "對於 ``editline``,``completekey='tab'`` 會被替換為 ``'^I'``。" + +#: ../../library/cmd.rst:52 msgid "Cmd Objects" msgstr "Cmd 物件" -#: ../../library/cmd.rst:44 +#: ../../library/cmd.rst:54 msgid "A :class:`Cmd` instance has the following methods:" -msgstr "" +msgstr ":class:`Cmd` 實例具有以下方法:" -#: ../../library/cmd.rst:49 +#: ../../library/cmd.rst:59 msgid "" "Repeatedly issue a prompt, accept input, parse an initial prefix off the " "received input, and dispatch to action methods, passing them the remainder " "of the line as argument." msgstr "" +"重複顯示提示字元、接收輸入、剖析接收到的輸入字串前綴,並派發給動作方法,將其" +"餘部分作為引數傳遞給它們" -#: ../../library/cmd.rst:53 +#: ../../library/cmd.rst:63 msgid "" "The optional argument is a banner or intro string to be issued before the " "first prompt (this overrides the :attr:`intro` class attribute)." msgstr "" +"此可選引數為橫幅或導言字串,會在首次顯示提示字元前輸出(此值會覆寫 :attr:" +"`intro` 類別屬性)。" -#: ../../library/cmd.rst:56 +#: ../../library/cmd.rst:66 msgid "" "If the :mod:`readline` module is loaded, input will automatically inherit :" "program:`bash`\\ -like history-list editing (e.g. :kbd:`Control-P` scrolls " @@ -95,12 +129,16 @@ msgid "" "`Control-F` moves the cursor to the right non-destructively, :kbd:`Control-" "B` moves the cursor to the left non-destructively, etc.)." msgstr "" +"如果已載入 :mod:`readline` 模組,輸入將自動繼承類似 :program:`bash` 的歷史紀" +"錄編輯功能(例如 :kbd:`Control-P` 可向上捲動至上一個命令,:kbd:`Control-N` 向" +"下捲動至下一個命令,:kbd:`Control-F` 非破壞性地將游標向右移動,:kbd:`Control-" +"B` 非破壞性地將游標向左移動等)。" -#: ../../library/cmd.rst:62 +#: ../../library/cmd.rst:72 msgid "An end-of-file on input is passed back as the string ``'EOF'``." -msgstr "" +msgstr "當輸入為檔案結尾(EOF)時,會傳回字串 ``'EOF'``。" -#: ../../library/cmd.rst:68 +#: ../../library/cmd.rst:78 msgid "" "An interpreter instance will recognize a command name ``foo`` if and only if " "it has a method :meth:`!do_foo`. As a special case, a line beginning with " @@ -108,15 +146,21 @@ msgid "" "another special case, a line beginning with the character ``'!'`` is " "dispatched to the method :meth:`!do_shell` (if such a method is defined)." msgstr "" +"直譯器實例僅當存在 :meth:`!do_foo` 方法時,才會識別命令名稱 ``foo``。作為特殊" +"情況,以字元 ``'?'`` 開頭的列會被派發至 :meth:`do_help` 方法;另一個特殊情況" +"是,以字元 ``'!'`` 開頭的列會被派發至 :meth:`!do_shell` 方法(若該方法已定" +"義)。" -#: ../../library/cmd.rst:74 +#: ../../library/cmd.rst:84 msgid "" "This method will return when the :meth:`postcmd` method returns a true " "value. The *stop* argument to :meth:`postcmd` is the return value from the " "command's corresponding :meth:`!do_\\*` method." msgstr "" +"當 :meth:`postcmd` 方法回傳真值時,此方法將會結束。傳遞給 :meth:`postcmd` 的 " +"*stop* 引數是該命令對應的 :meth:`!do_\\*` 方法的回傳值。" -#: ../../library/cmd.rst:78 +#: ../../library/cmd.rst:88 msgid "" "If completion is enabled, completing commands will be done automatically, " "and completing of commands args is done by calling :meth:`!complete_foo` " @@ -127,8 +171,13 @@ msgid "" "could be used to provide different completion depending upon which position " "the argument is in." msgstr "" +"如果啟用了自動完成,命令的自動完成將會自動執行,而命令引數的自動完成則是透過" +"呼叫 :meth:`!complete_foo` 方法並傳入 *text*、*line*、*begidx* 和 *endidx* 引" +"數來處理。*text* 是要比對的字串前綴:所有回傳的符合項都必須以此字串開頭。" +"*line* 是目前的輸入列(前置空白會被移除),*begidx* 和 *endidx* 則分別是前綴" +"字串的起始與結束索引,可用來根據引數所在的位置提供不同的自動完成結果。" -#: ../../library/cmd.rst:89 +#: ../../library/cmd.rst:99 msgid "" "All subclasses of :class:`Cmd` inherit a predefined :meth:`!do_help`. This " "method, called with an argument ``'bar'``, invokes the corresponding method :" @@ -138,8 +187,13 @@ msgid "" "help_\\*` methods or commands that have docstrings), and also lists any " "undocumented commands." msgstr "" +"所有 :class:`Cmd` 的子類別都會繼承預先定義的 :meth:`!do_help` 方法。當此方法" +"接收到引數 ``'bar'`` 時,會呼叫對應的 :meth:`!help_bar` 方法;若該方法不存" +"在,則會列印 :meth:`!do_bar` 的說明字串(若有的話)。若未提供任何引數,:meth:" +"`!do_help` 會列出所有可用的說明主題(也就是所有具有對應 :meth:`!help_\\*` 方" +"法或有說明字串的命令),並且也會列出所有尚未記錄的命令。" -#: ../../library/cmd.rst:100 +#: ../../library/cmd.rst:110 msgid "" "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 :" @@ -149,33 +203,46 @@ msgid "" "command *str*, the return value of that method is returned, otherwise the " "return value from the :meth:`default` method is returned." msgstr "" +"將引數視為在回應提示字元時所輸入的內容來直譯。這個方法可以被覆寫,但通常不需" +"要這麼做;參見 :meth:`precmd` 與 :meth:`postcmd` 方法,它們提供實用的執行勾點" +"(hook)。此方法的回傳值是一個旗標,用來指出是否應該停止直譯器對命令的直譯。" +"若有對應 *str* 命令的 :meth:`!do_\\*` 方法,則會回傳該方法的回傳值;否則,回" +"傳值將來自 :meth:`default` 方法。" -#: ../../library/cmd.rst:111 +#: ../../library/cmd.rst:121 msgid "" "Method called when an empty line is entered in response to the prompt. If " "this method is not overridden, it repeats the last nonempty command entered." msgstr "" +"在回應提示字元時輸入空白列,會呼叫此方法。若此方法未被覆寫,則會重復上一次輸" +"入的非空命令。" -#: ../../library/cmd.rst:117 +#: ../../library/cmd.rst:127 msgid "" "Method called on an input line when the command prefix is not recognized. If " "this method is not overridden, it prints an error message and returns." msgstr "" +"當輸入列中的命令前綴無法辨識時,會呼叫此方法。若此方法未被覆寫,則會輸出並回" +"傳錯誤訊息。" -#: ../../library/cmd.rst:123 +#: ../../library/cmd.rst:133 msgid "" "Method called to complete an input line when no command-specific :meth:`!" "complete_\\*` method is available. By default, it returns an empty list." msgstr "" +"當沒有對應特定命令的 :meth:`!complete_\\*` 方法時,會呼叫此方法以完成輸入列。" +"預設會回傳空串列。" -#: ../../library/cmd.rst:129 +#: ../../library/cmd.rst:139 msgid "" "Method called to display a list of strings as a compact set of columns. Each " "column is only as wide as necessary. Columns are separated by two spaces for " "readability." msgstr "" +"此方法用來將字串串列顯示為緊湊的欄集合。每一欄的寬度僅足以容納其內容,各欄之" +"間以兩個空格分隔,以提高可讀性。" -#: ../../library/cmd.rst:136 +#: ../../library/cmd.rst:146 msgid "" "Hook method executed just before the command line *line* is interpreted, but " "after the input prompt is generated and issued. This method is a stub in :" @@ -184,8 +251,12 @@ msgid "" "the :meth:`precmd` implementation may re-write the command or simply return " "*line* unchanged." msgstr "" +"勾點方法會在直譯命令列 *line* 前執行,但會在提示字元產生並顯示後才觸發。這個" +"方法在 :class:`Cmd` 類別中為 stub,預期由子類別覆寫。回傳值會作為 :meth:" +"`onecmd` 方法所執行的命令;:meth:`precmd` 的實作可以重寫該命令,或直接回傳未" +"變更的 *line*。" -#: ../../library/cmd.rst:146 +#: ../../library/cmd.rst:156 msgid "" "Hook method executed just after a command dispatch is finished. This method " "is a stub in :class:`Cmd`; it exists to be overridden by subclasses. *line* " @@ -195,75 +266,92 @@ msgid "" "this method will be used as the new value for the internal flag which " "corresponds to *stop*; returning false will cause interpretation to continue." msgstr "" +"勾點方法會在命令派發完成後執行。這個方法在 :class:`Cmd` 類別中為 stub,預期由" +"子類別覆寫。*line* 是剛剛執行的命令列,而 *stop* 是一個旗標,用來指出在呼叫 :" +"meth:`postcmd` 後是否應終止執行;該值即為 :meth:`onecmd` 方法的回傳值。本方法" +"的回傳值將會更新內部的 *stop* 旗標;若回傳 false,則會繼續進行直譯。" -#: ../../library/cmd.rst:157 +#: ../../library/cmd.rst:167 msgid "" "Hook method executed once when :meth:`cmdloop` is called. This method is a " "stub in :class:`Cmd`; it exists to be overridden by subclasses." msgstr "" +"當 :meth:`cmdloop` 被呼叫時,此勾點方法會執行一次。這個方法在 :class:`Cmd` 類" +"別中為 stub,預期由子類別覆寫。" -#: ../../library/cmd.rst:163 +#: ../../library/cmd.rst:173 msgid "" "Hook method executed once when :meth:`cmdloop` is about to return. This " "method is a stub in :class:`Cmd`; it exists to be overridden by subclasses." msgstr "" +"當 :meth:`cmdloop` 即將回傳時,此勾點方法會執行一次。這個方法在 :class:`Cmd` " +"類別中為 stub,預期由子類別覆寫。" -#: ../../library/cmd.rst:167 +#: ../../library/cmd.rst:177 msgid "" "Instances of :class:`Cmd` subclasses have some public instance variables:" -msgstr "" +msgstr ":class:`Cmd` 子類別的實例包含一些公開的實例變數:" -#: ../../library/cmd.rst:171 +#: ../../library/cmd.rst:181 msgid "The prompt issued to solicit input." -msgstr "" +msgstr "用來請求輸入的提示字元。" -#: ../../library/cmd.rst:176 +#: ../../library/cmd.rst:186 msgid "The string of characters accepted for the command prefix." -msgstr "" +msgstr "可作為命令前綴的字元字串" -#: ../../library/cmd.rst:181 +#: ../../library/cmd.rst:191 msgid "The last nonempty command prefix seen." -msgstr "" +msgstr "最後一個遇到的非空命令前綴" -#: ../../library/cmd.rst:186 +#: ../../library/cmd.rst:196 msgid "" "A list of queued input lines. The cmdqueue list is checked in :meth:" "`cmdloop` when new input is needed; if it is nonempty, its elements will be " "processed in order, as if entered at the prompt." msgstr "" +"排入佇列的輸入列串列。當 :meth:`cmdloop` 需要新輸入時,會檢查 cmdqueue 串列;" +"若不為空,其元素將依序處理,就如同它們是在提示字元中輸入的一樣。" -#: ../../library/cmd.rst:193 +#: ../../library/cmd.rst:203 msgid "" "A string to issue as an intro or banner. May be overridden by giving the :" "meth:`cmdloop` method an argument." msgstr "" +"作為簡介或橫幅的字串。可透過為 :meth:`cmdloop` 方法提供引數來覆寫此內容。" -#: ../../library/cmd.rst:199 +#: ../../library/cmd.rst:209 msgid "" "The header to issue if the help output has a section for documented commands." -msgstr "" +msgstr "若說明輸出包含已記錄命令的區段,則會顯示的標頭字串。" -#: ../../library/cmd.rst:204 +#: ../../library/cmd.rst:214 msgid "" "The header to issue if the help output has a section for miscellaneous help " "topics (that is, there are :meth:`!help_\\*` methods without corresponding :" "meth:`!do_\\*` methods)." msgstr "" +"若說明輸出包含雜項說明主題的區段(也就是存在 :meth:`!help_\\*` 方法但沒有對應" +"的 :meth:`!do_\\*` 方法),則會顯示的標頭字串。" -#: ../../library/cmd.rst:211 +#: ../../library/cmd.rst:221 msgid "" "The header to issue if the help output has a section for undocumented " "commands (that is, there are :meth:`!do_\\*` methods without corresponding :" "meth:`!help_\\*` methods)." msgstr "" +"若說明輸出包含未記錄命令的區段(也就是存在 :meth:`!do_\\*` 方法但沒有對應的 :" +"meth:`!help_\\*` 方法),則會顯示的標頭字串。" -#: ../../library/cmd.rst:218 +#: ../../library/cmd.rst:228 msgid "" "The character used to draw separator lines under the help-message headers. " "If empty, no ruler line is drawn. It defaults to ``'='``." msgstr "" +"用於在說明訊息的標頭下方繪製分隔線的字元。若為空,則不會繪製分隔線。預設為 " +"``'='``。" -#: ../../library/cmd.rst:224 +#: ../../library/cmd.rst:234 msgid "" "A flag, defaulting to true. If true, :meth:`cmdloop` uses :func:`input` to " "display a prompt and read the next command; if false, :data:`sys.stdout." @@ -272,32 +360,43 @@ msgid "" "the interpreter will automatically support :program:`Emacs`\\ -like line " "editing and command-history keystrokes.)" msgstr "" +"一個旗標,預設為 true。若為 true,:meth:`cmdloop` 會使用 :func:`input` 來顯示" +"提示字元並讀取下一個命令;若為 false,則會改用 :data:`sys.stdout.write() " +"` 和 :data:`sys.stdin.readline() `。(這表示在支援的系" +"統中,透過 import :mod:`readline` module,直譯器將自動支援類似 :program:" +"`Emacs` 的列編輯與命令歷史快捷鍵。)" -#: ../../library/cmd.rst:234 +#: ../../library/cmd.rst:244 msgid "Cmd Example" -msgstr "" +msgstr "Cmd 範例" -#: ../../library/cmd.rst:238 +#: ../../library/cmd.rst:248 msgid "" "The :mod:`cmd` module is mainly useful for building custom shells that let a " "user work with a program interactively." msgstr "" +":mod:`cmd` module 主要用於建構自訂 shell,讓使用者能以互動方式操作程式。" -#: ../../library/cmd.rst:241 +#: ../../library/cmd.rst:251 msgid "" "This section presents a simple example of how to build a shell around a few " "of the commands in the :mod:`turtle` module." msgstr "" +"本節將示範如何以 :mod:`turtle` module 中的幾個命令為基礎,建立一個簡單的 " +"shell。" -#: ../../library/cmd.rst:244 +#: ../../library/cmd.rst:254 msgid "" "Basic turtle commands such as :meth:`~turtle.forward` are added to a :class:" "`Cmd` subclass with method named :meth:`!do_forward`. The argument is " "converted to a number and dispatched to the turtle module. The docstring is " "used in the help utility provided by the shell." msgstr "" +"像是 :meth:`~turtle.forward` 這樣的基本 turtle 命令,可透過新增名為 :meth:`!" +"do_forward` 的方法加入至 :class:`Cmd` 子類別中。傳入的引數會轉換為數值,並傳" +"送給 turtle 模組。該方法的說明字串會用於 shell 所提供的說明功能中。" -#: ../../library/cmd.rst:249 +#: ../../library/cmd.rst:259 msgid "" "The example also includes a basic record and playback facility implemented " "with the :meth:`~Cmd.precmd` method which is responsible for converting the " @@ -305,8 +404,11 @@ msgid "" "do_playback` method reads the file and adds the recorded commands to the :" "attr:`~Cmd.cmdqueue` for immediate playback::" msgstr "" +"此範例同時包含一個簡單的錄製與重播功能,其實作方式是透過 :meth:`~Cmd.precmd` " +"方法,負責將輸入轉為小寫並寫入檔案。:meth:`!do_playback` 方法則會讀取該檔案," +"並將錄製的命令加入 :attr:`~Cmd.cmdqueue` 中以供立即重播::" -#: ../../library/cmd.rst:255 +#: ../../library/cmd.rst:265 msgid "" "import cmd, sys\n" "from turtle import *\n" @@ -385,15 +487,90 @@ msgid "" "if __name__ == '__main__':\n" " TurtleShell().cmdloop()" msgstr "" +"import cmd, sys\n" +"from turtle import *\n" +"\n" +"class TurtleShell(cmd.Cmd):\n" +" intro = '歡迎來到 turtle shell。輸入 help 或 ? 來列出命令。\\n'\n" +" prompt = '(turtle) '\n" +" file = None\n" +"\n" +" # ----- 基本烏龜命令 -----\n" +" def do_forward(self, arg):\n" +" '將烏龜向前移動指定的距離: FORWARD 10'\n" +" forward(*parse(arg))\n" +" def do_right(self, arg):\n" +" '將烏龜右轉指定的角度: RIGHT 20'\n" +" right(*parse(arg))\n" +" def do_left(self, arg):\n" +" '將烏龜左轉指定的角度: LEFT 90'\n" +" left(*parse(arg))\n" +" def do_goto(self, arg):\n" +" '將烏龜移動到指定的絕對位置並改變方向。 GOTO 100 200'\n" +" goto(*parse(arg))\n" +" def do_home(self, arg):\n" +" '將烏龜返回起始位置: HOME'\n" +" home()\n" +" def do_circle(self, arg):\n" +" '畫出指定半徑、範圍和步數的圓: CIRCLE 50'\n" +" circle(*parse(arg))\n" +" def do_position(self, arg):\n" +" '顯示當前烏龜位置: POSITION'\n" +" print('當前位置是 %d %d\\n' % position())\n" +" def do_heading(self, arg):\n" +" '顯示當前烏龜方向角度: HEADING'\n" +" print('當前方向是 %d\\n' % (heading(),))\n" +" def do_color(self, arg):\n" +" '設定顏色: COLOR BLUE'\n" +" color(arg.lower())\n" +" def do_undo(self, arg):\n" +" '撤銷(重複)最後一次烏龜動作: UNDO'\n" +" def do_reset(self, arg):\n" +" '清除畫面並將烏龜返回到中心: RESET'\n" +" reset()\n" +" def do_bye(self, arg):\n" +" '停止錄製、關閉烏龜視窗並退出: BYE'\n" +" print('感謝使用 Turtle')\n" +" self.close()\n" +" bye()\n" +" return True\n" +"\n" +" # ----- 錄製與回放 -----\n" +" def do_record(self, arg):\n" +" '將未來命令儲存至檔案: RECORD rose.cmd'\n" +" self.file = open(arg, 'w')\n" +" def do_playback(self, arg):\n" +" '從檔案回放命令: PLAYBACK rose.cmd'\n" +" self.close()\n" +" with open(arg) as f:\n" +" self.cmdqueue.extend(f.read().splitlines())\n" +" def precmd(self, line):\n" +" line = line.lower()\n" +" if self.file and 'playback' not in line:\n" +" print(line, file=self.file)\n" +" return line\n" +" def close(self):\n" +" if self.file:\n" +" self.file.close()\n" +" self.file = None\n" +"\n" +"def parse(arg):\n" +" '將一串零個或多個數字轉換為引數 tuple'\n" +" return tuple(map(int, arg.split()))\n" +"\n" +"if __name__ == '__main__':\n" +" TurtleShell().cmdloop()" -#: ../../library/cmd.rst:330 +#: ../../library/cmd.rst:340 msgid "" "Here is a sample session with the turtle shell showing the help functions, " "using blank lines to repeat commands, and the simple record and playback " "facility:" msgstr "" +"以下是與 turtle shell 的一段範例互動,展示了說明功能、使用空白列重複執行命" +"令,以及簡單的錄製與重播功能:" -#: ../../library/cmd.rst:333 +#: ../../library/cmd.rst:343 msgid "" "Welcome to the turtle shell. Type help or ? to list commands.\n" "\n" @@ -453,23 +630,23 @@ msgid "" "(turtle) bye\n" "Thank you for using Turtle" msgstr "" -"Welcome to the turtle shell. Type help or ? to list commands.\n" +"歡迎來到 turtle shell。輸入 help 或 ? 來列出命令。\n" "\n" "(turtle) ?\n" "\n" -"Documented commands (type help ):\n" +"已記錄的命令(輸入 help <主題>):\n" "========================================\n" "bye color goto home playback record right\n" "circle forward heading left position reset undo\n" "\n" "(turtle) help forward\n" -"Move the turtle forward by the specified distance: FORWARD 10\n" +"將烏龜向前移動指定的距離: FORWARD 10\n" "(turtle) record spiral.cmd\n" "(turtle) position\n" -"Current position is 0 0\n" +"當前位置是 0 0\n" "\n" "(turtle) heading\n" -"Current heading is 0\n" +"當前方向是 0\n" "\n" "(turtle) reset\n" "(turtle) circle 20\n" @@ -486,7 +663,7 @@ msgstr "" "(turtle) right 30\n" "(turtle) circle 120\n" "(turtle) heading\n" -"Current heading is 180\n" +"當前方向是 180\n" "\n" "(turtle) forward 100\n" "(turtle)\n" @@ -502,23 +679,23 @@ msgstr "" "(turtle) right 90\n" "(turtle) forward 300\n" "(turtle) playback spiral.cmd\n" -"Current position is 0 0\n" +"當前位置是 0 0\n" "\n" -"Current heading is 0\n" +"當前方向是 0\n" "\n" -"Current heading is 180\n" +"當前方向是 180\n" "\n" "(turtle) bye\n" -"Thank you for using Turtle" +"感謝使用 Turtle" -#: ../../library/cmd.rst:64 +#: ../../library/cmd.rst:74 msgid "? (question mark)" msgstr "? (問號)" -#: ../../library/cmd.rst:64 +#: ../../library/cmd.rst:74 msgid "in a command interpreter" -msgstr "於 command interpreter(指令直譯器)中" +msgstr "於 command interpreter(命令直譯器)中" -#: ../../library/cmd.rst:64 +#: ../../library/cmd.rst:74 msgid "! (exclamation)" msgstr "! (驚嘆號)" diff --git a/library/cmdline.po b/library/cmdline.po index 5f894724f8..aea947803e 100644 --- a/library/cmdline.po +++ b/library/cmdline.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-10-12 00:03+0000\n" +"POT-Creation-Date: 2025-05-04 00:16+0000\n" "PO-Revision-Date: 2023-10-14 16:03+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -62,8 +62,8 @@ msgid ":ref:`dis `" msgstr ":ref:`dis `" #: ../../library/cmdline.rst:16 -msgid ":mod:`doctest`" -msgstr ":mod:`doctest`" +msgid ":ref:`doctest `" +msgstr ":ref:`doctest `" #: ../../library/cmdline.rst:17 msgid ":mod:`!encodings.rot_13`" @@ -122,8 +122,8 @@ msgid ":ref:`pickletools `" msgstr ":ref:`pickletools `" #: ../../library/cmdline.rst:31 -msgid ":mod:`platform`" -msgstr ":mod:`platform`" +msgid ":ref:`platform `" +msgstr ":ref:`platform `" #: ../../library/cmdline.rst:32 msgid ":mod:`poplib`" @@ -154,73 +154,81 @@ msgid ":mod:`quopri`" msgstr ":mod:`quopri`" #: ../../library/cmdline.rst:39 +msgid ":ref:`random `" +msgstr ":ref:`random `" + +#: ../../library/cmdline.rst:40 msgid ":mod:`runpy`" msgstr ":mod:`runpy`" -#: ../../library/cmdline.rst:40 +#: ../../library/cmdline.rst:41 msgid ":ref:`site `" msgstr ":ref:`site `" -#: ../../library/cmdline.rst:41 +#: ../../library/cmdline.rst:42 msgid ":ref:`sqlite3 `" msgstr ":ref:`sqlite3 `" -#: ../../library/cmdline.rst:42 +#: ../../library/cmdline.rst:43 +msgid ":ref:`symtable `" +msgstr ":ref:`symtable `" + +#: ../../library/cmdline.rst:44 msgid ":ref:`sysconfig `" msgstr ":ref:`sysconfig `" -#: ../../library/cmdline.rst:43 +#: ../../library/cmdline.rst:45 msgid ":mod:`tabnanny`" msgstr ":mod:`tabnanny`" -#: ../../library/cmdline.rst:44 +#: ../../library/cmdline.rst:46 msgid ":ref:`tarfile `" msgstr ":ref:`tarfile `" -#: ../../library/cmdline.rst:45 +#: ../../library/cmdline.rst:47 msgid ":mod:`!this`" msgstr ":mod:`!this`" -#: ../../library/cmdline.rst:46 +#: ../../library/cmdline.rst:48 msgid ":ref:`timeit `" msgstr ":ref:`timeit `" -#: ../../library/cmdline.rst:47 +#: ../../library/cmdline.rst:49 msgid ":ref:`tokenize `" msgstr ":ref:`tokenize `" -#: ../../library/cmdline.rst:48 +#: ../../library/cmdline.rst:50 msgid ":ref:`trace `" msgstr ":ref:`trace `" -#: ../../library/cmdline.rst:49 +#: ../../library/cmdline.rst:51 msgid ":mod:`turtledemo`" msgstr ":mod:`turtledemo`" -#: ../../library/cmdline.rst:50 +#: ../../library/cmdline.rst:52 msgid ":ref:`unittest `" msgstr ":ref:`unittest `" -#: ../../library/cmdline.rst:51 +#: ../../library/cmdline.rst:53 msgid ":ref:`uuid `" msgstr ":ref:`uuid `" -#: ../../library/cmdline.rst:52 +#: ../../library/cmdline.rst:54 msgid ":mod:`venv`" msgstr ":mod:`venv`" -#: ../../library/cmdline.rst:53 +#: ../../library/cmdline.rst:55 msgid ":mod:`webbrowser`" msgstr ":mod:`webbrowser`" -#: ../../library/cmdline.rst:54 +#: ../../library/cmdline.rst:56 msgid ":ref:`zipapp `" msgstr ":ref:`zipapp `" -#: ../../library/cmdline.rst:55 +#: ../../library/cmdline.rst:57 msgid ":ref:`zipfile `" msgstr ":ref:`zipfile `" -#: ../../library/cmdline.rst:57 +#: ../../library/cmdline.rst:59 msgid "See also the :ref:`Python command-line interface `." msgstr "另請見 :ref:`Python 命令列介面 `。" diff --git a/library/cmdlinelibs.po b/library/cmdlinelibs.po new file mode 100644 index 0000000000..74afa150da --- /dev/null +++ b/library/cmdlinelibs.po @@ -0,0 +1,32 @@ +# Copyright (C) 2001-2024, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.13\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-12-29 11:18+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" +"Language: zh_TW\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../../library/cmdlinelibs.rst:5 +msgid "Command Line Interface Libraries" +msgstr "命令列介面函式庫" + +#: ../../library/cmdlinelibs.rst:7 +msgid "" +"The modules described in this chapter assist with implementing command line " +"and terminal interfaces for applications." +msgstr "本章節所描述的模組協助實作應用程式的命令列與終端介面。" + +#: ../../library/cmdlinelibs.rst:10 +msgid "Here's an overview:" +msgstr "以下為概覽:" diff --git a/library/code.po b/library/code.po index 2e2f496e04..108750d790 100644 --- a/library/code.po +++ b/library/code.po @@ -1,15 +1,15 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: +# Matt Wang , 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-09 00:03+0000\n" -"PO-Revision-Date: 2018-05-23 14:40+0000\n" -"Last-Translator: Adrian Liaw \n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"PO-Revision-Date: 2025-07-13 14:40+0000\n" +"Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -32,41 +32,77 @@ msgid "" "in Python. Two classes and convenience functions are included which can be " "used to build applications which provide an interactive interpreter prompt." msgstr "" +"``code`` 模組提供在 Python 中實作讀取-求值-印出迴圈(read-eval-print loops)的" +"設施。包含兩個類別和便利函式,可用於建立提供互動式直譯器提示的應用程式。" #: ../../library/code.rst:18 msgid "" "This class deals with parsing and interpreter state (the user's namespace); " "it does not deal with input buffering or prompting or input file naming (the " "filename is always passed in explicitly). The optional *locals* argument " -"specifies the dictionary in which code will be executed; it defaults to a " -"newly created dictionary with key ``'__name__'`` set to ``'__console__'`` " -"and key ``'__doc__'`` set to ``None``." +"specifies a mapping to use as the namespace in which code will be executed; " +"it defaults to a newly created dictionary with key ``'__name__'`` set to " +"``'__console__'`` and key ``'__doc__'`` set to ``None``." msgstr "" +"這個類別處理剖析和直譯器狀態(使用者的命名空間);它不處理輸入緩衝、提示或輸" +"入檔案命名(檔案名稱總是明確傳入)。可選的 *locals* 引數指定一個對映,作為執" +"行程式碼的命名空間;它預設為新建立的字典,鍵 ``'__name__'`` 設為 " +"``'__console__'`` 而鍵 ``'__doc__'`` 會設為 ``None``。" -#: ../../library/code.rst:28 +#: ../../library/code.rst:25 +msgid "" +"Note that functions and classes objects created under an :class:`!" +"InteractiveInterpreter` instance will belong to the namespace specified by " +"*locals*. They are only pickleable if *locals* is the namespace of an " +"existing module." +msgstr "" +"請注意,在 :class:`!InteractiveInterpreter` 實例下建立的函式和類別物件將屬於" +"由 *locals* 指定的命名空間。只有當 *locals* 是現有模組的命名空間時,它們才會" +"是可被 pickle 的。" + +#: ../../library/code.rst:34 msgid "" "Closely emulate the behavior of the interactive Python interpreter. This " "class builds on :class:`InteractiveInterpreter` and adds prompting using the " -"familiar ``sys.ps1`` and ``sys.ps2``, and input buffering." +"familiar ``sys.ps1`` and ``sys.ps2``, and input buffering. If *local_exit* " +"is true, ``exit()`` and ``quit()`` in the console will not raise :exc:" +"`SystemExit`, but instead return to the calling code." msgstr "" +"近似地模擬出互動式 Python 直譯器的行為。這個類別建立" +"在 :class:`InteractiveInterpreter` 的基礎上,並加入使用熟悉的 ``sys.ps1`` 和 " +"``sys.ps2`` 的提示,以及輸入緩衝。如果 *local_exit* 為 true,控制台中的 " +"``exit()`` 和 ``quit()`` 將不會引發 :exc:`SystemExit`,而是回傳到呼叫程式碼。" -#: ../../library/code.rst:35 +#: ../../library/code.rst:40 ../../library/code.rst:58 +msgid "Added *local_exit* parameter." +msgstr "新增 *local_exit* 參數。" + +#: ../../library/code.rst:45 msgid "" "Convenience function to run a read-eval-print loop. This creates a new " "instance of :class:`InteractiveConsole` and sets *readfunc* to be used as " "the :meth:`InteractiveConsole.raw_input` method, if provided. If *local* is " "provided, it is passed to the :class:`InteractiveConsole` constructor for " -"use as the default namespace for the interpreter loop. The :meth:" -"`~InteractiveConsole.interact` method of the instance is then run with " +"use as the default namespace for the interpreter loop. If *local_exit* is " +"provided, it is passed to the :class:`InteractiveConsole` constructor. The :" +"meth:`~InteractiveConsole.interact` method of the instance is then run with " "*banner* and *exitmsg* passed as the banner and exit message to use, if " "provided. The console object is discarded after use." msgstr "" +"執行 read-eval-print 迴圈的便利函式。這會建立一" +"個 :class:`InteractiveConsole` 的新實例,並設定 *readfunc* 以用" +"於 :meth:`InteractiveConsole.raw_input` 方法(如有提供)。如果 *local* 有被提" +"供,它會被傳給 :class:`InteractiveConsole` 的建構函式以作為直譯器迴圈的預設命" +"名空間。如果有提供 *local_exit*,它會被傳給 :class:`InteractiveConsole` 構建" +"函式。然後實例的 :meth:`~InteractiveConsole.interact` 方法會執行,並傳入 " +"*banner* 和 *exitmsg* 以作為要使用的橫幅和退出訊息(如有提供)。控制台物件在" +"使用後就會被丟棄。" -#: ../../library/code.rst:44 +#: ../../library/code.rst:55 msgid "Added *exitmsg* parameter." msgstr "新增 *exitmsg* 參數。" -#: ../../library/code.rst:50 +#: ../../library/code.rst:57 msgid "" "This function is useful for programs that want to emulate Python's " "interpreter main loop (a.k.a. the read-eval-print loop). The tricky part is " @@ -75,16 +111,23 @@ msgid "" "syntax error). This function *almost* always makes the same decision as the " "real interpreter main loop." msgstr "" +"這個函式對於想要模擬 Python 的直譯器主迴圈(即讀取-求值-印出迴圈)的程式很有" +"用。最棘手的部分是判斷使用者何時輸入了一個不完整的命令,而這個命令可以透過輸" +"入更多文字來完成(相對於完整的命令或語法錯誤)。這個函式\\ *幾乎*\\ 總是做出" +"與真正的直譯器主迴圈相同的判斷。" -#: ../../library/code.rst:57 +#: ../../library/code.rst:70 msgid "" "*source* is the source string; *filename* is the optional filename from " "which source was read, defaulting to ``''``; and *symbol* is the " "optional grammar start symbol, which should be ``'single'`` (the default), " "``'eval'`` or ``'exec'``." msgstr "" +"*source* 是來源字串;*filename* 是讀取來源的可選檔案名稱,預設為 " +"``''``;*symbol* 是可選的文法 (grammar) 起始符號,其應為 " +"``'single'``\\ (預設值)、``'eval'`` 或 ``'exec'``。" -#: ../../library/code.rst:62 +#: ../../library/code.rst:75 msgid "" "Returns a code object (the same as ``compile(source, filename, symbol)``) if " "the command is complete and valid; ``None`` if the command is incomplete; " @@ -92,61 +135,86 @@ msgid "" "error, or raises :exc:`OverflowError` or :exc:`ValueError` if the command " "contains an invalid literal." msgstr "" +"如果命令完整且有效,則回傳程式碼物件(與 ``compile(source,filename,symbol)`` " +"相同);如果命令不完整,則回傳 ``None``;如果命令完整但包含語法錯誤,則引" +"發 :exc:`SyntaxError`,如果命令包含無效的字面值 (literal),則引" +"發 :exc:`OverflowError` 或 :exc:`ValueError`。" -#: ../../library/code.rst:72 +#: ../../library/code.rst:85 msgid "Interactive Interpreter Objects" -msgstr "" +msgstr "互動式直譯器物件" -#: ../../library/code.rst:77 +#: ../../library/code.rst:90 msgid "" "Compile and run some source in the interpreter. Arguments are the same as " "for :func:`compile_command`; the default for *filename* is ``''``, " "and for *symbol* is ``'single'``. One of several things can happen:" msgstr "" +"在直譯器中編譯並執行某些原始碼。引數與 :func:`compile_command` 相同;" +"*filename* 的預設值是 ``''``,*symbol* 的預設值是 ``'single'``。有幾種" +"情況會發生:" -#: ../../library/code.rst:81 +#: ../../library/code.rst:94 msgid "" "The input is incorrect; :func:`compile_command` raised an exception (:exc:" "`SyntaxError` or :exc:`OverflowError`). A syntax traceback will be printed " "by calling the :meth:`showsyntaxerror` method. :meth:`runsource` returns " "``False``." msgstr "" +"輸入不正確;:func:`compile_command` 會引發例外(:exc:`SyntaxError` " +"或 :exc:`OverflowError`)。語法回溯 (syntax traceback) 會透過呼" +"叫 :meth:`showsyntaxerror` 方法來印出。:meth:`runsource` 會回傳 ``False``。" -#: ../../library/code.rst:86 +#: ../../library/code.rst:99 msgid "" "The input is incomplete, and more input is required; :func:`compile_command` " "returned ``None``. :meth:`runsource` returns ``True``." msgstr "" +"輸入不完整,需要更多輸入;:func:`compile_command` 回傳了 " +"``None``。:meth:`runsource` 會回傳 ``True``。" -#: ../../library/code.rst:89 +#: ../../library/code.rst:102 msgid "" "The input is complete; :func:`compile_command` returned a code object. The " "code is executed by calling the :meth:`runcode` (which also handles run-time " "exceptions, except for :exc:`SystemExit`). :meth:`runsource` returns " "``False``." msgstr "" +"輸入完整;:func:`compile_command` 回傳一個程式碼物件。程式碼會透過呼" +"叫 :meth:`runcode` 執行(它也會處理執行時的例外,除 :exc:`SystemExit` 以" +"外)。:meth:`runsource` 會回傳 ``False``。" -#: ../../library/code.rst:93 +#: ../../library/code.rst:100 +msgid "" +"The return value can be used to decide whether to use ``sys.ps1`` or " +"``sys.ps2`` to prompt the next line." +msgstr "回傳值可用來決定是使用 ``sys.ps1`` 還是 ``sys.ps2`` 以提示下一列。" + +#: ../../library/code.rst:106 msgid "" "The return value can be used to decide whether to use ``sys.ps1`` or ``sys." "ps2`` to prompt the next line." -msgstr "" +msgstr "回傳值可用來決定是使用 ``sys.ps1`` 還是 ``sys.ps2`` 以提示下一列。" -#: ../../library/code.rst:99 +#: ../../library/code.rst:112 msgid "" "Execute a code object. When an exception occurs, :meth:`showtraceback` is " "called to display a traceback. All exceptions are caught except :exc:" "`SystemExit`, which is allowed to propagate." msgstr "" +"執行程式碼物件。當例外發生時,會呼叫 :meth:`showtraceback` 來顯示回溯。除" +"了 :exc:`SystemExit` 允許繼續傳播之外,所有的例外都會被捕獲。" -#: ../../library/code.rst:103 +#: ../../library/code.rst:116 msgid "" "A note about :exc:`KeyboardInterrupt`: this exception may occur elsewhere in " "this code, and may not always be caught. The caller should be prepared to " "deal with it." msgstr "" +"關於 :exc:`KeyboardInterrupt` 的注意事項:此例外可能發生在此程式碼的其他地" +"方,而且不一定會被捕獲到。呼叫者應該準備好處理它。" -#: ../../library/code.rst:110 +#: ../../library/code.rst:117 msgid "" "Display the syntax error that just occurred. This does not display a stack " "trace because there isn't one for syntax errors. If *filename* is given, it " @@ -154,39 +222,48 @@ msgid "" "Python's parser, because it always uses ``''`` when reading from a " "string. The output is written by the :meth:`write` method." msgstr "" +"顯示剛剛發生的語法錯誤。這不會顯示堆疊追蹤 (stack trace),因為語法錯誤沒有堆疊追蹤。" +"如果給出 *filename*,它會被塞入例外,而不是 Python 剖析器提供的預設檔案名稱,因為它" +"從字串讀取時總是使用 ``''``。輸出會由 :meth:`write` 方法寫入。" -#: ../../library/code.rst:119 +#: ../../library/code.rst:126 msgid "" "Display the exception that just occurred. We remove the first stack item " "because it is within the interpreter object implementation. The output is " "written by the :meth:`write` method." msgstr "" +"顯示剛剛發生的例外。我們移除第一個堆疊項目,因為它在直譯器物件的實作範圍內。" +"輸出由 :meth:`write` 方法寫入。" -#: ../../library/code.rst:123 +#: ../../library/code.rst:130 msgid "" "The full chained traceback is displayed instead of just the primary " "traceback." -msgstr "" +msgstr "會顯示完整的連鎖回溯記錄,而不只是主要回溯。" -#: ../../library/code.rst:129 +#: ../../library/code.rst:142 msgid "" "Write a string to the standard error stream (``sys.stderr``). Derived " "classes should override this to provide the appropriate output handling as " "needed." msgstr "" +"寫入字串到標準錯誤串流 (``sys.stderr``)。衍生類別應覆寫此功能,以根據需求提供" +"適當的輸出處理。" -#: ../../library/code.rst:136 +#: ../../library/code.rst:149 msgid "Interactive Console Objects" -msgstr "" +msgstr "互動式控制台物件" -#: ../../library/code.rst:138 +#: ../../library/code.rst:145 msgid "" "The :class:`InteractiveConsole` class is a subclass of :class:" "`InteractiveInterpreter`, and so offers all the methods of the interpreter " "objects as well as the following additions." msgstr "" +":class:`InteractiveConsole` 類別是 :class:`InteractiveInterpreter` 的子類別," +"因此提供了所有直譯器物件的方法以及下列新增的功能。" -#: ../../library/code.rst:145 +#: ../../library/code.rst:152 msgid "" "Closely emulate the interactive Python console. The optional *banner* " "argument specify the banner to print before the first interaction; by " @@ -195,23 +272,28 @@ msgid "" "(so as not to confuse this with the real interpreter -- since it's so " "close!)." msgstr "" +"近似地模擬互動式 Python 控制台。可選的 *banner* 引數指定在第一次互動之前要印" +"出的横幅;預設會印出類似標準 Python 直譯器所列印的横幅,接著是控制台物" +"件在括弧中的類別名稱 (以免與真正的直譯器混淆 -- 因為它是如此接近!)。" -#: ../../library/code.rst:151 +#: ../../library/code.rst:158 msgid "" "The optional *exitmsg* argument specifies an exit message printed when " "exiting. Pass the empty string to suppress the exit message. If *exitmsg* is " "not given or ``None``, a default message is printed." msgstr "" +"可選的 *exitmsg* 引數指定退出時列印的退出訊息。傳遞空字串以抑制退出訊息。如果" +"沒有給 *exitmsg* 或 ``None``,則會印出預設訊息。" -#: ../../library/code.rst:155 +#: ../../library/code.rst:168 msgid "To suppress printing any banner, pass an empty string." -msgstr "" +msgstr "若要抑制印出任何橫幅,請傳入空字串。" -#: ../../library/code.rst:158 +#: ../../library/code.rst:171 msgid "Print an exit message when exiting." -msgstr "" +msgstr "退出時印出退出訊息。" -#: ../../library/code.rst:164 +#: ../../library/code.rst:171 msgid "" "Push a line of source text to the interpreter. The line should not have a " "trailing newline; it may have internal newlines. The line is appended to a " @@ -223,15 +305,24 @@ msgid "" "is required, ``False`` if the line was dealt with in some way (this is the " "same as :meth:`!runsource`)." msgstr "" +"推送一行原始文字到直譯器。這一行不應該有尾部換行符號;它可能有內部換行符號。這行文字" +"會被附加到緩衝區,並且直譯器的 :meth:`~InteractiveInterpreter.runsource` 方法" +"會被呼叫,並以緩衝區的串接內容做為原始碼。如果這表示命令已執行或無效,緩衝區" +"會被重設;否則,命令會不完整,且緩衝區會保持該行被附加後的樣子。如果需要更多的輸" +"入,回傳值是 ``True``,如果該行已經以某種方式處理,回傳值是 ``False``\\ (這" +"與 :meth:`!runsource` 相同)。" -#: ../../library/code.rst:176 +#: ../../library/code.rst:183 msgid "Remove any unhandled source text from the input buffer." -msgstr "" +msgstr "從輸入緩衝區移除任何未處理的原始文字。" -#: ../../library/code.rst:181 +#: ../../library/code.rst:188 msgid "" "Write a prompt and read a line. The returned line does not include the " "trailing newline. When the user enters the EOF key sequence, :exc:" "`EOFError` is raised. The base implementation reads from ``sys.stdin``; a " "subclass may replace this with a different implementation." msgstr "" +"寫入一個提示並讀取一行。回傳的行不包括尾部的換行符號。當使用者輸入 EOF 鍵序時," +"會引發 :exc:`EOFError`。基底實作會從 ``sys.stdin`` 讀取;子類別可以用不同的實作" +"替代。" diff --git a/library/codecs.po b/library/codecs.po index fe49b0fa68..fdd1bfcb7c 100644 --- a/library/codecs.po +++ b/library/codecs.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-09 00:03+0000\n" +"POT-Creation-Date: 2025-07-28 00:20+0000\n" "PO-Revision-Date: 2018-05-23 14:40+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -43,7 +42,7 @@ msgstr "" msgid "" "The module defines the following functions for encoding and decoding with " "any codec:" -msgstr "" +msgstr "這個模組定義了以下函式,用於以任何編解碼器來編碼與解碼:" #: ../../library/codecs.rst:38 msgid "Encodes *obj* using the codec registered for *encoding*." @@ -71,17 +70,26 @@ msgid "" "information on codec error handling." msgstr "" -#: ../../library/codecs.rst:56 +#: ../../library/codecs.rst:58 +msgid "" +"Return a mapping suitable for encoding with a custom single-byte encoding. " +"Given a :class:`str` *string* of up to 256 characters representing a " +"decoding table, returns either a compact internal mapping object " +"``EncodingMap`` or a :class:`dictionary ` mapping character ordinals " +"to byte values. Raises a :exc:`TypeError` on invalid input." +msgstr "" + +#: ../../library/codecs.rst:64 msgid "The full details for each codec can also be looked up directly:" msgstr "" -#: ../../library/codecs.rst:60 +#: ../../library/codecs.rst:68 msgid "" "Looks up the codec info in the Python codec registry and returns a :class:" "`CodecInfo` object as defined below." msgstr "" -#: ../../library/codecs.rst:63 +#: ../../library/codecs.rst:71 msgid "" "Encodings are first looked up in the registry's cache. If not found, the " "list of registered search functions is scanned. If no :class:`CodecInfo` " @@ -89,17 +97,17 @@ msgid "" "`CodecInfo` object is stored in the cache and returned to the caller." msgstr "" -#: ../../library/codecs.rst:70 +#: ../../library/codecs.rst:78 msgid "" "Codec details when looking up the codec registry. The constructor arguments " "are stored in attributes of the same name:" msgstr "" -#: ../../library/codecs.rst:76 +#: ../../library/codecs.rst:84 msgid "The name of the encoding." -msgstr "" +msgstr "編碼的名稱。" -#: ../../library/codecs.rst:82 +#: ../../library/codecs.rst:90 msgid "" "The stateless encoding and decoding functions. These must be functions or " "methods which have the same interface as the :meth:`~Codec.encode` and :meth:" @@ -108,7 +116,7 @@ msgid "" "mode." msgstr "" -#: ../../library/codecs.rst:92 +#: ../../library/codecs.rst:100 msgid "" "Incremental encoder and decoder classes or factory functions. These have to " "provide the interface defined by the base classes :class:" @@ -116,77 +124,77 @@ msgid "" "Incremental codecs can maintain state." msgstr "" -#: ../../library/codecs.rst:101 +#: ../../library/codecs.rst:109 msgid "" "Stream writer and reader classes or factory functions. These have to provide " "the interface defined by the base classes :class:`StreamWriter` and :class:" "`StreamReader`, respectively. Stream codecs can maintain state." msgstr "" -#: ../../library/codecs.rst:106 +#: ../../library/codecs.rst:114 msgid "" "To simplify access to the various codec components, the module provides " "these additional functions which use :func:`lookup` for the codec lookup:" msgstr "" -#: ../../library/codecs.rst:111 +#: ../../library/codecs.rst:119 msgid "" "Look up the codec for the given encoding and return its encoder function." msgstr "" -#: ../../library/codecs.rst:113 ../../library/codecs.rst:120 -#: ../../library/codecs.rst:146 ../../library/codecs.rst:154 +#: ../../library/codecs.rst:121 ../../library/codecs.rst:128 +#: ../../library/codecs.rst:154 ../../library/codecs.rst:162 msgid "Raises a :exc:`LookupError` in case the encoding cannot be found." msgstr "" -#: ../../library/codecs.rst:118 +#: ../../library/codecs.rst:126 msgid "" "Look up the codec for the given encoding and return its decoder function." msgstr "" -#: ../../library/codecs.rst:125 +#: ../../library/codecs.rst:133 msgid "" "Look up the codec for the given encoding and return its incremental encoder " "class or factory function." msgstr "" -#: ../../library/codecs.rst:128 +#: ../../library/codecs.rst:136 msgid "" "Raises a :exc:`LookupError` in case the encoding cannot be found or the " "codec doesn't support an incremental encoder." msgstr "" -#: ../../library/codecs.rst:134 +#: ../../library/codecs.rst:142 msgid "" "Look up the codec for the given encoding and return its incremental decoder " "class or factory function." msgstr "" -#: ../../library/codecs.rst:137 +#: ../../library/codecs.rst:145 msgid "" "Raises a :exc:`LookupError` in case the encoding cannot be found or the " "codec doesn't support an incremental decoder." msgstr "" -#: ../../library/codecs.rst:143 +#: ../../library/codecs.rst:151 msgid "" "Look up the codec for the given encoding and return its :class:" "`StreamReader` class or factory function." msgstr "" -#: ../../library/codecs.rst:151 +#: ../../library/codecs.rst:159 msgid "" "Look up the codec for the given encoding and return its :class:" "`StreamWriter` class or factory function." msgstr "" -#: ../../library/codecs.rst:156 +#: ../../library/codecs.rst:164 msgid "" "Custom codecs are made available by registering a suitable codec search " "function:" msgstr "" -#: ../../library/codecs.rst:161 +#: ../../library/codecs.rst:169 msgid "" "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 " @@ -195,17 +203,17 @@ msgid "" "``None``." msgstr "" -#: ../../library/codecs.rst:167 +#: ../../library/codecs.rst:175 msgid "Hyphens and spaces are converted to underscore." msgstr "" -#: ../../library/codecs.rst:173 +#: ../../library/codecs.rst:181 msgid "" "Unregister a codec search function and clear the registry's cache. If the " "search function is not registered, do nothing." msgstr "" -#: ../../library/codecs.rst:179 +#: ../../library/codecs.rst:187 msgid "" "While the builtin :func:`open` and the associated :mod:`io` module are the " "recommended approach for working with encoded text files, this module " @@ -213,14 +221,14 @@ msgid "" "wider range of codecs when working with binary files:" msgstr "" -#: ../../library/codecs.rst:186 +#: ../../library/codecs.rst:194 msgid "" "Open an encoded file using the given *mode* and return an instance of :class:" "`StreamReaderWriter`, providing transparent encoding/decoding. The default " "file mode is ``'r'``, meaning to open the file in read mode." msgstr "" -#: ../../library/codecs.rst:192 +#: ../../library/codecs.rst:200 msgid "" "If *encoding* is not ``None``, then the underlying encoded files are always " "opened in binary mode. No automatic conversion of ``'\\n'`` is done on " @@ -228,38 +236,38 @@ msgid "" "to the built-in :func:`open` function; the ``'b'`` is automatically added." msgstr "" -#: ../../library/codecs.rst:198 +#: ../../library/codecs.rst:206 msgid "" "*encoding* specifies the encoding which is to be used for the file. Any " "encoding that encodes to and decodes from bytes is allowed, and the data " "types supported by the file methods depend on the codec used." msgstr "" -#: ../../library/codecs.rst:202 +#: ../../library/codecs.rst:210 msgid "" "*errors* may be given to define the error handling. It defaults to " "``'strict'`` which causes a :exc:`ValueError` to be raised in case an " "encoding error occurs." msgstr "" -#: ../../library/codecs.rst:205 +#: ../../library/codecs.rst:213 msgid "" "*buffering* has the same meaning as for the built-in :func:`open` function. " "It defaults to -1 which means that the default buffer size will be used." msgstr "" -#: ../../library/codecs.rst:208 +#: ../../library/codecs.rst:216 msgid "The ``'U'`` mode has been removed." -msgstr "" +msgstr "已移除 ``'U'`` 模式。" -#: ../../library/codecs.rst:214 +#: ../../library/codecs.rst:222 msgid "" "Return a :class:`StreamRecoder` instance, a wrapped version of *file* which " "provides transparent transcoding. The original file is closed when the " "wrapped version is closed." msgstr "" -#: ../../library/codecs.rst:218 +#: ../../library/codecs.rst:226 msgid "" "Data written to the wrapped file is decoded according to the given " "*data_encoding* and then written to the original file as bytes using " @@ -267,41 +275,41 @@ msgid "" "*file_encoding*, and the result is encoded using *data_encoding*." msgstr "" -#: ../../library/codecs.rst:224 +#: ../../library/codecs.rst:232 msgid "If *file_encoding* is not given, it defaults to *data_encoding*." msgstr "" -#: ../../library/codecs.rst:226 +#: ../../library/codecs.rst:234 msgid "" "*errors* may be given to define the error handling. It defaults to " "``'strict'``, which causes :exc:`ValueError` to be raised in case an " "encoding error occurs." msgstr "" -#: ../../library/codecs.rst:233 +#: ../../library/codecs.rst:241 msgid "" "Uses an incremental encoder to iteratively encode the input provided by " -"*iterator*. This function is a :term:`generator`. The *errors* argument (as " -"well as any other keyword argument) is passed through to the incremental " -"encoder." +"*iterator*. *iterator* must yield :class:`str` objects. This function is a :" +"term:`generator`. The *errors* argument (as well as any other keyword " +"argument) is passed through to the incremental encoder." msgstr "" -#: ../../library/codecs.rst:238 +#: ../../library/codecs.rst:246 msgid "" "This function requires that the codec accept text :class:`str` objects to " "encode. Therefore it does not support bytes-to-bytes encoders such as " "``base64_codec``." msgstr "" -#: ../../library/codecs.rst:245 +#: ../../library/codecs.rst:253 msgid "" "Uses an incremental decoder to iteratively decode the input provided by " -"*iterator*. This function is a :term:`generator`. The *errors* argument (as " -"well as any other keyword argument) is passed through to the incremental " -"decoder." +"*iterator*. *iterator* must yield :class:`bytes` objects. This function is " +"a :term:`generator`. The *errors* argument (as well as any other keyword " +"argument) is passed through to the incremental decoder." msgstr "" -#: ../../library/codecs.rst:250 +#: ../../library/codecs.rst:258 msgid "" "This function requires that the codec accept :class:`bytes` objects to " "decode. Therefore it does not support text-to-text encoders such as " @@ -309,13 +317,32 @@ msgid "" "`iterencode`." msgstr "" -#: ../../library/codecs.rst:256 +#: ../../library/codecs.rst:266 +msgid "" +"Return a :class:`tuple` containing the raw bytes of *buffer*, a :ref:`buffer-" +"compatible object ` or :class:`str` (encoded to UTF-8 before " +"processing), and their length in bytes." +msgstr "" + +#: ../../library/codecs.rst:270 +msgid "The *errors* argument is ignored." +msgstr "忽略 *errors* 引數。" + +#: ../../library/codecs.rst:272 +msgid "" +">>> codecs.readbuffer_encode(b\"Zito\")\n" +"(b'Zito', 4)" +msgstr "" +">>> codecs.readbuffer_encode(b\"Zito\")\n" +"(b'Zito', 4)" + +#: ../../library/codecs.rst:278 msgid "" "The module also provides the following constants which are useful for " "reading and writing to platform dependent files:" msgstr "" -#: ../../library/codecs.rst:271 +#: ../../library/codecs.rst:293 msgid "" "These constants define various byte sequences, being Unicode byte order " "marks (BOMs) for several encodings. They are used in UTF-16 and UTF-32 data " @@ -327,18 +354,18 @@ msgid "" "represent the BOM in UTF-8 and UTF-32 encodings." msgstr "" -#: ../../library/codecs.rst:285 +#: ../../library/codecs.rst:307 msgid "Codec Base Classes" msgstr "" -#: ../../library/codecs.rst:287 +#: ../../library/codecs.rst:309 msgid "" "The :mod:`codecs` module defines a set of base classes which define the " "interfaces for working with codec objects, and can also be used as the basis " "for custom codec implementations." msgstr "" -#: ../../library/codecs.rst:291 +#: ../../library/codecs.rst:313 msgid "" "Each codec has to define four interfaces to make it usable as codec in " "Python: stateless encoder, stateless decoder, stream reader and stream " @@ -347,69 +374,69 @@ msgid "" "how the codec will handle encoding and decoding errors." msgstr "" -#: ../../library/codecs.rst:302 +#: ../../library/codecs.rst:324 msgid "Error Handlers" msgstr "" -#: ../../library/codecs.rst:304 +#: ../../library/codecs.rst:326 msgid "" "To simplify and standardize error handling, codecs may implement different " "error handling schemes by accepting the *errors* string argument:" msgstr "" -#: ../../library/codecs.rst:324 +#: ../../library/codecs.rst:346 msgid "" "The following error handlers can be used with all Python :ref:`standard-" "encodings` codecs:" msgstr "" -#: ../../library/codecs.rst:330 ../../library/codecs.rst:373 -#: ../../library/codecs.rst:393 +#: ../../library/codecs.rst:352 ../../library/codecs.rst:395 +#: ../../library/codecs.rst:415 msgid "Value" msgstr "" -#: ../../library/codecs.rst:330 ../../library/codecs.rst:373 -#: ../../library/codecs.rst:393 ../../library/codecs.rst:1330 -#: ../../library/codecs.rst:1398 ../../library/codecs.rst:1455 +#: ../../library/codecs.rst:352 ../../library/codecs.rst:395 +#: ../../library/codecs.rst:415 ../../library/codecs.rst:1360 +#: ../../library/codecs.rst:1432 ../../library/codecs.rst:1517 msgid "Meaning" msgstr "含義" -#: ../../library/codecs.rst:332 +#: ../../library/codecs.rst:354 msgid "``'strict'``" msgstr "``'strict'``" -#: ../../library/codecs.rst:332 +#: ../../library/codecs.rst:354 msgid "" "Raise :exc:`UnicodeError` (or a subclass), this is the default. Implemented " "in :func:`strict_errors`." msgstr "" -#: ../../library/codecs.rst:336 +#: ../../library/codecs.rst:358 msgid "``'ignore'``" msgstr "``'ignore'``" -#: ../../library/codecs.rst:336 +#: ../../library/codecs.rst:358 msgid "" "Ignore the malformed data and continue without further notice. Implemented " "in :func:`ignore_errors`." msgstr "" -#: ../../library/codecs.rst:340 +#: ../../library/codecs.rst:362 msgid "``'replace'``" msgstr "``'replace'``" -#: ../../library/codecs.rst:340 +#: ../../library/codecs.rst:362 msgid "" "Replace with a replacement marker. On encoding, use ``?`` (ASCII character). " "On decoding, use ``�`` (U+FFFD, the official REPLACEMENT CHARACTER). " "Implemented in :func:`replace_errors`." msgstr "" -#: ../../library/codecs.rst:346 +#: ../../library/codecs.rst:368 msgid "``'backslashreplace'``" msgstr "``'backslashreplace'``" -#: ../../library/codecs.rst:346 +#: ../../library/codecs.rst:368 msgid "" "Replace with backslashed escape sequences. On encoding, use hexadecimal form " "of Unicode code point with formats :samp:`\\\\x{hh}` :samp:`\\\\u{xxxx}` :" @@ -417,11 +444,11 @@ msgid "" "format :samp:`\\\\x{hh}`. Implemented in :func:`backslashreplace_errors`." msgstr "" -#: ../../library/codecs.rst:355 +#: ../../library/codecs.rst:377 msgid "``'surrogateescape'``" msgstr "``'surrogateescape'``" -#: ../../library/codecs.rst:355 +#: ../../library/codecs.rst:377 msgid "" "On decoding, replace byte with individual surrogate code ranging from " "``U+DC80`` to ``U+DCFF``. This code will then be turned back into the same " @@ -429,92 +456,92 @@ msgid "" "data. (See :pep:`383` for more.)" msgstr "" -#: ../../library/codecs.rst:369 +#: ../../library/codecs.rst:391 msgid "" "The following error handlers are only applicable to encoding (within :term:" "`text encodings `):" msgstr "" -#: ../../library/codecs.rst:375 +#: ../../library/codecs.rst:397 msgid "``'xmlcharrefreplace'``" msgstr "``'xmlcharrefreplace'``" -#: ../../library/codecs.rst:375 +#: ../../library/codecs.rst:397 msgid "" "Replace with XML/HTML numeric character reference, which is a decimal form " "of Unicode code point with format :samp:`&#{num};`. Implemented in :func:" "`xmlcharrefreplace_errors`." msgstr "" -#: ../../library/codecs.rst:381 +#: ../../library/codecs.rst:403 msgid "``'namereplace'``" msgstr "``'namereplace'``" -#: ../../library/codecs.rst:381 +#: ../../library/codecs.rst:403 msgid "" "Replace with ``\\N{...}`` escape sequences, what appears in the braces is " "the Name property from Unicode Character Database. Implemented in :func:" "`namereplace_errors`." msgstr "" -#: ../../library/codecs.rst:390 +#: ../../library/codecs.rst:412 msgid "" "In addition, the following error handler is specific to the given codecs:" msgstr "" -#: ../../library/codecs.rst:13 ../../library/codecs.rst:393 +#: ../../library/codecs.rst:13 ../../library/codecs.rst:415 msgid "Codecs" msgstr "" -#: ../../library/codecs.rst:395 +#: ../../library/codecs.rst:417 msgid "``'surrogatepass'``" msgstr "``'surrogatepass'``" -#: ../../library/codecs.rst:395 +#: ../../library/codecs.rst:417 msgid "utf-8, utf-16, utf-32, utf-16-be, utf-16-le, utf-32-be, utf-32-le" msgstr "utf-8, utf-16, utf-32, utf-16-be, utf-16-le, utf-32-be, utf-32-le" -#: ../../library/codecs.rst:395 +#: ../../library/codecs.rst:417 msgid "" "Allow encoding and decoding surrogate code point (``U+D800`` - ``U+DFFF``) " "as normal code point. Otherwise these codecs treat the presence of surrogate " "code point in :class:`str` as an error." msgstr "" -#: ../../library/codecs.rst:402 +#: ../../library/codecs.rst:424 msgid "The ``'surrogateescape'`` and ``'surrogatepass'`` error handlers." msgstr "" -#: ../../library/codecs.rst:405 +#: ../../library/codecs.rst:427 msgid "" "The ``'surrogatepass'`` error handler now works with utf-16\\* and utf-32\\* " "codecs." msgstr "" -#: ../../library/codecs.rst:409 +#: ../../library/codecs.rst:431 msgid "The ``'namereplace'`` error handler." msgstr "" -#: ../../library/codecs.rst:412 +#: ../../library/codecs.rst:434 msgid "" "The ``'backslashreplace'`` error handler now works with decoding and " "translating." msgstr "" -#: ../../library/codecs.rst:416 +#: ../../library/codecs.rst:438 msgid "" "The set of allowed values can be extended by registering a new named error " "handler:" msgstr "" -#: ../../library/codecs.rst:421 +#: ../../library/codecs.rst:443 msgid "" "Register the error handling function *error_handler* under the name *name*. " "The *error_handler* argument will be called during encoding and decoding in " "case of an error, when *name* is specified as the errors parameter." msgstr "" -#: ../../library/codecs.rst:425 +#: ../../library/codecs.rst:447 msgid "" "For encoding, *error_handler* will be called with a :exc:" "`UnicodeEncodeError` instance, which contains information about the location " @@ -529,66 +556,66 @@ msgid "" "position is out of bound an :exc:`IndexError` will be raised." msgstr "" -#: ../../library/codecs.rst:437 +#: ../../library/codecs.rst:459 msgid "" "Decoding and translating works similarly, except :exc:`UnicodeDecodeError` " "or :exc:`UnicodeTranslateError` will be passed to the handler and that the " "replacement from the error handler will be put into the output directly." msgstr "" -#: ../../library/codecs.rst:442 +#: ../../library/codecs.rst:464 msgid "" "Previously registered error handlers (including the standard error handlers) " "can be looked up by name:" msgstr "" -#: ../../library/codecs.rst:447 +#: ../../library/codecs.rst:469 msgid "Return the error handler previously registered under the name *name*." msgstr "" -#: ../../library/codecs.rst:449 +#: ../../library/codecs.rst:471 msgid "Raises a :exc:`LookupError` in case the handler cannot be found." msgstr "" -#: ../../library/codecs.rst:451 +#: ../../library/codecs.rst:473 msgid "" "The following standard error handlers are also made available as module " "level functions:" msgstr "" -#: ../../library/codecs.rst:456 +#: ../../library/codecs.rst:478 msgid "Implements the ``'strict'`` error handling." msgstr "" -#: ../../library/codecs.rst:458 +#: ../../library/codecs.rst:480 msgid "Each encoding or decoding error raises a :exc:`UnicodeError`." msgstr "" -#: ../../library/codecs.rst:463 +#: ../../library/codecs.rst:485 msgid "Implements the ``'ignore'`` error handling." msgstr "" -#: ../../library/codecs.rst:465 +#: ../../library/codecs.rst:487 msgid "" "Malformed data is ignored; encoding or decoding is continued without further " "notice." msgstr "" -#: ../../library/codecs.rst:471 +#: ../../library/codecs.rst:493 msgid "Implements the ``'replace'`` error handling." msgstr "" -#: ../../library/codecs.rst:473 +#: ../../library/codecs.rst:495 msgid "" "Substitutes ``?`` (ASCII character) for encoding errors or ``�`` (U+FFFD, " "the official REPLACEMENT CHARACTER) for decoding errors." msgstr "" -#: ../../library/codecs.rst:479 +#: ../../library/codecs.rst:501 msgid "Implements the ``'backslashreplace'`` error handling." msgstr "" -#: ../../library/codecs.rst:481 +#: ../../library/codecs.rst:503 msgid "" "Malformed data is replaced by a backslashed escape sequence. On encoding, " "use the hexadecimal form of Unicode code point with formats :samp:`\\\\x{hh}" @@ -596,30 +623,30 @@ msgid "" "hexadecimal form of byte value with format :samp:`\\\\x{hh}`." msgstr "" -#: ../../library/codecs.rst:487 +#: ../../library/codecs.rst:509 msgid "Works with decoding and translating." msgstr "" -#: ../../library/codecs.rst:493 +#: ../../library/codecs.rst:515 msgid "" "Implements the ``'xmlcharrefreplace'`` error handling (for encoding within :" "term:`text encoding` only)." msgstr "" -#: ../../library/codecs.rst:496 +#: ../../library/codecs.rst:518 msgid "" "The unencodable character is replaced by an appropriate XML/HTML numeric " "character reference, which is a decimal form of Unicode code point with " "format :samp:`&#{num};` ." msgstr "" -#: ../../library/codecs.rst:503 +#: ../../library/codecs.rst:525 msgid "" "Implements the ``'namereplace'`` error handling (for encoding within :term:" "`text encoding` only)." msgstr "" -#: ../../library/codecs.rst:506 +#: ../../library/codecs.rst:528 msgid "" "The unencodable character is replaced by a ``\\N{...}`` escape sequence. The " "set of characters that appear in the braces is the Name property from " @@ -627,17 +654,17 @@ msgid "" "will be converted to byte sequence ``\\N{LATIN SMALL LETTER SHARP S}`` ." msgstr "" -#: ../../library/codecs.rst:517 +#: ../../library/codecs.rst:539 msgid "Stateless Encoding and Decoding" msgstr "" -#: ../../library/codecs.rst:519 +#: ../../library/codecs.rst:541 msgid "" "The base :class:`Codec` class defines these methods which also define the " "function interfaces of the stateless encoder and decoder:" msgstr "" -#: ../../library/codecs.rst:527 +#: ../../library/codecs.rst:549 msgid "" "Encodes the object *input* and returns a tuple (output object, length " "consumed). For instance, :term:`text encoding` converts a string object to a " @@ -645,26 +672,26 @@ msgid "" "``iso-8859-1``)." msgstr "" -#: ../../library/codecs.rst:532 ../../library/codecs.rst:554 +#: ../../library/codecs.rst:554 ../../library/codecs.rst:576 msgid "" "The *errors* argument defines the error handling to apply. It defaults to " "``'strict'`` handling." msgstr "" -#: ../../library/codecs.rst:535 +#: ../../library/codecs.rst:557 msgid "" "The method may not store state in the :class:`Codec` instance. Use :class:" "`StreamWriter` for codecs which have to keep state in order to make encoding " "efficient." msgstr "" -#: ../../library/codecs.rst:539 +#: ../../library/codecs.rst:561 msgid "" "The encoder must be able to handle zero length input and return an empty " "object of the output object type in this situation." msgstr "" -#: ../../library/codecs.rst:545 +#: ../../library/codecs.rst:567 msgid "" "Decodes the object *input* and returns a tuple (output object, length " "consumed). For instance, for a :term:`text encoding`, decoding converts a " @@ -672,31 +699,31 @@ msgid "" "object." msgstr "" -#: ../../library/codecs.rst:550 +#: ../../library/codecs.rst:572 msgid "" "For text encodings and bytes-to-bytes codecs, *input* must be a bytes object " "or one which provides the read-only buffer interface -- for example, buffer " "objects and memory mapped files." msgstr "" -#: ../../library/codecs.rst:557 +#: ../../library/codecs.rst:579 msgid "" "The method may not store state in the :class:`Codec` instance. Use :class:" "`StreamReader` for codecs which have to keep state in order to make decoding " "efficient." msgstr "" -#: ../../library/codecs.rst:561 +#: ../../library/codecs.rst:583 msgid "" "The decoder must be able to handle zero length input and return an empty " "object of the output object type in this situation." msgstr "" -#: ../../library/codecs.rst:566 +#: ../../library/codecs.rst:588 msgid "Incremental Encoding and Decoding" msgstr "" -#: ../../library/codecs.rst:568 +#: ../../library/codecs.rst:590 msgid "" "The :class:`IncrementalEncoder` and :class:`IncrementalDecoder` classes " "provide the basic interface for incremental encoding and decoding. Encoding/" @@ -707,7 +734,7 @@ msgid "" "during method calls." msgstr "" -#: ../../library/codecs.rst:576 +#: ../../library/codecs.rst:598 msgid "" "The joined output of calls to the :meth:`~IncrementalEncoder.encode`/:meth:" "`~IncrementalDecoder.decode` method is the same as if all the single inputs " @@ -715,36 +742,36 @@ msgid "" "encoder/decoder." msgstr "" -#: ../../library/codecs.rst:585 +#: ../../library/codecs.rst:607 msgid "IncrementalEncoder Objects" msgstr "IncrementalEncoder 物件" -#: ../../library/codecs.rst:587 +#: ../../library/codecs.rst:609 msgid "" "The :class:`IncrementalEncoder` class is used for encoding an input in " "multiple steps. It defines the following methods which every incremental " "encoder must define in order to be compatible with the Python codec registry." msgstr "" -#: ../../library/codecs.rst:594 +#: ../../library/codecs.rst:616 msgid "Constructor for an :class:`IncrementalEncoder` instance." -msgstr "" +msgstr ":class:`IncrementalEncoder` 的建構函式。" -#: ../../library/codecs.rst:596 +#: ../../library/codecs.rst:618 msgid "" "All incremental encoders must provide this constructor interface. They are " "free to add additional keyword arguments, but only the ones defined here are " "used by the Python codec registry." msgstr "" -#: ../../library/codecs.rst:600 +#: ../../library/codecs.rst:622 msgid "" "The :class:`IncrementalEncoder` may implement different error handling " "schemes by providing the *errors* keyword argument. See :ref:`error-" "handlers` for possible values." msgstr "" -#: ../../library/codecs.rst:604 +#: ../../library/codecs.rst:626 msgid "" "The *errors* argument will be assigned to an attribute of the same name. " "Assigning to this attribute makes it possible to switch between different " @@ -752,21 +779,21 @@ msgid "" "`IncrementalEncoder` object." msgstr "" -#: ../../library/codecs.rst:612 +#: ../../library/codecs.rst:634 msgid "" "Encodes *object* (taking the current state of the encoder into account) and " "returns the resulting encoded object. If this is the last call to :meth:" "`encode` *final* must be true (the default is false)." msgstr "" -#: ../../library/codecs.rst:619 +#: ../../library/codecs.rst:641 msgid "" "Reset the encoder to the initial state. The output is discarded: call ``." "encode(object, final=True)``, passing an empty byte or text string if " "necessary, to reset the encoder and to get the output." msgstr "" -#: ../../library/codecs.rst:626 +#: ../../library/codecs.rst:648 msgid "" "Return the current state of the encoder which must be an integer. The " "implementation should make sure that ``0`` is the most common state. (States " @@ -775,42 +802,42 @@ msgid "" "into an integer.)" msgstr "" -#: ../../library/codecs.rst:635 +#: ../../library/codecs.rst:657 msgid "" "Set the state of the encoder to *state*. *state* must be an encoder state " "returned by :meth:`getstate`." msgstr "" -#: ../../library/codecs.rst:642 +#: ../../library/codecs.rst:664 msgid "IncrementalDecoder Objects" msgstr "IncrementalDecoder 物件" -#: ../../library/codecs.rst:644 +#: ../../library/codecs.rst:666 msgid "" "The :class:`IncrementalDecoder` class is used for decoding an input in " "multiple steps. It defines the following methods which every incremental " "decoder must define in order to be compatible with the Python codec registry." msgstr "" -#: ../../library/codecs.rst:651 +#: ../../library/codecs.rst:673 msgid "Constructor for an :class:`IncrementalDecoder` instance." -msgstr "" +msgstr ":class:`IncrementalDecoder` 的建構函式。" -#: ../../library/codecs.rst:653 +#: ../../library/codecs.rst:675 msgid "" "All incremental decoders must provide this constructor interface. They are " "free to add additional keyword arguments, but only the ones defined here are " "used by the Python codec registry." msgstr "" -#: ../../library/codecs.rst:657 +#: ../../library/codecs.rst:679 msgid "" "The :class:`IncrementalDecoder` may implement different error handling " "schemes by providing the *errors* keyword argument. See :ref:`error-" "handlers` for possible values." msgstr "" -#: ../../library/codecs.rst:661 +#: ../../library/codecs.rst:683 msgid "" "The *errors* argument will be assigned to an attribute of the same name. " "Assigning to this attribute makes it possible to switch between different " @@ -818,7 +845,7 @@ msgid "" "`IncrementalDecoder` object." msgstr "" -#: ../../library/codecs.rst:669 +#: ../../library/codecs.rst:691 msgid "" "Decodes *object* (taking the current state of the decoder into account) and " "returns the resulting decoded object. If this is the last call to :meth:" @@ -829,11 +856,11 @@ msgid "" "(which might raise an exception)." msgstr "" -#: ../../library/codecs.rst:680 +#: ../../library/codecs.rst:702 msgid "Reset the decoder to the initial state." -msgstr "" +msgstr "將解碼器重設到初始狀態。" -#: ../../library/codecs.rst:685 +#: ../../library/codecs.rst:707 msgid "" "Return the current state of the decoder. This must be a tuple with two " "items, the first must be the buffer containing the still undecoded input. " @@ -848,59 +875,59 @@ msgid "" "bytes of the resulting string into an integer.)" msgstr "" -#: ../../library/codecs.rst:700 +#: ../../library/codecs.rst:722 msgid "" "Set the state of the decoder to *state*. *state* must be a decoder state " "returned by :meth:`getstate`." msgstr "" -#: ../../library/codecs.rst:705 +#: ../../library/codecs.rst:727 msgid "Stream Encoding and Decoding" -msgstr "" +msgstr "串流編碼和解碼" -#: ../../library/codecs.rst:708 +#: ../../library/codecs.rst:730 msgid "" "The :class:`StreamWriter` and :class:`StreamReader` classes provide generic " "working interfaces which can be used to implement new encoding submodules " "very easily. See :mod:`!encodings.utf_8` for an example of how this is done." msgstr "" -#: ../../library/codecs.rst:716 +#: ../../library/codecs.rst:738 msgid "StreamWriter Objects" msgstr "StreamWriter 物件" -#: ../../library/codecs.rst:718 +#: ../../library/codecs.rst:740 msgid "" "The :class:`StreamWriter` class is a subclass of :class:`Codec` and defines " "the following methods which every stream writer must define in order to be " "compatible with the Python codec registry." msgstr "" -#: ../../library/codecs.rst:725 +#: ../../library/codecs.rst:747 msgid "Constructor for a :class:`StreamWriter` instance." -msgstr "" +msgstr ":class:`StreamWriter` 的建構函式。" -#: ../../library/codecs.rst:727 +#: ../../library/codecs.rst:749 msgid "" "All stream writers must provide this constructor interface. They are free to " "add additional keyword arguments, but only the ones defined here are used by " "the Python codec registry." msgstr "" -#: ../../library/codecs.rst:731 +#: ../../library/codecs.rst:753 msgid "" "The *stream* argument must be a file-like object open for writing text or " "binary data, as appropriate for the specific codec." msgstr "" -#: ../../library/codecs.rst:734 +#: ../../library/codecs.rst:756 msgid "" "The :class:`StreamWriter` may implement different error handling schemes by " "providing the *errors* keyword argument. See :ref:`error-handlers` for the " "standard error handlers the underlying stream codec may support." msgstr "" -#: ../../library/codecs.rst:738 +#: ../../library/codecs.rst:760 msgid "" "The *errors* argument will be assigned to an attribute of the same name. " "Assigning to this attribute makes it possible to switch between different " @@ -908,70 +935,70 @@ msgid "" "object." msgstr "" -#: ../../library/codecs.rst:744 +#: ../../library/codecs.rst:766 msgid "Writes the object's contents encoded to the stream." msgstr "" -#: ../../library/codecs.rst:749 +#: ../../library/codecs.rst:771 msgid "" "Writes the concatenated iterable of strings to the stream (possibly by " "reusing the :meth:`write` method). Infinite or very large iterables are not " "supported. The standard bytes-to-bytes codecs do not support this method." msgstr "" -#: ../../library/codecs.rst:757 ../../library/codecs.rst:852 +#: ../../library/codecs.rst:779 ../../library/codecs.rst:874 msgid "Resets the codec buffers used for keeping internal state." msgstr "" -#: ../../library/codecs.rst:759 +#: ../../library/codecs.rst:781 msgid "" "Calling this method should ensure that the data on the output is put into a " "clean state that allows appending of new fresh data without having to rescan " "the whole stream to recover state." msgstr "" -#: ../../library/codecs.rst:764 +#: ../../library/codecs.rst:786 msgid "" "In addition to the above methods, the :class:`StreamWriter` must also " "inherit all other methods and attributes from the underlying stream." msgstr "" -#: ../../library/codecs.rst:771 +#: ../../library/codecs.rst:793 msgid "StreamReader Objects" msgstr "StreamReader 物件" -#: ../../library/codecs.rst:773 +#: ../../library/codecs.rst:795 msgid "" "The :class:`StreamReader` class is a subclass of :class:`Codec` and defines " "the following methods which every stream reader must define in order to be " "compatible with the Python codec registry." msgstr "" -#: ../../library/codecs.rst:780 +#: ../../library/codecs.rst:802 msgid "Constructor for a :class:`StreamReader` instance." -msgstr "" +msgstr ":class:`StreamReader` 的建構函式。" -#: ../../library/codecs.rst:782 +#: ../../library/codecs.rst:804 msgid "" "All stream readers must provide this constructor interface. They are free to " "add additional keyword arguments, but only the ones defined here are used by " "the Python codec registry." msgstr "" -#: ../../library/codecs.rst:786 +#: ../../library/codecs.rst:808 msgid "" "The *stream* argument must be a file-like object open for reading text or " "binary data, as appropriate for the specific codec." msgstr "" -#: ../../library/codecs.rst:789 +#: ../../library/codecs.rst:811 msgid "" "The :class:`StreamReader` may implement different error handling schemes by " "providing the *errors* keyword argument. See :ref:`error-handlers` for the " "standard error handlers the underlying stream codec may support." msgstr "" -#: ../../library/codecs.rst:793 +#: ../../library/codecs.rst:815 msgid "" "The *errors* argument will be assigned to an attribute of the same name. " "Assigning to this attribute makes it possible to switch between different " @@ -979,24 +1006,24 @@ msgid "" "object." msgstr "" -#: ../../library/codecs.rst:797 +#: ../../library/codecs.rst:819 msgid "" "The set of allowed values for the *errors* argument can be extended with :" "func:`register_error`." msgstr "" -#: ../../library/codecs.rst:803 +#: ../../library/codecs.rst:825 msgid "Decodes data from the stream and returns the resulting object." msgstr "" -#: ../../library/codecs.rst:805 +#: ../../library/codecs.rst:827 msgid "" "The *chars* argument indicates the number of decoded code points or bytes to " "return. The :func:`read` method will never return more data than requested, " "but it might return less, if there is not enough available." msgstr "" -#: ../../library/codecs.rst:810 +#: ../../library/codecs.rst:832 msgid "" "The *size* argument indicates the approximate maximum number of encoded " "bytes or code points to read for decoding. The decoder can modify this " @@ -1005,13 +1032,13 @@ msgid "" "huge files in one step." msgstr "" -#: ../../library/codecs.rst:817 +#: ../../library/codecs.rst:839 msgid "" "The *firstline* flag indicates that it would be sufficient to only return " "the first line, if there are decoding errors on later lines." msgstr "" -#: ../../library/codecs.rst:821 +#: ../../library/codecs.rst:843 msgid "" "The method should use a greedy read strategy meaning that it should read as " "much data as is allowed within the definition of the encoding and the given " @@ -1019,68 +1046,68 @@ msgid "" "the stream, these should be read too." msgstr "" -#: ../../library/codecs.rst:829 +#: ../../library/codecs.rst:851 msgid "Read one line from the input stream and return the decoded data." msgstr "" -#: ../../library/codecs.rst:831 +#: ../../library/codecs.rst:853 msgid "" "*size*, if given, is passed as size argument to the stream's :meth:`read` " "method." msgstr "" -#: ../../library/codecs.rst:834 +#: ../../library/codecs.rst:856 msgid "" "If *keepends* is false line-endings will be stripped from the lines returned." msgstr "" -#: ../../library/codecs.rst:840 +#: ../../library/codecs.rst:862 msgid "" "Read all lines available on the input stream and return them as a list of " "lines." msgstr "" -#: ../../library/codecs.rst:843 +#: ../../library/codecs.rst:865 msgid "" "Line-endings are implemented using the codec's :meth:`decode` method and are " "included in the list entries if *keepends* is true." msgstr "" -#: ../../library/codecs.rst:846 +#: ../../library/codecs.rst:868 msgid "" "*sizehint*, if given, is passed as the *size* argument to the stream's :meth:" "`read` method." msgstr "" -#: ../../library/codecs.rst:854 +#: ../../library/codecs.rst:876 msgid "" "Note that no stream repositioning should take place. This method is " "primarily intended to be able to recover from decoding errors." msgstr "" -#: ../../library/codecs.rst:858 +#: ../../library/codecs.rst:880 msgid "" "In addition to the above methods, the :class:`StreamReader` must also " "inherit all other methods and attributes from the underlying stream." msgstr "" -#: ../../library/codecs.rst:864 +#: ../../library/codecs.rst:886 msgid "StreamReaderWriter Objects" msgstr "StreamReaderWriter 物件" -#: ../../library/codecs.rst:866 +#: ../../library/codecs.rst:888 msgid "" "The :class:`StreamReaderWriter` is a convenience class that allows wrapping " "streams which work in both read and write modes." msgstr "" -#: ../../library/codecs.rst:869 ../../library/codecs.rst:893 +#: ../../library/codecs.rst:891 ../../library/codecs.rst:915 msgid "" "The design is such that one can use the factory functions returned by the :" "func:`lookup` function to construct the instance." msgstr "" -#: ../../library/codecs.rst:875 +#: ../../library/codecs.rst:897 msgid "" "Creates a :class:`StreamReaderWriter` instance. *stream* must be a file-like " "object. *Reader* and *Writer* must be factory functions or classes providing " @@ -1089,24 +1116,24 @@ msgid "" "writers." msgstr "" -#: ../../library/codecs.rst:880 +#: ../../library/codecs.rst:902 msgid "" ":class:`StreamReaderWriter` instances define the combined interfaces of :" "class:`StreamReader` and :class:`StreamWriter` classes. They inherit all " "other methods and attributes from the underlying stream." msgstr "" -#: ../../library/codecs.rst:888 +#: ../../library/codecs.rst:910 msgid "StreamRecoder Objects" msgstr "StreamRecoder 物件" -#: ../../library/codecs.rst:890 +#: ../../library/codecs.rst:912 msgid "" "The :class:`StreamRecoder` translates data from one encoding to another, " "which is sometimes useful when dealing with different encoding environments." msgstr "" -#: ../../library/codecs.rst:899 +#: ../../library/codecs.rst:921 msgid "" "Creates a :class:`StreamRecoder` instance which implements a two-way " "conversion: *encode* and *decode* work on the frontend — the data visible to " @@ -1114,17 +1141,17 @@ msgid "" "while *Reader* and *Writer* work on the backend — the data in *stream*." msgstr "" -#: ../../library/codecs.rst:905 +#: ../../library/codecs.rst:927 msgid "" "You can use these objects to do transparent transcodings, e.g., from Latin-1 " "to UTF-8 and back." msgstr "" -#: ../../library/codecs.rst:908 +#: ../../library/codecs.rst:930 msgid "The *stream* argument must be a file-like object." -msgstr "" +msgstr "*stream* 引數必須是類檔案物件。" -#: ../../library/codecs.rst:910 +#: ../../library/codecs.rst:932 msgid "" "The *encode* and *decode* arguments must adhere to the :class:`Codec` " "interface. *Reader* and *Writer* must be factory functions or classes " @@ -1132,24 +1159,24 @@ msgid "" "interface respectively." msgstr "" -#: ../../library/codecs.rst:915 +#: ../../library/codecs.rst:937 msgid "" "Error handling is done in the same way as defined for the stream readers and " "writers." msgstr "" -#: ../../library/codecs.rst:919 +#: ../../library/codecs.rst:941 msgid "" ":class:`StreamRecoder` instances define the combined interfaces of :class:" "`StreamReader` and :class:`StreamWriter` classes. They inherit all other " "methods and attributes from the underlying stream." msgstr "" -#: ../../library/codecs.rst:927 +#: ../../library/codecs.rst:949 msgid "Encodings and Unicode" -msgstr "" +msgstr "編碼和 Unicode" -#: ../../library/codecs.rst:929 +#: ../../library/codecs.rst:951 msgid "" "Strings are stored internally as sequences of code points in range " "``U+0000``--``U+10FFFF``. (See :pep:`393` for more details about the " @@ -1161,7 +1188,7 @@ msgid "" "which are collectivity referred to as :term:`text encodings `." msgstr "" -#: ../../library/codecs.rst:939 +#: ../../library/codecs.rst:961 msgid "" "The simplest text encoding (called ``'latin-1'`` or ``'iso-8859-1'``) maps " "the code points 0--255 to the bytes ``0x0``--``0xff``, which means that a " @@ -1172,7 +1199,7 @@ msgid "" "position 3: ordinal not in range(256)``." msgstr "" -#: ../../library/codecs.rst:947 +#: ../../library/codecs.rst:969 msgid "" "There's another group of encodings (the so called charmap encodings) that " "choose a different subset of all Unicode code points and how these code " @@ -1182,7 +1209,7 @@ msgid "" "that shows you which character is mapped to which byte value." msgstr "" -#: ../../library/codecs.rst:954 +#: ../../library/codecs.rst:976 msgid "" "All of these encodings can only encode 256 of the 1114112 code points " "defined in Unicode. A simple and straightforward way that can store each " @@ -1212,7 +1239,7 @@ msgid "" "normal character that will be decoded like any other." msgstr "" -#: ../../library/codecs.rst:980 +#: ../../library/codecs.rst:1002 msgid "" "There's another encoding that is able to encode the full range of Unicode " "characters: UTF-8. UTF-8 is an 8-bit encoding, which means there are no " @@ -1223,59 +1250,59 @@ msgid "" "which when concatenated give the Unicode character):" msgstr "" -#: ../../library/codecs.rst:989 +#: ../../library/codecs.rst:1011 msgid "Range" msgstr "" -#: ../../library/codecs.rst:989 +#: ../../library/codecs.rst:1011 msgid "Encoding" msgstr "" -#: ../../library/codecs.rst:991 +#: ../../library/codecs.rst:1013 msgid "``U-00000000`` ... ``U-0000007F``" msgstr "``U-00000000`` ... ``U-0000007F``" -#: ../../library/codecs.rst:991 +#: ../../library/codecs.rst:1013 msgid "0xxxxxxx" msgstr "0xxxxxxx" -#: ../../library/codecs.rst:993 +#: ../../library/codecs.rst:1015 msgid "``U-00000080`` ... ``U-000007FF``" msgstr "``U-00000080`` ... ``U-000007FF``" -#: ../../library/codecs.rst:993 +#: ../../library/codecs.rst:1015 msgid "110xxxxx 10xxxxxx" msgstr "110xxxxx 10xxxxxx" -#: ../../library/codecs.rst:995 +#: ../../library/codecs.rst:1017 msgid "``U-00000800`` ... ``U-0000FFFF``" msgstr "``U-00000800`` ... ``U-0000FFFF``" -#: ../../library/codecs.rst:995 +#: ../../library/codecs.rst:1017 msgid "1110xxxx 10xxxxxx 10xxxxxx" msgstr "1110xxxx 10xxxxxx 10xxxxxx" -#: ../../library/codecs.rst:997 +#: ../../library/codecs.rst:1019 msgid "``U-00010000`` ... ``U-0010FFFF``" msgstr "``U-00010000`` ... ``U-0010FFFF``" -#: ../../library/codecs.rst:997 +#: ../../library/codecs.rst:1019 msgid "11110xxx 10xxxxxx 10xxxxxx 10xxxxxx" msgstr "11110xxx 10xxxxxx 10xxxxxx 10xxxxxx" -#: ../../library/codecs.rst:1000 +#: ../../library/codecs.rst:1022 msgid "" "The least significant bit of the Unicode character is the rightmost x bit." msgstr "" -#: ../../library/codecs.rst:1002 +#: ../../library/codecs.rst:1024 msgid "" "As UTF-8 is an 8-bit encoding no BOM is required and any ``U+FEFF`` " "character in the decoded string (even if it's the first character) is " "treated as a ``ZERO WIDTH NO-BREAK SPACE``." msgstr "" -#: ../../library/codecs.rst:1006 +#: ../../library/codecs.rst:1028 msgid "" "Without external information it's impossible to reliably determine which " "encoding was used for encoding a string. Each charmap encoding can decode " @@ -1301,7 +1328,7 @@ msgstr "" msgid "INVERTED QUESTION MARK" msgstr "" -#: ../../library/codecs.rst:1022 +#: ../../library/codecs.rst:1044 msgid "" "in iso-8859-1), this increases the probability that a ``utf-8-sig`` encoding " "can be correctly guessed from the byte sequence. So here the BOM is not used " @@ -1313,11 +1340,11 @@ msgid "" "the use of the BOM is discouraged and should generally be avoided." msgstr "" -#: ../../library/codecs.rst:1035 +#: ../../library/codecs.rst:1057 msgid "Standard Encodings" -msgstr "" +msgstr "標準編碼" -#: ../../library/codecs.rst:1037 +#: ../../library/codecs.rst:1059 msgid "" "Python comes with a number of codecs built-in, either implemented as C " "functions or with dictionaries as mapping tables. The following table lists " @@ -1325,11 +1352,18 @@ msgid "" "for which the encoding is likely used. Neither the list of aliases nor the " "list of languages is meant to be exhaustive. Notice that spelling " "alternatives that only differ in case or use a hyphen instead of an " -"underscore are also valid aliases; therefore, e.g. ``'utf-8'`` is a valid " -"alias for the ``'utf_8'`` codec." +"underscore are also valid aliases because they are equivalent when " +"normalized by :func:`~encodings.normalize_encoding`. For example, " +"``'utf-8'`` is a valid alias for the ``'utf_8'`` codec." msgstr "" -#: ../../library/codecs.rst:1047 +#: ../../library/codecs.rst:1071 +msgid "" +"The below table lists the most common aliases, for a complete list refer to " +"the source :source:`aliases.py ` file." +msgstr "" + +#: ../../library/codecs.rst:1076 msgid "" "Some common encodings can bypass the codecs lookup machinery to improve " "performance. These optimization opportunities are only recognized by CPython " @@ -1339,11 +1373,11 @@ msgid "" "Using alternative aliases for these encodings may result in slower execution." msgstr "" -#: ../../library/codecs.rst:1055 +#: ../../library/codecs.rst:1084 msgid "Optimization opportunity recognized for us-ascii." msgstr "" -#: ../../library/codecs.rst:1058 +#: ../../library/codecs.rst:1087 msgid "" "Many of the character sets support the same languages. They vary in " "individual characters (e.g. whether the EURO SIGN is supported or not), and " @@ -1351,504 +1385,504 @@ msgid "" "languages in particular, the following variants typically exist:" msgstr "" -#: ../../library/codecs.rst:1063 +#: ../../library/codecs.rst:1092 msgid "an ISO 8859 codeset" msgstr "" -#: ../../library/codecs.rst:1065 +#: ../../library/codecs.rst:1094 msgid "" "a Microsoft Windows code page, which is typically derived from an 8859 " "codeset, but replaces control characters with additional graphic characters" msgstr "" -#: ../../library/codecs.rst:1068 +#: ../../library/codecs.rst:1097 msgid "an IBM EBCDIC code page" msgstr "" -#: ../../library/codecs.rst:1070 +#: ../../library/codecs.rst:1099 msgid "an IBM PC code page, which is ASCII compatible" msgstr "" -#: ../../library/codecs.rst:1075 ../../library/codecs.rst:1330 -#: ../../library/codecs.rst:1398 ../../library/codecs.rst:1455 +#: ../../library/codecs.rst:1104 ../../library/codecs.rst:1360 +#: ../../library/codecs.rst:1432 ../../library/codecs.rst:1517 msgid "Codec" msgstr "" -#: ../../library/codecs.rst:1075 ../../library/codecs.rst:1330 -#: ../../library/codecs.rst:1398 ../../library/codecs.rst:1455 +#: ../../library/codecs.rst:1104 ../../library/codecs.rst:1360 +#: ../../library/codecs.rst:1432 ../../library/codecs.rst:1517 msgid "Aliases" msgstr "" -#: ../../library/codecs.rst:1075 +#: ../../library/codecs.rst:1104 msgid "Languages" msgstr "語言" -#: ../../library/codecs.rst:1077 +#: ../../library/codecs.rst:1106 msgid "ascii" msgstr "ascii" -#: ../../library/codecs.rst:1077 +#: ../../library/codecs.rst:1106 msgid "646, us-ascii" msgstr "646, us-ascii" -#: ../../library/codecs.rst:1077 ../../library/codecs.rst:1083 -#: ../../library/codecs.rst:1091 +#: ../../library/codecs.rst:1106 ../../library/codecs.rst:1112 +#: ../../library/codecs.rst:1120 msgid "English" msgstr "英文" -#: ../../library/codecs.rst:1079 +#: ../../library/codecs.rst:1108 msgid "big5" msgstr "big5" -#: ../../library/codecs.rst:1079 +#: ../../library/codecs.rst:1108 msgid "big5-tw, csbig5" msgstr "big5-tw, csbig5" -#: ../../library/codecs.rst:1079 ../../library/codecs.rst:1081 -#: ../../library/codecs.rst:1139 +#: ../../library/codecs.rst:1108 ../../library/codecs.rst:1110 +#: ../../library/codecs.rst:1169 msgid "Traditional Chinese" msgstr "繁體中文" -#: ../../library/codecs.rst:1081 +#: ../../library/codecs.rst:1110 msgid "big5hkscs" msgstr "big5hkscs" -#: ../../library/codecs.rst:1081 +#: ../../library/codecs.rst:1110 msgid "big5-hkscs, hkscs" msgstr "big5-hkscs, hkscs" -#: ../../library/codecs.rst:1083 +#: ../../library/codecs.rst:1112 msgid "cp037" msgstr "cp037" -#: ../../library/codecs.rst:1083 +#: ../../library/codecs.rst:1112 msgid "IBM037, IBM039" msgstr "IBM037, IBM039" -#: ../../library/codecs.rst:1085 +#: ../../library/codecs.rst:1114 msgid "cp273" msgstr "cp273" -#: ../../library/codecs.rst:1085 +#: ../../library/codecs.rst:1114 msgid "273, IBM273, csIBM273" msgstr "273, IBM273, csIBM273" -#: ../../library/codecs.rst:1085 +#: ../../library/codecs.rst:1114 msgid "German" msgstr "德文" -#: ../../library/codecs.rst:1089 +#: ../../library/codecs.rst:1118 msgid "cp424" msgstr "cp424" -#: ../../library/codecs.rst:1089 +#: ../../library/codecs.rst:1118 msgid "EBCDIC-CP-HE, IBM424" msgstr "EBCDIC-CP-HE, IBM424" -#: ../../library/codecs.rst:1089 ../../library/codecs.rst:1109 -#: ../../library/codecs.rst:1119 ../../library/codecs.rst:1162 -#: ../../library/codecs.rst:1225 +#: ../../library/codecs.rst:1118 ../../library/codecs.rst:1138 +#: ../../library/codecs.rst:1148 ../../library/codecs.rst:1192 +#: ../../library/codecs.rst:1255 msgid "Hebrew" msgstr "希伯來文" -#: ../../library/codecs.rst:1091 +#: ../../library/codecs.rst:1120 msgid "cp437" msgstr "cp437" -#: ../../library/codecs.rst:1091 +#: ../../library/codecs.rst:1120 msgid "437, IBM437" msgstr "437, IBM437" -#: ../../library/codecs.rst:1093 +#: ../../library/codecs.rst:1122 msgid "cp500" msgstr "cp500" -#: ../../library/codecs.rst:1093 +#: ../../library/codecs.rst:1122 msgid "EBCDIC-CP-BE, EBCDIC-CP-CH, IBM500" msgstr "EBCDIC-CP-BE, EBCDIC-CP-CH, IBM500" -#: ../../library/codecs.rst:1093 ../../library/codecs.rst:1102 -#: ../../library/codecs.rst:1113 ../../library/codecs.rst:1149 -#: ../../library/codecs.rst:1156 ../../library/codecs.rst:1209 -#: ../../library/codecs.rst:1237 ../../library/codecs.rst:1265 +#: ../../library/codecs.rst:1122 ../../library/codecs.rst:1131 +#: ../../library/codecs.rst:1142 ../../library/codecs.rst:1179 +#: ../../library/codecs.rst:1186 ../../library/codecs.rst:1239 +#: ../../library/codecs.rst:1267 ../../library/codecs.rst:1295 msgid "Western Europe" msgstr "" -#: ../../library/codecs.rst:1096 +#: ../../library/codecs.rst:1125 msgid "cp720" msgstr "cp720" -#: ../../library/codecs.rst:1096 ../../library/codecs.rst:1123 -#: ../../library/codecs.rst:1164 ../../library/codecs.rst:1221 +#: ../../library/codecs.rst:1125 ../../library/codecs.rst:1152 +#: ../../library/codecs.rst:1194 ../../library/codecs.rst:1251 msgid "Arabic" msgstr "阿拉伯文" -#: ../../library/codecs.rst:1098 +#: ../../library/codecs.rst:1127 msgid "cp737" msgstr "cp737" -#: ../../library/codecs.rst:1098 ../../library/codecs.rst:1129 -#: ../../library/codecs.rst:1133 ../../library/codecs.rst:1158 -#: ../../library/codecs.rst:1223 ../../library/codecs.rst:1258 +#: ../../library/codecs.rst:1127 ../../library/codecs.rst:1158 +#: ../../library/codecs.rst:1162 ../../library/codecs.rst:1188 +#: ../../library/codecs.rst:1253 ../../library/codecs.rst:1288 msgid "Greek" msgstr "希臘文" -#: ../../library/codecs.rst:1100 +#: ../../library/codecs.rst:1129 msgid "cp775" msgstr "cp775" -#: ../../library/codecs.rst:1100 +#: ../../library/codecs.rst:1129 msgid "IBM775" msgstr "IBM775" -#: ../../library/codecs.rst:1100 ../../library/codecs.rst:1166 -#: ../../library/codecs.rst:1216 ../../library/codecs.rst:1233 +#: ../../library/codecs.rst:1129 ../../library/codecs.rst:1196 +#: ../../library/codecs.rst:1246 ../../library/codecs.rst:1263 msgid "Baltic languages" msgstr "" -#: ../../library/codecs.rst:1102 +#: ../../library/codecs.rst:1131 msgid "cp850" msgstr "cp850" -#: ../../library/codecs.rst:1102 +#: ../../library/codecs.rst:1131 msgid "850, IBM850" msgstr "850, IBM850" -#: ../../library/codecs.rst:1104 +#: ../../library/codecs.rst:1133 msgid "cp852" msgstr "cp852" -#: ../../library/codecs.rst:1104 +#: ../../library/codecs.rst:1133 msgid "852, IBM852" msgstr "852, IBM852" -#: ../../library/codecs.rst:1104 ../../library/codecs.rst:1151 -#: ../../library/codecs.rst:1212 ../../library/codecs.rst:1262 +#: ../../library/codecs.rst:1133 ../../library/codecs.rst:1181 +#: ../../library/codecs.rst:1242 ../../library/codecs.rst:1292 msgid "Central and Eastern Europe" msgstr "" -#: ../../library/codecs.rst:1106 +#: ../../library/codecs.rst:1135 msgid "cp855" msgstr "cp855" -#: ../../library/codecs.rst:1106 +#: ../../library/codecs.rst:1135 msgid "855, IBM855" msgstr "855, IBM855" -#: ../../library/codecs.rst:1106 ../../library/codecs.rst:1153 -#: ../../library/codecs.rst:1218 ../../library/codecs.rst:1255 -msgid "Bulgarian, Byelorussian, Macedonian, Russian, Serbian" +#: ../../library/codecs.rst:1135 ../../library/codecs.rst:1183 +#: ../../library/codecs.rst:1248 ../../library/codecs.rst:1285 +msgid "Belarusian, Bulgarian, Macedonian, Russian, Serbian" msgstr "" -#: ../../library/codecs.rst:1109 +#: ../../library/codecs.rst:1138 msgid "cp856" msgstr "cp856" -#: ../../library/codecs.rst:1111 +#: ../../library/codecs.rst:1140 msgid "cp857" msgstr "cp857" -#: ../../library/codecs.rst:1111 +#: ../../library/codecs.rst:1140 msgid "857, IBM857" msgstr "857, IBM857" -#: ../../library/codecs.rst:1111 ../../library/codecs.rst:1143 -#: ../../library/codecs.rst:1160 ../../library/codecs.rst:1227 -#: ../../library/codecs.rst:1267 +#: ../../library/codecs.rst:1140 ../../library/codecs.rst:1173 +#: ../../library/codecs.rst:1190 ../../library/codecs.rst:1257 +#: ../../library/codecs.rst:1297 msgid "Turkish" msgstr "土耳其文" -#: ../../library/codecs.rst:1113 +#: ../../library/codecs.rst:1142 msgid "cp858" msgstr "cp858" -#: ../../library/codecs.rst:1113 +#: ../../library/codecs.rst:1142 msgid "858, IBM858" msgstr "858, IBM858" -#: ../../library/codecs.rst:1115 +#: ../../library/codecs.rst:1144 msgid "cp860" msgstr "cp860" -#: ../../library/codecs.rst:1115 +#: ../../library/codecs.rst:1144 msgid "860, IBM860" msgstr "860, IBM860" -#: ../../library/codecs.rst:1115 +#: ../../library/codecs.rst:1144 msgid "Portuguese" msgstr "" -#: ../../library/codecs.rst:1117 +#: ../../library/codecs.rst:1146 msgid "cp861" msgstr "cp861" -#: ../../library/codecs.rst:1117 +#: ../../library/codecs.rst:1146 msgid "861, CP-IS, IBM861" msgstr "861, CP-IS, IBM861" -#: ../../library/codecs.rst:1117 ../../library/codecs.rst:1260 +#: ../../library/codecs.rst:1146 ../../library/codecs.rst:1290 msgid "Icelandic" msgstr "" -#: ../../library/codecs.rst:1119 +#: ../../library/codecs.rst:1148 msgid "cp862" msgstr "cp862" -#: ../../library/codecs.rst:1119 +#: ../../library/codecs.rst:1148 msgid "862, IBM862" msgstr "862, IBM862" -#: ../../library/codecs.rst:1121 +#: ../../library/codecs.rst:1150 msgid "cp863" msgstr "cp863" -#: ../../library/codecs.rst:1121 +#: ../../library/codecs.rst:1150 msgid "863, IBM863" msgstr "863, IBM863" -#: ../../library/codecs.rst:1121 +#: ../../library/codecs.rst:1150 msgid "Canadian" msgstr "" -#: ../../library/codecs.rst:1123 +#: ../../library/codecs.rst:1152 msgid "cp864" msgstr "cp864" -#: ../../library/codecs.rst:1123 +#: ../../library/codecs.rst:1152 msgid "IBM864" msgstr "IBM864" -#: ../../library/codecs.rst:1125 +#: ../../library/codecs.rst:1154 msgid "cp865" msgstr "cp865" -#: ../../library/codecs.rst:1125 +#: ../../library/codecs.rst:1154 msgid "865, IBM865" msgstr "865, IBM865" -#: ../../library/codecs.rst:1125 +#: ../../library/codecs.rst:1154 msgid "Danish, Norwegian" msgstr "" -#: ../../library/codecs.rst:1127 +#: ../../library/codecs.rst:1156 msgid "cp866" msgstr "cp866" -#: ../../library/codecs.rst:1127 +#: ../../library/codecs.rst:1156 msgid "866, IBM866" msgstr "866, IBM866" -#: ../../library/codecs.rst:1127 ../../library/codecs.rst:1243 +#: ../../library/codecs.rst:1156 ../../library/codecs.rst:1273 msgid "Russian" msgstr "俄羅斯文" -#: ../../library/codecs.rst:1129 +#: ../../library/codecs.rst:1158 msgid "cp869" msgstr "cp869" -#: ../../library/codecs.rst:1129 +#: ../../library/codecs.rst:1158 msgid "869, CP-GR, IBM869" msgstr "869, CP-GR, IBM869" -#: ../../library/codecs.rst:1131 +#: ../../library/codecs.rst:1160 msgid "cp874" msgstr "cp874" -#: ../../library/codecs.rst:1131 +#: ../../library/codecs.rst:1160 msgid "Thai" msgstr "泰文" -#: ../../library/codecs.rst:1133 +#: ../../library/codecs.rst:1162 msgid "cp875" msgstr "cp875" -#: ../../library/codecs.rst:1135 +#: ../../library/codecs.rst:1164 msgid "cp932" msgstr "cp932" -#: ../../library/codecs.rst:1135 -msgid "932, ms932, mskanji, ms-kanji" -msgstr "932, ms932, mskanji, ms-kanji" - -#: ../../library/codecs.rst:1135 ../../library/codecs.rst:1170 -#: ../../library/codecs.rst:1172 ../../library/codecs.rst:1174 -#: ../../library/codecs.rst:1191 ../../library/codecs.rst:1194 -#: ../../library/codecs.rst:1199 ../../library/codecs.rst:1202 -#: ../../library/codecs.rst:1204 ../../library/codecs.rst:1272 -#: ../../library/codecs.rst:1275 ../../library/codecs.rst:1278 +#: ../../library/codecs.rst:1164 +msgid "932, ms932, mskanji, ms-kanji, windows-31j" +msgstr "932, ms932, mskanji, ms-kanji, windows-31j" + +#: ../../library/codecs.rst:1164 ../../library/codecs.rst:1200 +#: ../../library/codecs.rst:1202 ../../library/codecs.rst:1204 +#: ../../library/codecs.rst:1221 ../../library/codecs.rst:1224 +#: ../../library/codecs.rst:1229 ../../library/codecs.rst:1232 +#: ../../library/codecs.rst:1234 ../../library/codecs.rst:1302 +#: ../../library/codecs.rst:1305 ../../library/codecs.rst:1308 msgid "Japanese" msgstr "日文" -#: ../../library/codecs.rst:1137 +#: ../../library/codecs.rst:1167 msgid "cp949" msgstr "cp949" -#: ../../library/codecs.rst:1137 +#: ../../library/codecs.rst:1167 msgid "949, ms949, uhc" msgstr "949, ms949, uhc" -#: ../../library/codecs.rst:1137 ../../library/codecs.rst:1176 -#: ../../library/codecs.rst:1206 ../../library/codecs.rst:1241 +#: ../../library/codecs.rst:1167 ../../library/codecs.rst:1206 +#: ../../library/codecs.rst:1236 ../../library/codecs.rst:1271 msgid "Korean" msgstr "韓文" -#: ../../library/codecs.rst:1139 +#: ../../library/codecs.rst:1169 msgid "cp950" msgstr "cp950" -#: ../../library/codecs.rst:1139 +#: ../../library/codecs.rst:1169 msgid "950, ms950" msgstr "950, ms950" -#: ../../library/codecs.rst:1141 +#: ../../library/codecs.rst:1171 msgid "cp1006" msgstr "cp1006" -#: ../../library/codecs.rst:1141 +#: ../../library/codecs.rst:1171 msgid "Urdu" msgstr "" -#: ../../library/codecs.rst:1143 +#: ../../library/codecs.rst:1173 msgid "cp1026" msgstr "cp1026" -#: ../../library/codecs.rst:1143 +#: ../../library/codecs.rst:1173 msgid "ibm1026" msgstr "ibm1026" -#: ../../library/codecs.rst:1145 +#: ../../library/codecs.rst:1175 msgid "cp1125" msgstr "cp1125" -#: ../../library/codecs.rst:1145 +#: ../../library/codecs.rst:1175 msgid "1125, ibm1125, cp866u, ruscii" msgstr "1125, ibm1125, cp866u, ruscii" -#: ../../library/codecs.rst:1145 ../../library/codecs.rst:1249 +#: ../../library/codecs.rst:1175 ../../library/codecs.rst:1279 msgid "Ukrainian" msgstr "烏克蘭文" -#: ../../library/codecs.rst:1149 +#: ../../library/codecs.rst:1179 msgid "cp1140" msgstr "cp1140" -#: ../../library/codecs.rst:1149 +#: ../../library/codecs.rst:1179 msgid "ibm1140" msgstr "ibm1140" -#: ../../library/codecs.rst:1151 +#: ../../library/codecs.rst:1181 msgid "cp1250" msgstr "cp1250" -#: ../../library/codecs.rst:1151 +#: ../../library/codecs.rst:1181 msgid "windows-1250" msgstr "windows-1250" -#: ../../library/codecs.rst:1153 +#: ../../library/codecs.rst:1183 msgid "cp1251" msgstr "cp1251" -#: ../../library/codecs.rst:1153 +#: ../../library/codecs.rst:1183 msgid "windows-1251" msgstr "windows-1251" -#: ../../library/codecs.rst:1156 +#: ../../library/codecs.rst:1186 msgid "cp1252" msgstr "cp1252" -#: ../../library/codecs.rst:1156 +#: ../../library/codecs.rst:1186 msgid "windows-1252" msgstr "windows-1252" -#: ../../library/codecs.rst:1158 +#: ../../library/codecs.rst:1188 msgid "cp1253" msgstr "cp1253" -#: ../../library/codecs.rst:1158 +#: ../../library/codecs.rst:1188 msgid "windows-1253" msgstr "windows-1253" -#: ../../library/codecs.rst:1160 +#: ../../library/codecs.rst:1190 msgid "cp1254" msgstr "cp1254" -#: ../../library/codecs.rst:1160 +#: ../../library/codecs.rst:1190 msgid "windows-1254" msgstr "windows-1254" -#: ../../library/codecs.rst:1162 +#: ../../library/codecs.rst:1192 msgid "cp1255" msgstr "cp1255" -#: ../../library/codecs.rst:1162 +#: ../../library/codecs.rst:1192 msgid "windows-1255" msgstr "windows-1255" -#: ../../library/codecs.rst:1164 +#: ../../library/codecs.rst:1194 msgid "cp1256" msgstr "cp1256" -#: ../../library/codecs.rst:1164 +#: ../../library/codecs.rst:1194 msgid "windows-1256" msgstr "windows-1256" -#: ../../library/codecs.rst:1166 +#: ../../library/codecs.rst:1196 msgid "cp1257" msgstr "cp1257" -#: ../../library/codecs.rst:1166 +#: ../../library/codecs.rst:1196 msgid "windows-1257" msgstr "windows-1257" -#: ../../library/codecs.rst:1168 +#: ../../library/codecs.rst:1198 msgid "cp1258" msgstr "cp1258" -#: ../../library/codecs.rst:1168 +#: ../../library/codecs.rst:1198 msgid "windows-1258" msgstr "windows-1258" -#: ../../library/codecs.rst:1168 +#: ../../library/codecs.rst:1198 msgid "Vietnamese" msgstr "越南文" -#: ../../library/codecs.rst:1170 +#: ../../library/codecs.rst:1200 msgid "euc_jp" msgstr "euc_jp" -#: ../../library/codecs.rst:1170 +#: ../../library/codecs.rst:1200 msgid "eucjp, ujis, u-jis" msgstr "eucjp, ujis, u-jis" -#: ../../library/codecs.rst:1172 +#: ../../library/codecs.rst:1202 msgid "euc_jis_2004" msgstr "euc_jis_2004" -#: ../../library/codecs.rst:1172 +#: ../../library/codecs.rst:1202 msgid "jisx0213, eucjis2004" msgstr "jisx0213, eucjis2004" -#: ../../library/codecs.rst:1174 +#: ../../library/codecs.rst:1204 msgid "euc_jisx0213" msgstr "euc_jisx0213" -#: ../../library/codecs.rst:1174 +#: ../../library/codecs.rst:1204 msgid "eucjisx0213" msgstr "eucjisx0213" -#: ../../library/codecs.rst:1176 +#: ../../library/codecs.rst:1206 msgid "euc_kr" msgstr "euc_kr" -#: ../../library/codecs.rst:1176 +#: ../../library/codecs.rst:1206 msgid "euckr, korean, ksc5601, ks_c-5601, ks_c-5601-1987, ksx1001, ks_x-1001" msgstr "euckr, korean, ksc5601, ks_c-5601, ks_c-5601-1987, ksx1001, ks_x-1001" -#: ../../library/codecs.rst:1180 +#: ../../library/codecs.rst:1210 msgid "gb2312" msgstr "gb2312" -#: ../../library/codecs.rst:1180 +#: ../../library/codecs.rst:1210 msgid "" "chinese, csiso58gb231280, euc-cn, euccn, eucgb2312-cn, gb2312-1980, " "gb2312-80, iso-ir-58" @@ -1856,446 +1890,446 @@ msgstr "" "chinese, csiso58gb231280, euc-cn, euccn, eucgb2312-cn, gb2312-1980, " "gb2312-80, iso-ir-58" -#: ../../library/codecs.rst:1180 ../../library/codecs.rst:1189 +#: ../../library/codecs.rst:1210 ../../library/codecs.rst:1219 msgid "Simplified Chinese" msgstr "簡體中文" -#: ../../library/codecs.rst:1185 +#: ../../library/codecs.rst:1215 msgid "gbk" msgstr "gbk" -#: ../../library/codecs.rst:1185 +#: ../../library/codecs.rst:1215 msgid "936, cp936, ms936" msgstr "936, cp936, ms936" -#: ../../library/codecs.rst:1185 ../../library/codecs.rst:1187 +#: ../../library/codecs.rst:1215 ../../library/codecs.rst:1217 msgid "Unified Chinese" msgstr "" -#: ../../library/codecs.rst:1187 +#: ../../library/codecs.rst:1217 msgid "gb18030" msgstr "gb18030" -#: ../../library/codecs.rst:1187 +#: ../../library/codecs.rst:1217 msgid "gb18030-2000" msgstr "gb18030-2000" -#: ../../library/codecs.rst:1189 +#: ../../library/codecs.rst:1219 msgid "hz" -msgstr "" +msgstr "hz" -#: ../../library/codecs.rst:1189 +#: ../../library/codecs.rst:1219 msgid "hzgb, hz-gb, hz-gb-2312" msgstr "hzgb, hz-gb, hz-gb-2312" -#: ../../library/codecs.rst:1191 +#: ../../library/codecs.rst:1221 msgid "iso2022_jp" msgstr "iso2022_jp" -#: ../../library/codecs.rst:1191 +#: ../../library/codecs.rst:1221 msgid "csiso2022jp, iso2022jp, iso-2022-jp" msgstr "csiso2022jp, iso2022jp, iso-2022-jp" -#: ../../library/codecs.rst:1194 +#: ../../library/codecs.rst:1224 msgid "iso2022_jp_1" msgstr "iso2022_jp_1" -#: ../../library/codecs.rst:1194 +#: ../../library/codecs.rst:1224 msgid "iso2022jp-1, iso-2022-jp-1" msgstr "iso2022jp-1, iso-2022-jp-1" -#: ../../library/codecs.rst:1196 +#: ../../library/codecs.rst:1226 msgid "iso2022_jp_2" msgstr "iso2022_jp_2" -#: ../../library/codecs.rst:1196 +#: ../../library/codecs.rst:1226 msgid "iso2022jp-2, iso-2022-jp-2" msgstr "iso2022jp-2, iso-2022-jp-2" -#: ../../library/codecs.rst:1196 +#: ../../library/codecs.rst:1226 msgid "Japanese, Korean, Simplified Chinese, Western Europe, Greek" msgstr "" -#: ../../library/codecs.rst:1199 +#: ../../library/codecs.rst:1229 msgid "iso2022_jp_2004" msgstr "iso2022_jp_2004" -#: ../../library/codecs.rst:1199 +#: ../../library/codecs.rst:1229 msgid "iso2022jp-2004, iso-2022-jp-2004" msgstr "iso2022jp-2004, iso-2022-jp-2004" -#: ../../library/codecs.rst:1202 +#: ../../library/codecs.rst:1232 msgid "iso2022_jp_3" msgstr "iso2022_jp_3" -#: ../../library/codecs.rst:1202 +#: ../../library/codecs.rst:1232 msgid "iso2022jp-3, iso-2022-jp-3" msgstr "iso2022jp-3, iso-2022-jp-3" -#: ../../library/codecs.rst:1204 +#: ../../library/codecs.rst:1234 msgid "iso2022_jp_ext" msgstr "iso2022_jp_ext" -#: ../../library/codecs.rst:1204 +#: ../../library/codecs.rst:1234 msgid "iso2022jp-ext, iso-2022-jp-ext" msgstr "iso2022jp-ext, iso-2022-jp-ext" -#: ../../library/codecs.rst:1206 +#: ../../library/codecs.rst:1236 msgid "iso2022_kr" msgstr "iso2022_kr" -#: ../../library/codecs.rst:1206 +#: ../../library/codecs.rst:1236 msgid "csiso2022kr, iso2022kr, iso-2022-kr" msgstr "csiso2022kr, iso2022kr, iso-2022-kr" -#: ../../library/codecs.rst:1209 +#: ../../library/codecs.rst:1239 msgid "latin_1" msgstr "latin_1" -#: ../../library/codecs.rst:1209 +#: ../../library/codecs.rst:1239 msgid "iso-8859-1, iso8859-1, 8859, cp819, latin, latin1, L1" msgstr "iso-8859-1, iso8859-1, 8859, cp819, latin, latin1, L1" -#: ../../library/codecs.rst:1212 +#: ../../library/codecs.rst:1242 msgid "iso8859_2" msgstr "iso8859_2" -#: ../../library/codecs.rst:1212 +#: ../../library/codecs.rst:1242 msgid "iso-8859-2, latin2, L2" msgstr "iso-8859-2, latin2, L2" -#: ../../library/codecs.rst:1214 +#: ../../library/codecs.rst:1244 msgid "iso8859_3" msgstr "iso8859_3" -#: ../../library/codecs.rst:1214 +#: ../../library/codecs.rst:1244 msgid "iso-8859-3, latin3, L3" msgstr "iso-8859-3, latin3, L3" -#: ../../library/codecs.rst:1214 +#: ../../library/codecs.rst:1244 msgid "Esperanto, Maltese" msgstr "" -#: ../../library/codecs.rst:1216 +#: ../../library/codecs.rst:1246 msgid "iso8859_4" msgstr "iso8859_4" -#: ../../library/codecs.rst:1216 +#: ../../library/codecs.rst:1246 msgid "iso-8859-4, latin4, L4" msgstr "iso-8859-4, latin4, L4" -#: ../../library/codecs.rst:1218 +#: ../../library/codecs.rst:1248 msgid "iso8859_5" msgstr "iso8859_5" -#: ../../library/codecs.rst:1218 +#: ../../library/codecs.rst:1248 msgid "iso-8859-5, cyrillic" msgstr "iso-8859-5, cyrillic" -#: ../../library/codecs.rst:1221 +#: ../../library/codecs.rst:1251 msgid "iso8859_6" msgstr "iso8859_6" -#: ../../library/codecs.rst:1221 +#: ../../library/codecs.rst:1251 msgid "iso-8859-6, arabic" msgstr "iso-8859-6, arabic" -#: ../../library/codecs.rst:1223 +#: ../../library/codecs.rst:1253 msgid "iso8859_7" msgstr "iso8859_7" -#: ../../library/codecs.rst:1223 +#: ../../library/codecs.rst:1253 msgid "iso-8859-7, greek, greek8" msgstr "iso-8859-7, greek, greek8" -#: ../../library/codecs.rst:1225 +#: ../../library/codecs.rst:1255 msgid "iso8859_8" msgstr "iso8859_8" -#: ../../library/codecs.rst:1225 +#: ../../library/codecs.rst:1255 msgid "iso-8859-8, hebrew" msgstr "iso-8859-8, hebrew" -#: ../../library/codecs.rst:1227 +#: ../../library/codecs.rst:1257 msgid "iso8859_9" msgstr "iso8859_9" -#: ../../library/codecs.rst:1227 +#: ../../library/codecs.rst:1257 msgid "iso-8859-9, latin5, L5" msgstr "iso-8859-9, latin5, L5" -#: ../../library/codecs.rst:1229 +#: ../../library/codecs.rst:1259 msgid "iso8859_10" msgstr "iso8859_10" -#: ../../library/codecs.rst:1229 +#: ../../library/codecs.rst:1259 msgid "iso-8859-10, latin6, L6" msgstr "iso-8859-10, latin6, L6" -#: ../../library/codecs.rst:1229 +#: ../../library/codecs.rst:1259 msgid "Nordic languages" msgstr "" -#: ../../library/codecs.rst:1231 +#: ../../library/codecs.rst:1261 msgid "iso8859_11" msgstr "iso8859_11" -#: ../../library/codecs.rst:1231 +#: ../../library/codecs.rst:1261 msgid "iso-8859-11, thai" msgstr "iso-8859-11, thai" -#: ../../library/codecs.rst:1231 +#: ../../library/codecs.rst:1261 msgid "Thai languages" -msgstr "" +msgstr "泰語" -#: ../../library/codecs.rst:1233 +#: ../../library/codecs.rst:1263 msgid "iso8859_13" msgstr "iso8859_13" -#: ../../library/codecs.rst:1233 +#: ../../library/codecs.rst:1263 msgid "iso-8859-13, latin7, L7" msgstr "iso-8859-13, latin7, L7" -#: ../../library/codecs.rst:1235 +#: ../../library/codecs.rst:1265 msgid "iso8859_14" msgstr "iso8859_14" -#: ../../library/codecs.rst:1235 +#: ../../library/codecs.rst:1265 msgid "iso-8859-14, latin8, L8" msgstr "iso-8859-14, latin8, L8" -#: ../../library/codecs.rst:1235 +#: ../../library/codecs.rst:1265 msgid "Celtic languages" msgstr "" -#: ../../library/codecs.rst:1237 +#: ../../library/codecs.rst:1267 msgid "iso8859_15" msgstr "iso8859_15" -#: ../../library/codecs.rst:1237 +#: ../../library/codecs.rst:1267 msgid "iso-8859-15, latin9, L9" msgstr "iso-8859-15, latin9, L9" -#: ../../library/codecs.rst:1239 +#: ../../library/codecs.rst:1269 msgid "iso8859_16" msgstr "iso8859_16" -#: ../../library/codecs.rst:1239 +#: ../../library/codecs.rst:1269 msgid "iso-8859-16, latin10, L10" msgstr "iso-8859-16, latin10, L10" -#: ../../library/codecs.rst:1239 +#: ../../library/codecs.rst:1269 msgid "South-Eastern Europe" msgstr "" -#: ../../library/codecs.rst:1241 +#: ../../library/codecs.rst:1271 msgid "johab" msgstr "" -#: ../../library/codecs.rst:1241 +#: ../../library/codecs.rst:1271 msgid "cp1361, ms1361" msgstr "cp1361, ms1361" -#: ../../library/codecs.rst:1243 +#: ../../library/codecs.rst:1273 msgid "koi8_r" msgstr "koi8_r" -#: ../../library/codecs.rst:1245 +#: ../../library/codecs.rst:1275 msgid "koi8_t" msgstr "koi8_t" -#: ../../library/codecs.rst:1245 +#: ../../library/codecs.rst:1275 msgid "Tajik" msgstr "" -#: ../../library/codecs.rst:1249 +#: ../../library/codecs.rst:1279 msgid "koi8_u" msgstr "koi8_u" -#: ../../library/codecs.rst:1251 +#: ../../library/codecs.rst:1281 msgid "kz1048" msgstr "kz1048" -#: ../../library/codecs.rst:1251 +#: ../../library/codecs.rst:1281 msgid "kz_1048, strk1048_2002, rk1048" msgstr "kz_1048, strk1048_2002, rk1048" -#: ../../library/codecs.rst:1251 ../../library/codecs.rst:1269 +#: ../../library/codecs.rst:1281 ../../library/codecs.rst:1299 msgid "Kazakh" msgstr "" -#: ../../library/codecs.rst:1255 +#: ../../library/codecs.rst:1285 msgid "mac_cyrillic" msgstr "mac_cyrillic" -#: ../../library/codecs.rst:1255 +#: ../../library/codecs.rst:1285 msgid "maccyrillic" msgstr "" -#: ../../library/codecs.rst:1258 +#: ../../library/codecs.rst:1288 msgid "mac_greek" msgstr "mac_greek" -#: ../../library/codecs.rst:1258 +#: ../../library/codecs.rst:1288 msgid "macgreek" msgstr "" -#: ../../library/codecs.rst:1260 +#: ../../library/codecs.rst:1290 msgid "mac_iceland" msgstr "mac_iceland" -#: ../../library/codecs.rst:1260 +#: ../../library/codecs.rst:1290 msgid "maciceland" msgstr "" -#: ../../library/codecs.rst:1262 +#: ../../library/codecs.rst:1292 msgid "mac_latin2" msgstr "mac_latin2" -#: ../../library/codecs.rst:1262 +#: ../../library/codecs.rst:1292 msgid "maclatin2, maccentraleurope, mac_centeuro" msgstr "maclatin2, maccentraleurope, mac_centeuro" -#: ../../library/codecs.rst:1265 +#: ../../library/codecs.rst:1295 msgid "mac_roman" msgstr "mac_roman" -#: ../../library/codecs.rst:1265 +#: ../../library/codecs.rst:1295 msgid "macroman, macintosh" msgstr "macroman, macintosh" -#: ../../library/codecs.rst:1267 +#: ../../library/codecs.rst:1297 msgid "mac_turkish" msgstr "mac_turkish" -#: ../../library/codecs.rst:1267 +#: ../../library/codecs.rst:1297 msgid "macturkish" msgstr "" -#: ../../library/codecs.rst:1269 +#: ../../library/codecs.rst:1299 msgid "ptcp154" msgstr "ptcp154" -#: ../../library/codecs.rst:1269 +#: ../../library/codecs.rst:1299 msgid "csptcp154, pt154, cp154, cyrillic-asian" msgstr "csptcp154, pt154, cp154, cyrillic-asian" -#: ../../library/codecs.rst:1272 +#: ../../library/codecs.rst:1302 msgid "shift_jis" msgstr "shift_jis" -#: ../../library/codecs.rst:1272 +#: ../../library/codecs.rst:1302 msgid "csshiftjis, shiftjis, sjis, s_jis" msgstr "csshiftjis, shiftjis, sjis, s_jis" -#: ../../library/codecs.rst:1275 +#: ../../library/codecs.rst:1305 msgid "shift_jis_2004" msgstr "shift_jis_2004" -#: ../../library/codecs.rst:1275 +#: ../../library/codecs.rst:1305 msgid "shiftjis2004, sjis_2004, sjis2004" msgstr "shiftjis2004, sjis_2004, sjis2004" -#: ../../library/codecs.rst:1278 +#: ../../library/codecs.rst:1308 msgid "shift_jisx0213" msgstr "shift_jisx0213" -#: ../../library/codecs.rst:1278 +#: ../../library/codecs.rst:1308 msgid "shiftjisx0213, sjisx0213, s_jisx0213" msgstr "shiftjisx0213, sjisx0213, s_jisx0213" -#: ../../library/codecs.rst:1281 +#: ../../library/codecs.rst:1311 msgid "utf_32" msgstr "utf_32" -#: ../../library/codecs.rst:1281 +#: ../../library/codecs.rst:1311 msgid "U32, utf32" msgstr "U32, utf32" -#: ../../library/codecs.rst:1281 ../../library/codecs.rst:1283 -#: ../../library/codecs.rst:1285 ../../library/codecs.rst:1287 -#: ../../library/codecs.rst:1289 ../../library/codecs.rst:1291 -#: ../../library/codecs.rst:1293 ../../library/codecs.rst:1295 -#: ../../library/codecs.rst:1297 +#: ../../library/codecs.rst:1311 ../../library/codecs.rst:1313 +#: ../../library/codecs.rst:1315 ../../library/codecs.rst:1317 +#: ../../library/codecs.rst:1319 ../../library/codecs.rst:1321 +#: ../../library/codecs.rst:1323 ../../library/codecs.rst:1325 +#: ../../library/codecs.rst:1327 msgid "all languages" msgstr "" -#: ../../library/codecs.rst:1283 +#: ../../library/codecs.rst:1313 msgid "utf_32_be" msgstr "utf_32_be" -#: ../../library/codecs.rst:1283 +#: ../../library/codecs.rst:1313 msgid "UTF-32BE" msgstr "UTF-32BE" -#: ../../library/codecs.rst:1285 +#: ../../library/codecs.rst:1315 msgid "utf_32_le" msgstr "utf_32_le" -#: ../../library/codecs.rst:1285 +#: ../../library/codecs.rst:1315 msgid "UTF-32LE" msgstr "UTF-32LE" -#: ../../library/codecs.rst:1287 +#: ../../library/codecs.rst:1317 msgid "utf_16" msgstr "utf_16" -#: ../../library/codecs.rst:1287 +#: ../../library/codecs.rst:1317 msgid "U16, utf16" msgstr "U16, utf16" -#: ../../library/codecs.rst:1289 +#: ../../library/codecs.rst:1319 msgid "utf_16_be" msgstr "utf_16_be" -#: ../../library/codecs.rst:1289 +#: ../../library/codecs.rst:1319 msgid "UTF-16BE" msgstr "UTF-16BE" -#: ../../library/codecs.rst:1291 +#: ../../library/codecs.rst:1321 msgid "utf_16_le" msgstr "utf_16_le" -#: ../../library/codecs.rst:1291 +#: ../../library/codecs.rst:1321 msgid "UTF-16LE" msgstr "UTF-16LE" -#: ../../library/codecs.rst:1293 +#: ../../library/codecs.rst:1323 msgid "utf_7" msgstr "utf_7" -#: ../../library/codecs.rst:1293 +#: ../../library/codecs.rst:1323 msgid "U7, unicode-1-1-utf-7" msgstr "U7, unicode-1-1-utf-7" -#: ../../library/codecs.rst:1295 +#: ../../library/codecs.rst:1325 msgid "utf_8" msgstr "utf_8" -#: ../../library/codecs.rst:1295 +#: ../../library/codecs.rst:1325 msgid "U8, UTF, utf8, cp65001" msgstr "U8, UTF, utf8, cp65001" -#: ../../library/codecs.rst:1297 +#: ../../library/codecs.rst:1327 msgid "utf_8_sig" msgstr "utf_8_sig" -#: ../../library/codecs.rst:1300 +#: ../../library/codecs.rst:1330 msgid "" "The utf-16\\* and utf-32\\* encoders no longer allow surrogate code points " "(``U+D800``--``U+DFFF``) to be encoded. The utf-32\\* decoders no longer " "decode byte sequences that correspond to surrogate code points." msgstr "" -#: ../../library/codecs.rst:1306 +#: ../../library/codecs.rst:1336 msgid "``cp65001`` is now an alias to ``utf_8``." -msgstr "" +msgstr "``cp65001`` 現在是 ``utf_8`` 的別名。" -#: ../../library/codecs.rst:1311 +#: ../../library/codecs.rst:1341 msgid "Python Specific Encodings" msgstr "" -#: ../../library/codecs.rst:1313 +#: ../../library/codecs.rst:1343 msgid "" "A number of predefined codecs are specific to Python, so their codec names " "have no meaning outside Python. These are listed in the tables below based " @@ -2305,274 +2339,369 @@ msgid "" "asymmetric codecs, the stated meaning describes the encoding direction." msgstr "" -#: ../../library/codecs.rst:1321 +#: ../../library/codecs.rst:1351 msgid "Text Encodings" msgstr "" -#: ../../library/codecs.rst:1323 +#: ../../library/codecs.rst:1353 msgid "" "The following codecs provide :class:`str` to :class:`bytes` encoding and :" "term:`bytes-like object` to :class:`str` decoding, similar to the Unicode " "text encodings." msgstr "" -#: ../../library/codecs.rst:1332 +#: ../../library/codecs.rst:1362 msgid "idna" msgstr "idna" -#: ../../library/codecs.rst:1332 +#: ../../library/codecs.rst:1362 msgid "" "Implement :rfc:`3490`, see also :mod:`encodings.idna`. Only " "``errors='strict'`` is supported." msgstr "" -#: ../../library/codecs.rst:1338 +#: ../../library/codecs.rst:1368 msgid "mbcs" msgstr "mbcs" -#: ../../library/codecs.rst:1338 +#: ../../library/codecs.rst:1368 msgid "ansi, dbcs" msgstr "ansi, dbcs" -#: ../../library/codecs.rst:1338 +#: ../../library/codecs.rst:1368 msgid "" "Windows only: Encode the operand according to the ANSI codepage (CP_ACP)." msgstr "" -#: ../../library/codecs.rst:1342 +#: ../../library/codecs.rst:1372 msgid "oem" msgstr "oem" -#: ../../library/codecs.rst:1342 +#: ../../library/codecs.rst:1372 msgid "" "Windows only: Encode the operand according to the OEM codepage (CP_OEMCP)." msgstr "" -#: ../../library/codecs.rst:1348 +#: ../../library/codecs.rst:1378 msgid "palmos" msgstr "" -#: ../../library/codecs.rst:1348 +#: ../../library/codecs.rst:1378 msgid "Encoding of PalmOS 3.5." msgstr "" -#: ../../library/codecs.rst:1350 +#: ../../library/codecs.rst:1380 msgid "punycode" msgstr "" -#: ../../library/codecs.rst:1350 +#: ../../library/codecs.rst:1380 msgid "Implement :rfc:`3492`. Stateful codecs are not supported." msgstr "" -#: ../../library/codecs.rst:1354 +#: ../../library/codecs.rst:1384 msgid "raw_unicode_escape" msgstr "raw_unicode_escape" -#: ../../library/codecs.rst:1354 +#: ../../library/codecs.rst:1384 msgid "" "Latin-1 encoding with :samp:`\\\\u{XXXX}` and :samp:`\\\\U{XXXXXXXX}` for " "other code points. Existing backslashes are not escaped in any way. It is " "used in the Python pickle protocol." msgstr "" -#: ../../library/codecs.rst:1364 +#: ../../library/codecs.rst:1394 msgid "undefined" msgstr "" -#: ../../library/codecs.rst:1364 +#: ../../library/codecs.rst:1394 +msgid "This Codec should only be used for testing purposes." +msgstr "" + +#: ../../library/codecs.rst:1398 msgid "" "Raise an exception for all conversions, even empty strings. The error " "handler is ignored." msgstr "" -#: ../../library/codecs.rst:1369 +#: ../../library/codecs.rst:1403 msgid "unicode_escape" msgstr "unicode_escape" -#: ../../library/codecs.rst:1369 +#: ../../library/codecs.rst:1403 msgid "" "Encoding suitable as the contents of a Unicode literal in ASCII-encoded " "Python source code, except that quotes are not escaped. Decode from Latin-1 " "source code. Beware that Python source code actually uses UTF-8 by default." msgstr "" -#: ../../library/codecs.rst:1381 +#: ../../library/codecs.rst:1415 msgid "\"unicode_internal\" codec is removed." msgstr "" -#: ../../library/codecs.rst:1388 +#: ../../library/codecs.rst:1422 msgid "Binary Transforms" msgstr "" -#: ../../library/codecs.rst:1390 +#: ../../library/codecs.rst:1424 msgid "" "The following codecs provide binary transforms: :term:`bytes-like object` " "to :class:`bytes` mappings. They are not supported by :meth:`bytes.decode` " "(which only produces :class:`str` output)." msgstr "" -#: ../../library/codecs.rst:1398 +#: ../../library/codecs.rst:1432 msgid "Encoder / decoder" msgstr "" -#: ../../library/codecs.rst:1400 +#: ../../library/codecs.rst:1434 msgid "base64_codec [#b64]_" msgstr "base64_codec [#b64]_" -#: ../../library/codecs.rst:1400 +#: ../../library/codecs.rst:1434 msgid "base64, base_64" msgstr "base64, base_64" -#: ../../library/codecs.rst:1400 +#: ../../library/codecs.rst:1434 msgid "" "Convert the operand to multiline MIME base64 (the result always includes a " "trailing ``'\\n'``)." msgstr "" -#: ../../library/codecs.rst:1405 +#: ../../library/codecs.rst:1439 msgid "" "accepts any :term:`bytes-like object` as input for encoding and decoding" msgstr "" -#: ../../library/codecs.rst:1400 +#: ../../library/codecs.rst:1434 msgid ":meth:`base64.encodebytes` / :meth:`base64.decodebytes`" msgstr ":meth:`base64.encodebytes` / :meth:`base64.decodebytes`" -#: ../../library/codecs.rst:1411 +#: ../../library/codecs.rst:1445 msgid "bz2_codec" msgstr "bz2_codec" -#: ../../library/codecs.rst:1411 +#: ../../library/codecs.rst:1445 msgid "bz2" msgstr "bz2" -#: ../../library/codecs.rst:1411 +#: ../../library/codecs.rst:1445 msgid "Compress the operand using bz2." msgstr "" -#: ../../library/codecs.rst:1411 +#: ../../library/codecs.rst:1445 msgid ":meth:`bz2.compress` / :meth:`bz2.decompress`" msgstr ":meth:`bz2.compress` / :meth:`bz2.decompress`" -#: ../../library/codecs.rst:1414 +#: ../../library/codecs.rst:1448 msgid "hex_codec" msgstr "hex_codec" -#: ../../library/codecs.rst:1414 +#: ../../library/codecs.rst:1448 msgid "hex" msgstr "hex" -#: ../../library/codecs.rst:1414 +#: ../../library/codecs.rst:1448 msgid "" "Convert the operand to hexadecimal representation, with two digits per byte." msgstr "" -#: ../../library/codecs.rst:1414 +#: ../../library/codecs.rst:1448 msgid ":meth:`binascii.b2a_hex` / :meth:`binascii.a2b_hex`" msgstr ":meth:`binascii.b2a_hex` / :meth:`binascii.a2b_hex`" -#: ../../library/codecs.rst:1419 +#: ../../library/codecs.rst:1453 msgid "quopri_codec" msgstr "quopri_codec" -#: ../../library/codecs.rst:1419 +#: ../../library/codecs.rst:1453 msgid "quopri, quotedprintable, quoted_printable" msgstr "quopri, quotedprintable, quoted_printable" -#: ../../library/codecs.rst:1419 +#: ../../library/codecs.rst:1453 msgid "Convert the operand to MIME quoted printable." msgstr "" -#: ../../library/codecs.rst:1419 +#: ../../library/codecs.rst:1453 msgid ":meth:`quopri.encode` with ``quotetabs=True`` / :meth:`quopri.decode`" msgstr ":meth:`quopri.encode` with ``quotetabs=True`` / :meth:`quopri.decode`" -#: ../../library/codecs.rst:1423 +#: ../../library/codecs.rst:1457 msgid "uu_codec" msgstr "uu_codec" -#: ../../library/codecs.rst:1423 +#: ../../library/codecs.rst:1457 msgid "uu" msgstr "uu" -#: ../../library/codecs.rst:1423 +#: ../../library/codecs.rst:1457 msgid "Convert the operand using uuencode." msgstr "" -#: ../../library/codecs.rst:1423 -#, fuzzy -msgid "" -":meth:`!uu.encode` / :meth:`!uu.decode` (Note: :mod:`uu` is deprecated.)" -msgstr ":meth:`uu.encode` / :meth:`uu.decode`" - -#: ../../library/codecs.rst:1428 +#: ../../library/codecs.rst:1460 msgid "zlib_codec" msgstr "zlib_codec" -#: ../../library/codecs.rst:1428 +#: ../../library/codecs.rst:1460 msgid "zip, zlib" msgstr "zip, zlib" -#: ../../library/codecs.rst:1428 +#: ../../library/codecs.rst:1460 msgid "Compress the operand using gzip." msgstr "" -#: ../../library/codecs.rst:1428 +#: ../../library/codecs.rst:1460 msgid ":meth:`zlib.compress` / :meth:`zlib.decompress`" msgstr ":meth:`zlib.compress` / :meth:`zlib.decompress`" -#: ../../library/codecs.rst:1432 +#: ../../library/codecs.rst:1464 msgid "" "In addition to :term:`bytes-like objects `, " "``'base64_codec'`` also accepts ASCII-only instances of :class:`str` for " "decoding" msgstr "" -#: ../../library/codecs.rst:1436 +#: ../../library/codecs.rst:1468 msgid "Restoration of the binary transforms." msgstr "" -#: ../../library/codecs.rst:1439 +#: ../../library/codecs.rst:1471 msgid "Restoration of the aliases for the binary transforms." msgstr "" -#: ../../library/codecs.rst:1446 +#: ../../library/codecs.rst:1478 +msgid "Standalone Codec Functions" +msgstr "" + +#: ../../library/codecs.rst:1480 +msgid "" +"The following functions provide encoding and decoding functionality similar " +"to codecs, but are not available as named codecs through :func:`codecs." +"encode` or :func:`codecs.decode`. They are used internally (for example, by :" +"mod:`pickle`) and behave similarly to the ``string_escape`` codec that was " +"removed in Python 3." +msgstr "" + +#: ../../library/codecs.rst:1487 +msgid "" +"Encode *input* using escape sequences. Similar to how :func:`repr` on bytes " +"produces escaped byte values." +msgstr "" + +#: ../../library/codecs.rst:1490 +msgid "*input* must be a :class:`bytes` object." +msgstr "*input* 必須是 :class:`bytes` 物件。" + +#: ../../library/codecs.rst:1492 ../../library/codecs.rst:1501 +msgid "" +"Returns a tuple ``(output, length)`` where *output* is a :class:`bytes` " +"object and *length* is the number of bytes consumed." +msgstr "" + +#: ../../library/codecs.rst:1497 +msgid "Decode *input* from escape sequences back to the original bytes." +msgstr "" + +#: ../../library/codecs.rst:1499 +msgid "*input* must be a :term:`bytes-like object`." +msgstr "*input* 必須是 :term:`bytes-like object`。" + +#: ../../library/codecs.rst:1508 msgid "Text Transforms" msgstr "" -#: ../../library/codecs.rst:1448 +#: ../../library/codecs.rst:1510 msgid "" "The following codec provides a text transform: a :class:`str` to :class:" "`str` mapping. It is not supported by :meth:`str.encode` (which only " "produces :class:`bytes` output)." msgstr "" -#: ../../library/codecs.rst:1457 +#: ../../library/codecs.rst:1519 msgid "rot_13" msgstr "rot_13" -#: ../../library/codecs.rst:1457 +#: ../../library/codecs.rst:1519 msgid "rot13" msgstr "" -#: ../../library/codecs.rst:1457 +#: ../../library/codecs.rst:1519 msgid "Return the Caesar-cypher encryption of the operand." msgstr "" -#: ../../library/codecs.rst:1462 +#: ../../library/codecs.rst:1524 msgid "Restoration of the ``rot_13`` text transform." msgstr "" -#: ../../library/codecs.rst:1465 +#: ../../library/codecs.rst:1527 msgid "Restoration of the ``rot13`` alias." msgstr "" -#: ../../library/codecs.rst:1470 +#: ../../library/codecs.rst:1532 +msgid ":mod:`encodings` --- Encodings package" +msgstr "" + +#: ../../library/codecs.rst:1537 +msgid "This module implements the following functions:" +msgstr "" + +#: ../../library/codecs.rst:1541 +msgid "Normalize encoding name *encoding*." +msgstr "" + +#: ../../library/codecs.rst:1543 +msgid "" +"Normalization works as follows: all non-alphanumeric characters except the " +"dot used for Python package names are collapsed and replaced with a single " +"underscore, leading and trailing underscores are removed. For example, ``' " +"-;#'`` becomes ``'_'``." +msgstr "" + +#: ../../library/codecs.rst:1548 +msgid "Note that *encoding* should be ASCII only." +msgstr "" + +#: ../../library/codecs.rst:1552 +msgid "" +"The following function should not be used directly, except for testing " +"purposes; :func:`codecs.lookup` should be used instead." +msgstr "" + +#: ../../library/codecs.rst:1558 +msgid "" +"Search for the codec module corresponding to the given encoding name " +"*encoding*." +msgstr "" + +#: ../../library/codecs.rst:1561 +msgid "" +"This function first normalizes the *encoding* using :func:" +"`normalize_encoding`, then looks for a corresponding alias. It attempts to " +"import a codec module from the encodings package using either the alias or " +"the normalized name. If the module is found and defines a valid " +"``getregentry()`` function that returns a :class:`codecs.CodecInfo` object, " +"the codec is cached and returned." +msgstr "" + +#: ../../library/codecs.rst:1568 +msgid "" +"If the codec module defines a ``getaliases()`` function any returned aliases " +"are registered for future use." +msgstr "" + +#: ../../library/codecs.rst:1572 +msgid "This module implements the following exception:" +msgstr "" + +#: ../../library/codecs.rst:1576 +msgid "Raised when a codec is invalid or incompatible." +msgstr "" + +#: ../../library/codecs.rst:1580 msgid "" ":mod:`encodings.idna` --- Internationalized Domain Names in Applications" msgstr "" -#: ../../library/codecs.rst:1476 +#: ../../library/codecs.rst:1586 msgid "" "This module implements :rfc:`3490` (Internationalized Domain Names in " "Applications) and :rfc:`3492` (Nameprep: A Stringprep Profile for " @@ -2580,13 +2709,13 @@ msgid "" "encoding and :mod:`stringprep`." msgstr "" -#: ../../library/codecs.rst:1481 +#: ../../library/codecs.rst:1591 msgid "" "If you need the IDNA 2008 standard from :rfc:`5891` and :rfc:`5895`, use the " "third-party :pypi:`idna` module." msgstr "" -#: ../../library/codecs.rst:1484 +#: ../../library/codecs.rst:1594 msgid "" "These RFCs together define a protocol to support non-ASCII characters in " "domain names. A domain name containing non-ASCII characters (such as ``www." @@ -2600,7 +2729,7 @@ msgid "" "presenting them to the user." msgstr "" -#: ../../library/codecs.rst:1495 +#: ../../library/codecs.rst:1605 msgid "" "Python supports this conversion in several ways: the ``idna`` codec " "performs conversion between Unicode and ACE, separating an input string into " @@ -2617,14 +2746,14 @@ msgid "" "sends that field at all)." msgstr "" -#: ../../library/codecs.rst:1508 +#: ../../library/codecs.rst:1618 msgid "" "When receiving host names from the wire (such as in reverse name lookup), no " "automatic conversion to Unicode is performed: applications wishing to " "present such host names to the user should decode them to Unicode." msgstr "" -#: ../../library/codecs.rst:1512 +#: ../../library/codecs.rst:1622 msgid "" "The module :mod:`encodings.idna` also implements the nameprep procedure, " "which performs certain normalizations on host names, to achieve case-" @@ -2632,49 +2761,49 @@ msgid "" "characters. The nameprep functions can be used directly if desired." msgstr "" -#: ../../library/codecs.rst:1520 +#: ../../library/codecs.rst:1630 msgid "" "Return the nameprepped version of *label*. The implementation currently " "assumes query strings, so ``AllowUnassigned`` is true." msgstr "" -#: ../../library/codecs.rst:1526 +#: ../../library/codecs.rst:1636 msgid "" "Convert a label to ASCII, as specified in :rfc:`3490`. ``UseSTD3ASCIIRules`` " "is assumed to be false." msgstr "" -#: ../../library/codecs.rst:1532 +#: ../../library/codecs.rst:1642 msgid "Convert a label to Unicode, as specified in :rfc:`3490`." msgstr "" -#: ../../library/codecs.rst:1536 +#: ../../library/codecs.rst:1646 msgid ":mod:`encodings.mbcs` --- Windows ANSI codepage" -msgstr "" +msgstr ":mod:`encodings.mbcs` --- Windows ANSI 碼頁" -#: ../../library/codecs.rst:1541 +#: ../../library/codecs.rst:1651 msgid "This module implements the ANSI codepage (CP_ACP)." -msgstr "" +msgstr "這個模組實作了 ANSI 碼頁 (CP_ACP)。" -#: ../../library/codecs.rst:1543 -msgid ":ref:`Availability `: Windows." -msgstr ":ref:`適用 `:Windows。" +#: ../../library/codecs.rst:1653 +msgid "Availability" +msgstr "可用性" -#: ../../library/codecs.rst:1545 +#: ../../library/codecs.rst:1655 msgid "" "Before 3.2, the *errors* argument was ignored; ``'replace'`` was always used " "to encode, and ``'ignore'`` to decode." msgstr "" -#: ../../library/codecs.rst:1549 +#: ../../library/codecs.rst:1659 msgid "Support any error handler." msgstr "" -#: ../../library/codecs.rst:1554 +#: ../../library/codecs.rst:1664 msgid ":mod:`encodings.utf_8_sig` --- UTF-8 codec with BOM signature" msgstr "" -#: ../../library/codecs.rst:1560 +#: ../../library/codecs.rst:1670 msgid "" "This module implements a variant of the UTF-8 codec. On encoding, a UTF-8 " "encoded BOM will be prepended to the UTF-8 encoded bytes. For the stateful " @@ -2703,71 +2832,71 @@ msgstr "streams(串流)" msgid "stackable" msgstr "stackable(可堆疊)" -#: ../../library/codecs.rst:312 +#: ../../library/codecs.rst:334 msgid "strict" msgstr "strict" -#: ../../library/codecs.rst:312 ../../library/codecs.rst:364 -#: ../../library/codecs.rst:387 +#: ../../library/codecs.rst:334 ../../library/codecs.rst:386 +#: ../../library/codecs.rst:409 msgid "error handler's name" msgstr "error handler's name(錯誤處理器名稱)" -#: ../../library/codecs.rst:312 +#: ../../library/codecs.rst:334 msgid "ignore" msgstr "ignore" -#: ../../library/codecs.rst:312 +#: ../../library/codecs.rst:334 msgid "replace" msgstr "replace" -#: ../../library/codecs.rst:312 +#: ../../library/codecs.rst:334 msgid "backslashreplace" msgstr "backslashreplace" -#: ../../library/codecs.rst:312 +#: ../../library/codecs.rst:334 msgid "surrogateescape" msgstr "surrogateescape" -#: ../../library/codecs.rst:312 +#: ../../library/codecs.rst:334 msgid "? (question mark)" msgstr "? (問號)" -#: ../../library/codecs.rst:312 +#: ../../library/codecs.rst:334 msgid "replacement character" msgstr "replacement character(替代字元)" -#: ../../library/codecs.rst:312 +#: ../../library/codecs.rst:334 msgid "\\ (backslash)" msgstr "\\ (反斜線)" -#: ../../library/codecs.rst:312 ../../library/codecs.rst:364 +#: ../../library/codecs.rst:334 ../../library/codecs.rst:386 msgid "escape sequence" msgstr "escape sequence(跳脫序列)" -#: ../../library/codecs.rst:312 +#: ../../library/codecs.rst:334 msgid "\\x" msgstr "\\x" -#: ../../library/codecs.rst:312 +#: ../../library/codecs.rst:334 msgid "\\u" msgstr "\\u" -#: ../../library/codecs.rst:312 +#: ../../library/codecs.rst:334 msgid "\\U" msgstr "\\U" -#: ../../library/codecs.rst:364 +#: ../../library/codecs.rst:386 msgid "xmlcharrefreplace" msgstr "xmlcharrefreplace" -#: ../../library/codecs.rst:364 +#: ../../library/codecs.rst:386 msgid "namereplace" msgstr "namereplace" -#: ../../library/codecs.rst:364 +#: ../../library/codecs.rst:386 msgid "\\N" msgstr "\\N" -#: ../../library/codecs.rst:387 +#: ../../library/codecs.rst:409 msgid "surrogatepass" msgstr "surrogatepass" diff --git a/library/codeop.po b/library/codeop.po index bdb19c3cca..36b73d432c 100644 --- a/library/codeop.po +++ b/library/codeop.po @@ -1,15 +1,16 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: +# Liang-Bo Wang , 2016 +# Matt Wang , 2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-05-09 00:03+0000\n" -"PO-Revision-Date: 2016-11-19 00:28+0000\n" -"Last-Translator: Liang-Bo Wang \n" +"PO-Revision-Date: 2024-09-24 20:28+0000\n" +"Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -34,32 +35,41 @@ msgid "" "include such a loop in your program you probably want to use the :mod:`code` " "module instead." msgstr "" +":mod:`codeop` 模組提供了可以模擬 Python read-eval-print 循環的工具程式 " +"(utilities),就像在 :mod:`code` 模組中所做的那樣。因此你可能不想直接使用該模" +"組;如果你想在程式中包含這樣的循環,你可能需要使用 :mod:`code` 模組。" #: ../../library/codeop.rst:20 msgid "There are two parts to this job:" -msgstr "" +msgstr "這個任務有兩個部分:" #: ../../library/codeop.rst:22 msgid "" "Being able to tell if a line of input completes a Python statement: in " "short, telling whether to print '``>>>``' or '``...``' next." msgstr "" +"能夠判斷一列輸入是否完成了一項 Python 陳述式:簡而言之,判斷接下來是列印 " +"'``>>>``' 還是 '``...``'。" #: ../../library/codeop.rst:25 msgid "" "Remembering which future statements the user has entered, so subsequent " "input can be compiled with these in effect." msgstr "" +"記住使用者輸入了哪些未來陳述式,以便後續輸入可以在這些陳述式生效的情況下進行" +"編譯。" #: ../../library/codeop.rst:28 msgid "" "The :mod:`codeop` module provides a way of doing each of these things, and a " "way of doing them both." msgstr "" +":mod:`codeop` 模組提供了一種完成上述每項任務的方法,以及同時完成這兩項任務的" +"方法。" #: ../../library/codeop.rst:31 msgid "To do just the former:" -msgstr "" +msgstr "只做前者:" #: ../../library/codeop.rst:35 msgid "" @@ -69,6 +79,10 @@ msgid "" "``''``. Returns ``None`` if *source* is *not* valid Python code, but " "is a prefix of valid Python code." msgstr "" +"嘗試編譯 *source*,它應該是 Python 程式碼的字串,如果 *source* 是有效的 " +"Python 程式碼,則回傳一個程式碼物件 (code object)。在這種情況下,程式碼物件的" +"檔案名稱屬性將為 *filename*,預設為 ``''``。如果 *source* 不是有效的 " +"Python 程式碼,而是有效 Python 程式碼的前綴,則回傳 ``None``。" #: ../../library/codeop.rst:41 msgid "" @@ -76,6 +90,9 @@ msgid "" "`SyntaxError` is raised if there is invalid Python syntax, and :exc:" "`OverflowError` or :exc:`ValueError` if there is an invalid literal." msgstr "" +"如果 *source* 有問題,就會引發例外。如果存在無效的 Python 語法則會引發 :exc:" +"`SyntaxError`;如果存在無效的文字 (literal),則會引發 :exc:`OverflowError` " +"或 :exc:`ValueError`。" #: ../../library/codeop.rst:45 msgid "" @@ -84,6 +101,9 @@ msgid "" "or as an :term:`expression` (``'eval'``). Any other value will cause :exc:" "`ValueError` to be raised." msgstr "" +"*symbol* 引數決定 *source* 是否編譯為陳述式(``'single'``,為預設值)、為\\ :" +"term:`陳述式 `\\ 序列 (``'exec'``) 或為\\ :term:`運算式 " +"` (``'eval'``)。任何其他值都會導致引發 :exc:`ValueError`。" #: ../../library/codeop.rst:52 msgid "" @@ -93,6 +113,10 @@ msgid "" "backslash followed by two newlines may be followed by arbitrary garbage. " "This will be fixed once the API for the parser is better." msgstr "" +"剖析器 (parser) 有可能(但通常不會)在到達原始碼的結尾之前停止剖析並獲得成功" +"的結果;在這種情況下,尾隨符號可能會被忽略而不是導致錯誤。例如,反斜線後面加" +"上兩個換行符號後可以是任意的無意義符號。這個問題在未來會因為剖析器 API 的改善" +"而被解決。" #: ../../library/codeop.rst:61 msgid "" @@ -102,6 +126,9 @@ msgid "" "statement, the instance 'remembers' and compiles all subsequent program " "texts with the statement in force." msgstr "" +"此類別的實例具有 :meth:`~object.__call__` 方法,其簽名與內建函式 :func:" +"`compile` 相同,區別在於如果實例編譯包含 :mod:`__future__` 陳述式的程式文本," +"實例會「記住」並使用該陳述式開始編譯所有後續程式文本。" #: ../../library/codeop.rst:70 msgid "" @@ -111,3 +138,6 @@ msgid "" "'remembers' and compiles all subsequent program texts with the statement in " "force." msgstr "" +"此類別的實例具有 :meth:`~object.__call__` 方法,其簽名與內建函式 :func:" +"`compile_command` 相同,區別在於如果實例編譯包含 :mod:`__future__` 陳述式的程" +"式文本,實例會「記住」並使用該陳述式開始編譯所有後續程式文本。" diff --git a/library/collections.abc.po b/library/collections.abc.po index 7d3b69e86f..e680b63eff 100644 --- a/library/collections.abc.po +++ b/library/collections.abc.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-07 03:11+0800\n" +"POT-Creation-Date: 2025-02-22 08:51+0000\n" "PO-Revision-Date: 2018-05-23 14:41+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -46,7 +45,7 @@ msgstr "" #: ../../library/collections.abc.rst:30 msgid "" -"1) A newly written class can inherit directly from one of the abstract base " +"A newly written class can inherit directly from one of the abstract base " "classes. The class must supply the required abstract methods. The " "remaining mixin methods come from inheritance and can be overridden if " "desired. Other methods may be added as needed:" @@ -72,7 +71,7 @@ msgstr "" #: ../../library/collections.abc.rst:50 msgid "" -"2) Existing classes and built-in classes can be registered as \"virtual " +"Existing classes and built-in classes can be registered as \"virtual " "subclasses\" of the ABCs. Those classes should define the full API " "including all of the abstract methods and all of the mixin methods. This " "lets users rely on :func:`issubclass` or :func:`isinstance` tests to " @@ -112,11 +111,11 @@ msgstr "" #: ../../library/collections.abc.rst:82 msgid "" -"3) Some simple interfaces are directly recognizable by the presence of the " +"Some simple interfaces are directly recognizable by the presence of the " "required methods (unless those methods have been set to :const:`None`):" msgstr "" -#: ../../library/collections.abc.rst:86 +#: ../../library/collections.abc.rst:85 msgid "" "class E:\n" " def __iter__(self): ...\n" @@ -126,7 +125,7 @@ msgstr "" " def __iter__(self): ...\n" " def __next__(self): ..." -#: ../../library/collections.abc.rst:92 +#: ../../library/collections.abc.rst:91 msgid "" ">>> issubclass(E, Iterable)\n" "True\n" @@ -138,7 +137,7 @@ msgstr "" ">>> isinstance(E(), Iterable)\n" "True" -#: ../../library/collections.abc.rst:99 +#: ../../library/collections.abc.rst:98 msgid "" "Complex interfaces do not support this last technique because an interface " "is more than just the presence of method names. Interfaces specify " @@ -148,184 +147,186 @@ msgid "" "insufficient for distinguishing a :class:`Sequence` from a :class:`Mapping`." msgstr "" -#: ../../library/collections.abc.rst:107 +#: ../../library/collections.abc.rst:106 msgid "" "These abstract classes now support ``[]``. See :ref:`types-genericalias` " "and :pep:`585`." msgstr "" -#: ../../library/collections.abc.rst:114 +#: ../../library/collections.abc.rst:113 msgid "Collections Abstract Base Classes" msgstr "" -#: ../../library/collections.abc.rst:116 +#: ../../library/collections.abc.rst:115 msgid "" "The collections module offers the following :term:`ABCs `:" msgstr "" -#: ../../library/collections.abc.rst:121 +#: ../../library/collections.abc.rst:120 msgid "ABC" msgstr "ABC" -#: ../../library/collections.abc.rst:121 +#: ../../library/collections.abc.rst:120 msgid "Inherits from" msgstr "" -#: ../../library/collections.abc.rst:121 +#: ../../library/collections.abc.rst:120 msgid "Abstract Methods" msgstr "" -#: ../../library/collections.abc.rst:121 +#: ../../library/collections.abc.rst:120 msgid "Mixin Methods" msgstr "" -#: ../../library/collections.abc.rst:123 +#: ../../library/collections.abc.rst:122 msgid ":class:`Container` [1]_" msgstr ":class:`Container` [1]_" -#: ../../library/collections.abc.rst:123 +#: ../../library/collections.abc.rst:122 msgid "``__contains__``" msgstr "``__contains__``" -#: ../../library/collections.abc.rst:124 +#: ../../library/collections.abc.rst:123 msgid ":class:`Hashable` [1]_" msgstr ":class:`Hashable` [1]_" -#: ../../library/collections.abc.rst:124 +#: ../../library/collections.abc.rst:123 msgid "``__hash__``" msgstr "``__hash__``" -#: ../../library/collections.abc.rst:125 +#: ../../library/collections.abc.rst:124 msgid ":class:`Iterable` [1]_ [2]_" msgstr ":class:`Iterable` [1]_ [2]_" -#: ../../library/collections.abc.rst:125 ../../library/collections.abc.rst:126 +#: ../../library/collections.abc.rst:124 ../../library/collections.abc.rst:125 msgid "``__iter__``" msgstr "``__iter__``" -#: ../../library/collections.abc.rst:126 +#: ../../library/collections.abc.rst:125 msgid ":class:`Iterator` [1]_" msgstr ":class:`Iterator` [1]_" -#: ../../library/collections.abc.rst:126 ../../library/collections.abc.rst:127 +#: ../../library/collections.abc.rst:125 ../../library/collections.abc.rst:126 msgid ":class:`Iterable`" msgstr ":class:`Iterable`" -#: ../../library/collections.abc.rst:126 +#: ../../library/collections.abc.rst:125 msgid "``__next__``" msgstr "``__next__``" -#: ../../library/collections.abc.rst:127 +#: ../../library/collections.abc.rst:126 msgid ":class:`Reversible` [1]_" msgstr ":class:`Reversible` [1]_" -#: ../../library/collections.abc.rst:127 +#: ../../library/collections.abc.rst:126 msgid "``__reversed__``" msgstr "``__reversed__``" -#: ../../library/collections.abc.rst:128 +#: ../../library/collections.abc.rst:127 msgid ":class:`Generator` [1]_" msgstr ":class:`Generator` [1]_" -#: ../../library/collections.abc.rst:128 +#: ../../library/collections.abc.rst:127 msgid ":class:`Iterator`" msgstr ":class:`Iterator`" -#: ../../library/collections.abc.rst:128 ../../library/collections.abc.rst:176 +#: ../../library/collections.abc.rst:127 ../../library/collections.abc.rst:176 msgid "``send``, ``throw``" msgstr "``send``、``throw``" -#: ../../library/collections.abc.rst:128 +#: ../../library/collections.abc.rst:127 msgid "``close``, ``__iter__``, ``__next__``" msgstr "``close``、``__iter__``、``__next__``" -#: ../../library/collections.abc.rst:129 +#: ../../library/collections.abc.rst:128 msgid ":class:`Sized` [1]_" msgstr ":class:`Sized` [1]_" -#: ../../library/collections.abc.rst:129 ../../library/collections.abc.rst:168 +#: ../../library/collections.abc.rst:128 msgid "``__len__``" msgstr "``__len__``" -#: ../../library/collections.abc.rst:130 +#: ../../library/collections.abc.rst:129 msgid ":class:`Callable` [1]_" msgstr ":class:`Callable` [1]_" -#: ../../library/collections.abc.rst:130 +#: ../../library/collections.abc.rst:129 msgid "``__call__``" msgstr "``__call__``" -#: ../../library/collections.abc.rst:131 +#: ../../library/collections.abc.rst:130 msgid ":class:`Collection` [1]_" msgstr ":class:`Collection` [1]_" -#: ../../library/collections.abc.rst:131 +#: ../../library/collections.abc.rst:130 msgid ":class:`Sized`, :class:`Iterable`, :class:`Container`" msgstr ":class:`Sized`、:class:`Iterable`、:class:`Container`" -#: ../../library/collections.abc.rst:131 ../../library/collections.abc.rst:147 +#: ../../library/collections.abc.rst:130 ../../library/collections.abc.rst:146 msgid "``__contains__``, ``__iter__``, ``__len__``" msgstr "``__contains__``、``__iter__``、``__len__``" -#: ../../library/collections.abc.rst:135 ../../library/collections.abc.rst:138 -#: ../../library/collections.abc.rst:144 +#: ../../library/collections.abc.rst:134 ../../library/collections.abc.rst:137 +#: ../../library/collections.abc.rst:143 msgid ":class:`Sequence`" msgstr ":class:`Sequence`" -#: ../../library/collections.abc.rst:135 +#: ../../library/collections.abc.rst:134 msgid ":class:`Reversible`, :class:`Collection`" msgstr ":class:`Reversible`, :class:`Collection`" -#: ../../library/collections.abc.rst:135 ../../library/collections.abc.rst:144 +#: ../../library/collections.abc.rst:134 ../../library/collections.abc.rst:143 msgid "``__getitem__``, ``__len__``" msgstr "``__getitem__``、``__len__``" -#: ../../library/collections.abc.rst:135 +#: ../../library/collections.abc.rst:134 msgid "" "``__contains__``, ``__iter__``, ``__reversed__``, ``index``, and ``count``" msgstr "" "``__contains__``、``__iter__``、``__reversed__``、``index`` 和 ``count``" -#: ../../library/collections.abc.rst:138 +#: ../../library/collections.abc.rst:137 msgid ":class:`MutableSequence`" msgstr ":class:`MutableSequence`" -#: ../../library/collections.abc.rst:138 +#: ../../library/collections.abc.rst:137 msgid "" "``__getitem__``, ``__setitem__``, ``__delitem__``, ``__len__``, ``insert``" msgstr "" "``__getitem__``、``__setitem__``、``__delitem__``、``__len__``、``insert``" -#: ../../library/collections.abc.rst:138 +#: ../../library/collections.abc.rst:137 msgid "" "Inherited :class:`Sequence` methods and ``append``, ``clear``, ``reverse``, " "``extend``, ``pop``, ``remove``, and ``__iadd__``" msgstr "" -#: ../../library/collections.abc.rst:144 +#: ../../library/collections.abc.rst:143 msgid ":class:`ByteString`" msgstr ":class:`ByteString`" -#: ../../library/collections.abc.rst:144 +#: ../../library/collections.abc.rst:143 msgid "Inherited :class:`Sequence` methods" msgstr "" -#: ../../library/collections.abc.rst:147 ../../library/collections.abc.rst:151 +#: ../../library/collections.abc.rst:146 ../../library/collections.abc.rst:151 msgid ":class:`Set`" msgstr ":class:`Set`" -#: ../../library/collections.abc.rst:147 ../../library/collections.abc.rst:157 +#: ../../library/collections.abc.rst:146 ../../library/collections.abc.rst:157 msgid ":class:`Collection`" msgstr ":class:`Collection`" -#: ../../library/collections.abc.rst:147 +#: ../../library/collections.abc.rst:146 msgid "" "``__le__``, ``__lt__``, ``__eq__``, ``__ne__``, ``__gt__``, ``__ge__``, " -"``__and__``, ``__or__``, ``__sub__``, ``__xor__``, and ``isdisjoint``" +"``__and__``, ``__or__``, ``__sub__``, ``__rsub__``, ``__xor__``, " +"``__rxor__`` and ``isdisjoint``" msgstr "" "``__le__``、``__lt__``、``__eq__``、``__ne__``、``__gt__``、``__ge__``、" -"``__and__``、``__or__``、``__sub__``、``__xor__`` 與 ``isdisjoint``" +"``__and__``、``__or__``、``__sub__``、``__rsub__``、``__xor__``、" +"``__rxor__`` 和 ``isdisjoint``" #: ../../library/collections.abc.rst:151 msgid ":class:`MutableSet`" @@ -381,6 +382,10 @@ msgstr ":class:`MappingView`" msgid ":class:`Sized`" msgstr ":class:`Sized`" +#: ../../library/collections.abc.rst:168 +msgid "``__init__``, ``__len__`` and ``__repr__``" +msgstr "``__init__``、``__len__`` 和 ``__repr__``" + #: ../../library/collections.abc.rst:169 msgid ":class:`ItemsView`" msgstr ":class:`ItemsView`" @@ -472,7 +477,7 @@ msgstr "``__buffer__``" #: ../../library/collections.abc.rst:185 msgid "Footnotes" -msgstr "註解" +msgstr "註腳" #: ../../library/collections.abc.rst:186 msgid "" diff --git a/library/collections.po b/library/collections.po index 6ec399fe02..28aa3f51f9 100644 --- a/library/collections.po +++ b/library/collections.po @@ -1,16 +1,15 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # 周 忠毅 , 2016 # Adrian Liaw , 2018 -# Matt Wang , 2022 +# Matt Wang , 2022-2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-03-04 00:14+0000\n" "PO-Revision-Date: 2024-01-22 21:42+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -33,12 +32,12 @@ msgstr "**原始碼:**\\ :source:`Lib/collections/__init__.py`" #: ../../library/collections.rst:20 msgid "" "This module implements specialized container datatypes providing " -"alternatives to Python's general purpose built-in containers, :class:" -"`dict`, :class:`list`, :class:`set`, and :class:`tuple`." +"alternatives to Python's general purpose built-in " +"containers, :class:`dict`, :class:`list`, :class:`set`, and :class:`tuple`." msgstr "" -"這個模組實作了一些特別的容器資料型態,用來替代 Python 一般內建的容器,例如 :" -"class:`dict`\\ (字典)、:class:`list`\\ (串列)、:class:`set`\\ (集合)" -"和 :class:`tuple`\\ (元組)。" +"這個模組實作了一些特別的容器資料型態,用來替代 Python 一般內建的容器,例" +"如 :class:`dict`\\ (字典)、:class:`list`\\ (串列)、:class:`set`\\ (集" +"合)和 :class:`tuple`\\ (元組)。" #: ../../library/collections.rst:25 msgid ":func:`namedtuple`" @@ -125,8 +124,8 @@ msgid "" "calls." msgstr "" ":class:`ChainMap`\\ (對映鏈結)類別的目的是快速將數個對映連結在一起,讓它們" -"可以被當作一個單元來處理。它通常會比建立一個新的字典並多次呼叫 :meth:`~dict." -"update` 來得更快。" +"可以被當作一個單元來處理。它通常會比建立一個新的字典並多次呼" +"叫 :meth:`~dict.update` 來得更快。" #: ../../library/collections.rst:46 msgid "" @@ -189,8 +188,8 @@ msgid "" "which mappings are searched. The list should always contain at least one " "mapping." msgstr "" -"一個可被更新的對映列表,這個列表是按照被搜索的順序來排列,在 ChainMap 中它是" -"唯一被儲存的狀態,可被修改來變換搜索順序。回傳的列表都至少包含一個對映。" +"一個可被更新的對映列表,這個列表是按照被搜尋的順序來排列,在 ChainMap 中它是" +"唯一被儲存的狀態,可被修改來變換搜尋順序。回傳的列表都至少包含一個對映。" #: ../../library/collections.rst:77 msgid "" @@ -202,10 +201,10 @@ msgid "" "or new empty dict. This method is used for creating subcontexts that can be " "updated without altering values in any of the parent mappings." msgstr "" -"回傳包含一個新對映的 :class:`ChainMap`, 新對映後面接著當前實例的所有現存對" +"回傳包含一個新對映的 :class:`ChainMap`, 新對映後面接著目前實例的所有現存對" "映。如果有給定 ``m``,``m`` 會成為那個最前面的新對映;若沒有指定,則會加上一" -"個空 dict,如此一來呼叫 ``d.new_child()`` 就等同於 ``ChainMap({}, *d." -"maps)``。這個方法用於建立子上下文,而保持父對映的不變。" +"個空 dict,如此一來呼叫 ``d.new_child()`` 就等同於 ``ChainMap({}, " +"*d.maps)``。這個方法用於建立子上下文,而保持父對映的不變。" #: ../../library/collections.rst:86 msgid "The optional ``m`` parameter was added." @@ -219,13 +218,14 @@ msgstr "增加了對關鍵字引數的支援。" msgid "" "Property returning a new :class:`ChainMap` containing all of the maps in the " "current instance except the first one. This is useful for skipping the " -"first map in the search. Use cases are similar to those for the :keyword:" -"`nonlocal` keyword used in :term:`nested scopes `. The use " -"cases also parallel those for the built-in :func:`super` function. A " -"reference to ``d.parents`` is equivalent to: ``ChainMap(*d.maps[1:])``." +"first map in the search. Use cases are similar to those for " +"the :keyword:`nonlocal` keyword used in :term:`nested scopes `. The use cases also parallel those for the built-in :func:`super` " +"function. A reference to ``d.parents`` is equivalent to: " +"``ChainMap(*d.maps[1:])``." msgstr "" "回傳一個包含除了第一個以外所有其他對映的新 :class:`ChainMap` 的特性,可用於需" -"要跳過第一個對映的搜索。使用情境類似於在\\ :term:`巢狀作用域 `\\ 當中使用 :keyword:`nonlocal` 關鍵字,也可與內建函式 :func:`super` " "做類比。引用 ``d.parents`` 等同於 ``ChainMap(*d.maps[1:])``。" @@ -284,14 +284,14 @@ msgstr "" msgid "" "Django's `Context class `_ for templating is a read-only chain of mappings. It " -"also features pushing and popping of contexts similar to the :meth:" -"`~collections.ChainMap.new_child` method and the :attr:`~collections." -"ChainMap.parents` property." +"also features pushing and popping of contexts similar to " +"the :meth:`~collections.ChainMap.new_child` method and " +"the :attr:`~collections.ChainMap.parents` property." msgstr "" "Django 中用於模板的 `Context class `_ 是唯讀的對映鏈,也具有加入 (push) 和移除 " -"(pop) 上下文的功能,與 :meth:`~collections.ChainMap.new_child` 方法和 :attr:" -"`~collections.ChainMap.parents` 特性類似。" +"(pop) 上下文的功能,與 :meth:`~collections.ChainMap.new_child` 方法" +"和 :attr:`~collections.ChainMap.parents` 特性類似。" #: ../../library/collections.rst:136 msgid "" @@ -306,11 +306,11 @@ msgstr "" #: ../../library/collections.rst:141 msgid "" -"A `greatly simplified read-only version of Chainmap `_." +"A `greatly simplified read-only version of Chainmap `_." msgstr "" -"一個\\ `極度簡化、維讀版本的 Chainmap `_。" +"一個\\ `極度簡化、維讀版本的 Chainmap `_。" #: ../../library/collections.rst:146 msgid ":class:`ChainMap` Examples and Recipes" @@ -612,7 +612,7 @@ msgid "" "list(c) # list unique elements\n" "set(c) # convert to a set\n" "dict(c) # convert to a regular dictionary\n" -"c.items() # convert to a list of (elem, cnt) pairs\n" +"c.items() # access the (elem, cnt) pairs\n" "Counter(dict(list_of_pairs)) # convert from a list of (elem, cnt) pairs\n" "c.most_common()[:-n-1:-1] # n least common elements\n" "+c # remove zero and negative counts" @@ -693,13 +693,13 @@ msgstr "使用 :meth:`~Counter.most_common` 方法的唯一條件是其值要是 msgid "" "For in-place operations such as ``c[key] += 1``, the value type need only " "support addition and subtraction. So fractions, floats, and decimals would " -"work and negative values are supported. The same is also true for :meth:" -"`~Counter.update` and :meth:`~Counter.subtract` which allow negative and " -"zero values for both inputs and outputs." +"work and negative values are supported. The same is also true " +"for :meth:`~Counter.update` and :meth:`~Counter.subtract` which allow " +"negative and zero values for both inputs and outputs." msgstr "" "像是 ``c[key] += 1`` 的原地操作中,其值之型別只必須支援加減,所以分數、浮點" -"數、十進位數與其負值都可以使用。同理,:meth:`~Counter.update` 和 :meth:" -"`~Counter.subtract` 也都允許 0 或負值為輸入或輸出。" +"數、十進位數與其負值都可以使用。同理,:meth:`~Counter.update` " +"和 :meth:`~Counter.subtract` 也都允許 0 或負值為輸入或輸出。" #: ../../library/collections.rst:422 msgid "" @@ -719,8 +719,8 @@ msgstr ":meth:`~Counter.elements` 方法需要其計數為正值,如為 0 或 #: ../../library/collections.rst:432 msgid "" -"`Bag class `_ in Smalltalk." +"`Bag class `_ in Smalltalk." msgstr "" "Smalltalk 中的 `Bag class `_。" @@ -753,8 +753,8 @@ msgid "" "To enumerate all distinct multisets of a given size over a given set of " "elements, see :func:`itertools.combinations_with_replacement`::" msgstr "" -"若要根據給定的元素集合來列舉出所有不重複且擁有指定元素數量的 multiset,請見 :" -"func:`itertools.combinations_with_replacement`: ::" +"若要根據給定的元素集合來列舉出所有不重複且擁有指定元素數量的 multiset,請" +"見 :func:`itertools.combinations_with_replacement`: ::" #: ../../library/collections.rst:447 msgid "" @@ -772,9 +772,9 @@ msgid "" "with data from *iterable*. If *iterable* is not specified, the new deque is " "empty." msgstr "" -"回傳一個新的 deque(雙端佇列)物件,將 *iterable* 中的資料由左至右(使用 :" -"meth:`append`\\ )加入來做初始化。如果 *iterable* 並未給定,回傳的則是一個空" -"的 deque。" +"回傳一個新的 deque(雙端佇列)物件,將 *iterable* 中的資料由左至右(使" +"用 :meth:`append`\\ )加入來做初始化。如果 *iterable* 並未給定,回傳的則是一" +"個空的 deque。" #: ../../library/collections.rst:458 msgid "" @@ -868,32 +868,32 @@ msgstr "在 deque 位置 *i* 中插入 *x*。" #: ../../library/collections.rst:535 msgid "" -"If the insertion would cause a bounded deque to grow beyond *maxlen*, an :" -"exc:`IndexError` is raised." +"If the insertion would cause a bounded deque to grow beyond *maxlen*, " +"an :exc:`IndexError` is raised." msgstr "" -"如果此插入操作導致 deque 超過其長度上限 *maxlen* 的話,會引發 :exc:" -"`IndexError` 例外。" +"如果此插入操作導致 deque 超過其長度上限 *maxlen* 的話,會引" +"發 :exc:`IndexError` 例外。" #: ../../library/collections.rst:543 msgid "" "Remove and return an element from the right side of the deque. If no " "elements are present, raises an :exc:`IndexError`." msgstr "" -"移除並回傳 deque 的最右側元素,若本來就沒有任何元素,則會引發 :exc:" -"`IndexError`。" +"移除並回傳 deque 的最右側元素,若本來就沒有任何元素,則會引" +"發 :exc:`IndexError`。" #: ../../library/collections.rst:549 msgid "" "Remove and return an element from the left side of the deque. If no elements " "are present, raises an :exc:`IndexError`." msgstr "" -"移除並回傳 deque 的最左側元素,若本來就沒有任何元素,則會引發 :exc:" -"`IndexError`。" +"移除並回傳 deque 的最左側元素,若本來就沒有任何元素,則會引" +"發 :exc:`IndexError`。" #: ../../library/collections.rst:555 msgid "" -"Remove the first occurrence of *value*. If not found, raises a :exc:" -"`ValueError`." +"Remove the first occurrence of *value*. If not found, raises " +"a :exc:`ValueError`." msgstr "移除第一個出現的 *value*,如果沒找到的話就引發一個 :exc:`ValueError`。" #: ../../library/collections.rst:561 @@ -1052,17 +1052,17 @@ msgstr "" #: ../../library/collections.rst:678 msgid "" "A `round-robin scheduler `_ can be implemented with input iterators stored in a :" -"class:`deque`. Values are yielded from the active iterator in position " -"zero. If that iterator is exhausted, it can be removed with :meth:`~deque." -"popleft`; otherwise, it can be cycled back to the end with the :meth:`~deque." -"rotate` method::" +"robin_scheduling>`_ can be implemented with input iterators stored in " +"a :class:`deque`. Values are yielded from the active iterator in position " +"zero. If that iterator is exhausted, it can be removed " +"with :meth:`~deque.popleft`; otherwise, it can be cycled back to the end " +"with the :meth:`~deque.rotate` method::" msgstr "" "一個\\ `輪詢調度器 `_\\ 可以透過在 :class:`deque` 中放入 iterator 來實現,值自" -"當前 iterator 的位置 0 取出,如果 iterator 已經消耗完畢就用 :meth:`~deque." -"popleft` 將其從佇列中移除,否則利用 :meth:`~deque.rotate` 來將其移至佇列尾" -"端: ::" +"目前 iterator 的位置 0 取出,如果 iterator 已經消耗完畢就" +"用 :meth:`~deque.popleft` 將其從佇列中移除,否則利用 :meth:`~deque.rotate` 來" +"將其移至佇列尾端: ::" #: ../../library/collections.rst:685 msgid "" @@ -1103,18 +1103,19 @@ msgstr "" #: ../../library/collections.rst:706 msgid "" -"To implement :class:`deque` slicing, use a similar approach applying :meth:" -"`~deque.rotate` to bring a target element to the left side of the deque. " -"Remove old entries with :meth:`~deque.popleft`, add new entries with :meth:" -"`~deque.extend`, and then reverse the rotation. With minor variations on " -"that approach, it is easy to implement Forth style stack manipulations such " -"as ``dup``, ``drop``, ``swap``, ``over``, ``pick``, ``rot``, and ``roll``." +"To implement :class:`deque` slicing, use a similar approach " +"applying :meth:`~deque.rotate` to bring a target element to the left side of " +"the deque. Remove old entries with :meth:`~deque.popleft`, add new entries " +"with :meth:`~deque.extend`, and then reverse the rotation. With minor " +"variations on that approach, it is easy to implement Forth style stack " +"manipulations such as ``dup``, ``drop``, ``swap``, ``over``, ``pick``, " +"``rot``, and ``roll``." msgstr "" "要實現 :class:`deque` 切片,可使用近似以下方法:使用 :meth:`~deque.rotate` 來" -"將目標元素移動到 deque 最左側,用 :meth:`~deque.popleft` 移除舊元素並用 :" -"meth:`~deque.extend` 加入新元素,最後再反向 rotate。在這個方法上做小小的更動" -"就能簡單地實現 Forth 風格的 stack 操作,例如 ``dup``、``drop``、``swap``、" -"``over``、``pick``、``rot`` 和 ``roll``。" +"將目標元素移動到 deque 最左側,用 :meth:`~deque.popleft` 移除舊元素並" +"用 :meth:`~deque.extend` 加入新元素,最後再反向 rotate。在這個方法上做小小的" +"更動就能簡單地實現 Forth 風格的 stack 操作,例如 ``dup``、``drop``、" +"``swap``、``over``、``pick``、``rot`` 和 ``roll``。" #: ../../library/collections.rst:716 msgid ":class:`defaultdict` objects" @@ -1128,15 +1129,15 @@ msgid "" "the :class:`dict` class and is not documented here." msgstr "" "回傳一個新的類似字典的物件。:class:`defaultdict` 是內建類別 :class:`dict` 的" -"子類別。它覆蓋掉了一個方法並添加了一個可寫入的實例變數。其餘功能與 :class:" -"`dict` 相同,此文件不再複述。" +"子類別。它覆蓋掉了一個方法並添加了一個可寫入的實例變數。其餘功能" +"與 :class:`dict` 相同,此文件不再複述。" #: ../../library/collections.rst:725 msgid "" -"The first argument provides the initial value for the :attr:" -"`default_factory` attribute; it defaults to ``None``. All remaining " -"arguments are treated the same as if they were passed to the :class:`dict` " -"constructor, including keyword arguments." +"The first argument provides the initial value for " +"the :attr:`default_factory` attribute; it defaults to ``None``. All " +"remaining arguments are treated the same as if they were passed to " +"the :class:`dict` constructor, including keyword arguments." msgstr "" "第一個引數為 :attr:`default_factory` 屬性提供了初始值,他被預設為 ``None``," "所有其他的引數(包括關鍵字引數)都會被傳遞給 :class:`dict` 的建構函式 " @@ -1150,8 +1151,8 @@ msgstr ":class:`defaultdict` 物件支援以下 :class:`dict` 所沒有的方法 #: ../../library/collections.rst:736 msgid "" -"If the :attr:`default_factory` attribute is ``None``, this raises a :exc:" -"`KeyError` exception with the *key* as argument." +"If the :attr:`default_factory` attribute is ``None``, this raises " +"a :exc:`KeyError` exception with the *key* as argument." msgstr "" "如果 :attr:`default_factory` 屬性為 ``None``,呼叫此方法會引發一個附帶引數 " "*key* 的 :exc:`KeyError` 例外。" @@ -1175,24 +1176,24 @@ msgstr "" #: ../../library/collections.rst:746 msgid "" -"This method is called by the :meth:`~object.__getitem__` method of the :" -"class:`dict` class when the requested key is not found; whatever it returns " -"or raises is then returned or raised by :meth:`~object.__getitem__`." +"This method is called by the :meth:`~object.__getitem__` method of " +"the :class:`dict` class when the requested key is not found; whatever it " +"returns or raises is then returned or raised by :meth:`~object.__getitem__`." msgstr "" -"在無法找到所要求的鍵時,此方法會被 :class:`dict` 類別的 :meth:`~object." -"__getitem__` 方法呼叫。無論此方法回傳了值還是引發了例外,都會被 :meth:" -"`~object.__getitem__` 所傳遞。" +"在無法找到所要求的鍵時,此方法會被 :class:`dict` 類別" +"的 :meth:`~object.__getitem__` 方法呼叫。無論此方法回傳了值還是引發了例外,都" +"會被 :meth:`~object.__getitem__` 所傳遞。" #: ../../library/collections.rst:750 msgid "" -"Note that :meth:`__missing__` is *not* called for any operations besides :" -"meth:`~object.__getitem__`. This means that :meth:`get` will, like normal " -"dictionaries, return ``None`` as a default rather than using :attr:" -"`default_factory`." +"Note that :meth:`__missing__` is *not* called for any operations " +"besides :meth:`~object.__getitem__`. This means that :meth:`~dict.get` will, " +"like normal dictionaries, return ``None`` as a default rather than " +"using :attr:`default_factory`." msgstr "" "注意,:meth:`__missing__` *不會*\\ 被 :meth:`~object.__getitem__` 以外的其他" -"方法呼叫,這意味著 :meth:`get` 會像一般的 dict 那樣回傳 ``None`` 做為預設值," -"而非使用 :attr:`default_factory`。" +"方法呼叫,這意味著 :meth:`~dict.get` 會像一般的 dict 那樣回傳 ``None`` 做為預" +"設值,而非使用 :attr:`default_factory`。" #: ../../library/collections.rst:756 msgid ":class:`defaultdict` objects support the following instance variable:" @@ -1207,7 +1208,7 @@ msgstr "" "此屬性為 :meth:`__missing__` 方法所使用。如果有引數被傳入建構函式,則此屬性會" "被初始化成第一個引數,如未提供引數則被初始化為 ``None``。" -#: ../../library/collections.rst:765 ../../library/collections.rst:1182 +#: ../../library/collections.rst:765 ../../library/collections.rst:1192 msgid "" "Added merge (``|``) and update (``|=``) operators, specified in :pep:`584`." msgstr "新增合併 (``|``) 和更新 (``|=``) 運算子,請見 :pep:`584`。" @@ -1227,40 +1228,41 @@ msgstr "" #: ../../library/collections.rst:784 msgid "" "When each key is encountered for the first time, it is not already in the " -"mapping; so an entry is automatically created using the :attr:`~defaultdict." -"default_factory` function which returns an empty :class:`list`. The :meth:" -"`list.append` operation then attaches the value to the new list. When keys " -"are encountered again, the look-up proceeds normally (returning the list for " -"that key) and the :meth:`list.append` operation adds another value to the " -"list. This technique is simpler and faster than an equivalent technique " +"mapping; so an entry is automatically created using " +"the :attr:`~defaultdict.default_factory` function which returns an " +"empty :class:`list`. The :meth:`!list.append` operation then attaches the " +"value to the new list. When keys are encountered again, the look-up " +"proceeds normally (returning the list for that key) and the :meth:`!" +"list.append` operation adds another value to the list. This technique is " +"simpler and faster than an equivalent technique " "using :meth:`dict.setdefault`:" msgstr "" -"當每個鍵第一次被存取時,它還沒有存在於對映中,所以會自動呼叫 :attr:" -"`~defaultdict.default_factory` 方法來回傳一個空的 :class:`list` 以建立一個條" -"目,:meth:`list.append` 操作後續會再新增值到這個新的列表裡。當再次存取該鍵" -"時,就如普通字典般操作(回傳該鍵所對應到的 list),:meth:`list.append` 也會新" -"增另一個值到 list 中。和使用與其等價的 :meth:`dict.setdefault` 相比,這個技巧" -"更加快速和簡單:" +"當每個鍵第一次被存取時,它還沒有存在於對映中,所以會自動呼" +"叫 :attr:`~defaultdict.default_factory` 方法來回傳一個空的 :class:`list` 以建" +"立一個條目,:meth:`!list.append` 操作後續會再新增值到這個新的列表裡。當再次存" +"取該鍵時,就如普通字典般操作(回傳該鍵所對應到的 list),:meth:`!" +"list.append` 也會新增另一個值到 list 中。和使用與其等價" +"的 :meth:`dict.setdefault` 相比,這個技巧更加快速和簡單:" #: ../../library/collections.rst:799 msgid "" -"Setting the :attr:`~defaultdict.default_factory` to :class:`int` makes the :" -"class:`defaultdict` useful for counting (like a bag or multiset in other " -"languages):" +"Setting the :attr:`~defaultdict.default_factory` to :class:`int` makes " +"the :class:`defaultdict` useful for counting (like a bag or multiset in " +"other languages):" msgstr "" -"設定 :attr:`~defaultdict.default_factory` 為 :class:`int` 使得 :class:" -"`defaultdict` 可被用於計數(類似其他語言中的 bag 或 multiset):" +"設定 :attr:`~defaultdict.default_factory` 為 :class:`int` 使" +"得 :class:`defaultdict` 可被用於計數(類似其他語言中的 bag 或 multiset):" #: ../../library/collections.rst:811 msgid "" -"When a letter is first encountered, it is missing from the mapping, so the :" -"attr:`~defaultdict.default_factory` function calls :func:`int` to supply a " -"default count of zero. The increment operation then builds up the count for " -"each letter." +"When a letter is first encountered, it is missing from the mapping, so " +"the :attr:`~defaultdict.default_factory` function calls :func:`int` to " +"supply a default count of zero. The increment operation then builds up the " +"count for each letter." msgstr "" -"當一個字母首次被存取時,它並不存在於對映中,則 :attr:`~defaultdict." -"default_factory` 函式會呼叫 :func:`int` 來提供一個整數 0 作為預設值。後續的增" -"加操作繼續對每個字母做計數。" +"當一個字母首次被存取時,它並不存在於對映中," +"則 :attr:`~defaultdict.default_factory` 函式會呼叫 :func:`int` 來提供一個整" +"數 0 作為預設值。後續的增加操作繼續對每個字母做計數。" #: ../../library/collections.rst:815 msgid "" @@ -1274,11 +1276,11 @@ msgstr "" #: ../../library/collections.rst:828 msgid "" -"Setting the :attr:`~defaultdict.default_factory` to :class:`set` makes the :" -"class:`defaultdict` useful for building a dictionary of sets:" +"Setting the :attr:`~defaultdict.default_factory` to :class:`set` makes " +"the :class:`defaultdict` useful for building a dictionary of sets:" msgstr "" -"將 :attr:`~defaultdict.default_factory` 設為 :class:`set` 使 :class:" -"`defaultdict` 可用於構建一個值為 set 的字典:" +"將 :attr:`~defaultdict.default_factory` 設為 :class:`set` " +"使 :class:`defaultdict` 可用於構建一個值為 set 的字典:" #: ../../library/collections.rst:841 msgid ":func:`namedtuple` Factory Function for Tuples with Named Fields" @@ -1300,16 +1302,17 @@ msgid "" "Returns a new tuple subclass named *typename*. The new subclass is used to " "create tuple-like objects that have fields accessible by attribute lookup as " "well as being indexable and iterable. Instances of the subclass also have a " -"helpful docstring (with typename and field_names) and a helpful :meth:" -"`__repr__` method which lists the tuple contents in a ``name=value`` format." +"helpful docstring (with *typename* and *field_names*) and a " +"helpful :meth:`~object.__repr__` method which lists the tuple contents in a " +"``name=value`` format." msgstr "" "回傳一個名為 *typename* 的新 tuple 子類別。這個新的子類別被用於建立類似 " "tuple 的物件,可以透過屬性名稱來存取欄位,它同時也是可索引 (indexable) 和可疊" -"代的 (iterable)。子類別實例同樣有文件字串 (docstring)(有類別名 typename 和欄" -"位名 field_names)和一個好用的 :meth:`__repr__` 方法,可將 tuple 內容以 " -"``name=value`` 格式列出。" +"代的 (iterable)。子類別實例同樣有文件字串 (docstring)(有類別名稱 *typename* " +"和欄位名 *field_names*)和一個好用的 :meth:`~object.__repr__` 方法,可將 " +"tuple 內容以 ``name=value`` 格式列出。" -#: ../../library/collections.rst:855 +#: ../../library/collections.rst:856 msgid "" "The *field_names* are a sequence of strings such as ``['x', 'y']``. " "Alternatively, *field_names* can be a single string with each fieldname " @@ -1318,19 +1321,20 @@ msgstr "" "*field_names* 是一個像 ``['x', 'y']`` 一樣的字串序列。*field_names* 也可以是" "一個用空白或逗號分隔各個欄位名稱的字串,比如 ``'x y'`` 或者 ``'x, y'``。" -#: ../../library/collections.rst:859 +#: ../../library/collections.rst:860 msgid "" "Any valid Python identifier may be used for a fieldname except for names " "starting with an underscore. Valid identifiers consist of letters, digits, " -"and underscores but do not start with a digit or underscore and cannot be a :" -"mod:`keyword` such as *class*, *for*, *return*, *global*, *pass*, or *raise*." +"and underscores but do not start with a digit or underscore and cannot be " +"a :mod:`keyword` such as *class*, *for*, *return*, *global*, *pass*, or " +"*raise*." msgstr "" "除了底線開頭以外的其他任何有效 Python 識別字 (identifier) 都可以作為欄位名" "稱,有效識別字由字母、數字、底線所組成,但不能是數字或底線開頭,也不能是關鍵" "詞 :mod:`keyword`,例如 *class*、*for*、*return*、*global*、*pass* 或 " "*raise*。" -#: ../../library/collections.rst:865 +#: ../../library/collections.rst:866 msgid "" "If *rename* is true, invalid fieldnames are automatically replaced with " "positional names. For example, ``['abc', 'def', 'ghi', 'abc']`` is " @@ -1341,7 +1345,7 @@ msgstr "" "'def', 'ghi', 'abc']`` 會被轉換成 ``['abc', '_1', 'ghi', '_3']``,移除了關鍵" "字 ``def`` 和重複欄位名 ``abc``。" -#: ../../library/collections.rst:870 +#: ../../library/collections.rst:871 msgid "" "*defaults* can be ``None`` or an :term:`iterable` of default values. Since " "fields with a default value must come after any fields without a default, " @@ -1355,14 +1359,15 @@ msgstr "" "如 fieldnames 為 ``['x', 'y', 'z']`` 且 defaults 為 ``(1, 2)``,那麼 ``x`` 就" "必須被給定一個引數,``y`` 被預設為 ``1``,``z`` 則被預設為 ``2``。" -#: ../../library/collections.rst:877 +#: ../../library/collections.rst:878 msgid "" -"If *module* is defined, the ``__module__`` attribute of the named tuple is " -"set to that value." +"If *module* is defined, the :attr:`~type.__module__` attribute of the named " +"tuple is set to that value." msgstr "" -"如果 *module* 值有被定義,named tuple 的 ``__module__`` 屬性就被設定為該值。" +"如果 *module* 值有被定義,named tuple 的 :attr:`~type.__module__` 屬性就被設" +"定為該值。" -#: ../../library/collections.rst:880 +#: ../../library/collections.rst:881 msgid "" "Named tuple instances do not have per-instance dictionaries, so they are " "lightweight and require no more memory than regular tuples." @@ -1370,17 +1375,17 @@ msgstr "" "Named tuple 實例中沒有字典,所以它們更加輕量,且和一般 tuple 相比佔用更少記憶" "體。" -#: ../../library/collections.rst:883 +#: ../../library/collections.rst:884 msgid "" "To support pickling, the named tuple class should be assigned to a variable " "that matches *typename*." msgstr "要支援 pickle,應將 named tuple 類別賦值給一個符合 *typename* 的變數。" -#: ../../library/collections.rst:886 +#: ../../library/collections.rst:887 msgid "Added support for *rename*." msgstr "新增對於 *rename* 的支援。" -#: ../../library/collections.rst:889 +#: ../../library/collections.rst:890 msgid "" "The *verbose* and *rename* parameters became :ref:`keyword-only arguments " "`." @@ -1388,20 +1393,21 @@ msgstr "" "*verbose* 和 *rename* 參數成為\\ :ref:`僅限關鍵字引數 `。" -#: ../../library/collections.rst:893 +#: ../../library/collections.rst:894 msgid "Added the *module* parameter." msgstr "新增 *module* 參數。" -#: ../../library/collections.rst:896 -msgid "Removed the *verbose* parameter and the :attr:`_source` attribute." -msgstr "移除 *verbose* 參數和 :attr:`_source` 屬性。" +#: ../../library/collections.rst:897 +msgid "Removed the *verbose* parameter and the :attr:`!_source` attribute." +msgstr "移除 *verbose* 參數和 :attr:`!_source` 屬性。" -#: ../../library/collections.rst:899 +#: ../../library/collections.rst:900 msgid "" -"Added the *defaults* parameter and the :attr:`_field_defaults` attribute." -msgstr "新增 *defaults* 參數和 :attr:`_field_defaults` 屬性。" +"Added the *defaults* parameter and " +"the :attr:`~somenamedtuple._field_defaults` attribute." +msgstr "新增 *defaults* 參數和 :attr:`~somenamedtuple._field_defaults` 屬性。" -#: ../../library/collections.rst:903 +#: ../../library/collections.rst:904 msgid "" ">>> # Basic example\n" ">>> Point = namedtuple('Point', ['x', 'y'])\n" @@ -1418,7 +1424,7 @@ msgid "" "Point(x=11, y=22)" msgstr "" -#: ../../library/collections.rst:919 +#: ../../library/collections.rst:920 msgid "" "Named tuples are especially useful for assigning field names to result " "tuples returned by the :mod:`csv` or :mod:`sqlite3` modules::" @@ -1426,7 +1432,7 @@ msgstr "" "Named tuple 在賦予欄位名稱於 :mod:`csv` 或 :mod:`sqlite3` 模組回傳之 tuple 時" "相當有用: ::" -#: ../../library/collections.rst:922 +#: ../../library/collections.rst:923 msgid "" "EmployeeRecord = namedtuple('EmployeeRecord', 'name, age, title, department, " "paygrade')\n" @@ -1460,7 +1466,7 @@ msgstr "" "for emp in map(EmployeeRecord._make, cursor.fetchall()):\n" " print(emp.name, emp.title)" -#: ../../library/collections.rst:935 +#: ../../library/collections.rst:936 msgid "" "In addition to the methods inherited from tuples, named tuples support three " "additional methods and two attributes. To prevent conflicts with field " @@ -1469,12 +1475,12 @@ msgstr "" "除了繼承自 tuple 的方法,named tuple 還支援三個額外的方法和兩個屬性。為了防止" "欄位名稱有衝突,方法和屬性的名稱以底線開頭。" -#: ../../library/collections.rst:941 +#: ../../library/collections.rst:942 msgid "" "Class method that makes a new instance from an existing sequence or iterable." msgstr "從已存在的序列或可疊代物件建立一個新實例的類別方法。" -#: ../../library/collections.rst:943 +#: ../../library/collections.rst:944 msgid "" ">>> t = [11, 22]\n" ">>> Point._make(t)\n" @@ -1484,13 +1490,13 @@ msgstr "" ">>> Point._make(t)\n" "Point(x=11, y=22)" -#: ../../library/collections.rst:951 +#: ../../library/collections.rst:952 msgid "" "Return a new :class:`dict` which maps field names to their corresponding " "values:" msgstr "回傳一個將欄位名稱對映至對應值的 :class:`dict`:" -#: ../../library/collections.rst:954 +#: ../../library/collections.rst:955 msgid "" ">>> p = Point(x=11, y=22)\n" ">>> p._asdict()\n" @@ -1500,11 +1506,11 @@ msgstr "" ">>> p._asdict()\n" "{'x': 11, 'y': 22}" -#: ../../library/collections.rst:960 +#: ../../library/collections.rst:961 msgid "Returns an :class:`OrderedDict` instead of a regular :class:`dict`." msgstr "回傳一個 :class:`OrderedDict` 而非 :class:`dict`。" -#: ../../library/collections.rst:963 +#: ../../library/collections.rst:964 msgid "" "Returns a regular :class:`dict` instead of an :class:`OrderedDict`. As of " "Python 3.7, regular dicts are guaranteed to be ordered. If the extra " @@ -1515,13 +1521,13 @@ msgstr "" "dict 已經保證有順序性,如果需要 :class:`OrderedDict` 所專屬的特性,推薦的解法" "是將結果專換成所需的類型:``OrderedDict(nt._asdict())``。" -#: ../../library/collections.rst:972 +#: ../../library/collections.rst:973 msgid "" "Return a new instance of the named tuple replacing specified fields with new " "values::" msgstr "回傳一個新的 named tuple 實例,並將指定欄位替換為新的值: ::" -#: ../../library/collections.rst:975 +#: ../../library/collections.rst:976 msgid "" ">>> p = Point(x=11, y=22)\n" ">>> p._replace(x=33)\n" @@ -1539,7 +1545,18 @@ msgstr "" "... inventory[partnum] = record._replace(price=newprices[partnum], " "timestamp=time.now())" -#: ../../library/collections.rst:984 +#: ../../library/collections.rst:983 +msgid "" +"Named tuples are also supported by generic function :func:`copy.replace`." +msgstr "" + +#: ../../library/collections.rst:985 +msgid "" +"Raise :exc:`TypeError` instead of :exc:`ValueError` for invalid keyword " +"arguments." +msgstr "" + +#: ../../library/collections.rst:991 msgid "" "Tuple of strings listing the field names. Useful for introspection and for " "creating new named tuple types from existing named tuples." @@ -1547,7 +1564,7 @@ msgstr "" "列出 tuple 欄位名稱的字串,用於自我檢查或是從現有 named tuple 建立一個新的 " "named tuple 型別。" -#: ../../library/collections.rst:987 +#: ../../library/collections.rst:994 msgid "" ">>> p._fields # view the field names\n" "('x', 'y')\n" @@ -1558,11 +1575,11 @@ msgid "" "Pixel(x=11, y=22, red=128, green=255, blue=0)" msgstr "" -#: ../../library/collections.rst:999 +#: ../../library/collections.rst:1006 msgid "Dictionary mapping field names to default values." msgstr "將欄位名稱對映至預設值的字典。" -#: ../../library/collections.rst:1001 +#: ../../library/collections.rst:1008 msgid "" ">>> Account = namedtuple('Account', ['type', 'balance'], defaults=[0])\n" ">>> Account._field_defaults\n" @@ -1576,13 +1593,13 @@ msgstr "" ">>> Account('premium')\n" "Account(type='premium', balance=0)" -#: ../../library/collections.rst:1009 +#: ../../library/collections.rst:1016 msgid "" -"To retrieve a field whose name is stored in a string, use the :func:" -"`getattr` function:" +"To retrieve a field whose name is stored in a string, use " +"the :func:`getattr` function:" msgstr "要取得這個名稱存於字串的欄位,要使用 :func:`getattr` 函式:" -#: ../../library/collections.rst:1015 +#: ../../library/collections.rst:1022 msgid "" "To convert a dictionary to a named tuple, use the double-star-operator (as " "described in :ref:`tut-unpacking-arguments`):" @@ -1590,7 +1607,7 @@ msgstr "" "(如\\ :ref:`tut-unpacking-arguments`\\ 所述)將一個字典轉換成 named tuple," "要使用 \\*\\* 雙星號運算子:" -#: ../../library/collections.rst:1022 +#: ../../library/collections.rst:1029 msgid "" "Since a named tuple is a regular Python class, it is easy to add or change " "functionality with a subclass. Here is how to add a calculated field and a " @@ -1599,7 +1616,7 @@ msgstr "" "因為一個 named tuple 是一個常規的 Python 類別,我們可以很容易的透過子類別來新" "增或更改功能,以下是如何新增一個計算得到的欄位和固定寬度的輸出列印格式:" -#: ../../library/collections.rst:1026 +#: ../../library/collections.rst:1033 msgid "" ">>> class Point(namedtuple('Point', ['x', 'y'])):\n" "... __slots__ = ()\n" @@ -1629,7 +1646,7 @@ msgstr "" "Point: x= 3.000 y= 4.000 hypot= 5.000\n" "Point: x=14.000 y= 0.714 hypot=14.018" -#: ../../library/collections.rst:1041 +#: ../../library/collections.rst:1048 msgid "" "The subclass shown above sets ``__slots__`` to an empty tuple. This helps " "keep memory requirements low by preventing the creation of instance " @@ -1638,26 +1655,26 @@ msgstr "" "上面的子類別將 ``__slots__`` 設定為空 tuple,這樣一來就防止了字典實例被建立," "因而保持了較低的記憶體用量。" -#: ../../library/collections.rst:1044 +#: ../../library/collections.rst:1051 msgid "" "Subclassing is not useful for adding new, stored fields. Instead, simply " "create a new named tuple type from the :attr:`~somenamedtuple._fields` " "attribute:" msgstr "" -"子類別化無法用於增加新的、已被儲存的欄位,應當透過 :attr:`~somenamedtuple." -"_fields` 屬性以建立一個新的 named tuple 來實現:" +"子類別化無法用於增加新的、已被儲存的欄位,應當透" +"過 :attr:`~somenamedtuple._fields` 屬性以建立一個新的 named tuple 來實現:" -#: ../../library/collections.rst:1049 +#: ../../library/collections.rst:1056 msgid "" "Docstrings can be customized by making direct assignments to the ``__doc__`` " "fields:" msgstr "透過直接賦值給 ``__doc__``,可以自訂說明文件字串:" -#: ../../library/collections.rst:1058 +#: ../../library/collections.rst:1065 msgid "Property docstrings became writeable." msgstr "文件字串屬性變成可寫入。" -#: ../../library/collections.rst:1063 +#: ../../library/collections.rst:1070 msgid "" "See :class:`typing.NamedTuple` for a way to add type hints for named " "tuples. It also provides an elegant notation using the :keyword:`class` " @@ -1666,7 +1683,7 @@ msgstr "" "關於為 named tuple 新增型別提示的方法,請參閱 :class:`typing.NamedTuple`,它" "運用 :keyword:`class` 關鍵字以提供了一個簡潔的表示法: ::" -#: ../../library/collections.rst:1067 +#: ../../library/collections.rst:1074 msgid "" "class Component(NamedTuple):\n" " part_number: int\n" @@ -1678,15 +1695,15 @@ msgstr "" " weight: float\n" " description: Optional[str] = None" -#: ../../library/collections.rst:1072 +#: ../../library/collections.rst:1079 msgid "" "See :meth:`types.SimpleNamespace` for a mutable namespace based on an " "underlying dictionary instead of a tuple." msgstr "" -"關於以 dict 而非 tuple 為底層的可變命名空間,請參考 :meth:`types." -"SimpleNamespace`。" +"關於以 dict 而非 tuple 為底層的可變命名空間,請參" +"考 :meth:`types.SimpleNamespace`。" -#: ../../library/collections.rst:1075 +#: ../../library/collections.rst:1082 msgid "" "The :mod:`dataclasses` module provides a decorator and functions for " "automatically adding generated special methods to user-defined classes." @@ -1694,11 +1711,11 @@ msgstr "" ":mod:`dataclasses` 模組提供了一個裝飾器和一些函式,用於自動將被生成的特殊方法" "新增到使用者定義的類別中。" -#: ../../library/collections.rst:1080 +#: ../../library/collections.rst:1087 msgid ":class:`OrderedDict` objects" msgstr ":class:`OrderedDict` 物件" -#: ../../library/collections.rst:1082 +#: ../../library/collections.rst:1089 msgid "" "Ordered dictionaries are just like regular dictionaries but have some extra " "capabilities relating to ordering operations. They have become less " @@ -1709,11 +1726,11 @@ msgstr "" "功能,但由於內建的 :class:`dict` 類別現在已經有記憶插入順序的能力(Python " "3.7 中確保了這種新行為),它們變得不那麼重要了。" -#: ../../library/collections.rst:1088 +#: ../../library/collections.rst:1095 msgid "Some differences from :class:`dict` still remain:" msgstr "仍存在一些與 :class:`dict` 的不同之處:" -#: ../../library/collections.rst:1090 +#: ../../library/collections.rst:1097 msgid "" "The regular :class:`dict` was designed to be very good at mapping " "operations. Tracking insertion order was secondary." @@ -1721,7 +1738,7 @@ msgstr "" "常規的 :class:`dict` 被設計成非常擅長於對映相關操作,追蹤插入的順序為次要目" "標。" -#: ../../library/collections.rst:1093 +#: ../../library/collections.rst:1100 msgid "" "The :class:`OrderedDict` was designed to be good at reordering operations. " "Space efficiency, iteration speed, and the performance of update operations " @@ -1730,7 +1747,7 @@ msgstr "" ":class:`OrderedDict` 則被設計成擅長於重新排序相關的操作,空間效率、疊代速度和" "更新操作的效能則為次要設計目標。" -#: ../../library/collections.rst:1097 +#: ../../library/collections.rst:1104 msgid "" "The :class:`OrderedDict` algorithm can handle frequent reordering operations " "better than :class:`dict`. As shown in the recipes below, this makes it " @@ -1739,12 +1756,12 @@ msgstr "" ":class:`OrderedDict` 比起 :class:`dict` 更適合處理頻繁的重新排序操作,如在下" "方用法中所示,這讓它適合用於多種 LRU cache 的實作中。" -#: ../../library/collections.rst:1101 +#: ../../library/collections.rst:1108 msgid "" "The equality operation for :class:`OrderedDict` checks for matching order." msgstr ":class:`OrderedDict` 之相等性運算會檢查順序是否相同。" -#: ../../library/collections.rst:1103 +#: ../../library/collections.rst:1110 msgid "" "A regular :class:`dict` can emulate the order sensitive equality test with " "``p == q and all(k1 == k2 for k1, k2 in zip(p, q))``." @@ -1752,23 +1769,24 @@ msgstr "" "一個一般的 :class:`dict` 可以用 ``p == q and all(k1 == k2 for k1, k2 in " "zip(p, q))`` 來效仿有檢查順序的相等性運算。" -#: ../../library/collections.rst:1106 +#: ../../library/collections.rst:1113 msgid "" -"The :meth:`popitem` method of :class:`OrderedDict` has a different " -"signature. It accepts an optional argument to specify which item is popped." +"The :meth:`~OrderedDict.popitem` method of :class:`OrderedDict` has a " +"different signature. It accepts an optional argument to specify which item " +"is popped." msgstr "" -":class:`OrderedDict` 類別的 :meth:`popitem` 方法有不同的函式簽名 " -"(signature),它接受傳入一個選擇性引數來指定要移除哪個元素。" +":class:`OrderedDict` 類別的 :meth:`~OrderedDict.popitem` 方法有不同的函式簽" +"名 (signature),它接受傳入一個選擇性引數來指定要移除哪個元素。" -#: ../../library/collections.rst:1109 +#: ../../library/collections.rst:1116 msgid "" "A regular :class:`dict` can emulate OrderedDict's ``od.popitem(last=True)`` " "with ``d.popitem()`` which is guaranteed to pop the rightmost (last) item." msgstr "" -"一個一般的 :class:`dict` 可以用 ``d.popitem()`` 來效仿 OrderedDict 的 ``od." -"popitem(last=True)``,這保證會移除最右邊(最後一個)的元素。" +"一個一般的 :class:`dict` 可以用 ``d.popitem()`` 來效仿 OrderedDict 的 " +"``od.popitem(last=True)``,這保證會移除最右邊(最後一個)的元素。" -#: ../../library/collections.rst:1112 +#: ../../library/collections.rst:1119 msgid "" "A regular :class:`dict` can emulate OrderedDict's ``od.popitem(last=False)`` " "with ``(k := next(iter(d)), d.pop(k))`` which will return and remove the " @@ -1778,15 +1796,15 @@ msgstr "" "OrderedDict 的 ``od.popitem(last=False)``,若最左邊(第一個)的元素存在,則將" "其回傳並移除。" -#: ../../library/collections.rst:1116 +#: ../../library/collections.rst:1123 msgid "" -":class:`OrderedDict` has a :meth:`move_to_end` method to efficiently " -"reposition an element to an endpoint." +":class:`OrderedDict` has a :meth:`~OrderedDict.move_to_end` method to " +"efficiently reposition an element to an endpoint." msgstr "" -":class:`OrderedDict` 有個 :meth:`move_to_end` 方法可有效率地將一個元素重新排" -"列到任一端。" +":class:`OrderedDict` 有個 :meth:`~OrderedDict.move_to_end` 方法可有效率地將一" +"個元素重新排列到任一端。" -#: ../../library/collections.rst:1119 +#: ../../library/collections.rst:1126 msgid "" "A regular :class:`dict` can emulate OrderedDict's ``od.move_to_end(k, " "last=True)`` with ``d[k] = d.pop(k)`` which will move the key and its " @@ -1796,7 +1814,7 @@ msgstr "" "``od.move_to_end(k, last=True)``,這會將該鍵與其對應到的值移動至最右(最後" "面)的位置。" -#: ../../library/collections.rst:1123 +#: ../../library/collections.rst:1130 msgid "" "A regular :class:`dict` does not have an efficient equivalent for " "OrderedDict's ``od.move_to_end(k, last=False)`` which moves the key and its " @@ -1806,18 +1824,20 @@ msgstr "" "last=False)`` 等價的有效方式,這是將鍵與其對應到的值移動至最左(最前面)位置" "的方法。" -#: ../../library/collections.rst:1127 -msgid "Until Python 3.8, :class:`dict` lacked a :meth:`__reversed__` method." -msgstr "在 Python 3.8 之前,:class:`dict` 並沒有 :meth:`__reversed__` 方法。" +#: ../../library/collections.rst:1134 +msgid "" +"Until Python 3.8, :class:`dict` lacked a :meth:`~object.__reversed__` method." +msgstr "" +"在 Python 3.8 之前,:class:`dict` 並沒有 :meth:`~object.__reversed__` 方法。" -#: ../../library/collections.rst:1132 +#: ../../library/collections.rst:1139 msgid "" "Return an instance of a :class:`dict` subclass that has methods specialized " "for rearranging dictionary order." msgstr "" "回傳一個 :class:`dict` 子類別的實例,它具有專門用於重新排列字典順序的方法。" -#: ../../library/collections.rst:1139 +#: ../../library/collections.rst:1146 msgid "" "The :meth:`popitem` method for ordered dictionaries returns and removes a " "(key, value) pair. The pairs are returned in :abbr:`LIFO (last-in, first-" @@ -1829,7 +1849,7 @@ msgstr "" "回傳鍵值對,否則就按 :abbr:`FIFO (first-in, first-out)` 先進先出的順序回傳鍵" "值對。" -#: ../../library/collections.rst:1146 +#: ../../library/collections.rst:1153 msgid "" "Move an existing *key* to either end of an ordered dictionary. The item is " "moved to the right end if *last* is true (the default) or to the beginning " @@ -1839,7 +1859,7 @@ msgstr "" "設值)則將元素移至右端;如果 *last* 為假值則將元素移至左端。如果 *key* 不存在" "則會引發 :exc:`KeyError`:" -#: ../../library/collections.rst:1151 +#: ../../library/collections.rst:1158 msgid "" ">>> d = OrderedDict.fromkeys('abcde')\n" ">>> d.move_to_end('b')\n" @@ -1857,7 +1877,7 @@ msgstr "" ">>> ''.join(d)\n" "'bacde'" -#: ../../library/collections.rst:1163 +#: ../../library/collections.rst:1170 msgid "" "In addition to the usual mapping methods, ordered dictionaries also support " "reverse iteration using :func:`reversed`." @@ -1865,41 +1885,47 @@ msgstr "" "除了普通的對映方法,ordered dictionary 還支援了透過 :func:`reversed` 來做倒序" "疊代。" -#: ../../library/collections.rst:1166 +#: ../../library/collections.rst:1175 msgid "" "Equality tests between :class:`OrderedDict` objects are order-sensitive and " -"are implemented as ``list(od1.items())==list(od2.items())``. Equality tests " -"between :class:`OrderedDict` objects and other :class:`~collections.abc." -"Mapping` objects are order-insensitive like regular dictionaries. This " -"allows :class:`OrderedDict` objects to be substituted anywhere a regular " -"dictionary is used." +"are roughly equivalent to ``list(od1.items())==list(od2.items())``." msgstr "" -":class:`OrderedDict` 物件之間的相等性運算是會檢查順序是否相同的,是透過 " -"``list(od1.items())==list(od2.items())`` 來實現。:class:`OrderedDict` 物件和" -"其他 :class:`~collections.abc.Mapping` 物件間的相等性運算則像普通字典一樣不考" -"慮順序性,這使得 :class:`OrderedDict` 可於任何字典可使用的時機中被替換掉。" +":class:`OrderedDict` 物件之間的相等性運算是會檢查順序是否相同的,大致等價於 " +"``list(od1.items())==list(od2.items())``。" -#: ../../library/collections.rst:1173 +#: ../../library/collections.rst:1178 msgid "" -"The items, keys, and values :term:`views ` of :class:" -"`OrderedDict` now support reverse iteration using :func:`reversed`." +"Equality tests between :class:`OrderedDict` objects and " +"other :class:`~collections.abc.Mapping` objects are order-insensitive like " +"regular dictionaries. This allows :class:`OrderedDict` objects to be " +"substituted anywhere a regular dictionary is used." +msgstr "" +":class:`OrderedDict` 物件和其他 :class:`~collections.abc.Mapping` 物件間的相" +"等性運算則像普通字典一樣不考慮順序性,這使得 :class:`OrderedDict` 可於任何字" +"典可使用的時機中被替換掉。" + +#: ../../library/collections.rst:1183 +msgid "" +"The items, keys, and values :term:`views ` " +"of :class:`OrderedDict` now support reverse iteration using :func:`reversed`." msgstr "" ":class:`OrderedDict` 的項 (item)、鍵與值之\\ :term:`視圖 `\\ 現在可透過 :func:`reversed` 來倒序疊代。" -#: ../../library/collections.rst:1177 +#: ../../library/collections.rst:1187 msgid "" "With the acceptance of :pep:`468`, order is retained for keyword arguments " -"passed to the :class:`OrderedDict` constructor and its :meth:`update` method." +"passed to the :class:`OrderedDict` constructor and its :meth:`~dict.update` " +"method." msgstr "" -"隨著 :pep:`468` 被核可,被傳入給 :class:`OrderedDict` 建構函式與其 :meth:" -"`update` 方法的關鍵字引數之順序被保留了下來。" +"隨著 :pep:`468` 被核可,被傳入給 :class:`OrderedDict` 建構函式與" +"其 :meth:`~dict.update` 方法的關鍵字引數之順序被保留了下來。" -#: ../../library/collections.rst:1187 +#: ../../library/collections.rst:1197 msgid ":class:`OrderedDict` Examples and Recipes" msgstr ":class:`OrderedDict` 範例與用法" -#: ../../library/collections.rst:1189 +#: ../../library/collections.rst:1199 msgid "" "It is straightforward to create an ordered dictionary variant that remembers " "the order the keys were *last* inserted. If a new entry overwrites an " @@ -1909,7 +1935,7 @@ msgstr "" "建立一個能夠記住鍵\\ *最後*\\ 插入順序的 ordered dictionary 變體很簡單。如果" "新條目覆蓋了現有條目,則原本插入位置會被更改並移動至末端: ::" -#: ../../library/collections.rst:1194 +#: ../../library/collections.rst:1204 msgid "" "class LastUpdatedOrderedDict(OrderedDict):\n" " 'Store items in the order the keys were last added'\n" @@ -1919,15 +1945,15 @@ msgid "" " self.move_to_end(key)" msgstr "" -#: ../../library/collections.rst:1201 +#: ../../library/collections.rst:1211 msgid "" -"An :class:`OrderedDict` would also be useful for implementing variants of :" -"func:`functools.lru_cache`:" +"An :class:`OrderedDict` would also be useful for implementing variants " +"of :func:`functools.lru_cache`:" msgstr "" ":class:`OrderedDict` 在實現一個 :func:`functools.lru_cache` 的變形版本時也非" "常有用:" -#: ../../library/collections.rst:1204 +#: ../../library/collections.rst:1214 msgid "" "from collections import OrderedDict\n" "from time import time\n" @@ -1950,11 +1976,11 @@ msgid "" " result = self.func(*args)\n" " self.cache[args] = time(), result\n" " if len(self.cache) > self.maxsize:\n" -" self.cache.popitem(0)\n" +" self.cache.popitem(last=False)\n" " return result" msgstr "" -#: ../../library/collections.rst:1231 +#: ../../library/collections.rst:1241 msgid "" "class MultiHitLRUCache:\n" " \"\"\" LRU cache that defers caching a result until\n" @@ -1983,59 +2009,60 @@ msgid "" " if self.requests[args] <= self.cache_after:\n" " self.requests.move_to_end(args)\n" " if len(self.requests) > self.maxrequests:\n" -" self.requests.popitem(0)\n" +" self.requests.popitem(last=False)\n" " else:\n" " self.requests.pop(args, None)\n" " self.cache[args] = result\n" " if len(self.cache) > self.maxsize:\n" -" self.cache.popitem(0)\n" +" self.cache.popitem(last=False)\n" " return result" msgstr "" -#: ../../library/collections.rst:1300 +#: ../../library/collections.rst:1310 msgid ":class:`UserDict` objects" msgstr ":class:`UserDict` 物件" -#: ../../library/collections.rst:1302 +#: ../../library/collections.rst:1312 msgid "" "The class, :class:`UserDict` acts as a wrapper around dictionary objects. " "The need for this class has been partially supplanted by the ability to " "subclass directly from :class:`dict`; however, this class can be easier to " "work with because the underlying dictionary is accessible as an attribute." msgstr "" -":class:`UserDict` 類別是作為 dict 物件的包裝器。因為已經可以直接自 :class:" -"`dict` 建立子類別,這個類別的需求已部分被滿足,不過這個類別使用起來更方便,因" -"為被包裝的字典可以作為其屬性來存取。" +":class:`UserDict` 類別是作為 dict 物件的包裝器。因為已經可以直接" +"自 :class:`dict` 建立子類別,這個類別的需求已部分被滿足,不過這個類別使用起來" +"更方便,因為被包裝的字典可以作為其屬性來存取。" -#: ../../library/collections.rst:1310 +#: ../../library/collections.rst:1320 msgid "" "Class that simulates a dictionary. The instance's contents are kept in a " -"regular dictionary, which is accessible via the :attr:`data` attribute of :" -"class:`UserDict` instances. If *initialdata* is provided, :attr:`data` is " -"initialized with its contents; note that a reference to *initialdata* will " -"not be kept, allowing it to be used for other purposes." +"regular dictionary, which is accessible via the :attr:`data` attribute " +"of :class:`UserDict` instances. If *initialdata* is provided, :attr:`data` " +"is initialized with its contents; note that a reference to *initialdata* " +"will not be kept, allowing it to be used for other purposes." msgstr "" -"模擬字典的類別。實例的內容被存於一個字典,可透過 :class:`UserDict` 的 :attr:" -"`data` 屬性來做存取。如果有提供 *initialdata*,:attr:`data` 屬性會被初始化為" -"其值;要注意指到 *initialdata* 的參照不會被保留,使其可被用於其他目的。" +"模擬字典的類別。實例的內容被存於一個字典,可透過 :class:`UserDict` " +"的 :attr:`data` 屬性來做存取。如果有提供 *initialdata*,:attr:`data` 屬性會被" +"初始化為其值;要注意指到 *initialdata* 的參照不會被保留,使其可被用於其他目" +"的。" -#: ../../library/collections.rst:1316 +#: ../../library/collections.rst:1326 msgid "" -"In addition to supporting the methods and operations of mappings, :class:" -"`UserDict` instances provide the following attribute:" +"In addition to supporting the methods and operations of " +"mappings, :class:`UserDict` instances provide the following attribute:" msgstr "" "除了支援作為對映所需的方法與操作,:class:`UserDict` 實例提供了以下屬性:" -#: ../../library/collections.rst:1321 +#: ../../library/collections.rst:1331 msgid "" "A real dictionary used to store the contents of the :class:`UserDict` class." msgstr "一個真實的字典,用於儲存 :class:`UserDict` 類別的資料內容。" -#: ../../library/collections.rst:1327 +#: ../../library/collections.rst:1337 msgid ":class:`UserList` objects" msgstr ":class:`UserList` 物件" -#: ../../library/collections.rst:1329 +#: ../../library/collections.rst:1339 msgid "" "This class acts as a wrapper around list objects. It is a useful base class " "for your own list-like classes which can inherit from them and override " @@ -2046,7 +2073,7 @@ msgstr "" "入新方法來定義你所需的一個類似於 list 的類別。如此一來,我們可以為 list 加入" "新的特性。" -#: ../../library/collections.rst:1334 +#: ../../library/collections.rst:1344 msgid "" "The need for this class has been partially supplanted by the ability to " "subclass directly from :class:`list`; however, this class can be easier to " @@ -2055,33 +2082,33 @@ msgstr "" "因為已經可以直接自 :class:`list` 建立子類別,這個類別的需求已部分被滿足,不過" "這個類別使用起來更方便,因為被包裝的 list 可以作為其屬性來存取。" -#: ../../library/collections.rst:1340 +#: ../../library/collections.rst:1350 msgid "" "Class that simulates a list. The instance's contents are kept in a regular " -"list, which is accessible via the :attr:`data` attribute of :class:" -"`UserList` instances. The instance's contents are initially set to a copy " -"of *list*, defaulting to the empty list ``[]``. *list* can be any iterable, " -"for example a real Python list or a :class:`UserList` object." -msgstr "" -"模擬 list 的類別。實例的內容被存於一個 list,可透過 :class:`UserList` 的 :" -"attr:`data` 屬性來做存取。實例內容被初始化為 *list* 的複製,預設為一個空的 " -"list ``[]``。*list* 可以是任何 iterable,例如一個真實的 Python list 或是一" +"list, which is accessible via the :attr:`data` attribute " +"of :class:`UserList` instances. The instance's contents are initially set " +"to a copy of *list*, defaulting to the empty list ``[]``. *list* can be any " +"iterable, for example a real Python list or a :class:`UserList` object." +msgstr "" +"模擬 list 的類別。實例的內容被存於一個 list,可透過 :class:`UserList` " +"的 :attr:`data` 屬性來做存取。實例內容被初始化為 *list* 的複製,預設為一個空" +"的 list ``[]``。*list* 可以是任何 iterable,例如一個真實的 Python list 或是一" "個 :class:`UserList` 物件。" -#: ../../library/collections.rst:1346 +#: ../../library/collections.rst:1356 msgid "" -"In addition to supporting the methods and operations of mutable sequences, :" -"class:`UserList` instances provide the following attribute:" +"In addition to supporting the methods and operations of mutable " +"sequences, :class:`UserList` instances provide the following attribute:" msgstr "除了支援可變序列的方法與操作,:class:`UserList` 實例提供了以下屬性:" -#: ../../library/collections.rst:1351 +#: ../../library/collections.rst:1361 msgid "" -"A real :class:`list` object used to store the contents of the :class:" -"`UserList` class." +"A real :class:`list` object used to store the contents of " +"the :class:`UserList` class." msgstr "" "一個真實的 :class:`list` 物件,用於儲存 :class:`UserList` 類別的資料內容。" -#: ../../library/collections.rst:1354 +#: ../../library/collections.rst:1364 msgid "" "**Subclassing requirements:** Subclasses of :class:`UserList` are expected " "to offer a constructor which can be called with either no arguments or one " @@ -2095,7 +2122,7 @@ msgstr "" "例,為了達成上述目的,它假設建構函式可傳入單一參數來呼叫,該參數即是做為數據" "來源的一個序列物件。" -#: ../../library/collections.rst:1361 +#: ../../library/collections.rst:1371 msgid "" "If a derived class does not wish to comply with this requirement, all of the " "special methods supported by this class will need to be overridden; please " @@ -2105,11 +2132,11 @@ msgstr "" "如果希望一個自此獲得的子類別不遵從上述要求,那所有該類別支援的特殊方法則必須" "被覆寫;請參考原始碼來理解在這情況下哪些方法是必須提供的。" -#: ../../library/collections.rst:1367 +#: ../../library/collections.rst:1377 msgid ":class:`UserString` objects" msgstr ":class:`UserString` 物件" -#: ../../library/collections.rst:1369 +#: ../../library/collections.rst:1379 msgid "" "The class, :class:`UserString` acts as a wrapper around string objects. The " "need for this class has been partially supplanted by the ability to subclass " @@ -2120,7 +2147,7 @@ msgstr "" "建立子類別,這個類別的需求已經部分被滿足,不過這個類別使用起來更方便,因為被" "包裝的字串可以作為其屬性來存取。" -#: ../../library/collections.rst:1377 +#: ../../library/collections.rst:1387 msgid "" "Class that simulates a string object. The instance's content is kept in a " "regular string object, which is accessible via the :attr:`data` attribute " @@ -2132,21 +2159,21 @@ msgstr "" "的 :attr:`data` 屬性來做存取。實例內容被初始化為 *seq* 的複製,*seq* 引數可以" "是任何可被內建函式 :func:`str` 轉換成字串的物件。" -#: ../../library/collections.rst:1384 +#: ../../library/collections.rst:1394 msgid "" -"In addition to supporting the methods and operations of strings, :class:" -"`UserString` instances provide the following attribute:" +"In addition to supporting the methods and operations of " +"strings, :class:`UserString` instances provide the following attribute:" msgstr "" "除了支援字串的方法和操作以外,:class:`UserString` 實例也提供了以下屬性:" -#: ../../library/collections.rst:1389 +#: ../../library/collections.rst:1399 msgid "" -"A real :class:`str` object used to store the contents of the :class:" -"`UserString` class." +"A real :class:`str` object used to store the contents of " +"the :class:`UserString` class." msgstr "" "一個真實的 :class:`str` 物件,用來儲存 :class:`UserString` 類別的資料內容。" -#: ../../library/collections.rst:1392 +#: ../../library/collections.rst:1402 msgid "" "New methods ``__getnewargs__``, ``__rmod__``, ``casefold``, ``format_map``, " "``isprintable``, and ``maketrans``." diff --git a/library/colorsys.po b/library/colorsys.po index 2cc404f6b8..3bf0334312 100644 --- a/library/colorsys.po +++ b/library/colorsys.po @@ -6,7 +6,7 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2022-02-15 20:58+0800\n" diff --git a/library/compileall.po b/library/compileall.po index c21e67b18b..645f85c5df 100644 --- a/library/compileall.po +++ b/library/compileall.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 14:41+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -36,17 +36,16 @@ msgid "" msgstr "" #: ../../includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not Emscripten, not WASI." -msgstr "" +msgid "Availability" +msgstr "可用性" #: ../../includes/wasm-notavail.rst:5 msgid "" -"This module does not work or is not available on WebAssembly platforms " -"``wasm32-emscripten`` and ``wasm32-wasi``. See :ref:`wasm-availability` for " -"more information." +"This module does not work or is not available on WebAssembly. See :ref:`wasm-" +"availability` for more information." msgstr "" -"此模組在 WebAssembly 平台 ``wasm32-emscripten`` 和 ``wasm32-wasi`` 上無法作用" -"或無法使用。有關更多資訊,請參閱 :ref:`wasm-availability`。" +"此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" +"availability`。" #: ../../library/compileall.rst:22 msgid "Command-line use" @@ -90,26 +89,40 @@ msgid "" "executed." msgstr "" -#: ../../library/compileall.rst:61 +#: ../../library/compileall.rst:60 msgid "" -"Remove (``-s``) or append (``-p``) the given prefix of paths recorded in the " -"``.pyc`` files. Cannot be combined with ``-d``." +"Remove the given prefix from paths recorded in the ``.pyc`` files. Paths are " +"made relative to the prefix." +msgstr "" + +#: ../../library/compileall.rst:63 +msgid "This option can be used with ``-p`` but not with ``-d``." msgstr "" #: ../../library/compileall.rst:67 msgid "" +"Prepend the given prefix to paths recorded in the ``.pyc`` files. Use ``-p /" +"`` to make the paths absolute." +msgstr "" + +#: ../../library/compileall.rst:70 +msgid "This option can be used with ``-s`` but not with ``-d``." +msgstr "" + +#: ../../library/compileall.rst:74 +msgid "" "regex is used to search the full path to each file considered for " "compilation, and if the regex produces a match, the file is skipped." msgstr "" -#: ../../library/compileall.rst:72 +#: ../../library/compileall.rst:79 msgid "" "Read the file ``list`` and add each line that it contains to the list of " "files and directories to compile. If ``list`` is ``-``, read lines from " "``stdin``." msgstr "" -#: ../../library/compileall.rst:78 +#: ../../library/compileall.rst:85 msgid "" "Write the byte-code files to their legacy locations and names, which may " "overwrite byte-code files created by another version of Python. The default " @@ -117,7 +130,7 @@ msgid "" "byte-code files from multiple versions of Python to coexist." msgstr "" -#: ../../library/compileall.rst:85 +#: ../../library/compileall.rst:92 msgid "" "Control the maximum recursion level for subdirectories. If this is given, " "then ``-l`` option will not be taken into account. :program:`python -m " @@ -125,13 +138,13 @@ msgid "" " -l`." msgstr "" -#: ../../library/compileall.rst:92 +#: ../../library/compileall.rst:99 msgid "" "Use *N* workers to compile the files within the given directory. If ``0`` is " -"used, then the result of :func:`os.cpu_count` will be used." +"used, then the result of :func:`os.process_cpu_count` will be used." msgstr "" -#: ../../library/compileall.rst:98 +#: ../../library/compileall.rst:105 msgid "" "Control how the generated byte-code files are invalidated at runtime. The " "``timestamp`` value, means that ``.pyc`` files with the source timestamp and " @@ -144,53 +157,53 @@ msgid "" "the ``SOURCE_DATE_EPOCH`` environment variable is set." msgstr "" -#: ../../library/compileall.rst:111 +#: ../../library/compileall.rst:118 msgid "" "Compile with the given optimization level. May be used multiple times to " "compile for multiple levels at a time (for example, ``compileall -o 1 -o " "2``)." msgstr "" -#: ../../library/compileall.rst:117 +#: ../../library/compileall.rst:124 msgid "Ignore symlinks pointing outside the given directory." msgstr "" -#: ../../library/compileall.rst:121 +#: ../../library/compileall.rst:128 msgid "" "If two ``.pyc`` files with different optimization level have the same " "content, use hard links to consolidate duplicate files." msgstr "" -#: ../../library/compileall.rst:124 +#: ../../library/compileall.rst:131 msgid "Added the ``-i``, ``-b`` and ``-h`` options." msgstr "新增選項 ``-i``、``-b`` 與 ``-h``。" -#: ../../library/compileall.rst:127 +#: ../../library/compileall.rst:134 msgid "" "Added the ``-j``, ``-r``, and ``-qq`` options. ``-q`` option was changed " "to a multilevel value. ``-b`` will always produce a byte-code file ending " "in ``.pyc``, never ``.pyo``." msgstr "" -#: ../../library/compileall.rst:132 +#: ../../library/compileall.rst:139 msgid "Added the ``--invalidation-mode`` option." msgstr "新增選項 ``--invalidation-mode``。" -#: ../../library/compileall.rst:135 +#: ../../library/compileall.rst:142 msgid "" "Added the ``-s``, ``-p``, ``-e`` and ``--hardlink-dupes`` options. Raised " "the default recursion limit from 10 to :py:func:`sys.getrecursionlimit()`. " "Added the possibility to specify the ``-o`` option multiple times." msgstr "" -#: ../../library/compileall.rst:142 +#: ../../library/compileall.rst:149 msgid "" "There is no command-line option to control the optimization level used by " "the :func:`compile` function, because the Python interpreter itself already " "provides the option: :program:`python -O -m compileall`." msgstr "" -#: ../../library/compileall.rst:146 +#: ../../library/compileall.rst:153 msgid "" "Similarly, the :func:`compile` function respects the :data:`sys." "pycache_prefix` setting. The generated bytecode cache will only be useful " @@ -198,24 +211,24 @@ msgid "" "that will be used at runtime." msgstr "" -#: ../../library/compileall.rst:152 +#: ../../library/compileall.rst:159 msgid "Public functions" msgstr "" -#: ../../library/compileall.rst:156 +#: ../../library/compileall.rst:163 msgid "" "Recursively descend the directory tree named by *dir*, compiling all :file:`." "py` files along the way. Return a true value if all the files compiled " "successfully, and a false value otherwise." msgstr "" -#: ../../library/compileall.rst:160 +#: ../../library/compileall.rst:167 msgid "" "The *maxlevels* parameter is used to limit the depth of the recursion; it " "defaults to ``sys.getrecursionlimit()``." msgstr "" -#: ../../library/compileall.rst:163 +#: ../../library/compileall.rst:170 msgid "" "If *ddir* is given, it is prepended to the path to each file being compiled " "for use in compilation time tracebacks, and is also compiled in to the byte-" @@ -224,13 +237,13 @@ msgid "" "executed." msgstr "" -#: ../../library/compileall.rst:169 +#: ../../library/compileall.rst:176 msgid "" "If *force* is true, modules are re-compiled even if the timestamps are up to " "date." msgstr "" -#: ../../library/compileall.rst:172 +#: ../../library/compileall.rst:179 msgid "" "If *rx* is given, its ``search`` method is called on the complete path to " "each file considered for compilation, and if it returns a true value, the " @@ -238,14 +251,14 @@ msgid "" "expression, given as a :ref:`re.Pattern ` object." msgstr "" -#: ../../library/compileall.rst:177 ../../library/compileall.rst:254 +#: ../../library/compileall.rst:184 ../../library/compileall.rst:261 msgid "" "If *quiet* is ``False`` or ``0`` (the default), the filenames and other " "information are printed to standard out. Set to ``1``, only errors are " "printed. Set to ``2``, all output is suppressed." msgstr "" -#: ../../library/compileall.rst:181 ../../library/compileall.rst:258 +#: ../../library/compileall.rst:188 ../../library/compileall.rst:265 msgid "" "If *legacy* is true, byte-code files are written to their legacy locations " "and names, which may overwrite byte-code files created by another version of " @@ -254,7 +267,7 @@ msgid "" "coexist." msgstr "" -#: ../../library/compileall.rst:187 ../../library/compileall.rst:264 +#: ../../library/compileall.rst:194 ../../library/compileall.rst:271 msgid "" "*optimize* specifies the optimization level for the compiler. It is passed " "to the built-in :func:`compile` function. Accepts also a sequence of " @@ -262,7 +275,7 @@ msgid "" "file in one call." msgstr "" -#: ../../library/compileall.rst:191 +#: ../../library/compileall.rst:198 msgid "" "The argument *workers* specifies how many workers are used to compile files " "in parallel. The default is to not use multiple workers. If the platform " @@ -272,80 +285,80 @@ msgid "" "`ValueError` will be raised." msgstr "" -#: ../../library/compileall.rst:198 ../../library/compileall.rst:268 +#: ../../library/compileall.rst:205 ../../library/compileall.rst:275 msgid "" "*invalidation_mode* should be a member of the :class:`py_compile." "PycInvalidationMode` enum and controls how the generated pycs are " "invalidated at runtime." msgstr "" -#: ../../library/compileall.rst:202 ../../library/compileall.rst:272 +#: ../../library/compileall.rst:209 ../../library/compileall.rst:279 msgid "" "The *stripdir*, *prependdir* and *limit_sl_dest* arguments correspond to the " "``-s``, ``-p`` and ``-e`` options described above. They may be specified as " "``str`` or :py:class:`os.PathLike`." msgstr "" -#: ../../library/compileall.rst:206 ../../library/compileall.rst:276 +#: ../../library/compileall.rst:213 ../../library/compileall.rst:283 msgid "" "If *hardlink_dupes* is true and two ``.pyc`` files with different " "optimization level have the same content, use hard links to consolidate " "duplicate files." msgstr "" -#: ../../library/compileall.rst:209 ../../library/compileall.rst:307 +#: ../../library/compileall.rst:216 ../../library/compileall.rst:314 msgid "Added the *legacy* and *optimize* parameter." msgstr "新增 *legacy* 與 *optimize* 參數。" -#: ../../library/compileall.rst:212 +#: ../../library/compileall.rst:219 msgid "Added the *workers* parameter." msgstr "新增 *workers* 參數。" -#: ../../library/compileall.rst:215 ../../library/compileall.rst:281 -#: ../../library/compileall.rst:310 +#: ../../library/compileall.rst:222 ../../library/compileall.rst:288 +#: ../../library/compileall.rst:317 msgid "*quiet* parameter was changed to a multilevel value." msgstr "" -#: ../../library/compileall.rst:218 ../../library/compileall.rst:284 -#: ../../library/compileall.rst:313 +#: ../../library/compileall.rst:225 ../../library/compileall.rst:291 +#: ../../library/compileall.rst:320 msgid "" "The *legacy* parameter only writes out ``.pyc`` files, not ``.pyo`` files no " "matter what the value of *optimize* is." msgstr "" -#: ../../library/compileall.rst:222 +#: ../../library/compileall.rst:229 msgid "Accepts a :term:`path-like object`." msgstr "" -#: ../../library/compileall.rst:225 ../../library/compileall.rst:288 -#: ../../library/compileall.rst:317 +#: ../../library/compileall.rst:232 ../../library/compileall.rst:295 +#: ../../library/compileall.rst:324 msgid "The *invalidation_mode* parameter was added." msgstr "新增 *invalidation_mode* 參數。" -#: ../../library/compileall.rst:228 ../../library/compileall.rst:291 -#: ../../library/compileall.rst:320 +#: ../../library/compileall.rst:235 ../../library/compileall.rst:298 +#: ../../library/compileall.rst:327 msgid "" "The *invalidation_mode* parameter's default value is updated to ``None``." msgstr "新增 *invalidation_mode* 參數的預設值被更新為 ``None``。" -#: ../../library/compileall.rst:231 +#: ../../library/compileall.rst:238 msgid "Setting *workers* to 0 now chooses the optimal number of cores." msgstr "" -#: ../../library/compileall.rst:234 +#: ../../library/compileall.rst:241 msgid "" "Added *stripdir*, *prependdir*, *limit_sl_dest* and *hardlink_dupes* " "arguments. Default value of *maxlevels* was changed from ``10`` to ``sys." "getrecursionlimit()``" msgstr "" -#: ../../library/compileall.rst:240 +#: ../../library/compileall.rst:247 msgid "" "Compile the file with path *fullname*. Return a true value if the file " "compiled successfully, and a false value otherwise." msgstr "" -#: ../../library/compileall.rst:243 +#: ../../library/compileall.rst:250 msgid "" "If *ddir* is given, it is prepended to the path to the file being compiled " "for use in compilation time tracebacks, and is also compiled in to the byte-" @@ -354,7 +367,7 @@ msgid "" "executed." msgstr "" -#: ../../library/compileall.rst:249 +#: ../../library/compileall.rst:256 msgid "" "If *rx* is given, its ``search`` method is passed the full path name to the " "file being compiled, and if it returns a true value, the file is not " @@ -363,20 +376,20 @@ msgid "" "object." msgstr "" -#: ../../library/compileall.rst:294 +#: ../../library/compileall.rst:301 msgid "" "Added *stripdir*, *prependdir*, *limit_sl_dest* and *hardlink_dupes* " "arguments." msgstr "" -#: ../../library/compileall.rst:299 +#: ../../library/compileall.rst:306 msgid "" "Byte-compile all the :file:`.py` files found along ``sys.path``. Return a " "true value if all the files compiled successfully, and a false value " "otherwise." msgstr "" -#: ../../library/compileall.rst:302 +#: ../../library/compileall.rst:309 msgid "" "If *skip_curdir* is true (the default), the current directory is not " "included in the search. All other parameters are passed to the :func:" @@ -384,13 +397,13 @@ msgid "" "``maxlevels`` defaults to ``0``." msgstr "" -#: ../../library/compileall.rst:323 +#: ../../library/compileall.rst:330 msgid "" "To force a recompile of all the :file:`.py` files in the :file:`Lib/` " "subdirectory and all its subdirectories::" msgstr "" -#: ../../library/compileall.rst:326 +#: ../../library/compileall.rst:333 msgid "" "import compileall\n" "\n" @@ -405,10 +418,10 @@ msgid "" "compileall.compile_dir(pathlib.Path('Lib/'), force=True)" msgstr "" -#: ../../library/compileall.rst:340 +#: ../../library/compileall.rst:347 msgid "Module :mod:`py_compile`" msgstr ":mod:`py_compile` 模組" -#: ../../library/compileall.rst:341 +#: ../../library/compileall.rst:348 msgid "Byte-compile a single source file." msgstr "" diff --git a/library/concurrency.po b/library/concurrency.po index 51f96db2f4..fc7278d186 100644 --- a/library/concurrency.po +++ b/library/concurrency.po @@ -6,7 +6,7 @@ # Matt Wang , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-09-13 00:11+0000\n" "PO-Revision-Date: 2021-11-23 13:36+0800\n" diff --git a/library/concurrent.futures.po b/library/concurrent.futures.po index d9a8e7b4a3..37d9b928e7 100644 --- a/library/concurrent.futures.po +++ b/library/concurrent.futures.po @@ -5,9 +5,9 @@ # Matt Wang , 2023-2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-07-28 00:20+0000\n" "PO-Revision-Date: 2023-01-24 03:33+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -51,17 +51,16 @@ msgstr "" "相同的介面,該介面由抽象的 :class:`Executor` 類別定義。" #: ../../includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not Emscripten, not WASI." -msgstr ":ref:`適用 `:非 Emscripten、非 WASI。" +msgid "Availability" +msgstr "可用性" #: ../../includes/wasm-notavail.rst:5 msgid "" -"This module does not work or is not available on WebAssembly platforms " -"``wasm32-emscripten`` and ``wasm32-wasi``. See :ref:`wasm-availability` for " -"more information." +"This module does not work or is not available on WebAssembly. See :ref:`wasm-" +"availability` for more information." msgstr "" -"此模組在 WebAssembly 平台 ``wasm32-emscripten`` 和 ``wasm32-wasi`` 上沒有作用" -"或不可使用。更多資訊,請參閱 :ref:`wasm-availability`。" +"此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" +"availability`。" #: ../../library/concurrent.futures.rst:25 msgid "Executor Objects" @@ -82,9 +81,7 @@ msgid "" "callable. ::" msgstr "" "為可呼叫物件 *fn* 排程來以 ``fn(*args, **kwargs)`` 的形式執行並回傳一個表示可" -"呼叫的執行的 :class:`Future` 物件。\n" -"\n" -"::" +"呼叫的執行的 :class:`Future` 物件。 ::" #: ../../library/concurrent.futures.rst:38 msgid "" @@ -155,7 +152,7 @@ msgid "" "submit` and :meth:`Executor.map` made after shutdown will raise :exc:" "`RuntimeError`." msgstr "" -"向 executor 發出訊號 (signal),表明它應該在當前未定 (pending) 的 future 完成" +"向 executor 發出訊號 (signal),表明它應該在目前未定 (pending) 的 future 完成" "執行時釋放它正在使用的任何資源。在關閉後呼叫 :meth:`Executor.submit` 和 :" "meth:`Executor.map` 將引發 :exc:`RuntimeError`。" @@ -262,6 +259,21 @@ msgid "" "a = executor.submit(wait_on_b)\n" "b = executor.submit(wait_on_a)" msgstr "" +"import time\n" +"def wait_on_b():\n" +" time.sleep(5)\n" +" print(b.result()) # b 永遠不會完成,因為它正在等待 a。\n" +" return 5\n" +"\n" +"def wait_on_a():\n" +" time.sleep(5)\n" +" print(a.result()) # a 永遠不會完成,因為它正在等待 b。\n" +" return 6\n" +"\n" +"\n" +"executor = ThreadPoolExecutor(max_workers=2)\n" +"a = executor.submit(wait_on_b)\n" +"b = executor.submit(wait_on_a)" #: ../../library/concurrent.futures.rst:136 msgid "And::" @@ -278,6 +290,14 @@ msgid "" "executor = ThreadPoolExecutor(max_workers=1)\n" "executor.submit(wait_on_future)" msgstr "" +"def wait_on_future():\n" +" f = executor.submit(pow, 5, 2)\n" +" # 這將永遠不會完成,因為只有一個工作執行緒且\n" +" # 它正在執行這個函式。\n" +" print(f.result())\n" +"\n" +"executor = ThreadPoolExecutor(max_workers=1)\n" +"executor.submit(wait_on_future)" #: ../../library/concurrent.futures.rst:150 msgid "" @@ -312,7 +332,7 @@ msgid "" msgstr "" "*initializer* 是一個可選的可呼叫物件,在每個工作執行緒開始時呼叫; " "*initargs* 是傳遞給 initializer 的引數元組 (tuple)。如果 *initializer* 引發例" -"外,所有當前未定的作業以及任何向池中提交 (submit) 更多作業的嘗試都將引發 :" +"外,所有目前未定的作業以及任何向池中提交 (submit) 更多作業的嘗試都將引發 :" "exc:`~concurrent.futures.thread.BrokenThreadPool`。" #: ../../library/concurrent.futures.rst:166 @@ -338,7 +358,7 @@ msgstr "" "thread) 的 :class:`threading.Thread` 名稱,以便於除錯。" #: ../../library/concurrent.futures.rst:179 -#: ../../library/concurrent.futures.rst:283 +#: ../../library/concurrent.futures.rst:292 msgid "Added the *initializer* and *initargs* arguments." msgstr "新增 *initializer* 與 *initargs* 引數。" @@ -361,11 +381,18 @@ msgstr "" "ThreadPoolExecutor 現在在啟動 *max_workers* 工作執行緒之前會重用 (reuse) 空閒" "的工作執行緒。" -#: ../../library/concurrent.futures.rst:195 +#: ../../library/concurrent.futures.rst:191 +msgid "" +"Default value of *max_workers* is changed to ``min(32, (os." +"process_cpu_count() or 1) + 4)``." +msgstr "" +"*max_workers* 的預設值被改為 ``min(32, (os.process_cpu_count() or 1) + 4)``。" + +#: ../../library/concurrent.futures.rst:199 msgid "ThreadPoolExecutor Example" msgstr "ThreadPoolExecutor 範例" -#: ../../library/concurrent.futures.rst:198 +#: ../../library/concurrent.futures.rst:202 msgid "" "import concurrent.futures\n" "import urllib.request\n" @@ -374,7 +401,7 @@ msgid "" " 'http://www.cnn.com/',\n" " 'http://europe.wsj.com/',\n" " 'http://www.bbc.co.uk/',\n" -" 'http://nonexistant-subdomain.python.org/']\n" +" 'http://nonexistent-subdomain.python.org/']\n" "\n" "# Retrieve a single page and report the URL and contents\n" "def load_url(url, timeout):\n" @@ -396,11 +423,11 @@ msgid "" " print('%r page is %d bytes' % (url, len(data)))" msgstr "" -#: ../../library/concurrent.futures.rst:227 +#: ../../library/concurrent.futures.rst:231 msgid "ProcessPoolExecutor" msgstr "ProcessPoolExecutor" -#: ../../library/concurrent.futures.rst:229 +#: ../../library/concurrent.futures.rst:233 msgid "" "The :class:`ProcessPoolExecutor` class is an :class:`Executor` subclass that " "uses a pool of processes to execute calls asynchronously. :class:" @@ -415,7 +442,7 @@ msgstr "" "Interpreter Lock) `,但也意味著只能執行和回傳可被 " "pickle 的 (picklable) 物件。" -#: ../../library/concurrent.futures.rst:236 +#: ../../library/concurrent.futures.rst:240 msgid "" "The ``__main__`` module must be importable by worker subprocesses. This " "means that :class:`ProcessPoolExecutor` will not work in the interactive " @@ -425,7 +452,7 @@ msgstr "" "class:`ProcessPoolExecutor` 將無法在交互式直譯器 (interactive interpreter) 中" "工作。" -#: ../../library/concurrent.futures.rst:239 +#: ../../library/concurrent.futures.rst:243 msgid "" "Calling :class:`Executor` or :class:`Future` methods from a callable " "submitted to a :class:`ProcessPoolExecutor` will result in deadlock." @@ -433,31 +460,39 @@ msgstr "" "從提交給 :class:`ProcessPoolExecutor` 的可呼叫物件中呼叫 :class:`Executor` " "或 :class:`Future` 方法將導致死鎖。" -#: ../../library/concurrent.futures.rst:244 +#: ../../library/concurrent.futures.rst:246 +msgid "" +"Note that the restrictions on functions and arguments needing to picklable " +"as per :class:`multiprocessing.Process` apply when using :meth:`~Executor." +"submit` and :meth:`~Executor.map` on a :class:`ProcessPoolExecutor`. A " +"function defined in a REPL or a lambda should not be expected to work." +msgstr "" + +#: ../../library/concurrent.futures.rst:253 msgid "" "An :class:`Executor` 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 the number of processors on the machine. If " -"*max_workers* is less than or equal to ``0``, then a :exc:`ValueError` will " -"be raised. On Windows, *max_workers* must be less than or equal to ``61``. " -"If it is not then :exc:`ValueError` 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 :mod:`multiprocessing` " -"context or ``None``. It will be used to launch the workers. If *mp_context* " -"is ``None`` or not given, the default :mod:`multiprocessing` context is " -"used. See :ref:`multiprocessing-start-methods`." +"not given, it will default to :func:`os.process_cpu_count`. If *max_workers* " +"is less than or equal to ``0``, then a :exc:`ValueError` will be raised. On " +"Windows, *max_workers* must be less than or equal to ``61``. If it is not " +"then :exc:`ValueError` 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 :mod:`multiprocessing` context or ``None``. " +"It will be used to launch the workers. If *mp_context* is ``None`` or not " +"given, the default :mod:`multiprocessing` context is used. See :ref:" +"`multiprocessing-start-methods`." msgstr "" "一個 :class:`Executor` 子類別,它使用了最多有 *max_workers* 個行程的池來非同" -"步地執行呼叫。如果 *max_workers* 為 ``None`` 或未給定,它將被預設為機器上的處" -"理器數量。如果 *max_workers* 小於或等於 ``0``,則會引發 :exc:`ValueError`。" -"在 Windows 上,*max_workers* 必須小於或等於 ``61``。如果不是,則會引發 :exc:" -"`ValueError`。如果 *max_workers* 為 ``None``,則預設選擇最多為 ``61``,即便有" -"更多處理器可用。*mp_context* 可以是 :mod:`multiprocessing` 情境 (context) 或 " -"``None``。它將用於啟動 worker。如果 *mp_context* 為 ``None`` 或未給定,則使用" -"預設的 :mod:`multiprocessing` 情境。請見 :ref:`multiprocessing-start-" -"methods`。" +"步地執行呼叫。如果 *max_workers* 為 ``None`` 或未給定,它將被預設為 :func:" +"`os.process_cpu_count`。如果 *max_workers* 小於或等於 ``0``,則會引發 :exc:" +"`ValueError`。在 Windows 上,*max_workers* 必須小於或等於 ``61``。如果不是," +"則會引發 :exc:`ValueError`。如果 *max_workers* 為 ``None``,則預設選擇最多為 " +"``61``,即便有更多處理器可用。*mp_context* 可以是 :mod:`multiprocessing` 情" +"境 (context) 或 ``None``。它將用於啟動 worker。如果 *mp_context* 為 ``None`` " +"或未給定,則使用預設的 :mod:`multiprocessing` 情境。請見 :ref:" +"`multiprocessing-start-methods`。" -#: ../../library/concurrent.futures.rst:258 +#: ../../library/concurrent.futures.rst:267 msgid "" "*initializer* is an optional callable that is called at the start of each " "worker process; *initargs* is a tuple of arguments passed to the " @@ -467,10 +502,10 @@ msgid "" msgstr "" "*initializer* 是一個可選的可呼叫物件,在每個工作行程 (worker process) 開始時" "呼叫;*initargs* 是傳遞給 initializer 的引數元組。如果 *initializer* 引發例" -"外,所有當前未定的作業以及任何向池中提交更多作業的嘗試都將引發 :exc:" +"外,所有目前未定的作業以及任何向池中提交更多作業的嘗試都將引發 :exc:" "`~concurrent.futures.process.BrokenProcessPool`。" -#: ../../library/concurrent.futures.rst:264 +#: ../../library/concurrent.futures.rst:273 msgid "" "*max_tasks_per_child* is an optional argument that specifies the maximum " "number of tasks a single process can execute before it will exit and be " @@ -486,7 +521,7 @@ msgstr "" "數的情況下,將預設使用 \"spawn\" 做為 multiprocessing 啟動方法。此功能與 " "\"fork\" 啟動方法不相容。" -#: ../../library/concurrent.futures.rst:272 +#: ../../library/concurrent.futures.rst:281 msgid "" "When one of the worker processes terminates abruptly, a :exc:`~concurrent." "futures.process.BrokenProcessPool` error is now raised. Previously, " @@ -497,14 +532,14 @@ msgstr "" "BrokenProcessPool` 錯誤。在過去,此行為是未定義的 (undefined),但對 executor " "或其 future 的操作經常會發生凍結或死鎖。" -#: ../../library/concurrent.futures.rst:279 +#: ../../library/concurrent.futures.rst:288 msgid "" "The *mp_context* argument was added to allow users to control the " "start_method for worker processes created by the pool." msgstr "" "新增了 *mp_context* 引數以允許使用者控制由池所建立的工作行程的 start_method。" -#: ../../library/concurrent.futures.rst:286 +#: ../../library/concurrent.futures.rst:295 msgid "" "The default :mod:`multiprocessing` start method (see :ref:`multiprocessing-" "start-methods`) will change away from *fork* in Python 3.14. Code that " @@ -517,14 +552,14 @@ msgstr "" "`ProcessPoolExecutor` 的程式碼應透過傳遞 ``mp_context=multiprocessing." "get_context(\"fork\")`` 參數來明確指定。" -#: ../../library/concurrent.futures.rst:293 +#: ../../library/concurrent.futures.rst:302 msgid "" "The *max_tasks_per_child* argument was added to allow users to control the " "lifetime of workers in the pool." msgstr "" "新增了 *max_tasks_per_child* 引數以允許使用者控制池中 worker 的生命週期。" -#: ../../library/concurrent.futures.rst:297 +#: ../../library/concurrent.futures.rst:306 msgid "" "On POSIX systems, if your application has multiple threads and the :mod:" "`multiprocessing` context uses the ``\"fork\"`` start method: The :func:`os." @@ -537,11 +572,17 @@ msgstr "" "能會引發 :exc:`DeprecationWarning`。傳遞一個 *mp_context* 以配置為使用不同的" "啟動方法。更多說明請參閱 :func:`os.fork` 文件。" -#: ../../library/concurrent.futures.rst:308 +#: ../../library/concurrent.futures.rst:314 +msgid "" +"*max_workers* uses :func:`os.process_cpu_count` by default, instead of :func:" +"`os.cpu_count`." +msgstr "" + +#: ../../library/concurrent.futures.rst:321 msgid "ProcessPoolExecutor Example" msgstr "ProcessPoolExecutor 範例" -#: ../../library/concurrent.futures.rst:311 +#: ../../library/concurrent.futures.rst:324 msgid "" "import concurrent.futures\n" "import math\n" @@ -609,11 +650,11 @@ msgstr "" "if __name__ == '__main__':\n" " main()" -#: ../../library/concurrent.futures.rst:346 +#: ../../library/concurrent.futures.rst:359 msgid "Future Objects" msgstr "Future 物件" -#: ../../library/concurrent.futures.rst:348 +#: ../../library/concurrent.futures.rst:361 msgid "" "The :class:`Future` class encapsulates the asynchronous execution of a " "callable. :class:`Future` instances are created by :meth:`Executor.submit`." @@ -621,7 +662,7 @@ msgstr "" ":class:`Future` 類別封裝了可呼叫物件的非同步執行。:class:`Future` 實例由 :" "meth:`Executor.submit` 建立。" -#: ../../library/concurrent.futures.rst:353 +#: ../../library/concurrent.futures.rst:366 msgid "" "Encapsulates the asynchronous execution of a callable. :class:`Future` " "instances are created by :meth:`Executor.submit` and should not be created " @@ -630,32 +671,32 @@ msgstr "" "封裝可呼叫物件的非同步執行。:class:`Future` 實例由 :meth:`Executor.submit` 建" "立,且除測試外不應直接建立。" -#: ../../library/concurrent.futures.rst:359 +#: ../../library/concurrent.futures.rst:372 msgid "" "Attempt to cancel the call. If the call is currently being executed or " "finished running and cannot be cancelled then the method will return " "``False``, otherwise the call will be cancelled and the method will return " "``True``." msgstr "" -"嘗試取消呼叫。如果呼叫當前正在執行或已完成運行且無法取消,則該方法將回傳 " +"嘗試取消呼叫。如果呼叫目前正在執行或已完成運行且無法取消,則該方法將回傳 " "``False``,否則呼叫將被取消並且該方法將回傳 ``True``。" -#: ../../library/concurrent.futures.rst:366 +#: ../../library/concurrent.futures.rst:379 msgid "Return ``True`` if the call was successfully cancelled." msgstr "如果該呼叫成功被取消,則回傳 ``True``。" -#: ../../library/concurrent.futures.rst:370 +#: ../../library/concurrent.futures.rst:383 msgid "" "Return ``True`` if the call is currently being executed and cannot be " "cancelled." msgstr "如果呼叫正在執行且無法取消,則回傳 ``True``。" -#: ../../library/concurrent.futures.rst:375 +#: ../../library/concurrent.futures.rst:388 msgid "" "Return ``True`` if the call was successfully cancelled or finished running." msgstr "如果呼叫成功被取消或結束運行,則回傳 ``True``。" -#: ../../library/concurrent.futures.rst:380 +#: ../../library/concurrent.futures.rst:393 msgid "" "Return the value returned by the call. If the call hasn't yet completed then " "this method will wait up to *timeout* seconds. If the call hasn't completed " @@ -667,19 +708,19 @@ msgstr "" "叫在 *timeout* 秒內未完成,則會引發 :exc:`TimeoutError`。*timeout* 可以是整數" "或浮點數。如果未指定 *timeout* 或為 ``None``,則等待時間就不會有限制。" -#: ../../library/concurrent.futures.rst:387 -#: ../../library/concurrent.futures.rst:401 +#: ../../library/concurrent.futures.rst:400 +#: ../../library/concurrent.futures.rst:414 msgid "" "If the future is cancelled before completing then :exc:`.CancelledError` " "will be raised." msgstr "如果 future 在完成之前被取消,那麼 :exc:`.CancelledError` 將被引發。" -#: ../../library/concurrent.futures.rst:390 +#: ../../library/concurrent.futures.rst:403 msgid "" "If the call raised an exception, this method will raise the same exception." msgstr "如果該呼叫引發了例外,此方法將引發相同的例外。" -#: ../../library/concurrent.futures.rst:394 +#: ../../library/concurrent.futures.rst:407 msgid "" "Return the exception raised by the call. If the call hasn't yet completed " "then this method will wait up to *timeout* seconds. If the call hasn't " @@ -691,11 +732,11 @@ msgstr "" "呼叫在 *timeout* 秒內未完成,則會引發 :exc:`TimeoutError`。 *timeout* 可以是" "整數或浮點數。如果未指定 *timeout* 或為 ``None``,則等待時間就不會有限制。" -#: ../../library/concurrent.futures.rst:404 +#: ../../library/concurrent.futures.rst:417 msgid "If the call completed without raising, ``None`` is returned." msgstr "如果呼叫在沒有引發的情況下完成,則回傳 ``None``。" -#: ../../library/concurrent.futures.rst:408 +#: ../../library/concurrent.futures.rst:421 msgid "" "Attaches the callable *fn* to the future. *fn* will be called, with the " "future as its only argument, when the future is cancelled or finishes " @@ -704,7 +745,7 @@ msgstr "" "將可呼叫的 *fn* 附加到 future 上。當 future 被取消或完成運行時,*fn* 將被以 " "future 作為其唯一引數來呼叫。" -#: ../../library/concurrent.futures.rst:412 +#: ../../library/concurrent.futures.rst:425 msgid "" "Added callables are called in the order that they were added and are always " "called in a thread belonging to the process that added them. If the " @@ -716,19 +757,19 @@ msgstr "" "如果可呼叫物件引發 :exc:`Exception` 子類別,它將被記錄 (log) 並忽略。如果可呼" "叫物件引發 :exc:`BaseException` 子類別,該行為未定義。" -#: ../../library/concurrent.futures.rst:418 +#: ../../library/concurrent.futures.rst:431 msgid "" "If the future has already completed or been cancelled, *fn* will be called " "immediately." msgstr "如果 future 已經完成或被取消,*fn* 將立即被呼叫。" -#: ../../library/concurrent.futures.rst:421 +#: ../../library/concurrent.futures.rst:434 msgid "" "The following :class:`Future` methods are meant for use in unit tests and :" "class:`Executor` implementations." msgstr "以下 :class:`Future` 方法旨在用於單元測試和 :class:`Executor` 實作。" -#: ../../library/concurrent.futures.rst:426 +#: ../../library/concurrent.futures.rst:439 msgid "" "This method should only be called by :class:`Executor` implementations " "before executing the work associated with the :class:`Future` and by unit " @@ -737,7 +778,7 @@ msgstr "" "此方法只能在與 :class:`Future` 關聯的工作被執行之前於 :class:`Executor` 實作" "中呼叫,或者在單元測試中呼叫。" -#: ../../library/concurrent.futures.rst:430 +#: ../../library/concurrent.futures.rst:443 msgid "" "If the method returns ``False`` then the :class:`Future` was cancelled, i." "e. :meth:`Future.cancel` was called and returned ``True``. Any threads " @@ -748,7 +789,7 @@ msgstr "" "cancel` 被呼叫並回傳 ``True``。任何等待 :class:`Future` 完成的執行緒(即透" "過 :func:`as_completed` 或 :func:`wait`)將被喚醒。" -#: ../../library/concurrent.futures.rst:435 +#: ../../library/concurrent.futures.rst:448 msgid "" "If the method returns ``True`` then the :class:`Future` was not cancelled " "and has been put in the running state, i.e. calls to :meth:`Future.running` " @@ -757,7 +798,7 @@ msgstr "" "如果該方法回傳 ``True`` 則代表 :class:`Future` 未被取消並已進入運行狀態,意即" "呼叫 :meth:`Future.running` 將回傳 ``True``。" -#: ../../library/concurrent.futures.rst:439 +#: ../../library/concurrent.futures.rst:452 msgid "" "This method can only be called once and cannot be called after :meth:`Future." "set_result` or :meth:`Future.set_exception` have been called." @@ -765,20 +806,20 @@ msgstr "" "此方法只能呼叫一次,且不能在呼叫 :meth:`Future.set_result` 或 :meth:`Future." "set_exception` 之後呼叫。" -#: ../../library/concurrent.futures.rst:445 +#: ../../library/concurrent.futures.rst:458 msgid "" "Sets the result of the work associated with the :class:`Future` to *result*." msgstr "將與 :class:`Future` 關聯的工作結果設定為 *result*。" -#: ../../library/concurrent.futures.rst:448 #: ../../library/concurrent.futures.rst:461 +#: ../../library/concurrent.futures.rst:474 msgid "" "This method should only be used by :class:`Executor` implementations and " "unit tests." msgstr "此方法只能在 :class:`Executor` 實作中和單元測試中使用。" -#: ../../library/concurrent.futures.rst:451 #: ../../library/concurrent.futures.rst:464 +#: ../../library/concurrent.futures.rst:477 msgid "" "This method raises :exc:`concurrent.futures.InvalidStateError` if the :class:" "`Future` is already done." @@ -786,18 +827,18 @@ msgstr "" "如果 :class:`Future` 已經完成,此方法會引發 :exc:`concurrent.futures." "InvalidStateError`。" -#: ../../library/concurrent.futures.rst:458 +#: ../../library/concurrent.futures.rst:471 msgid "" "Sets the result of the work associated with the :class:`Future` to the :" "class:`Exception` *exception*." msgstr "" "將與 :class:`Future` 關聯的工作結果設定為 :class:`Exception` *exception*。" -#: ../../library/concurrent.futures.rst:470 +#: ../../library/concurrent.futures.rst:483 msgid "Module Functions" msgstr "模組函式" -#: ../../library/concurrent.futures.rst:474 +#: ../../library/concurrent.futures.rst:487 msgid "" "Wait for the :class:`Future` instances (possibly created by different :class:" "`Executor` instances) given by *fs* to complete. Duplicate futures given to " @@ -813,7 +854,7 @@ msgstr "" "完成的 future(已完成或被取消的 future)。第二組名為 ``not_done``,包含未完成" "的 future(未定或運行中的 future)。" -#: ../../library/concurrent.futures.rst:482 +#: ../../library/concurrent.futures.rst:495 msgid "" "*timeout* can be used to control the maximum number of seconds to wait " "before returning. *timeout* can be an int or float. If *timeout* is not " @@ -822,25 +863,25 @@ msgstr "" "*timeout* 可用於控制回傳前等待的最大秒數。*timeout* 可以是整數或浮點數。如果" "未指定 *timeout* 或為 ``None``,則等待時間就沒有限制。" -#: ../../library/concurrent.futures.rst:486 +#: ../../library/concurrent.futures.rst:499 msgid "" "*return_when* indicates when this function should return. It must be one of " "the following constants:" msgstr "*return_when* 表示此函式應回傳的時間。它必須是以下常數之一:" -#: ../../library/concurrent.futures.rst:492 +#: ../../library/concurrent.futures.rst:505 msgid "Constant" msgstr "常數" -#: ../../library/concurrent.futures.rst:493 +#: ../../library/concurrent.futures.rst:506 msgid "Description" msgstr "描述" -#: ../../library/concurrent.futures.rst:496 +#: ../../library/concurrent.futures.rst:509 msgid "The function will return when any future finishes or is cancelled." msgstr "當任何 future 完成或被取消時,該函式就會回傳。" -#: ../../library/concurrent.futures.rst:499 +#: ../../library/concurrent.futures.rst:512 msgid "" "The function will return when any future finishes by raising an exception. " "If no future raises an exception then it is equivalent to :const:" @@ -849,11 +890,11 @@ msgstr "" "該函式會在任何 future 透過引發例外而完結時回傳。如果 future 沒有引發例外,那" "麼它等同於 :const:`ALL_COMPLETED`。" -#: ../../library/concurrent.futures.rst:504 +#: ../../library/concurrent.futures.rst:517 msgid "The function will return when all futures finish or are cancelled." msgstr "當所有 future 都完成或被取消時,該函式才會回傳。" -#: ../../library/concurrent.futures.rst:508 +#: ../../library/concurrent.futures.rst:521 msgid "" "Returns an iterator over the :class:`Future` instances (possibly created by " "different :class:`Executor` instances) given by *fs* that yields futures as " @@ -873,36 +914,36 @@ msgstr "" "`TimeoutError`。*timeout* 可以是整數或浮點數。如果未指定 *timeout* 或為 " "``None``,則等待時間就沒有限制。" -#: ../../library/concurrent.futures.rst:521 +#: ../../library/concurrent.futures.rst:534 msgid ":pep:`3148` -- futures - execute computations asynchronously" msgstr ":pep:`3148` -- futures - 非同步地執行運算" -#: ../../library/concurrent.futures.rst:522 +#: ../../library/concurrent.futures.rst:535 msgid "" "The proposal which described this feature for inclusion in the Python " "standard library." msgstr "描述此功能並提出被包含於 Python 標準函式庫中的提案。" -#: ../../library/concurrent.futures.rst:527 +#: ../../library/concurrent.futures.rst:540 msgid "Exception classes" msgstr "例外類別" -#: ../../library/concurrent.futures.rst:533 +#: ../../library/concurrent.futures.rst:546 msgid "Raised when a future is cancelled." msgstr "當 future 被取消時引發。" -#: ../../library/concurrent.futures.rst:537 +#: ../../library/concurrent.futures.rst:550 msgid "" "A deprecated alias of :exc:`TimeoutError`, raised when a future operation " "exceeds the given timeout." msgstr "" ":exc:`TimeoutError` 的棄用別名,在 future 操作超過給定超時 (timeout) 時引發。" -#: ../../library/concurrent.futures.rst:542 +#: ../../library/concurrent.futures.rst:555 msgid "This class was made an alias of :exc:`TimeoutError`." msgstr "這個類別是 :exc:`TimeoutError` 的別名。" -#: ../../library/concurrent.futures.rst:547 +#: ../../library/concurrent.futures.rst:560 msgid "" "Derived from :exc:`RuntimeError`, this exception class is raised when an " "executor is broken for some reason, and cannot be used to submit or execute " @@ -911,13 +952,13 @@ msgstr "" "衍生自 :exc:`RuntimeError`,當執行器因某種原因損壞時會引發此例外類別,並且不" "能用於提交或執行新任務。" -#: ../../library/concurrent.futures.rst:555 +#: ../../library/concurrent.futures.rst:568 msgid "" "Raised when an operation is performed on a future that is not allowed in the " "current state." -msgstr "當前狀態下不允許的 future 操作被執行時而引發。" +msgstr "目前狀態下不允許的 future 操作被執行時而引發。" -#: ../../library/concurrent.futures.rst:564 +#: ../../library/concurrent.futures.rst:577 msgid "" "Derived from :exc:`~concurrent.futures.BrokenExecutor`, this exception class " "is raised when one of the workers of a :class:`~concurrent.futures." @@ -926,7 +967,7 @@ msgstr "" "衍生自 :exc:`~concurrent.futures.BrokenExecutor`,當 :class:`~concurrent." "futures.ThreadPoolExecutor` 的其中一個 worker 初始化失敗時會引發此例外類別。" -#: ../../library/concurrent.futures.rst:575 +#: ../../library/concurrent.futures.rst:588 msgid "" "Derived from :exc:`~concurrent.futures.BrokenExecutor` (formerly :exc:" "`RuntimeError`), this exception class is raised when one of the workers of " diff --git a/library/concurrent.po b/library/concurrent.po index bfa5989eb2..43635439de 100644 --- a/library/concurrent.po +++ b/library/concurrent.po @@ -6,7 +6,7 @@ # Matt Wang , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-07-29 10:36+0000\n" "PO-Revision-Date: 2015-12-09 17:51+0000\n" diff --git a/library/configparser.po b/library/configparser.po index 47e50b76fd..4b3a98b31e 100644 --- a/library/configparser.po +++ b/library/configparser.po @@ -4,9 +4,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-02-19 00:13+0000\n" "PO-Revision-Date: 2018-05-23 14:41+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -69,15 +69,15 @@ msgid "" "sometimes used for configuration, but does not support comments." msgstr "" -#: ../../library/configparser.rst:60 +#: ../../library/configparser.rst:61 msgid "Quick Start" msgstr "" -#: ../../library/configparser.rst:62 +#: ../../library/configparser.rst:63 msgid "Let's take a very basic configuration file that looks like this:" msgstr "" -#: ../../library/configparser.rst:64 +#: ../../library/configparser.rst:65 msgid "" "[DEFAULT]\n" "ServerAliveInterval = 45\n" @@ -105,7 +105,7 @@ msgstr "" "Port = 50022\n" "ForwardX11 = no" -#: ../../library/configparser.rst:79 +#: ../../library/configparser.rst:80 msgid "" "The structure of INI files is described `in the following section " "<#supported-ini-file-structure>`_. Essentially, the file consists of " @@ -114,7 +114,7 @@ msgid "" "configuration file programmatically." msgstr "" -#: ../../library/configparser.rst:85 +#: ../../library/configparser.rst:86 msgid "" ">>> import configparser\n" ">>> config = configparser.ConfigParser()\n" @@ -132,21 +132,36 @@ msgid "" "... config.write(configfile)\n" "..." msgstr "" +">>> import configparser\n" +">>> config = configparser.ConfigParser()\n" +">>> config['DEFAULT'] = {'ServerAliveInterval': '45',\n" +"... 'Compression': 'yes',\n" +"... 'CompressionLevel': '9'}\n" +">>> config['forge.example'] = {}\n" +">>> config['forge.example']['User'] = 'hg'\n" +">>> config['topsecret.server.example'] = {}\n" +">>> topsecret = config['topsecret.server.example']\n" +">>> topsecret['Port'] = '50022' # mutates the parser\n" +">>> topsecret['ForwardX11'] = 'no' # same here\n" +">>> config['DEFAULT']['ForwardX11'] = 'yes'\n" +">>> with open('example.ini', 'w') as configfile:\n" +"... config.write(configfile)\n" +"..." -#: ../../library/configparser.rst:103 +#: ../../library/configparser.rst:104 msgid "" "As you can see, we can treat a config parser much like a dictionary. There " "are differences, `outlined later <#mapping-protocol-access>`_, but the " "behavior is very close to what you would expect from a dictionary." msgstr "" -#: ../../library/configparser.rst:107 +#: ../../library/configparser.rst:108 msgid "" "Now that we have created and saved a configuration file, let's read it back " "and explore the data it holds." msgstr "" -#: ../../library/configparser.rst:110 +#: ../../library/configparser.rst:111 msgid "" ">>> config = configparser.ConfigParser()\n" ">>> config.sections()\n" @@ -168,7 +183,7 @@ msgid "" "'no'\n" ">>> topsecret['Port']\n" "'50022'\n" -">>> for key in config['forge.example']: \n" +">>> for key in config['forge.example']:\n" "... print(key)\n" "user\n" "compressionlevel\n" @@ -178,8 +193,37 @@ msgid "" ">>> config['forge.example']['ForwardX11']\n" "'yes'" msgstr "" +">>> config = configparser.ConfigParser()\n" +">>> config.sections()\n" +"[]\n" +">>> config.read('example.ini')\n" +"['example.ini']\n" +">>> config.sections()\n" +"['forge.example', 'topsecret.server.example']\n" +">>> 'forge.example' in config\n" +"True\n" +">>> 'python.org' in config\n" +"False\n" +">>> config['forge.example']['User']\n" +"'hg'\n" +">>> config['DEFAULT']['Compression']\n" +"'yes'\n" +">>> topsecret = config['topsecret.server.example']\n" +">>> topsecret['ForwardX11']\n" +"'no'\n" +">>> topsecret['Port']\n" +"'50022'\n" +">>> for key in config['forge.example']:\n" +"... print(key)\n" +"user\n" +"compressionlevel\n" +"serveraliveinterval\n" +"compression\n" +"forwardx11\n" +">>> config['forge.example']['ForwardX11']\n" +"'yes'" -#: ../../library/configparser.rst:142 +#: ../../library/configparser.rst:143 msgid "" "As we can see above, the API is pretty straightforward. The only bit of " "magic involves the ``DEFAULT`` section which provides default values for all " @@ -187,17 +231,17 @@ msgid "" "and stored in lowercase [1]_." msgstr "" -#: ../../library/configparser.rst:147 ../../library/configparser.rst:966 +#: ../../library/configparser.rst:148 ../../library/configparser.rst:1003 msgid "" -"It is possible to read several configurations into a single :class:" -"`ConfigParser`, 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." +"It is possible to read several configurations into a " +"single :class:`ConfigParser`, 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." msgstr "" -#: ../../library/configparser.rst:154 ../../library/configparser.rst:973 +#: ../../library/configparser.rst:155 ../../library/configparser.rst:1010 msgid "" "[DEFAULT]\n" "ServerAliveInterval = -1" @@ -205,7 +249,7 @@ msgstr "" "[DEFAULT]\n" "ServerAliveInterval = -1" -#: ../../library/configparser.rst:159 ../../library/configparser.rst:978 +#: ../../library/configparser.rst:160 ../../library/configparser.rst:1015 msgid "" ">>> config_override = configparser.ConfigParser()\n" ">>> config_override['DEFAULT'] = {'ServerAliveInterval': '-1'}\n" @@ -229,24 +273,24 @@ msgstr "" ">>> print(config_override.get('DEFAULT', 'ServerAliveInterval'))\n" "-1" -#: ../../library/configparser.rst:173 +#: ../../library/configparser.rst:174 msgid "" "This behaviour is equivalent to a :meth:`ConfigParser.read` call with " "several files passed to the *filenames* parameter." msgstr "" -#: ../../library/configparser.rst:178 +#: ../../library/configparser.rst:179 msgid "Supported Datatypes" msgstr "" -#: ../../library/configparser.rst:180 +#: ../../library/configparser.rst:181 msgid "" "Config parsers do not guess datatypes of values in configuration files, " "always storing them internally as strings. This means that if you need " "other datatypes, you should convert on your own:" msgstr "" -#: ../../library/configparser.rst:184 +#: ../../library/configparser.rst:185 msgid "" ">>> int(topsecret['Port'])\n" "50022\n" @@ -258,7 +302,7 @@ msgstr "" ">>> float(topsecret['CompressionLevel'])\n" "9.0" -#: ../../library/configparser.rst:191 +#: ../../library/configparser.rst:192 msgid "" "Since this task is so common, config parsers provide a range of handy getter " "methods to handle integers, floats and booleans. The last one is the most " @@ -269,7 +313,7 @@ msgid "" "``'true'``/``'false'`` and ``'1'``/``'0'`` [1]_. For example:" msgstr "" -#: ../../library/configparser.rst:199 +#: ../../library/configparser.rst:200 msgid "" ">>> topsecret.getboolean('ForwardX11')\n" "False\n" @@ -285,7 +329,7 @@ msgstr "" ">>> config.getboolean('forge.example', 'Compression')\n" "True" -#: ../../library/configparser.rst:208 +#: ../../library/configparser.rst:209 msgid "" "Apart from :meth:`~ConfigParser.getboolean`, config parsers also provide " "equivalent :meth:`~ConfigParser.getint` and :meth:`~ConfigParser.getfloat` " @@ -293,17 +337,17 @@ msgid "" "ones. [1]_" msgstr "" -#: ../../library/configparser.rst:214 +#: ../../library/configparser.rst:215 msgid "Fallback Values" msgstr "" -#: ../../library/configparser.rst:216 +#: ../../library/configparser.rst:217 msgid "" "As with a dictionary, you can use a section's :meth:`~ConfigParser.get` " "method to provide fallback values:" msgstr "" -#: ../../library/configparser.rst:219 +#: ../../library/configparser.rst:220 msgid "" ">>> topsecret.get('Port')\n" "'50022'\n" @@ -321,7 +365,7 @@ msgstr "" ">>> topsecret.get('Cipher', '3des-cbc')\n" "'3des-cbc'" -#: ../../library/configparser.rst:229 +#: ../../library/configparser.rst:230 msgid "" "Please note that default values have precedence over fallback values. For " "instance, in our example the ``'CompressionLevel'`` key was specified only " @@ -330,7 +374,7 @@ msgid "" "specify a fallback:" msgstr "" -#: ../../library/configparser.rst:235 +#: ../../library/configparser.rst:236 msgid "" ">>> topsecret.get('CompressionLevel', '3')\n" "'9'" @@ -338,29 +382,29 @@ msgstr "" ">>> topsecret.get('CompressionLevel', '3')\n" "'9'" -#: ../../library/configparser.rst:240 +#: ../../library/configparser.rst:241 msgid "" -"One more thing to be aware of is that the parser-level :meth:`~ConfigParser." -"get` method provides a custom, more complex interface, maintained for " -"backwards compatibility. When using this method, a fallback value can be " -"provided via the ``fallback`` keyword-only argument:" +"One more thing to be aware of is that the parser-" +"level :meth:`~ConfigParser.get` method provides a custom, more complex " +"interface, maintained for backwards compatibility. When using this method, " +"a fallback value can be provided via the ``fallback`` keyword-only argument:" msgstr "" -#: ../../library/configparser.rst:245 +#: ../../library/configparser.rst:246 msgid "" ">>> config.get('forge.example', 'monster',\n" "... fallback='No such things as monsters')\n" "'No such things as monsters'" msgstr "" -#: ../../library/configparser.rst:251 +#: ../../library/configparser.rst:252 msgid "" -"The same ``fallback`` argument can be used with the :meth:`~ConfigParser." -"getint`, :meth:`~ConfigParser.getfloat` and :meth:`~ConfigParser.getboolean` " -"methods, for example:" +"The same ``fallback`` argument can be used with " +"the :meth:`~ConfigParser.getint`, :meth:`~ConfigParser.getfloat` " +"and :meth:`~ConfigParser.getboolean` methods, for example:" msgstr "" -#: ../../library/configparser.rst:255 +#: ../../library/configparser.rst:256 msgid "" ">>> 'BatchMode' in topsecret\n" "False\n" @@ -378,11 +422,11 @@ msgstr "" ">>> topsecret.getboolean('BatchMode', fallback=True)\n" "False" -#: ../../library/configparser.rst:267 +#: ../../library/configparser.rst:268 msgid "Supported INI File Structure" msgstr "" -#: ../../library/configparser.rst:269 +#: ../../library/configparser.rst:270 msgid "" "A configuration file consists of sections, each led by a ``[section]`` " "header, followed by key/value entries separated by a specific string (``=`` " @@ -395,24 +439,32 @@ msgid "" "parts of multiline values or ignored." msgstr "" -#: ../../library/configparser.rst:279 +#: ../../library/configparser.rst:280 msgid "" "By default, a valid section name can be any string that does not contain '\\" "\\n'. To change this, see :attr:`ConfigParser.SECTCRE`." msgstr "" -#: ../../library/configparser.rst:282 +#: ../../library/configparser.rst:283 +msgid "" +"The first section name may be omitted if the parser is configured to allow " +"an unnamed top level section with ``allow_unnamed_section=True``. In this " +"case, the keys/values may be retrieved by :const:`UNNAMED_SECTION` as in " +"``config[UNNAMED_SECTION]``." +msgstr "" + +#: ../../library/configparser.rst:288 msgid "" "Configuration files may include comments, prefixed by specific characters " "(``#`` and ``;`` by default [1]_). Comments may appear on their own on an " "otherwise empty line, possibly indented. [1]_" msgstr "" -#: ../../library/configparser.rst:286 ../../library/configparser.rst:349 +#: ../../library/configparser.rst:292 ../../library/configparser.rst:376 msgid "For example:" msgstr "舉例來說:" -#: ../../library/configparser.rst:288 +#: ../../library/configparser.rst:294 msgid "" "[Simple Values]\n" "key=value\n" @@ -457,18 +509,52 @@ msgid "" " # Did I mention we can indent comments, too?" msgstr "" -#: ../../library/configparser.rst:334 +#: ../../library/configparser.rst:342 +msgid "Unnamed Sections" +msgstr "" + +#: ../../library/configparser.rst:344 +msgid "" +"The name of the first section (or unique) may be omitted and values " +"retrieved by the :const:`UNNAMED_SECTION` attribute." +msgstr "" + +#: ../../library/configparser.rst:347 +msgid "" +">>> config = \"\"\"\n" +"... option = value\n" +"...\n" +"... [ Section 2 ]\n" +"... another = val\n" +"... \"\"\"\n" +">>> unnamed = configparser.ConfigParser(allow_unnamed_section=True)\n" +">>> unnamed.read_string(config)\n" +">>> unnamed.get(configparser.UNNAMED_SECTION, 'option')\n" +"'value'" +msgstr "" +">>> config = \"\"\"\n" +"... option = value\n" +"...\n" +"... [ Section 2 ]\n" +"... another = val\n" +"... \"\"\"\n" +">>> unnamed = configparser.ConfigParser(allow_unnamed_section=True)\n" +">>> unnamed.read_string(config)\n" +">>> unnamed.get(configparser.UNNAMED_SECTION, 'option')\n" +"'value'" + +#: ../../library/configparser.rst:361 msgid "Interpolation of values" msgstr "" -#: ../../library/configparser.rst:336 +#: ../../library/configparser.rst:363 msgid "" "On top of the core functionality, :class:`ConfigParser` supports " "interpolation. This means values can be preprocessed before returning them " "from ``get()`` calls." msgstr "" -#: ../../library/configparser.rst:344 +#: ../../library/configparser.rst:371 msgid "" "The default implementation used by :class:`ConfigParser`. It enables values " "to contain format strings which refer to other values in the same section, " @@ -476,7 +562,7 @@ msgid "" "can be provided on initialization." msgstr "" -#: ../../library/configparser.rst:351 +#: ../../library/configparser.rst:378 msgid "" "[Paths]\n" "home_dir: /Users\n" @@ -489,7 +575,7 @@ msgid "" "gain: 80%%" msgstr "" -#: ../../library/configparser.rst:362 +#: ../../library/configparser.rst:389 msgid "" "In the example above, :class:`ConfigParser` with *interpolation* set to " "``BasicInterpolation()`` would resolve ``%(home_dir)s`` to the value of " @@ -499,30 +585,30 @@ msgid "" "specific order in the configuration file." msgstr "" -#: ../../library/configparser.rst:369 +#: ../../library/configparser.rst:396 msgid "" -"With ``interpolation`` set to ``None``, the parser would simply return " -"``%(my_dir)s/Pictures`` as the value of ``my_pictures`` and ``%(home_dir)s/" +"With ``interpolation`` set to ``None``, the parser would simply return ``%" +"(my_dir)s/Pictures`` as the value of ``my_pictures`` and ``%(home_dir)s/" "lumberjack`` as the value of ``my_dir``." msgstr "" -#: ../../library/configparser.rst:377 +#: ../../library/configparser.rst:404 msgid "" "An alternative handler for interpolation which implements a more advanced " "syntax, used for instance in ``zc.buildout``. Extended interpolation is " "using ``${section:option}`` to denote a value from a foreign section. " -"Interpolation can span multiple levels. For convenience, if the ``section:" -"`` part is omitted, interpolation defaults to the current section (and " -"possibly the default values from the special section)." +"Interpolation can span multiple levels. For convenience, if the " +"``section:`` part is omitted, interpolation defaults to the current section " +"(and possibly the default values from the special section)." msgstr "" -#: ../../library/configparser.rst:384 +#: ../../library/configparser.rst:411 msgid "" "For example, the configuration specified above with basic interpolation, " "would look like this with extended interpolation:" msgstr "" -#: ../../library/configparser.rst:387 +#: ../../library/configparser.rst:414 msgid "" "[Paths]\n" "home_dir: /Users\n" @@ -535,11 +621,11 @@ msgid "" "cost: $$80" msgstr "" -#: ../../library/configparser.rst:398 +#: ../../library/configparser.rst:425 msgid "Values from other sections can be fetched as well:" msgstr "" -#: ../../library/configparser.rst:400 +#: ../../library/configparser.rst:427 msgid "" "[Common]\n" "home_dir: /Users\n" @@ -575,19 +661,19 @@ msgstr "" "my_pictures: ${my_dir}/Pictures\n" "python_dir: ${Frameworks:path}/Python/Versions/${Frameworks:Python}" -#: ../../library/configparser.rst:420 +#: ../../library/configparser.rst:447 msgid "Mapping Protocol Access" msgstr "" -#: ../../library/configparser.rst:424 +#: ../../library/configparser.rst:451 msgid "" "Mapping protocol access is a generic name for functionality that enables " -"using custom objects as if they were dictionaries. In case of :mod:" -"`configparser`, the mapping interface implementation is using the " +"using custom objects as if they were dictionaries. In case " +"of :mod:`configparser`, the mapping interface implementation is using the " "``parser['section']['option']`` notation." msgstr "" -#: ../../library/configparser.rst:429 +#: ../../library/configparser.rst:456 msgid "" "``parser['section']`` in particular returns a proxy for the section's data " "in the parser. This means that the values are not copied but they are taken " @@ -596,15 +682,15 @@ msgid "" "original parser." msgstr "" -#: ../../library/configparser.rst:435 +#: ../../library/configparser.rst:462 msgid "" ":mod:`configparser` objects behave as close to actual dictionaries as " -"possible. The mapping interface is complete and adheres to the :class:" -"`~collections.abc.MutableMapping` ABC. However, there are a few differences " -"that should be taken into account:" +"possible. The mapping interface is complete and adheres to " +"the :class:`~collections.abc.MutableMapping` ABC. However, there are a few " +"differences that should be taken into account:" msgstr "" -#: ../../library/configparser.rst:440 +#: ../../library/configparser.rst:467 msgid "" "By default, all keys in sections are accessible in a case-insensitive manner " "[1]_. E.g. ``for option in parser[\"section\"]`` yields only " @@ -613,7 +699,7 @@ msgid "" "expressions return ``True``::" msgstr "" -#: ../../library/configparser.rst:445 +#: ../../library/configparser.rst:472 msgid "" "\"a\" in parser[\"section\"]\n" "\"A\" in parser[\"section\"]" @@ -621,61 +707,61 @@ msgstr "" "\"a\" in parser[\"section\"]\n" "\"A\" in parser[\"section\"]" -#: ../../library/configparser.rst:448 +#: ../../library/configparser.rst:475 msgid "" -"All sections include ``DEFAULTSECT`` values as well which means that ``." -"clear()`` on a section may not leave the section visibly empty. This is " +"All sections include ``DEFAULTSECT`` values as well which means that " +"``.clear()`` on a section may not leave the section visibly empty. This is " "because default values cannot be deleted from the section (because " "technically they are not there). If they are overridden in the section, " "deleting causes the default value to be visible again. Trying to delete a " "default value causes a :exc:`KeyError`." msgstr "" -#: ../../library/configparser.rst:455 +#: ../../library/configparser.rst:482 msgid "``DEFAULTSECT`` cannot be removed from the parser:" msgstr "" -#: ../../library/configparser.rst:457 +#: ../../library/configparser.rst:484 msgid "trying to delete it raises :exc:`ValueError`," msgstr "" -#: ../../library/configparser.rst:459 +#: ../../library/configparser.rst:486 msgid "``parser.clear()`` leaves it intact," msgstr "" -#: ../../library/configparser.rst:461 +#: ../../library/configparser.rst:488 msgid "``parser.popitem()`` never returns it." msgstr "" -#: ../../library/configparser.rst:463 +#: ../../library/configparser.rst:490 msgid "" "``parser.get(section, option, **kwargs)`` - the second argument is **not** a " "fallback value. Note however that the section-level ``get()`` methods are " "compatible both with the mapping protocol and the classic configparser API." msgstr "" -#: ../../library/configparser.rst:467 +#: ../../library/configparser.rst:494 msgid "" "``parser.items()`` is compatible with the mapping protocol (returns a list " "of *section_name*, *section_proxy* pairs including the DEFAULTSECT). " -"However, this method can also be invoked with arguments: ``parser." -"items(section, raw, vars)``. The latter call returns a list of *option*, " -"*value* pairs for a specified ``section``, with all interpolations expanded " -"(unless ``raw=True`` is provided)." +"However, this method can also be invoked with arguments: " +"``parser.items(section, raw, vars)``. The latter call returns a list of " +"*option*, *value* pairs for a specified ``section``, with all interpolations " +"expanded (unless ``raw=True`` is provided)." msgstr "" -#: ../../library/configparser.rst:474 +#: ../../library/configparser.rst:501 msgid "" "The mapping protocol is implemented on top of the existing legacy API so " "that subclasses overriding the original interface still should have mappings " "working as expected." msgstr "" -#: ../../library/configparser.rst:480 +#: ../../library/configparser.rst:507 msgid "Customizing Parser Behaviour" msgstr "" -#: ../../library/configparser.rst:482 +#: ../../library/configparser.rst:509 msgid "" "There are nearly as many INI format variants as there are applications using " "it. :mod:`configparser` goes a long way to provide support for the largest " @@ -684,17 +770,17 @@ msgid "" "customize some of the features." msgstr "" -#: ../../library/configparser.rst:488 +#: ../../library/configparser.rst:515 msgid "" "The most common way to change the way a specific config parser works is to " "use the :meth:`!__init__` options:" msgstr "" -#: ../../library/configparser.rst:491 +#: ../../library/configparser.rst:518 msgid "*defaults*, default value: ``None``" msgstr "" -#: ../../library/configparser.rst:493 +#: ../../library/configparser.rst:520 msgid "" "This option accepts a dictionary of key-value pairs which will be initially " "put in the ``DEFAULT`` section. This makes for an elegant way to support " @@ -702,17 +788,17 @@ msgid "" "the documented default." msgstr "" -#: ../../library/configparser.rst:498 +#: ../../library/configparser.rst:525 msgid "" -"Hint: if you want to specify default values for a specific section, use :" -"meth:`~ConfigParser.read_dict` before you read the actual file." +"Hint: if you want to specify default values for a specific section, " +"use :meth:`~ConfigParser.read_dict` before you read the actual file." msgstr "" -#: ../../library/configparser.rst:501 +#: ../../library/configparser.rst:528 msgid "*dict_type*, default value: :class:`dict`" msgstr "" -#: ../../library/configparser.rst:503 +#: ../../library/configparser.rst:530 msgid "" "This option has a major impact on how the mapping protocol will behave and " "how the written configuration files look. With the standard dictionary, " @@ -720,20 +806,20 @@ msgid "" "goes for options within sections." msgstr "" -#: ../../library/configparser.rst:508 +#: ../../library/configparser.rst:535 msgid "" "An alternative dictionary type can be used for example to sort sections and " "options on write-back." msgstr "" -#: ../../library/configparser.rst:511 +#: ../../library/configparser.rst:538 msgid "" "Please note: there are ways to add a set of key-value pairs in a single " "operation. When you use a regular dictionary in those operations, the order " "of the keys will be ordered. For example:" msgstr "" -#: ../../library/configparser.rst:515 +#: ../../library/configparser.rst:542 msgid "" ">>> parser = configparser.ConfigParser()\n" ">>> parser.read_dict({'section1': {'key1': 'value1',\n" @@ -767,11 +853,11 @@ msgstr "" ">>> [option for option in parser['section3']]\n" "['foo', 'bar', 'baz']" -#: ../../library/configparser.rst:533 +#: ../../library/configparser.rst:560 msgid "*allow_no_value*, default value: ``False``" msgstr "" -#: ../../library/configparser.rst:535 +#: ../../library/configparser.rst:562 msgid "" "Some configuration files are known to include settings without values, but " "which otherwise conform to the syntax supported by :mod:`configparser`. The " @@ -779,7 +865,7 @@ msgid "" "such values should be accepted:" msgstr "" -#: ../../library/configparser.rst:540 +#: ../../library/configparser.rst:567 msgid "" ">>> import configparser\n" "\n" @@ -810,32 +896,32 @@ msgid "" "KeyError: 'does-not-exist'" msgstr "" -#: ../../library/configparser.rst:570 +#: ../../library/configparser.rst:597 msgid "*delimiters*, default value: ``('=', ':')``" msgstr "" -#: ../../library/configparser.rst:572 +#: ../../library/configparser.rst:599 msgid "" "Delimiters are substrings that delimit keys from values within a section. " "The first occurrence of a delimiting substring on a line is considered a " "delimiter. This means values (but not keys) can contain the delimiters." msgstr "" -#: ../../library/configparser.rst:576 +#: ../../library/configparser.rst:603 msgid "" -"See also the *space_around_delimiters* argument to :meth:`ConfigParser." -"write`." +"See also the *space_around_delimiters* argument " +"to :meth:`ConfigParser.write`." msgstr "" -#: ../../library/configparser.rst:579 +#: ../../library/configparser.rst:606 msgid "*comment_prefixes*, default value: ``('#', ';')``" msgstr "" -#: ../../library/configparser.rst:581 +#: ../../library/configparser.rst:608 msgid "*inline_comment_prefixes*, default value: ``None``" msgstr "" -#: ../../library/configparser.rst:583 +#: ../../library/configparser.rst:610 msgid "" "Comment prefixes are strings that indicate the start of a valid comment " "within a config file. *comment_prefixes* are used only on otherwise empty " @@ -845,13 +931,13 @@ msgid "" "used as prefixes for whole line comments." msgstr "" -#: ../../library/configparser.rst:590 +#: ../../library/configparser.rst:617 msgid "" "In previous versions of :mod:`configparser` behaviour matched " "``comment_prefixes=('#',';')`` and ``inline_comment_prefixes=(';',)``." msgstr "" -#: ../../library/configparser.rst:594 +#: ../../library/configparser.rst:621 msgid "" "Please note that config parsers don't support escaping of comment prefixes " "so using *inline_comment_prefixes* may prevent users from specifying option " @@ -861,7 +947,7 @@ msgid "" "values is to interpolate the prefix, for example::" msgstr "" -#: ../../library/configparser.rst:601 +#: ../../library/configparser.rst:628 msgid "" ">>> from configparser import ConfigParser, ExtendedInterpolation\n" ">>> parser = ConfigParser(interpolation=ExtendedInterpolation())\n" @@ -903,29 +989,30 @@ msgid "" "line #3" msgstr "" -#: ../../library/configparser.rst:640 +#: ../../library/configparser.rst:667 msgid "*strict*, default value: ``True``" msgstr "" -#: ../../library/configparser.rst:642 +#: ../../library/configparser.rst:669 msgid "" "When set to ``True``, the parser will not allow for any section or option " -"duplicates while reading from a single source (using :meth:`~ConfigParser." -"read_file`, :meth:`~ConfigParser.read_string` or :meth:`~ConfigParser." -"read_dict`). It is recommended to use strict parsers in new applications." +"duplicates while reading from a single source " +"(using :meth:`~ConfigParser.read_file`, :meth:`~ConfigParser.read_string` " +"or :meth:`~ConfigParser.read_dict`). It is recommended to use strict " +"parsers in new applications." msgstr "" -#: ../../library/configparser.rst:647 +#: ../../library/configparser.rst:674 msgid "" "In previous versions of :mod:`configparser` behaviour matched " "``strict=False``." msgstr "" -#: ../../library/configparser.rst:651 +#: ../../library/configparser.rst:678 msgid "*empty_lines_in_values*, default value: ``True``" msgstr "" -#: ../../library/configparser.rst:653 +#: ../../library/configparser.rst:680 msgid "" "In config parsers, values can span multiple lines as long as they are " "indented more than the key that holds them. By default parsers also let " @@ -935,7 +1022,7 @@ msgid "" "lose track of the file structure. Take for instance:" msgstr "" -#: ../../library/configparser.rst:660 +#: ../../library/configparser.rst:687 msgid "" "[Section]\n" "key = multiline\n" @@ -944,7 +1031,7 @@ msgid "" " this = is still a part of the multiline value of 'key'" msgstr "" -#: ../../library/configparser.rst:668 +#: ../../library/configparser.rst:695 msgid "" "This can be especially problematic for the user to see if she's using a " "proportional font to edit the file. That is why when your application does " @@ -953,13 +1040,13 @@ msgid "" "would produce two keys, ``key`` and ``this``." msgstr "" -#: ../../library/configparser.rst:674 +#: ../../library/configparser.rst:701 msgid "" "*default_section*, default value: ``configparser.DEFAULTSECT`` (that is: " "``\"DEFAULT\"``)" msgstr "" -#: ../../library/configparser.rst:677 +#: ../../library/configparser.rst:704 msgid "" "The convention of allowing a special section of default values for other " "sections or interpolation purposes is a powerful concept of this library, " @@ -968,44 +1055,44 @@ msgid "" "other valid section name. Some typical values include: ``\"general\"`` or " "``\"common\"``. The name provided is used for recognizing default sections " "when reading from any source and is used when writing configuration back to " -"a file. Its current value can be retrieved using the ``parser_instance." -"default_section`` attribute and may be modified at runtime (i.e. to convert " -"files from one format to another)." +"a file. Its current value can be retrieved using the " +"``parser_instance.default_section`` attribute and may be modified at runtime " +"(i.e. to convert files from one format to another)." msgstr "" -#: ../../library/configparser.rst:688 +#: ../../library/configparser.rst:715 msgid "*interpolation*, default value: ``configparser.BasicInterpolation``" msgstr "" -#: ../../library/configparser.rst:690 +#: ../../library/configparser.rst:717 msgid "" "Interpolation behaviour may be customized by providing a custom handler " "through the *interpolation* argument. ``None`` can be used to turn off " "interpolation completely, ``ExtendedInterpolation()`` provides a more " "advanced variant inspired by ``zc.buildout``. More on the subject in the " -"`dedicated documentation section <#interpolation-of-values>`_. :class:" -"`RawConfigParser` has a default value of ``None``." +"`dedicated documentation section <#interpolation-of-" +"values>`_. :class:`RawConfigParser` has a default value of ``None``." msgstr "" -#: ../../library/configparser.rst:697 +#: ../../library/configparser.rst:724 msgid "*converters*, default value: not set" msgstr "" -#: ../../library/configparser.rst:699 +#: ../../library/configparser.rst:726 msgid "" "Config parsers provide option value getters that perform type conversion. " "By default :meth:`~ConfigParser.getint`, :meth:`~ConfigParser.getfloat`, " "and :meth:`~ConfigParser.getboolean` 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 :meth:`!getdecimal` on both the parser object and all " -"section proxies. In other words, it will be possible to write both " +"implementing said conversion. For instance, passing ``{'decimal': " +"decimal.Decimal}`` would add :meth:`!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)``." msgstr "" -#: ../../library/configparser.rst:710 +#: ../../library/configparser.rst:737 msgid "" "If the converter needs to access the state of the parser, it can be " "implemented as a method on a config parser subclass. If the name of this " @@ -1013,14 +1100,14 @@ msgid "" "the dict-compatible form (see the ``getdecimal()`` example above)." msgstr "" -#: ../../library/configparser.rst:715 +#: ../../library/configparser.rst:742 msgid "" "More advanced customization may be achieved by overriding default values of " "these parser attributes. The defaults are defined on the classes, so they " "may be overridden by subclasses or by attribute assignment." msgstr "" -#: ../../library/configparser.rst:721 +#: ../../library/configparser.rst:748 msgid "" "By default when using :meth:`~ConfigParser.getboolean`, config parsers " "consider the following values ``True``: ``'1'``, ``'yes'``, ``'true'``, " @@ -1029,7 +1116,7 @@ msgid "" "strings and their Boolean outcomes. For example:" msgstr "" -#: ../../library/configparser.rst:727 +#: ../../library/configparser.rst:754 msgid "" ">>> custom = configparser.ConfigParser()\n" ">>> custom['section1'] = {'funky': 'nope'}\n" @@ -1051,13 +1138,13 @@ msgstr "" ">>> custom['section1'].getboolean('funky')\n" "False" -#: ../../library/configparser.rst:739 +#: ../../library/configparser.rst:766 msgid "" "Other typical Boolean pairs include ``accept``/``reject`` or ``enabled``/" "``disabled``." msgstr "" -#: ../../library/configparser.rst:745 +#: ../../library/configparser.rst:772 msgid "" "This method transforms option names on every read, get, or set operation. " "The default converts the name to lowercase. This also means that when a " @@ -1065,7 +1152,7 @@ msgid "" "method if that's unsuitable. For example:" msgstr "" -#: ../../library/configparser.rst:751 +#: ../../library/configparser.rst:778 msgid "" ">>> config = \"\"\"\n" "... [Section1]\n" @@ -1109,14 +1196,14 @@ msgstr "" ">>> list(custom['Section2'].keys())\n" "['AnotherKey']" -#: ../../library/configparser.rst:775 +#: ../../library/configparser.rst:802 msgid "" "The optionxform function transforms option names to a canonical form. This " "should be an idempotent function: if the name is already in canonical form, " "it should be returned unchanged." msgstr "" -#: ../../library/configparser.rst:782 +#: ../../library/configparser.rst:809 msgid "" "A compiled regular expression used to parse section headers. The default " "matches ``[section]`` to the name ``\"section\"``. Whitespace is considered " @@ -1125,7 +1212,7 @@ msgid "" "example:" msgstr "" -#: ../../library/configparser.rst:788 +#: ../../library/configparser.rst:815 msgid "" ">>> import re\n" ">>> config = \"\"\"\n" @@ -1163,18 +1250,18 @@ msgstr "" ">>> custom.sections()\n" "['Section 1', 'Section 2']" -#: ../../library/configparser.rst:810 +#: ../../library/configparser.rst:837 msgid "" "While ConfigParser objects also use an ``OPTCRE`` attribute for recognizing " "option lines, it's not recommended to override it because that would " "interfere with constructor options *allow_no_value* and *delimiters*." msgstr "" -#: ../../library/configparser.rst:816 +#: ../../library/configparser.rst:843 msgid "Legacy API Examples" msgstr "" -#: ../../library/configparser.rst:818 +#: ../../library/configparser.rst:845 msgid "" "Mainly because of backwards compatibility concerns, :mod:`configparser` " "provides also a legacy API with explicit ``get``/``set`` methods. While " @@ -1183,11 +1270,11 @@ msgid "" "advanced, low-level and downright counterintuitive." msgstr "" -#: ../../library/configparser.rst:824 +#: ../../library/configparser.rst:851 msgid "An example of writing to a configuration file::" msgstr "" -#: ../../library/configparser.rst:826 +#: ../../library/configparser.rst:853 msgid "" "import configparser\n" "\n" @@ -1211,11 +1298,11 @@ msgid "" " config.write(configfile)" msgstr "" -#: ../../library/configparser.rst:847 +#: ../../library/configparser.rst:874 msgid "An example of reading the configuration file again::" msgstr "" -#: ../../library/configparser.rst:849 +#: ../../library/configparser.rst:876 msgid "" "import configparser\n" "\n" @@ -1234,11 +1321,11 @@ msgid "" " print(config.get('Section1', 'foo'))" msgstr "" -#: ../../library/configparser.rst:865 +#: ../../library/configparser.rst:892 msgid "To get interpolation, use :class:`ConfigParser`::" msgstr "" -#: ../../library/configparser.rst:867 +#: ../../library/configparser.rst:894 msgid "" "import configparser\n" "\n" @@ -1273,13 +1360,13 @@ msgid "" " # -> None" msgstr "" -#: ../../library/configparser.rst:898 +#: ../../library/configparser.rst:925 msgid "" "Default values are available in both types of ConfigParsers. They are used " "in interpolation if an option used is not defined elsewhere. ::" msgstr "" -#: ../../library/configparser.rst:901 +#: ../../library/configparser.rst:928 msgid "" "import configparser\n" "\n" @@ -1293,11 +1380,11 @@ msgid "" "print(config.get('Section1', 'foo')) # -> \"Life is hard!\"" msgstr "" -#: ../../library/configparser.rst:916 +#: ../../library/configparser.rst:943 msgid "ConfigParser Objects" msgstr "ConfigParser 物件" -#: ../../library/configparser.rst:920 +#: ../../library/configparser.rst:953 msgid "" "The main configuration parser. When *defaults* is given, it is initialized " "into the dictionary of intrinsic defaults. When *dict_type* is given, it " @@ -1305,7 +1392,7 @@ msgid "" "the options within a section, and for the default values." msgstr "" -#: ../../library/configparser.rst:925 +#: ../../library/configparser.rst:958 msgid "" "When *delimiters* is given, it is used as the set of substrings that divide " "keys from values. When *comment_prefixes* is given, it will be used as the " @@ -1314,20 +1401,20 @@ msgid "" "as the set of substrings that prefix comments in non-empty lines." msgstr "" -#: ../../library/configparser.rst:931 +#: ../../library/configparser.rst:964 msgid "" "When *strict* is ``True`` (the default), the parser won't allow for any " "section or option duplicates while reading from a single source (file, " -"string or dictionary), raising :exc:`DuplicateSectionError` or :exc:" -"`DuplicateOptionError`. When *empty_lines_in_values* is ``False`` (default: " -"``True``), each empty line marks the end of an option. Otherwise, internal " -"empty lines of a multiline option are kept as part of the value. When " -"*allow_no_value* is ``True`` (default: ``False``), options without values " -"are accepted; the value held for these is ``None`` and they are serialized " -"without the trailing delimiter." +"string or dictionary), raising :exc:`DuplicateSectionError` " +"or :exc:`DuplicateOptionError`. When *empty_lines_in_values* is ``False`` " +"(default: ``True``), each empty line marks the end of an option. Otherwise, " +"internal empty lines of a multiline option are kept as part of the value. " +"When *allow_no_value* is ``True`` (default: ``False``), options without " +"values are accepted; the value held for these is ``None`` and they are " +"serialized without the trailing delimiter." msgstr "" -#: ../../library/configparser.rst:941 +#: ../../library/configparser.rst:974 msgid "" "When *default_section* is given, it specifies the name for the special " "section holding default values for other sections and interpolation purposes " @@ -1337,7 +1424,7 @@ msgid "" "settings to a new config file." msgstr "" -#: ../../library/configparser.rst:948 +#: ../../library/configparser.rst:981 msgid "" "Interpolation behaviour may be customized by providing a custom handler " "through the *interpolation* argument. ``None`` can be used to turn off " @@ -1346,16 +1433,16 @@ msgid "" "`dedicated documentation section <#interpolation-of-values>`_." msgstr "" -#: ../../library/configparser.rst:954 +#: ../../library/configparser.rst:987 msgid "" -"All option names used in interpolation will be passed through the :meth:" -"`optionxform` method just like any other option name reference. For " -"example, using the default implementation of :meth:`optionxform` (which " -"converts option names to lower case), the values ``foo %(bar)s`` and ``foo " -"%(BAR)s`` are equivalent." +"All option names used in interpolation will be passed through " +"the :meth:`optionxform` method just like any other option name reference. " +"For example, using the default implementation of :meth:`optionxform` (which " +"converts option names to lower case), the values ``foo %(bar)s`` and ``foo %" +"(BAR)s`` are equivalent." msgstr "" -#: ../../library/configparser.rst:960 +#: ../../library/configparser.rst:993 msgid "" "When *converters* is given, it should be a dictionary where each key " "represents the name of a type converter and each value is a callable " @@ -1364,44 +1451,61 @@ msgid "" "object and section proxies." msgstr "" -#: ../../library/configparser.rst:991 +#: ../../library/configparser.rst:999 +msgid "" +"When *allow_unnamed_section* is ``True`` (default: ``False``), the first " +"section name can be omitted. See the `\"Unnamed Sections\" section <#unnamed-" +"sections>`_." +msgstr "" + +#: ../../library/configparser.rst:1028 msgid "The default *dict_type* is :class:`collections.OrderedDict`." msgstr "" -#: ../../library/configparser.rst:994 +#: ../../library/configparser.rst:1031 ../../library/configparser.rst:1320 msgid "" "*allow_no_value*, *delimiters*, *comment_prefixes*, *strict*, " "*empty_lines_in_values*, *default_section* and *interpolation* were added." msgstr "" -#: ../../library/configparser.rst:999 +#: ../../library/configparser.rst:1036 ../../library/configparser.rst:1325 msgid "The *converters* argument was added." msgstr "新增 *converters* 引數。" -#: ../../library/configparser.rst:1002 +#: ../../library/configparser.rst:1039 msgid "" "The *defaults* argument is read with :meth:`read_dict`, providing consistent " "behavior across the parser: non-string keys and values are implicitly " "converted to strings." msgstr "" -#: ../../library/configparser.rst:1007 ../../library/configparser.rst:1270 +#: ../../library/configparser.rst:1044 ../../library/configparser.rst:1328 msgid "" "The default *dict_type* is :class:`dict`, since it now preserves insertion " "order." msgstr "" -#: ../../library/configparser.rst:1013 +#: ../../library/configparser.rst:1048 +msgid "" +"Raise a :exc:`MultilineContinuationError` when *allow_no_value* is ``True``, " +"and a key without a value is continued with an indented line." +msgstr "" + +#: ../../library/configparser.rst:1052 ../../library/configparser.rst:1332 +msgid "The *allow_unnamed_section* argument was added." +msgstr "新增 *allow_unnamed_section* 引數。" + +#: ../../library/configparser.rst:1057 msgid "Return a dictionary containing the instance-wide defaults." msgstr "" -#: ../../library/configparser.rst:1018 +#: ../../library/configparser.rst:1062 msgid "" "Return a list of the sections available; the *default section* is not " "included in the list." msgstr "" -#: ../../library/configparser.rst:1024 +#: ../../library/configparser.rst:1068 msgid "" "Add a section named *section* to the instance. If a section by the given " "name already exists, :exc:`DuplicateSectionError` is raised. If the " @@ -1409,34 +1513,34 @@ msgid "" "the section must be a string; if not, :exc:`TypeError` is raised." msgstr "" -#: ../../library/configparser.rst:1029 +#: ../../library/configparser.rst:1073 msgid "Non-string section names raise :exc:`TypeError`." msgstr "" -#: ../../library/configparser.rst:1035 +#: ../../library/configparser.rst:1079 msgid "" "Indicates whether the named *section* is present in the configuration. The " "*default section* is not acknowledged." msgstr "" -#: ../../library/configparser.rst:1041 +#: ../../library/configparser.rst:1085 msgid "Return a list of options available in the specified *section*." msgstr "" -#: ../../library/configparser.rst:1046 +#: ../../library/configparser.rst:1090 msgid "" -"If the given *section* exists, and contains the given *option*, return :" -"const:`True`; otherwise return :const:`False`. If the specified *section* " -"is :const:`None` or an empty string, DEFAULT is assumed." +"If the given *section* exists, and contains the given *option*, " +"return :const:`True`; otherwise return :const:`False`. If the specified " +"*section* is :const:`None` or an empty string, DEFAULT is assumed." msgstr "" -#: ../../library/configparser.rst:1053 +#: ../../library/configparser.rst:1097 msgid "" "Attempt to read and parse an iterable of filenames, returning a list of " "filenames which were successfully parsed." msgstr "" -#: ../../library/configparser.rst:1056 +#: ../../library/configparser.rst:1100 msgid "" "If *filenames* is a string, a :class:`bytes` object or a :term:`path-like " "object`, it is treated as a single filename. If a file named in *filenames* " @@ -1447,15 +1551,15 @@ msgid "" "be read." msgstr "" -#: ../../library/configparser.rst:1065 +#: ../../library/configparser.rst:1109 msgid "" "If none of the named files exist, the :class:`ConfigParser` instance will " "contain an empty dataset. An application which requires initial values to " -"be loaded from a file should load the required file or files using :meth:" -"`read_file` before calling :meth:`read` for any optional files::" +"be loaded from a file should load the required file or files " +"using :meth:`read_file` before calling :meth:`read` for any optional files::" msgstr "" -#: ../../library/configparser.rst:1071 +#: ../../library/configparser.rst:1115 msgid "" "import configparser, os\n" "\n" @@ -1471,49 +1575,49 @@ msgstr "" "config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')],\n" " encoding='cp1250')" -#: ../../library/configparser.rst:1078 +#: ../../library/configparser.rst:1122 msgid "" "Added the *encoding* parameter. Previously, all files were read using the " "default encoding for :func:`open`." msgstr "" -#: ../../library/configparser.rst:1082 +#: ../../library/configparser.rst:1126 msgid "The *filenames* parameter accepts a :term:`path-like object`." msgstr "" -#: ../../library/configparser.rst:1085 +#: ../../library/configparser.rst:1129 msgid "The *filenames* parameter accepts a :class:`bytes` object." msgstr "" -#: ../../library/configparser.rst:1091 +#: ../../library/configparser.rst:1135 msgid "" "Read and parse configuration data from *f* which must be an iterable " "yielding Unicode strings (for example files opened in text mode)." msgstr "" -#: ../../library/configparser.rst:1094 +#: ../../library/configparser.rst:1138 msgid "" "Optional argument *source* specifies the name of the file being read. If " "not given and *f* has a :attr:`!name` attribute, that is used for *source*; " "the default is ``''``." msgstr "" -#: ../../library/configparser.rst:1098 +#: ../../library/configparser.rst:1142 msgid "Replaces :meth:`!readfp`." msgstr "取代 :meth:`!readfp`。" -#: ../../library/configparser.rst:1103 +#: ../../library/configparser.rst:1147 msgid "Parse configuration data from a string." msgstr "" -#: ../../library/configparser.rst:1105 +#: ../../library/configparser.rst:1149 msgid "" "Optional argument *source* specifies a context-specific name of the string " "passed. If not given, ``''`` is used. This should commonly be a " "filesystem path or a URL." msgstr "" -#: ../../library/configparser.rst:1114 +#: ../../library/configparser.rst:1158 msgid "" "Load configuration from any object that provides a dict-like ``items()`` " "method. Keys are section names, values are dictionaries with keys and " @@ -1522,17 +1626,17 @@ msgid "" "automatically converted to strings." msgstr "" -#: ../../library/configparser.rst:1120 +#: ../../library/configparser.rst:1164 msgid "" "Optional argument *source* specifies a context-specific name of the " "dictionary passed. If not given, ```` is used." msgstr "" -#: ../../library/configparser.rst:1123 +#: ../../library/configparser.rst:1167 msgid "This method can be used to copy state between parsers." msgstr "" -#: ../../library/configparser.rst:1130 +#: ../../library/configparser.rst:1174 msgid "" "Get an *option* value for the named *section*. If *vars* is provided, it " "must be a dictionary. The *option* is looked up in *vars* (if provided), " @@ -1541,74 +1645,74 @@ msgid "" "provided as a *fallback* value." msgstr "" -#: ../../library/configparser.rst:1136 +#: ../../library/configparser.rst:1180 msgid "" "All the ``'%'`` interpolations are expanded in the return values, unless the " "*raw* argument is true. Values for interpolation keys are looked up in the " "same manner as the option." msgstr "" -#: ../../library/configparser.rst:1140 +#: ../../library/configparser.rst:1184 msgid "" "Arguments *raw*, *vars* and *fallback* are keyword only to protect users " "from trying to use the third argument as the *fallback* fallback (especially " "when using the mapping protocol)." msgstr "" -#: ../../library/configparser.rst:1148 +#: ../../library/configparser.rst:1192 msgid "" "A convenience method which coerces the *option* in the specified *section* " "to an integer. See :meth:`get` for explanation of *raw*, *vars* and " "*fallback*." msgstr "" -#: ../../library/configparser.rst:1155 +#: ../../library/configparser.rst:1199 msgid "" "A convenience method which coerces the *option* in the specified *section* " "to a floating-point number. See :meth:`get` for explanation of *raw*, " "*vars* and *fallback*." msgstr "" -#: ../../library/configparser.rst:1162 +#: ../../library/configparser.rst:1206 msgid "" "A convenience method which coerces the *option* in the specified *section* " "to a Boolean value. Note that the accepted values for the option are " "``'1'``, ``'yes'``, ``'true'``, and ``'on'``, which cause this method to " "return ``True``, and ``'0'``, ``'no'``, ``'false'``, and ``'off'``, which " "cause it to return ``False``. These string values are checked in a case-" -"insensitive manner. Any other value will cause it to raise :exc:" -"`ValueError`. See :meth:`get` for explanation of *raw*, *vars* and " -"*fallback*." +"insensitive manner. Any other value will cause it to " +"raise :exc:`ValueError`. See :meth:`get` for explanation of *raw*, *vars* " +"and *fallback*." msgstr "" -#: ../../library/configparser.rst:1175 +#: ../../library/configparser.rst:1219 msgid "" "When *section* is not given, return a list of *section_name*, " "*section_proxy* pairs, including DEFAULTSECT." msgstr "" -#: ../../library/configparser.rst:1178 +#: ../../library/configparser.rst:1222 msgid "" "Otherwise, return a list of *name*, *value* pairs for the options in the " -"given *section*. Optional arguments have the same meaning as for the :meth:" -"`get` method." +"given *section*. Optional arguments have the same meaning as for " +"the :meth:`get` method." msgstr "" -#: ../../library/configparser.rst:1182 +#: ../../library/configparser.rst:1226 msgid "" "Items present in *vars* no longer appear in the result. The previous " "behaviour mixed actual parser options with variables provided for " "interpolation." msgstr "" -#: ../../library/configparser.rst:1190 +#: ../../library/configparser.rst:1234 msgid "" "If the given section exists, set the given option to the specified value; " "otherwise raise :exc:`NoSectionError`. *option* and *value* must be " "strings; if not, :exc:`TypeError` is raised." msgstr "" -#: ../../library/configparser.rst:1197 +#: ../../library/configparser.rst:1241 msgid "" "Write a representation of the configuration to the specified :term:`file " "object`, which must be opened in text mode (accepting strings). This " @@ -1617,27 +1721,27 @@ msgid "" "surrounded by spaces." msgstr "" -#: ../../library/configparser.rst:1205 +#: ../../library/configparser.rst:1249 msgid "" "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*." msgstr "" -#: ../../library/configparser.rst:1213 +#: ../../library/configparser.rst:1257 msgid "" "Remove the specified *option* from the specified *section*. If the section " "does not exist, raise :exc:`NoSectionError`. If the option existed to be " "removed, return :const:`True`; otherwise return :const:`False`." msgstr "" -#: ../../library/configparser.rst:1221 +#: ../../library/configparser.rst:1265 msgid "" "Remove the specified *section* from the configuration. If the section in " "fact existed, return ``True``. Otherwise return ``False``." msgstr "" -#: ../../library/configparser.rst:1227 +#: ../../library/configparser.rst:1271 msgid "" "Transforms the option name *option* as found in an input file or as passed " "in by client code to the form that should be used in the internal " @@ -1646,7 +1750,7 @@ msgid "" "of this name on instances to affect this behavior." msgstr "" -#: ../../library/configparser.rst:1233 +#: ../../library/configparser.rst:1277 msgid "" "You don't need to subclass the parser to use this method, you can also set " "it on an instance, to a function that takes a string argument and returns a " @@ -1654,7 +1758,7 @@ msgid "" "sensitive::" msgstr "" -#: ../../library/configparser.rst:1238 +#: ../../library/configparser.rst:1282 msgid "" "cfgparser = ConfigParser()\n" "cfgparser.optionxform = str" @@ -1662,24 +1766,30 @@ msgstr "" "cfgparser = ConfigParser()\n" "cfgparser.optionxform = str" -#: ../../library/configparser.rst:1241 +#: ../../library/configparser.rst:1285 msgid "" "Note that when reading configuration files, whitespace around the option " "names is stripped before :meth:`optionxform` is called." msgstr "" -#: ../../library/configparser.rst:1247 +#: ../../library/configparser.rst:1291 +msgid "" +"A special object representing a section name used to reference the unnamed " +"section (see :ref:`unnamed-sections`)." +msgstr "" + +#: ../../library/configparser.rst:1296 msgid "" -"The maximum depth for recursive interpolation for :meth:`~configparser." -"ConfigParser.get` when the *raw* parameter is false. This is relevant only " -"when the default *interpolation* is used." +"The maximum depth for recursive interpolation " +"for :meth:`~configparser.ConfigParser.get` when the *raw* parameter is " +"false. This is relevant only when the default *interpolation* is used." msgstr "" -#: ../../library/configparser.rst:1255 +#: ../../library/configparser.rst:1304 msgid "RawConfigParser Objects" msgstr "RawConfigParser 物件" -#: ../../library/configparser.rst:1265 +#: ../../library/configparser.rst:1315 msgid "" "Legacy variant of the :class:`ConfigParser`. It has interpolation disabled " "by default and allows for non-string section names, option names, and values " @@ -1687,37 +1797,37 @@ msgid "" "``defaults=`` keyword argument handling." msgstr "" -#: ../../library/configparser.rst:1275 +#: ../../library/configparser.rst:1336 msgid "" "Consider using :class:`ConfigParser` instead which checks types of the " "values to be stored internally. If you don't want interpolation, you can " "use ``ConfigParser(interpolation=None)``." msgstr "" -#: ../../library/configparser.rst:1282 +#: ../../library/configparser.rst:1343 msgid "" "Add a section named *section* to the instance. If a section by the given " "name already exists, :exc:`DuplicateSectionError` is raised. If the " "*default section* name is passed, :exc:`ValueError` is raised." msgstr "" -#: ../../library/configparser.rst:1286 +#: ../../library/configparser.rst:1347 msgid "" "Type of *section* is not checked which lets users create non-string named " "sections. This behaviour is unsupported and may cause internal errors." msgstr "" -#: ../../library/configparser.rst:1292 +#: ../../library/configparser.rst:1353 msgid "" "If the given section exists, set the given option to the specified value; " -"otherwise raise :exc:`NoSectionError`. While it is possible to use :class:" -"`RawConfigParser` (or :class:`ConfigParser` with *raw* parameters set to " -"true) for *internal* storage of non-string values, full functionality " +"otherwise raise :exc:`NoSectionError`. While it is possible to " +"use :class:`RawConfigParser` (or :class:`ConfigParser` with *raw* parameters " +"set to true) for *internal* storage of non-string values, full functionality " "(including interpolation and output to files) can only be achieved using " "string values." msgstr "" -#: ../../library/configparser.rst:1299 +#: ../../library/configparser.rst:1360 msgid "" "This method lets users assign non-string values to keys internally. This " "behaviour is unsupported and will cause errors when attempting to write to a " @@ -1725,32 +1835,32 @@ msgid "" "not allow such assignments to take place." msgstr "" -#: ../../library/configparser.rst:1306 +#: ../../library/configparser.rst:1367 msgid "Exceptions" msgstr "例外" -#: ../../library/configparser.rst:1310 +#: ../../library/configparser.rst:1371 msgid "Base class for all other :mod:`configparser` exceptions." msgstr "" -#: ../../library/configparser.rst:1315 +#: ../../library/configparser.rst:1376 msgid "Exception raised when a specified section is not found." msgstr "" -#: ../../library/configparser.rst:1320 +#: ../../library/configparser.rst:1381 msgid "" "Exception raised if :meth:`~ConfigParser.add_section` is called with the " "name of a section that is already present or in strict parsers when a " "section if found more than once in a single input file, string or dictionary." msgstr "" -#: ../../library/configparser.rst:1324 +#: ../../library/configparser.rst:1385 msgid "" -"Added the optional *source* and *lineno* attributes and parameters to :meth:" -"`!__init__`." +"Added the optional *source* and *lineno* attributes and parameters " +"to :meth:`!__init__`." msgstr "" -#: ../../library/configparser.rst:1331 +#: ../../library/configparser.rst:1392 msgid "" "Exception raised by strict parsers if a single option appears twice during " "reading from a single file, string or dictionary. This catches misspellings " @@ -1758,58 +1868,64 @@ msgid "" "representing the same case-insensitive configuration key." msgstr "" -#: ../../library/configparser.rst:1339 +#: ../../library/configparser.rst:1400 msgid "" "Exception raised when a specified option is not found in the specified " "section." msgstr "" -#: ../../library/configparser.rst:1345 +#: ../../library/configparser.rst:1406 msgid "" "Base class for exceptions raised when problems occur performing string " "interpolation." msgstr "" -#: ../../library/configparser.rst:1351 +#: ../../library/configparser.rst:1412 msgid "" "Exception raised when string interpolation cannot be completed because the " -"number of iterations exceeds :const:`MAX_INTERPOLATION_DEPTH`. Subclass of :" -"exc:`InterpolationError`." +"number of iterations exceeds :const:`MAX_INTERPOLATION_DEPTH`. Subclass " +"of :exc:`InterpolationError`." msgstr "" -#: ../../library/configparser.rst:1358 +#: ../../library/configparser.rst:1419 msgid "" "Exception raised when an option referenced from a value does not exist. " "Subclass of :exc:`InterpolationError`." msgstr "" -#: ../../library/configparser.rst:1364 +#: ../../library/configparser.rst:1425 msgid "" "Exception raised when the source text into which substitutions are made does " "not conform to the required syntax. Subclass of :exc:`InterpolationError`." msgstr "" -#: ../../library/configparser.rst:1370 +#: ../../library/configparser.rst:1431 msgid "" "Exception raised when attempting to parse a file which has no section " "headers." msgstr "" -#: ../../library/configparser.rst:1376 +#: ../../library/configparser.rst:1437 msgid "Exception raised when errors occur attempting to parse a file." msgstr "" -#: ../../library/configparser.rst:1378 +#: ../../library/configparser.rst:1439 msgid "" "The ``filename`` attribute and :meth:`!__init__` constructor argument were " "removed. They have been available using the name ``source`` since 3.2." msgstr "" -#: ../../library/configparser.rst:1383 +#: ../../library/configparser.rst:1445 +msgid "" +"Exception raised when a key without a corresponding value is continued with " +"an indented line." +msgstr "" + +#: ../../library/configparser.rst:1451 msgid "Footnotes" -msgstr "註解" +msgstr "註腳" -#: ../../library/configparser.rst:1384 +#: ../../library/configparser.rst:1452 msgid "" "Config parsers allow for heavy customization. If you are interested in " "changing the behaviour outlined by the footnote reference, consult the " @@ -1836,14 +1952,14 @@ msgstr "ini file(ini 檔案)" msgid "Windows ini file" msgstr "Windows ini file(Windows ini 檔案)" -#: ../../library/configparser.rst:340 +#: ../../library/configparser.rst:367 msgid "% (percent)" msgstr "% (百分號)" -#: ../../library/configparser.rst:340 ../../library/configparser.rst:373 +#: ../../library/configparser.rst:367 ../../library/configparser.rst:400 msgid "interpolation in configuration files" msgstr "interpolation in configuration files(設定檔中的插值)" -#: ../../library/configparser.rst:373 +#: ../../library/configparser.rst:400 msgid "$ (dollar)" msgstr "$ (金錢符號)" diff --git a/library/constants.po b/library/constants.po index 4c7fe0034e..1d80e5ff7c 100644 --- a/library/constants.po +++ b/library/constants.po @@ -7,9 +7,9 @@ # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-07 03:11+0800\n" +"POT-Creation-Date: 2025-03-04 00:14+0000\n" "PO-Revision-Date: 2021-11-19 23:36+0800\n" "Last-Translator: Jordan Su \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -59,21 +59,22 @@ msgstr "" #: ../../library/constants.rst:30 msgid "" -"A special value which should be returned by the binary special methods (e." -"g. :meth:`~object.__eq__`, :meth:`~object.__lt__`, :meth:`~object.__add__`, :" -"meth:`~object.__rsub__`, etc.) to indicate that the operation is not " -"implemented with respect to the other type; may be returned by the in-place " -"binary special methods (e.g. :meth:`~object.__imul__`, :meth:`~object." -"__iand__`, etc.) for the same purpose. It should not be evaluated in a " -"boolean context. :data:`!NotImplemented` is the sole instance of the :data:" -"`types.NotImplementedType` type." +"A special value which should be returned by the binary special methods " +"(e.g. :meth:`~object.__eq__`, :meth:`~object.__lt__`, :meth:`~object.__add__`, :meth:`~object.__rsub__`, " +"etc.) to indicate that the operation is not implemented with respect to the " +"other type; may be returned by the in-place binary special methods " +"(e.g. :meth:`~object.__imul__`, :meth:`~object.__iand__`, etc.) for the same " +"purpose. It should not be evaluated in a boolean context. :data:`!" +"NotImplemented` is the sole instance of the :data:`types.NotImplementedType` " +"type." msgstr "" -"會被二元特殊方法 (binary special methods)(如::meth:`~object.__eq__`、:meth:" -"`~object.__lt__`、:meth:`~object.__add__`、:meth:`~object.__rsub__` 等)所回" -"傳的特殊值,代表著該運算沒有針對其他型別的實作。同理也可以被原地二元特殊方法 " -"(in-place binary special methods) (如::meth:`~object.__imul__`、:meth:" -"`~object.__iand__` 等)回傳。它不應該被作為 boolean(布林)來解讀。:data:`!" -"NotImplemented` 是型別 :data:`types.NotImplementedType` 的唯一實例。" +"會被二元特殊方法 (binary special methods)" +"(如::meth:`~object.__eq__`、:meth:`~object.__lt__`、:meth:`~object.__add__`、:meth:`~object.__rsub__` " +"等)所回傳的特殊值,代表著該運算沒有針對其他型別的實作。同理也可以被原地二元" +"特殊方法 (in-place binary special methods) " +"(如::meth:`~object.__imul__`、:meth:`~object.__iand__` 等)回傳。它不應該被" +"作為 boolean(布林)來解讀。:data:`!NotImplemented` 是型" +"別 :data:`types.NotImplementedType` 的唯一實例。" #: ../../library/constants.rst:40 msgid "" @@ -86,7 +87,7 @@ msgid "" "code." msgstr "" "當一個二元 (binary) 或原地 (in-place) 方法回傳 :data:`!NotImplemented`,直譯" -"器會嘗試反映該操作到其他型別(或是其他後援 (fallback),取決於是哪種運算子)。" +"器會嘗試反映該操作到其他型別(或是其他後備 (fallback),取決於是哪種運算子)。" "如果所有的常識都回傳 :data:`!NotImplemented`,直譯器會拋出適當的例外。不正確" "的回傳 :data:`!NotImplemented` 會造成誤導的錯誤訊息或是 :data:`!" "NotImplemented` 值被傳回到 Python 程式碼中。" @@ -97,15 +98,15 @@ msgstr "請參見 :ref:`implementing-the-arithmetic-operations` 以找到更多 #: ../../library/constants.rst:51 msgid "" -"``NotImplementedError`` and :data:`!NotImplemented` are not interchangeable, " -"even though they have similar names and purposes. See :exc:" -"`NotImplementedError` for details on when to use it." +":data:`!NotImplemented` and :exc:`!NotImplementedError` are not " +"interchangeable. This constant should only be used as described above; " +"see :exc:`NotImplementedError` for details on correct usage of the exception." msgstr "" -"``NotImplementedError`` 與 :data:`!NotImplemented` 並不一樣且不可互換。即使它" -"們有相似的名稱與用途。欲知更多如何使用它們的細節,請參見 :exc:" -"`NotImplementedError`。" +":data:`!NotImplemented` 與 :exc:`!NotImplementedError` 並不一樣且不可互換。這" +"個常數只能用於上述的情況;欲知更多如何正確使用它們的細節,請參" +"見 :exc:`NotImplementedError`。" -#: ../../library/constants.rst:55 +#: ../../library/constants.rst:56 msgid "" "Evaluating :data:`!NotImplemented` in a boolean context is deprecated. While " "it currently evaluates as true, it will emit a :exc:`DeprecationWarning`. It " @@ -115,7 +116,7 @@ msgstr "" "被解讀成 true,但會發出一個 :exc:`DeprecationWarning`。在未來版本的 Python 將" "會拋出 :exc:`TypeError`。" -#: ../../library/constants.rst:64 +#: ../../library/constants.rst:65 msgid "" "The same as the ellipsis literal \"``...``\". Special value used mostly in " "conjunction with extended slicing syntax for user-defined container data " @@ -123,32 +124,32 @@ msgid "" "type." msgstr "" "與刪節號 \"``...``\" 字面相同。為一特殊值,大多用於結合使用者定義資料型別的延" -"伸切片語法 (extended slicing syntax)。``Ellipsis`` 是型別 :data:`types." -"EllipsisType` 的唯一實例。" +"伸切片語法 (extended slicing syntax)。``Ellipsis`` 是型" +"別 :data:`types.EllipsisType` 的唯一實例。" -#: ../../library/constants.rst:71 +#: ../../library/constants.rst:72 msgid "" "This constant is true if Python was not started with an :option:`-O` option. " "See also the :keyword:`assert` statement." msgstr "" -"如果 Python 沒有被以 :option:`-O` 選項啟動,則此常數為 true。請參見 :keyword:" -"`assert` 陳述式。" +"如果 Python 沒有被以 :option:`-O` 選項啟動,則此常數為 true。請參" +"見 :keyword:`assert` 陳述式。" -#: ../../library/constants.rst:77 +#: ../../library/constants.rst:78 msgid "" "The names :data:`None`, :data:`False`, :data:`True` and :data:`__debug__` " -"cannot be reassigned (assignments to them, even as an attribute name, raise :" -"exc:`SyntaxError`), so they can be considered \"true\" constants." +"cannot be reassigned (assignments to them, even as an attribute name, " +"raise :exc:`SyntaxError`), so they can be considered \"true\" constants." msgstr "" ":data:`None`,:data:`False`,:data:`True`,以及 :data:`__debug__` 都是不能被" -"重新賦值的(任何對它們的賦值,即使是屬性的名稱,也會拋出 :exc:" -"`SyntaxError`)。因此,它們可以被視為”真正的”常數。" +"重新賦值的(任何對它們的賦值,即使是屬性的名稱,也會拋" +"出 :exc:`SyntaxError`)。因此,它們可以被視為”真正的”常數。" -#: ../../library/constants.rst:85 +#: ../../library/constants.rst:86 msgid "Constants added by the :mod:`site` module" msgstr "由 :mod:`site` module(模組)所添增的常數" -#: ../../library/constants.rst:87 +#: ../../library/constants.rst:88 msgid "" "The :mod:`site` module (which is imported automatically during startup, " "except if the :option:`-S` command-line option is given) adds several " @@ -159,7 +160,7 @@ msgstr "" "指令行選項)會添增一些常數到內建命名空間 (built-in namespace) 中。它們在互動" "式直譯器中是很有幫助的,但不應該在程式 (programs) 中被使用。" -#: ../../library/constants.rst:95 +#: ../../library/constants.rst:96 msgid "" "Objects that when printed, print a message like \"Use quit() or Ctrl-D (i.e. " "EOF) to exit\", and when called, raise :exc:`SystemExit` with the specified " @@ -168,23 +169,23 @@ msgstr "" "當印出物件時,會印出一個訊息: \"Use quit() or Ctrl-D (i.e. EOF) to exit\" 。" "當被呼叫時,則會拋出 :exc:`SystemExit` 並帶有指定的返回碼(exit code)。" -#: ../../library/constants.rst:102 +#: ../../library/constants.rst:103 msgid "" "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 :func:`elsewhere `." msgstr "" "當印出此物件時,會印出訊息 \"Type help() for interactive help, or " -"help(object) for help about object.\",並在呼叫時按所述的方式操作 :func:" -"`elsewhere `。" +"help(object) for help about object.\",並在呼叫時按所述的方式操" +"作 :func:`elsewhere `。" -#: ../../library/constants.rst:109 +#: ../../library/constants.rst:110 msgid "" "Objects that when printed or called, print the text of copyright or credits, " "respectively." msgstr "當印出或是呼叫此物件時,分別會印出版權與致謝的文字。" -#: ../../library/constants.rst:114 +#: ../../library/constants.rst:115 msgid "" "Object that when printed, prints the message \"Type license() to see the " "full license text\", and when called, displays the full license text in a " @@ -193,10 +194,10 @@ msgstr "" "當印出此物件時,會印出訊息 \"Type license() to see the full license text\"," "並在呼叫時以分頁形式印出完整的許可證文字(一次一整個畫面)。" -#: ../../library/constants.rst:61 +#: ../../library/constants.rst:62 msgid "..." msgstr "..." -#: ../../library/constants.rst:61 +#: ../../library/constants.rst:62 msgid "ellipsis literal" msgstr "ellipsis literal(刪節號)" diff --git a/library/contextlib.po b/library/contextlib.po index be7d46b7e0..a7be4735e6 100644 --- a/library/contextlib.po +++ b/library/contextlib.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-04-11 00:15+0000\n" "PO-Revision-Date: 2018-05-23 14:41+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,7 +21,7 @@ msgstr "" #: ../../library/contextlib.rst:2 msgid "" ":mod:`!contextlib` --- Utilities for :keyword:`!with`\\ -statement contexts" -msgstr "" +msgstr ":mod:`!contextlib` --- :keyword:`!with` 陳述式工具程式" #: ../../library/contextlib.rst:7 msgid "**Source code:** :source:`Lib/contextlib.py`" @@ -29,9 +29,9 @@ msgstr "**原始碼:**\\ :source:`Lib/contextlib.py`" #: ../../library/contextlib.rst:11 msgid "" -"This module provides utilities for common tasks involving the :keyword:" -"`with` statement. For more information see also :ref:`typecontextmanager` " -"and :ref:`context-managers`." +"This module provides utilities for common tasks involving " +"the :keyword:`with` statement. For more information see " +"also :ref:`typecontextmanager` and :ref:`context-managers`." msgstr "" #: ../../library/contextlib.rst:17 @@ -44,36 +44,38 @@ msgstr "" #: ../../library/contextlib.rst:23 msgid "" -"An :term:`abstract base class` for classes that implement :meth:`object." -"__enter__` and :meth:`object.__exit__`. A default implementation for :meth:" -"`object.__enter__` is provided which returns ``self`` while :meth:`object." -"__exit__` is an abstract method which by default returns ``None``. See also " -"the definition of :ref:`typecontextmanager`." +"An :term:`abstract base class` for classes that " +"implement :meth:`object.__enter__` and :meth:`object.__exit__`. A default " +"implementation for :meth:`object.__enter__` is provided which returns " +"``self`` while :meth:`object.__exit__` is an abstract method which by " +"default returns ``None``. See also the definition " +"of :ref:`typecontextmanager`." msgstr "" #: ../../library/contextlib.rst:34 msgid "" -"An :term:`abstract base class` for classes that implement :meth:`object." -"__aenter__` and :meth:`object.__aexit__`. A default implementation for :meth:" -"`object.__aenter__` is provided which returns ``self`` while :meth:`object." -"__aexit__` is an abstract method which by default returns ``None``. See also " -"the definition of :ref:`async-context-managers`." +"An :term:`abstract base class` for classes that " +"implement :meth:`object.__aenter__` and :meth:`object.__aexit__`. A default " +"implementation for :meth:`object.__aenter__` is provided which returns " +"``self`` while :meth:`object.__aexit__` is an abstract method which by " +"default returns ``None``. See also the definition of :ref:`async-context-" +"managers`." msgstr "" #: ../../library/contextlib.rst:46 msgid "" "This function is a :term:`decorator` that can be used to define a factory " "function for :keyword:`with` statement context managers, without needing to " -"create a class or separate :meth:`~object.__enter__` and :meth:`~object." -"__exit__` methods." +"create a class or separate :meth:`~object.__enter__` " +"and :meth:`~object.__exit__` methods." msgstr "" #: ../../library/contextlib.rst:50 msgid "" "While many objects natively support use in with statements, sometimes a " "resource needs to be managed that isn't a context manager in its own right, " -"and doesn't implement a ``close()`` method for use with ``contextlib." -"closing``" +"and doesn't implement a ``close()`` method for use with " +"``contextlib.closing``." msgstr "" #: ../../library/contextlib.rst:54 @@ -117,18 +119,18 @@ msgstr "" #: ../../library/contextlib.rst:79 msgid "" -"At the point where the generator yields, the block nested in the :keyword:" -"`with` statement is executed. The generator is then resumed after the block " -"is exited. If an unhandled exception occurs in the block, it is reraised " -"inside the generator at the point where the yield occurred. Thus, you can " -"use a :keyword:`try`...\\ :keyword:`except`...\\ :keyword:`finally` " -"statement to trap the error (if any), or ensure that some cleanup takes " -"place. If an exception is trapped merely in order to log it or to perform " -"some action (rather than to suppress it entirely), the generator must " -"reraise that exception. Otherwise the generator context manager will " -"indicate to the :keyword:`!with` statement that the exception has been " -"handled, and execution will resume with the statement immediately following " -"the :keyword:`!with` statement." +"At the point where the generator yields, the block nested in " +"the :keyword:`with` statement is executed. The generator is then resumed " +"after the block is exited. If an unhandled exception occurs in the block, it " +"is reraised inside the generator at the point where the yield occurred. " +"Thus, you can use a :keyword:`try`...\\ :keyword:`except`..." +"\\ :keyword:`finally` statement to trap the error (if any), or ensure that " +"some cleanup takes place. If an exception is trapped merely in order to log " +"it or to perform some action (rather than to suppress it entirely), the " +"generator must reraise that exception. Otherwise the generator context " +"manager will indicate to the :keyword:`!with` statement that the exception " +"has been handled, and execution will resume with the statement immediately " +"following the :keyword:`!with` statement." msgstr "" #: ../../library/contextlib.rst:91 @@ -148,8 +150,8 @@ msgstr "" #: ../../library/contextlib.rst:104 msgid "" -"Similar to :func:`~contextlib.contextmanager`, but creates an :ref:" -"`asynchronous context manager `." +"Similar to :func:`~contextlib.contextmanager`, but creates " +"an :ref:`asynchronous context manager `." msgstr "" #: ../../library/contextlib.rst:107 @@ -157,8 +159,8 @@ msgid "" "This function is a :term:`decorator` that can be used to define a factory " "function for :keyword:`async with` statement asynchronous context managers, " "without needing to create a class or separate :meth:`~object.__aenter__` " -"and :meth:`~object.__aexit__` methods. It must be applied to an :term:" -"`asynchronous generator` function." +"and :meth:`~object.__aexit__` methods. It must be applied to " +"an :term:`asynchronous generator` function." msgstr "" #: ../../library/contextlib.rst:113 @@ -288,10 +290,11 @@ msgstr "" #: ../../library/contextlib.rst:187 msgid "" "Most types managing resources support the :term:`context manager` protocol, " -"which closes *thing* on leaving the :keyword:`with` statement. As such, :" -"func:`!closing` is most useful for third party types that don't support " -"context managers. This example is purely for illustration purposes, as :func:" -"`~urllib.request.urlopen` would normally be used in a context manager." +"which closes *thing* on leaving the :keyword:`with` statement. As " +"such, :func:`!closing` is most useful for third party types that don't " +"support context managers. This example is purely for illustration purposes, " +"as :func:`~urllib.request.urlopen` would normally be used in a context " +"manager." msgstr "" #: ../../library/contextlib.rst:196 @@ -484,17 +487,17 @@ msgstr "" #: ../../library/contextlib.rst:315 msgid "" -"If the code within the :keyword:`!with` block raises a :exc:" -"`BaseExceptionGroup`, suppressed exceptions are removed from the group. Any " -"exceptions of the group which are not suppressed are re-raised in a new " -"group which is created using the original group's :meth:`~BaseExceptionGroup." -"derive` method." +"If the code within the :keyword:`!with` block raises " +"a :exc:`BaseExceptionGroup`, 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 :meth:`~BaseExceptionGroup.derive` method." msgstr "" #: ../../library/contextlib.rst:323 msgid "" -"``suppress`` now supports suppressing exceptions raised as part of a :exc:" -"`BaseExceptionGroup`." +"``suppress`` now supports suppressing exceptions raised as part of " +"a :exc:`BaseExceptionGroup`." msgstr "" #: ../../library/contextlib.rst:329 @@ -512,10 +515,10 @@ msgstr "" #: ../../library/contextlib.rst:335 msgid "" "For example, the output of :func:`help` normally is sent to *sys.stdout*. " -"You can capture that output in a string by redirecting the output to an :" -"class:`io.StringIO` object. The replacement stream is returned from the " -"``__enter__`` method and so is available as the target of the :keyword:" -"`with` statement::" +"You can capture that output in a string by redirecting the output to " +"an :class:`io.StringIO` object. The replacement stream is returned from the " +"``__enter__`` method and so is available as the target of " +"the :keyword:`with` statement::" msgstr "" #: ../../library/contextlib.rst:341 @@ -566,8 +569,8 @@ msgstr "" #: ../../library/contextlib.rst:369 msgid "" -"Similar to :func:`~contextlib.redirect_stdout` but redirecting :data:`sys." -"stderr` to another file or file-like object." +"Similar to :func:`~contextlib.redirect_stdout` but " +"redirecting :data:`sys.stderr` to another file or file-like object." msgstr "" #: ../../library/contextlib.rst:379 @@ -895,15 +898,16 @@ msgstr "" #: ../../library/contextlib.rst:571 msgid "" "As ``__enter__`` is *not* invoked, this method can be used to cover part of " -"an :meth:`~object.__enter__` implementation with a context manager's own :" -"meth:`~object.__exit__` method." +"an :meth:`~object.__enter__` implementation with a context manager's " +"own :meth:`~object.__exit__` method." msgstr "" #: ../../library/contextlib.rst:575 msgid "" "If passed an object that is not a context manager, this method assumes it is " -"a callback with the same signature as a context manager's :meth:`~object." -"__exit__` method and adds it directly to the callback stack." +"a callback with the same signature as a context " +"manager's :meth:`~object.__exit__` method and adds it directly to the " +"callback stack." msgstr "" #: ../../library/contextlib.rst:579 @@ -971,9 +975,10 @@ msgstr "" #: ../../library/contextlib.rst:624 msgid "" -"An :ref:`asynchronous context manager `, similar to :" -"class:`ExitStack`, that supports combining both synchronous and asynchronous " -"context managers, as well as having coroutines for cleanup logic." +"An :ref:`asynchronous context manager `, similar " +"to :class:`ExitStack`, that supports combining both synchronous and " +"asynchronous context managers, as well as having coroutines for cleanup " +"logic." msgstr "" #: ../../library/contextlib.rst:629 @@ -982,37 +987,37 @@ msgid "" "be used instead." msgstr "" -#: ../../library/contextlib.rst:634 +#: ../../library/contextlib.rst:635 msgid "" "Similar to :meth:`ExitStack.enter_context` but expects an asynchronous " "context manager." msgstr "" -#: ../../library/contextlib.rst:637 +#: ../../library/contextlib.rst:638 msgid "" "Raises :exc:`TypeError` instead of :exc:`AttributeError` if *cm* is not an " "asynchronous context manager." msgstr "" -#: ../../library/contextlib.rst:643 +#: ../../library/contextlib.rst:644 msgid "" "Similar to :meth:`ExitStack.push` but expects either an asynchronous context " "manager or a coroutine function." msgstr "" -#: ../../library/contextlib.rst:648 +#: ../../library/contextlib.rst:649 msgid "Similar to :meth:`ExitStack.callback` but expects a coroutine function." msgstr "" -#: ../../library/contextlib.rst:652 +#: ../../library/contextlib.rst:654 msgid "Similar to :meth:`ExitStack.close` but properly handles awaitables." msgstr "" -#: ../../library/contextlib.rst:654 +#: ../../library/contextlib.rst:656 msgid "Continuing the example for :func:`asynccontextmanager`::" msgstr "" -#: ../../library/contextlib.rst:656 +#: ../../library/contextlib.rst:658 msgid "" "async with AsyncExitStack() as stack:\n" " connections = [await stack.enter_async_context(get_connection())\n" @@ -1022,21 +1027,21 @@ msgid "" " # later in the list raise an exception." msgstr "" -#: ../../library/contextlib.rst:666 +#: ../../library/contextlib.rst:668 msgid "Examples and Recipes" msgstr "" -#: ../../library/contextlib.rst:668 +#: ../../library/contextlib.rst:670 msgid "" "This section describes some examples and recipes for making effective use of " "the tools provided by :mod:`contextlib`." msgstr "" -#: ../../library/contextlib.rst:673 +#: ../../library/contextlib.rst:675 msgid "Supporting a variable number of context managers" msgstr "" -#: ../../library/contextlib.rst:675 +#: ../../library/contextlib.rst:677 msgid "" "The primary use case for :class:`ExitStack` is the one given in the class " "documentation: supporting a variable number of context managers and other " @@ -1046,7 +1051,7 @@ msgid "" "of the context managers being optional::" msgstr "" -#: ../../library/contextlib.rst:682 +#: ../../library/contextlib.rst:684 msgid "" "with ExitStack() as stack:\n" " for resource in resources:\n" @@ -1057,27 +1062,27 @@ msgid "" " # Perform operations that use the acquired resources" msgstr "" -#: ../../library/contextlib.rst:690 +#: ../../library/contextlib.rst:692 msgid "" "As shown, :class:`ExitStack` also makes it quite easy to use :keyword:`with` " "statements to manage arbitrary resources that don't natively support the " "context management protocol." msgstr "" -#: ../../library/contextlib.rst:696 +#: ../../library/contextlib.rst:698 msgid "Catching exceptions from ``__enter__`` methods" msgstr "" -#: ../../library/contextlib.rst:698 +#: ../../library/contextlib.rst:700 msgid "" "It is occasionally desirable to catch exceptions from an ``__enter__`` " -"method implementation, *without* inadvertently catching exceptions from the :" -"keyword:`with` statement body or the context manager's ``__exit__`` method. " -"By using :class:`ExitStack` the steps in the context management protocol can " -"be separated slightly in order to allow this::" +"method implementation, *without* inadvertently catching exceptions from " +"the :keyword:`with` statement body or the context manager's ``__exit__`` " +"method. By using :class:`ExitStack` the steps in the context management " +"protocol can be separated slightly in order to allow this::" msgstr "" -#: ../../library/contextlib.rst:704 +#: ../../library/contextlib.rst:706 msgid "" "stack = ExitStack()\n" "try:\n" @@ -1089,36 +1094,36 @@ msgid "" " # Handle normal case" msgstr "" -#: ../../library/contextlib.rst:713 +#: ../../library/contextlib.rst:715 msgid "" "Actually needing to do this is likely to indicate that the underlying API " -"should be providing a direct resource management interface for use with :" -"keyword:`try`/:keyword:`except`/:keyword:`finally` statements, but not all " -"APIs are well designed in that regard. When a context manager is the only " -"resource management API provided, then :class:`ExitStack` can make it easier " -"to handle various situations that can't be handled directly in a :keyword:" -"`with` statement." +"should be providing a direct resource management interface for use " +"with :keyword:`try`/:keyword:`except`/:keyword:`finally` statements, but not " +"all APIs are well designed in that regard. When a context manager is the " +"only resource management API provided, then :class:`ExitStack` can make it " +"easier to handle various situations that can't be handled directly in " +"a :keyword:`with` statement." msgstr "" -#: ../../library/contextlib.rst:723 +#: ../../library/contextlib.rst:725 msgid "Cleaning up in an ``__enter__`` implementation" msgstr "" -#: ../../library/contextlib.rst:725 +#: ../../library/contextlib.rst:727 msgid "" "As noted in the documentation of :meth:`ExitStack.push`, this method can be " -"useful in cleaning up an already allocated resource if later steps in the :" -"meth:`~object.__enter__` implementation fail." +"useful in cleaning up an already allocated resource if later steps in " +"the :meth:`~object.__enter__` implementation fail." msgstr "" -#: ../../library/contextlib.rst:729 +#: ../../library/contextlib.rst:731 msgid "" "Here's an example of doing this for a context manager that accepts resource " "acquisition and release functions, along with an optional validation " "function, and maps them to the context management protocol::" msgstr "" -#: ../../library/contextlib.rst:733 +#: ../../library/contextlib.rst:735 msgid "" "from contextlib import contextmanager, AbstractContextManager, ExitStack\n" "\n" @@ -1156,11 +1161,11 @@ msgid "" " self.release_resource()" msgstr "" -#: ../../library/contextlib.rst:769 +#: ../../library/contextlib.rst:771 msgid "Replacing any use of ``try-finally`` and flag variables" msgstr "" -#: ../../library/contextlib.rst:771 +#: ../../library/contextlib.rst:773 msgid "" "A pattern you will sometimes see is a ``try-finally`` statement with a flag " "variable to indicate whether or not the body of the ``finally`` clause " @@ -1168,7 +1173,7 @@ msgid "" "by using an ``except`` clause instead), it looks something like this::" msgstr "" -#: ../../library/contextlib.rst:776 +#: ../../library/contextlib.rst:778 msgid "" "cleanup_needed = True\n" "try:\n" @@ -1188,21 +1193,21 @@ msgstr "" " if cleanup_needed:\n" " cleanup_resources()" -#: ../../library/contextlib.rst:785 +#: ../../library/contextlib.rst:787 msgid "" "As with any ``try`` statement based code, this can cause problems for " "development and review, because the setup code and the cleanup code can end " "up being separated by arbitrarily long sections of code." msgstr "" -#: ../../library/contextlib.rst:789 +#: ../../library/contextlib.rst:791 msgid "" ":class:`ExitStack` makes it possible to instead register a callback for " "execution at the end of a ``with`` statement, and then later decide to skip " "executing that callback::" msgstr "" -#: ../../library/contextlib.rst:793 +#: ../../library/contextlib.rst:795 msgid "" "from contextlib import ExitStack\n" "\n" @@ -1220,19 +1225,19 @@ msgstr "" " if result:\n" " stack.pop_all()" -#: ../../library/contextlib.rst:801 +#: ../../library/contextlib.rst:803 msgid "" "This allows the intended cleanup behaviour to be made explicit up front, " "rather than requiring a separate flag variable." msgstr "" -#: ../../library/contextlib.rst:804 +#: ../../library/contextlib.rst:806 msgid "" "If a particular application uses this pattern a lot, it can be simplified " "even further by means of a small helper class::" msgstr "" -#: ../../library/contextlib.rst:807 +#: ../../library/contextlib.rst:809 msgid "" "from contextlib import ExitStack\n" "\n" @@ -1264,14 +1269,14 @@ msgstr "" " if result:\n" " cb.cancel()" -#: ../../library/contextlib.rst:822 +#: ../../library/contextlib.rst:824 msgid "" "If the resource cleanup isn't already neatly bundled into a standalone " -"function, then it is still possible to use the decorator form of :meth:" -"`ExitStack.callback` to declare the resource cleanup in advance::" +"function, then it is still possible to use the decorator form " +"of :meth:`ExitStack.callback` to declare the resource cleanup in advance::" msgstr "" -#: ../../library/contextlib.rst:827 +#: ../../library/contextlib.rst:829 msgid "" "from contextlib import ExitStack\n" "\n" @@ -1293,24 +1298,24 @@ msgstr "" " if result:\n" " stack.pop_all()" -#: ../../library/contextlib.rst:837 +#: ../../library/contextlib.rst:839 msgid "" "Due to the way the decorator protocol works, a callback function declared " "this way cannot take any parameters. Instead, any resources to be released " "must be accessed as closure variables." msgstr "" -#: ../../library/contextlib.rst:843 +#: ../../library/contextlib.rst:845 msgid "Using a context manager as a function decorator" msgstr "" -#: ../../library/contextlib.rst:845 +#: ../../library/contextlib.rst:847 msgid "" ":class:`ContextDecorator` makes it possible to use a context manager in both " "an ordinary ``with`` statement and also as a function decorator." msgstr "" -#: ../../library/contextlib.rst:848 +#: ../../library/contextlib.rst:850 msgid "" "For example, it is sometimes useful to wrap functions or groups of " "statements with a logger that can track the time of entry and time of exit. " @@ -1319,7 +1324,7 @@ msgid "" "in a single definition::" msgstr "" -#: ../../library/contextlib.rst:854 +#: ../../library/contextlib.rst:856 msgid "" "from contextlib import ContextDecorator\n" "import logging\n" @@ -1351,11 +1356,11 @@ msgstr "" " def __exit__(self, exc_type, exc, exc_tb):\n" " logging.info('Exiting: %s', self.name)" -#: ../../library/contextlib.rst:869 +#: ../../library/contextlib.rst:871 msgid "Instances of this class can be used as both a context manager::" msgstr "" -#: ../../library/contextlib.rst:871 +#: ../../library/contextlib.rst:873 msgid "" "with track_entry_and_exit('widget loader'):\n" " print('Some time consuming activity goes here')\n" @@ -1365,11 +1370,11 @@ msgstr "" " print('Some time consuming activity goes here')\n" " load_widget()" -#: ../../library/contextlib.rst:875 +#: ../../library/contextlib.rst:877 msgid "And also as a function decorator::" msgstr "" -#: ../../library/contextlib.rst:877 +#: ../../library/contextlib.rst:879 msgid "" "@track_entry_and_exit('widget loader')\n" "def activity():\n" @@ -1381,29 +1386,29 @@ msgstr "" " print('Some time consuming activity goes here')\n" " load_widget()" -#: ../../library/contextlib.rst:882 +#: ../../library/contextlib.rst:884 msgid "" "Note that there is one additional limitation when using context managers as " -"function decorators: there's no way to access the return value of :meth:" -"`~object.__enter__`. If that value is needed, then it is still necessary to " -"use an explicit ``with`` statement." +"function decorators: there's no way to access the return value " +"of :meth:`~object.__enter__`. If that value is needed, then it is still " +"necessary to use an explicit ``with`` statement." msgstr "" -#: ../../library/contextlib.rst:889 +#: ../../library/contextlib.rst:891 msgid ":pep:`343` - The \"with\" statement" msgstr ":pep:`343` - \"with\" 陳述式" -#: ../../library/contextlib.rst:890 +#: ../../library/contextlib.rst:892 msgid "" "The specification, background, and examples for the Python :keyword:`with` " "statement." msgstr "" -#: ../../library/contextlib.rst:896 +#: ../../library/contextlib.rst:898 msgid "Single use, reusable and reentrant context managers" msgstr "" -#: ../../library/contextlib.rst:898 +#: ../../library/contextlib.rst:900 msgid "" "Most context managers are written in a way that means they can only be used " "effectively in a :keyword:`with` statement once. These single use context " @@ -1411,28 +1416,28 @@ msgid "" "them a second time will trigger an exception or otherwise not work correctly." msgstr "" -#: ../../library/contextlib.rst:904 +#: ../../library/contextlib.rst:906 msgid "" "This common limitation means that it is generally advisable to create " "context managers directly in the header of the :keyword:`with` statement " "where they are used (as shown in all of the usage examples above)." msgstr "" -#: ../../library/contextlib.rst:908 +#: ../../library/contextlib.rst:910 msgid "" "Files are an example of effectively single use context managers, since the " "first :keyword:`with` statement will close the file, preventing any further " "IO operations using that file object." msgstr "" -#: ../../library/contextlib.rst:912 +#: ../../library/contextlib.rst:914 msgid "" "Context managers created using :func:`contextmanager` are also single use " "context managers, and will complain about the underlying generator failing " "to yield if an attempt is made to use them a second time::" msgstr "" -#: ../../library/contextlib.rst:916 +#: ../../library/contextlib.rst:918 msgid "" ">>> from contextlib import contextmanager\n" ">>> @contextmanager\n" @@ -1474,11 +1479,11 @@ msgstr "" " ...\n" "RuntimeError: generator didn't yield" -#: ../../library/contextlib.rst:940 +#: ../../library/contextlib.rst:942 msgid "Reentrant context managers" msgstr "" -#: ../../library/contextlib.rst:942 +#: ../../library/contextlib.rst:944 msgid "" "More sophisticated context managers may be \"reentrant\". These context " "managers can not only be used in multiple :keyword:`with` statements, but " @@ -1486,14 +1491,14 @@ msgid "" "the same context manager." msgstr "" -#: ../../library/contextlib.rst:947 +#: ../../library/contextlib.rst:949 msgid "" ":class:`threading.RLock` is an example of a reentrant context manager, as " "are :func:`suppress`, :func:`redirect_stdout`, and :func:`chdir`. Here's a " "very simple example of reentrant use::" msgstr "" -#: ../../library/contextlib.rst:951 +#: ../../library/contextlib.rst:953 msgid "" ">>> from contextlib import redirect_stdout\n" ">>> from io import StringIO\n" @@ -1525,26 +1530,26 @@ msgstr "" "This is written to the stream rather than stdout\n" "This is also written to the stream" -#: ../../library/contextlib.rst:966 +#: ../../library/contextlib.rst:968 msgid "" "Real world examples of reentrancy are more likely to involve multiple " "functions calling each other and hence be far more complicated than this " "example." msgstr "" -#: ../../library/contextlib.rst:970 +#: ../../library/contextlib.rst:972 msgid "" "Note also that being reentrant is *not* the same thing as being thread " "safe. :func:`redirect_stdout`, for example, is definitely not thread safe, " -"as it makes a global modification to the system state by binding :data:`sys." -"stdout` to a different stream." +"as it makes a global modification to the system state by " +"binding :data:`sys.stdout` to a different stream." msgstr "" -#: ../../library/contextlib.rst:979 +#: ../../library/contextlib.rst:981 msgid "Reusable context managers" msgstr "" -#: ../../library/contextlib.rst:981 +#: ../../library/contextlib.rst:983 msgid "" "Distinct from both single use and reentrant context managers are " "\"reusable\" context managers (or, to be completely explicit, \"reusable, " @@ -1554,21 +1559,22 @@ msgid "" "manager instance has already been used in a containing with statement." msgstr "" -#: ../../library/contextlib.rst:988 +#: ../../library/contextlib.rst:990 msgid "" ":class:`threading.Lock` is an example of a reusable, but not reentrant, " -"context manager (for a reentrant lock, it is necessary to use :class:" -"`threading.RLock` instead)." +"context manager (for a reentrant lock, it is necessary to " +"use :class:`threading.RLock` instead)." msgstr "" -#: ../../library/contextlib.rst:992 +#: ../../library/contextlib.rst:994 msgid "" -"Another example of a reusable, but not reentrant, context manager is :class:" -"`ExitStack`, as it invokes *all* currently registered callbacks when leaving " -"any with statement, regardless of where those callbacks were added::" +"Another example of a reusable, but not reentrant, context manager " +"is :class:`ExitStack`, as it invokes *all* currently registered callbacks " +"when leaving any with statement, regardless of where those callbacks were " +"added::" msgstr "" -#: ../../library/contextlib.rst:997 +#: ../../library/contextlib.rst:999 msgid "" ">>> from contextlib import ExitStack\n" ">>> stack = ExitStack()\n" @@ -1622,7 +1628,7 @@ msgstr "" "Callback: from outer context\n" "Leaving outer context" -#: ../../library/contextlib.rst:1023 +#: ../../library/contextlib.rst:1025 msgid "" "As the output from the example shows, reusing a single stack object across " "multiple with statements works correctly, but attempting to nest them will " @@ -1630,13 +1636,13 @@ msgid "" "which is unlikely to be desirable behaviour." msgstr "" -#: ../../library/contextlib.rst:1028 +#: ../../library/contextlib.rst:1030 msgid "" "Using separate :class:`ExitStack` instances instead of reusing a single " "instance avoids that problem::" msgstr "" -#: ../../library/contextlib.rst:1031 +#: ../../library/contextlib.rst:1033 msgid "" ">>> from contextlib import ExitStack\n" ">>> with ExitStack() as outer_stack:\n" diff --git a/library/contextvars.po b/library/contextvars.po index 97e1b5cfd8..734d35fd88 100644 --- a/library/contextvars.po +++ b/library/contextvars.po @@ -1,12 +1,11 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-11 21:40+0800\n" -"PO-Revision-Date: 2018-07-15 18:56+0800\n" +"POT-Creation-Date: 2024-10-31 00:13+0000\n" +"PO-Revision-Date: 2025-07-30 22:06+0800\n" "Last-Translator: \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -14,6 +13,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 3.6\n" #: ../../library/contextvars.rst:2 msgid ":mod:`!contextvars` --- Context Variables" @@ -27,6 +27,10 @@ msgid "" "the :class:`~contextvars.Context` class should be used to manage the current " "context in asynchronous frameworks." msgstr "" +"本模組供 API 來管理、儲存及存取單一情境各自的狀態(context-local state)。 " +"用 :class:`~contextvars.ContextVar` 類別宣告和處理\\ *情境變數*。 :func:" +"`~contextvars.copy_context` 函式和 :class:`~contextvars.Context` 類別應在非同" +"步框架中管理目前的情境。" #: ../../library/contextvars.rst:17 msgid "" @@ -34,18 +38,21 @@ msgid "" "func:`threading.local` to prevent their state from bleeding to other code " "unexpectedly, when used in concurrent code." msgstr "" +"帶有狀態的 Context Manager 應該使用情境變數,而不是 :func:`threading.local`," +"才能防止它們的狀態在並行(concurrent)程式碼中使用時意外外溢並干擾到其他程式" +"碼。" #: ../../library/contextvars.rst:21 msgid "See also :pep:`567` for additional details." -msgstr "額外資訊請見 :pep:`567`。" +msgstr "其他詳細資訊,請參閱 :pep:`567`。" #: ../../library/contextvars.rst:27 msgid "Context Variables" -msgstr "" +msgstr "情境變數" #: ../../library/contextvars.rst:31 msgid "This class is used to declare a new Context Variable, e.g.::" -msgstr "" +msgstr "此類別用在宣告新的情境變數,例如:" #: ../../library/contextvars.rst:33 msgid "var: ContextVar[int] = ContextVar('var', default=42)" @@ -54,7 +61,7 @@ msgstr "var: ContextVar[int] = ContextVar('var', default=42)" #: ../../library/contextvars.rst:35 msgid "" "The required *name* parameter is used for introspection and debug purposes." -msgstr "" +msgstr "必要參數 *name* 用於自我檢查(introspection)和除錯。" #: ../../library/contextvars.rst:38 msgid "" @@ -62,6 +69,8 @@ msgid "" "`ContextVar.get` when no value for the variable is found in the current " "context." msgstr "" +"當在目前的情境中找不到變數的值時,:meth:`ContextVar.get` 會回傳可選的僅限關鍵字參" +"數 *default*。" #: ../../library/contextvars.rst:42 msgid "" @@ -70,57 +79,62 @@ msgid "" "context variables which prevents context variables from being properly " "garbage collected." msgstr "" +"**重要:**\\ 情境變數應該在最頂端的模組層級建立,絕對不要在閉包(closure)中" +"建立。 :class:`Context` 物件持有情境變數的強參照,這會阻止情境變數被正確地垃" +"圾回收(garbage collected)。" #: ../../library/contextvars.rst:49 msgid "The name of the variable. This is a read-only property." -msgstr "" +msgstr "這個變數的名稱。這是一個唯讀屬性。" #: ../../library/contextvars.rst:55 msgid "Return a value for the context variable for the current context." -msgstr "" +msgstr "回傳當前情境的情境變數值。" #: ../../library/contextvars.rst:57 msgid "" "If there is no value for the variable in the current context, the method " "will:" -msgstr "" +msgstr "如果在當前情境中沒有變數的值,此方法將:" #: ../../library/contextvars.rst:60 msgid "" "return the value of the *default* argument of the method, if provided; or" -msgstr "" +msgstr "回傳方法的 *default* 引數值(如果有的話);否則" #: ../../library/contextvars.rst:63 msgid "" "return the default value for the context variable, if it was created with " "one; or" -msgstr "" +msgstr "回傳情境變數的預設值(如果建立情境變數時有指定預設值的話);否則" #: ../../library/contextvars.rst:66 msgid "raise a :exc:`LookupError`." -msgstr "" +msgstr "會引發一個 :exc:`LookupError`。" #: ../../library/contextvars.rst:70 msgid "" "Call to set a new value for the context variable in the current context." -msgstr "" +msgstr "在目前的情境中,呼叫以設定情境變數的新值。" #: ../../library/contextvars.rst:73 msgid "" "The required *value* argument is the new value for the context variable." -msgstr "" +msgstr "*value* 屬必要引數,是情境變數的新值。" #: ../../library/contextvars.rst:76 msgid "" "Returns a :class:`~contextvars.Token` object that can be used to restore the " "variable to its previous value via the :meth:`ContextVar.reset` method." msgstr "" +"回傳一個 :class:`~contextvars.Token` 物件,該物件可透過 :meth:`ContextVar." +"reset` 方法,用來將變數還原到之前的值。" #: ../../library/contextvars.rst:82 msgid "" "Reset the context variable to the value it had before the :meth:`ContextVar." "set` that created the *token* was used." -msgstr "" +msgstr "將情境變數重設為使用 :meth:`ContextVar.set` 建立 *token* 前的值。" #: ../../library/contextvars.rst:85 msgid "For example::" @@ -137,6 +151,14 @@ msgid "" "# After the reset call the var has no value again, so\n" "# var.get() would raise a LookupError." msgstr "" +"var = ContextVar('var')\n" +"\n" +"token = var.set('new value')\n" +"# 使用 'var' 的程式碼;var.get() 回傳 'new value'。\n" +"var.reset(token)\n" +"\n" +"# 在重設呼叫之後,var 又沒有值了,所以\n" +"# var.get() 會引發 LookupError。" #: ../../library/contextvars.rst:99 msgid "" @@ -144,12 +166,14 @@ msgid "" "be passed to the :meth:`ContextVar.reset` method to revert the value of the " "variable to what it was before the corresponding *set*." msgstr "" +"*Token* 物件由 :meth:`ContextVar.set` 方法回傳,可以傳遞給 :meth:`ContextVar." +"reset` 方法,用以將變數的值還原為相對應的 *set* 之前的值。" #: ../../library/contextvars.rst:106 msgid "" "A read-only property. Points to the :class:`ContextVar` object that created " "the token." -msgstr "" +msgstr "唯讀屬性。 指向建立 token 的 :class:`ContextVar` 物件。" #: ../../library/contextvars.rst:111 msgid "" @@ -157,24 +181,27 @@ msgid "" "`ContextVar.set` method call that created the token. It points to :attr:" "`Token.MISSING` if the variable was not set before the call." msgstr "" +"唯讀屬性。 值為變數在呼叫 :meth:`ContextVar.set` 方法之前的值。如果變數在呼叫" +"前沒有設定,則指向 :attr:`Token.MISSING`。" #: ../../library/contextvars.rst:118 msgid "A marker object used by :attr:`Token.old_value`." -msgstr "" +msgstr "由 :attr:`Token.old_value` 使用的標記物件。" #: ../../library/contextvars.rst:122 msgid "Manual Context Management" -msgstr "" +msgstr "手動情境管理" #: ../../library/contextvars.rst:126 msgid "Returns a copy of the current :class:`~contextvars.Context` object." -msgstr "" +msgstr "回傳目前 :class:`~contextvars.Context` 物件的複本(copy)。" #: ../../library/contextvars.rst:128 msgid "" "The following snippet gets a copy of the current context and prints all " "variables and their values that are set in it::" msgstr "" +"以下程式碼片段會取得目前情境的複本,並顯示在其中設定的所有變數及其值:::" #: ../../library/contextvars.rst:131 msgid "" @@ -190,58 +217,125 @@ msgid "" "contexts with a few context variables and for contexts that have a lot of " "them." msgstr "" +"這個函式具有 *O*\\ (1) 的複雜度,也就是說,對於只有少許情境變數的情境和有大量" +"情境變數的情境,速度都一樣快。" #: ../../library/contextvars.rst:141 msgid "A mapping of :class:`ContextVars ` to their values." -msgstr "" +msgstr ":class:`ContextVars` 到其值的映射。" #: ../../library/contextvars.rst:143 msgid "" "``Context()`` creates an empty context with no values in it. To get a copy " "of the current context use the :func:`~contextvars.copy_context` function." msgstr "" +"``Context()`` 會建立一個沒有值的空情境。要取得目前情境的複本,請使用 :func:" +"`~contextvars.copy_context` 函式。" #: ../../library/contextvars.rst:147 msgid "" -"Every thread will have a different top-level :class:`~contextvars.Context` " -"object. This means that a :class:`ContextVar` object behaves in a similar " -"fashion to :func:`threading.local` when values are assigned in different " -"threads." +"Each thread has its own effective stack of :class:`!Context` objects. The :" +"term:`current context` is the :class:`!Context` object at the top of the " +"current thread's stack. All :class:`!Context` objects in the stacks are " +"considered to be *entered*." msgstr "" +"每個執行緒都有自己的 :class:`!Context` 物件中目前主控中的堆疊(stack)。:" +"term:`current context` 是目前執行緒堆疊頂端的 :class:`!Context` 物件。 堆疊" +"中的所有 :class:`!Context` 物件都被視為\\ *已進入*。" #: ../../library/contextvars.rst:152 -msgid "Context implements the :class:`collections.abc.Mapping` interface." +msgid "" +"*Entering* a context, which can be done by calling its :meth:`~Context.run` " +"method, makes the context the current context by pushing it onto the top of " +"the current thread's context stack." msgstr "" +"*進入*\\ 一個情境,可以藉由呼叫其 :meth:`~Context.run` 方法來完成,此\\ *進入" +"*\\ 的動作會將一情境推到目前執行緒的情境堆疊的頂端,使該情境成為目前的情境。" #: ../../library/contextvars.rst:156 msgid "" -"Execute ``callable(*args, **kwargs)`` code in the context object the *run* " -"method is called on. Return the result of the execution or propagate an " -"exception if one occurred." +"*Exiting* from the current context, which can be done by returning from the " +"callback passed to the :meth:`~Context.run` method, restores the current " +"context to what it was before the context was entered by popping the context " +"off the top of the context stack." msgstr "" +"如果你傳遞給 :meth:`~Context.run` 方法的回呼函式(callback functions),該函" +"式回傳之後,就會自動\\ *退出*\\ 目前的情境,這會將目前的情境還原到進入情境之" +"前的狀態,方法是將情境從情境堆疊的頂端彈出。" -#: ../../library/contextvars.rst:160 +#: ../../library/contextvars.rst:161 msgid "" -"Any changes to any context variables that *callable* makes will be contained " -"in the context object::" +"Since each thread has its own context stack, :class:`ContextVar` objects " +"behave in a similar fashion to :func:`threading.local` when values are " +"assigned in different threads." msgstr "" +"因為每個執行緒都有自己的情境堆疊,當值在不同的執行緒中被指定時, :class:" +"`ContextVar` 物件的行為與 :func:`threading.local` 相似。" -#: ../../library/contextvars.rst:163 +#: ../../library/contextvars.rst:165 msgid "" -"var = ContextVar('var')\n" +"Attempting to enter an already entered context, including contexts entered " +"in other threads, raises a :exc:`RuntimeError`." +msgstr "" +"嘗試進入已進入的情境,包括在其他執行緒中進入的情境,會引發 :exc:" +"`RuntimeError`。" + +#: ../../library/contextvars.rst:168 +msgid "After exiting a context, it can later be re-entered (from any thread)." +msgstr "退出情境後,之後可以重新進入(從任何執行緒)。" + +#: ../../library/contextvars.rst:170 +msgid "" +"Any changes to :class:`ContextVar` values via the :meth:`ContextVar.set` " +"method are recorded in the current context. The :meth:`ContextVar.get` " +"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)." +msgstr "" +"任何透過 :meth:`ContextVar.set` 方法對 :class:`ContextVar` 值的改變都會記錄在" +"目前的情境中。 :meth:`ContextVar.get` 方法回傳與當前情境相關的值。 退出情境" +"實際造成的效果會像是將其在進入情境時對情境變數所做的任何變一一彈出並還原(如" +"果需要,可以透過重新進入情境來還原值)。" + +#: ../../library/contextvars.rst:177 +msgid "Context implements the :class:`collections.abc.Mapping` interface." +msgstr "情境(Context)實作了 :class:`collections.abc.Mapping` 介面。" + +#: ../../library/contextvars.rst:181 +msgid "" +"Enters the Context, executes ``callable(*args, **kwargs)``, then exits the " +"Context. Returns *callable*'s return value, or propagates an exception if " +"one occurred." +msgstr "" +"進入 Context,執行``callable(*args, **kwargs)``,然後退出 Context。 回傳 " +"*callable* 的回傳值,如果發生例外(exception),則傳播例外。" + +#: ../../library/contextvars.rst:185 +msgid "Example:" +msgstr "例如:" + +#: ../../library/contextvars.rst:187 +msgid "" +"import contextvars\n" +"\n" +"var = contextvars.ContextVar('var')\n" "var.set('spam')\n" +"print(var.get()) # 'spam'\n" +"\n" +"ctx = contextvars.copy_context()\n" "\n" "def main():\n" " # 'var' was set to 'spam' before\n" " # calling 'copy_context()' and 'ctx.run(main)', so:\n" -" # var.get() == ctx[var] == 'spam'\n" +" print(var.get()) # 'spam'\n" +" print(ctx[var]) # 'spam'\n" "\n" " var.set('ham')\n" "\n" " # Now, after setting 'var' to 'ham':\n" -" # var.get() == ctx[var] == 'ham'\n" -"\n" -"ctx = copy_context()\n" +" print(var.get()) # 'ham'\n" +" print(ctx[var]) # 'ham'\n" "\n" "# Any changes that the 'main' function makes to 'var'\n" "# will be contained in 'ctx'.\n" @@ -249,75 +343,106 @@ msgid "" "\n" "# The 'main()' function was run in the 'ctx' context,\n" "# so changes to 'var' are contained in it:\n" -"# ctx[var] == 'ham'\n" +"print(ctx[var]) # 'ham'\n" "\n" "# However, outside of 'ctx', 'var' is still set to 'spam':\n" -"# var.get() == 'spam'" -msgstr "" - -#: ../../library/contextvars.rst:189 -msgid "" -"The method raises a :exc:`RuntimeError` when called on the same context " -"object from more than one OS thread, or when called recursively." +"print(var.get()) # 'spam'" msgstr "" +"import contextvars\n" +"\n" +"var = contextvars.ContextVar('var')\n" +"var.set('spam')\n" +"print(var.get()) # 'spam'\n" +"\n" +"ctx = contextvars.copy_context()\n" +"\n" +"def main():\n" +" # 'var' 之前被設成 'spam'\n" +" # 呼叫 'copy_context()' 和 'ctx.run(main)',所以:\n" +" print(var.get()) # 'spam'\n" +" print(ctx[var]) # 'spam'\n" +"\n" +" var.set('ham')\n" +"\n" +" # 現在, 在把 'var' 的值設成 'ham' 後:\n" +" print(var.get()) # 'ham'\n" +" print(ctx[var]) # 'ham'\n" +"\n" +"# 'main' 函式對 'var' 所做的任何變更都會\n" +"# 包含在 'ctx 裡:.\n" +"ctx.run(main)\n" +"\n" +"# 'main()' 函式是在 'ctx' 情境中執行,\n" +"# 所以對 'var' 的變更會保存在 'ctx' 中:\n" +"print(ctx[var]) # 'ham'\n" +"\n" +"# 但是,在 'ctx' 外, 'var' 的值仍然是 'spam':\n" +"print(var.get()) # 'spam'" -#: ../../library/contextvars.rst:195 +#: ../../library/contextvars.rst:233 msgid "Return a shallow copy of the context object." -msgstr "" +msgstr "回傳情境物件的淺層複本(shallow copy)。" -#: ../../library/contextvars.rst:199 +#: ../../library/contextvars.rst:237 msgid "" "Return ``True`` if the *context* has a value for *var* set; return ``False`` " "otherwise." msgstr "" +"如果\\ *情境*\\ 裡面有 *var* 的值,則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/contextvars.rst:204 +#: ../../library/contextvars.rst:242 msgid "" "Return the value of the *var* :class:`ContextVar` variable. If the variable " "is not set in the context object, a :exc:`KeyError` is raised." msgstr "" +"回傳 *var* :class:`ContextVar` 變數的值。如果該變數並沒有在情境物件中設定,則" +"會引發 :exc:`KeyError` 錯誤。" -#: ../../library/contextvars.rst:210 +#: ../../library/contextvars.rst:248 msgid "" "Return the value for *var* if *var* has the value in the context object. " "Return *default* otherwise. If *default* is not given, return ``None``." msgstr "" +"如果 *var* 的值在情境物件中,則回傳 *var* 的值。 否則回傳 *default*。 如果" +"沒有 *default* 值,則回傳``None``。" -#: ../../library/contextvars.rst:216 +#: ../../library/contextvars.rst:254 msgid "Return an iterator over the variables stored in the context object." -msgstr "" +msgstr "回傳儲存於情境物件中變數的疊代器。" -#: ../../library/contextvars.rst:221 +#: ../../library/contextvars.rst:259 msgid "Return the number of variables set in the context object." -msgstr "" +msgstr "回傳情境物件中的變數個數。" -#: ../../library/contextvars.rst:225 +#: ../../library/contextvars.rst:263 msgid "Return a list of all variables in the context object." -msgstr "" +msgstr "回傳情境物件中所有變數的串列。" -#: ../../library/contextvars.rst:229 +#: ../../library/contextvars.rst:267 msgid "Return a list of all variables' values in the context object." -msgstr "" +msgstr "回傳情境物件中所有變數的值的串列。" -#: ../../library/contextvars.rst:234 +#: ../../library/contextvars.rst:272 msgid "" "Return a list of 2-tuples containing all variables and their values in the " "context object." -msgstr "" +msgstr "回傳情境物件中所有變數與其值的 2-元組(2-tuples)的串列。" -#: ../../library/contextvars.rst:239 +#: ../../library/contextvars.rst:277 msgid "asyncio support" -msgstr "" +msgstr "對 asyncio 的支援" -#: ../../library/contextvars.rst:241 +#: ../../library/contextvars.rst:279 msgid "" "Context variables are natively supported in :mod:`asyncio` and are ready to " "be used without any extra configuration. For example, here is a simple echo " "server, that uses a context variable to make the address of a remote client " "available in the Task that handles that client::" msgstr "" +":mod:`asyncio` 原生支援情境變數,不需任何額外設定。 舉例來說,以下是一個簡單" +"的 echo 伺服器,使用情境變數讓遠端用戶端的位址在處理該用戶端的任務中可用:" -#: ../../library/contextvars.rst:247 +#: ../../library/contextvars.rst:285 msgid "" "import asyncio\n" "import contextvars\n" @@ -362,3 +487,45 @@ msgid "" "# telnet 127.0.0.1 8081\n" "# curl 127.0.0.1:8081" msgstr "" +"import asyncio\n" +"import contextvars\n" +"\n" +"client_addr_var = contextvars.ContextVar('client_addr')\n" +"\n" +"def render_goodbye():\n" +" # 即使不把目前處理中的用戶端(client)傳入此函式\n" +" # 仍可取得其位址\n" +"\n" +" client_addr = client_addr_var.get()\n" +" return f'Good bye, client @ {client_addr}\\r\\n'.encode()\n" +"\n" +"async def handle_request(reader, writer):\n" +" addr = writer.transport.get_extra_info('socket').getpeername()\n" +" client_addr_var.set(addr)\n" +"\n" +" # 在任何我們呼叫的程式碼中,都可以\n" +" # 呼叫 'client_addr_var.get()' 來取得用戶端的位址\n" +"\n" +" while True:\n" +" line = await reader.readline()\n" +" print(line)\n" +" if not line.strip():\n" +" break\n" +"\n" +" writer.write(b'HTTP/1.1 200 OK\\r\\n') # status line\n" +" writer.write(b'\\r\\n') # headers\n" +" writer.write(render_goodbye()) # body\n" +" writer.close()\n" +"\n" +"async def main():\n" +" srv = await asyncio.start_server(\n" +" handle_request, '127.0.0.1', 8081)\n" +"\n" +" async with srv:\n" +" await srv.serve_forever()\n" +"\n" +"asyncio.run(main())\n" +"\n" +"# 你可以使用 telnet 或 curl 測試:\n" +"# telnet 127.0.0.1 8081\n" +"# curl 127.0.0.1:8081" diff --git a/library/copy.po b/library/copy.po index df91a7a329..d3d49fd63f 100644 --- a/library/copy.po +++ b/library/copy.po @@ -6,9 +6,9 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-09 00:03+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2022-01-20 18:49+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -46,18 +46,24 @@ msgid "Interface summary:" msgstr "介面摘要:" #: ../../library/copy.rst:22 -msgid "Return a shallow copy of *x*." -msgstr "回傳 *x* 的淺層複製。" +msgid "Return a shallow copy of *obj*." +msgstr "回傳 *obj* 的淺層複製。" #: ../../library/copy.rst:27 -msgid "Return a deep copy of *x*." -msgstr "回傳 *x* 的深層複製。" +msgid "Return a deep copy of *obj*." +msgstr "回傳 *obj* 的深層複製。" #: ../../library/copy.rst:32 +msgid "" +"Creates a new object of the same type as *obj*, replacing fields with values " +"from *changes*." +msgstr "" + +#: ../../library/copy.rst:40 msgid "Raised for module specific errors." msgstr "引發針對特定模組的錯誤。" -#: ../../library/copy.rst:36 +#: ../../library/copy.rst:44 msgid "" "The difference between shallow and deep copying is only relevant for " "compound objects (objects that contain other objects, like lists or class " @@ -66,7 +72,7 @@ msgstr "" "淺層與深層複製的區別僅與複合物件(即包含 list 或類別的實例等其他物件的物件)" "相關:" -#: ../../library/copy.rst:39 +#: ../../library/copy.rst:47 msgid "" "A *shallow copy* constructs a new compound object and then (to the extent " "possible) inserts *references* into it to the objects found in the original." @@ -74,7 +80,7 @@ msgstr "" "*淺層複製*\\ 建構一個新的複合物件,然後(在儘可能的範圍內)將原始物件中找到的" "物件的\\ *參照*\\ 插入其中。" -#: ../../library/copy.rst:42 +#: ../../library/copy.rst:50 msgid "" "A *deep copy* constructs a new compound object and then, recursively, " "inserts *copies* into it of the objects found in the original." @@ -82,19 +88,19 @@ msgstr "" "*深層複製*\\ 建構一個新的複合物件,然後遞迴地將在原始物件裡找到的物件的\\ *副" "本*\\ 插入其中。" -#: ../../library/copy.rst:45 +#: ../../library/copy.rst:53 msgid "" "Two problems often exist with deep copy operations that don't exist with " "shallow copy operations:" msgstr "深層複製操作通常存在兩個問題,而淺層複製操作並不存在這些問題:" -#: ../../library/copy.rst:48 +#: ../../library/copy.rst:56 msgid "" "Recursive objects (compound objects that, directly or indirectly, contain a " "reference to themselves) may cause a recursive loop." msgstr "遞迴物件(直接或間接包含對自身參照的複合物件)可能會導致遞迴迴圈。" -#: ../../library/copy.rst:51 +#: ../../library/copy.rst:59 msgid "" "Because deep copy copies everything it may copy too much, such as data which " "is intended to be shared between copies." @@ -102,23 +108,23 @@ msgstr "" "由於深層複製會複製所有內容,因此可能會有過多複製(例如應該在副本之間共享的資" "料)。" -#: ../../library/copy.rst:54 +#: ../../library/copy.rst:62 msgid "The :func:`deepcopy` function avoids these problems by:" msgstr ":func:`deepcopy` 函式用以下方式避免了這些問題:" -#: ../../library/copy.rst:56 +#: ../../library/copy.rst:64 msgid "" "keeping a ``memo`` dictionary of objects already copied during the current " "copying pass; and" -msgstr "保留在當前複製過程中已複製的物件的 ``memo`` 字典;以及" +msgstr "保留在目前複製過程中已複製的物件的 ``memo`` 字典;以及" -#: ../../library/copy.rst:59 +#: ../../library/copy.rst:67 msgid "" "letting user-defined classes override the copying operation or the set of " "components copied." msgstr "允許使用者定義的類別複寫 (override) 複製操作或複製的元件集合。" -#: ../../library/copy.rst:62 +#: ../../library/copy.rst:70 msgid "" "This module does not copy types like module, method, stack trace, stack " "frame, file, socket, window, or any similar types. It does \"copy\" " @@ -131,7 +137,7 @@ msgstr "" "(淺層或深層地)\"複製\"函式和類別;這與 :mod:`pickle` 模組處理這類問題的方式" "是相似的。" -#: ../../library/copy.rst:67 +#: ../../library/copy.rst:75 msgid "" "Shallow copies of dictionaries can be made using :meth:`dict.copy`, and of " "lists by assigning a slice of the entire list, for example, ``copied_list = " @@ -140,7 +146,7 @@ msgstr "" "字典的淺層複製可以使用 :meth:`dict.copy`\\,而 list 的淺層複製可以透過賦值整" "個 list 的切片 (slice) 完成,例如,``copied_list = original_list[:]``。" -#: ../../library/copy.rst:73 +#: ../../library/copy.rst:81 msgid "" "Classes can use the same interfaces to control copying that they use to " "control pickling. See the description of module :mod:`pickle` for " @@ -151,30 +157,50 @@ msgstr "" "參考 :mod:`pickle` 模組。實際上,:mod:`copy` 模組使用的正是從 :mod:`copyreg` " "模組中註冊的 pickle 函式。" -#: ../../library/copy.rst:82 +#: ../../library/copy.rst:92 msgid "" "In order for a class to define its own copy implementation, it can define " -"special methods :meth:`__copy__` and :meth:`__deepcopy__`. The former is " -"called to implement the shallow copy operation; no additional arguments are " -"passed. The latter is called to implement the deep copy operation; it is " -"passed one argument, the ``memo`` dictionary. If the :meth:`__deepcopy__` " -"implementation needs to make a deep copy of a component, it should call the :" -"func:`deepcopy` function with the component as first argument and the memo " -"dictionary as second argument. The memo dictionary should be treated as an " -"opaque object." -msgstr "" -"想要為一個類別定義它自己的複製操作實作,可以透過定義特殊方法 :meth:" -"`__copy__` 和 :meth:`__deepcopy__`。呼叫前者以實現淺層複製操作;不必傳入額外" -"引數。呼叫後者以實現深層複製操作;它應傳入一個引數,即 ``memo`` 字典。如果 :" -"meth:`__deepcopy__` 實現需要建立一個元件的深層複製,它應當呼叫 :func:" -"`deepcopy` 函式並以該元件作為第一個引數、以該 memo 字典作為第二個引數。memo " -"字典應當被當作不透明物件 (opaque object) 來處理。" - -#: ../../library/copy.rst:94 +"special methods :meth:`~object.__copy__` and :meth:`~object.__deepcopy__`." +msgstr "" + +#: ../../library/copy.rst:98 +msgid "" +"Called to implement the shallow copy operation; no additional arguments are " +"passed." +msgstr "" + +#: ../../library/copy.rst:104 +msgid "" +"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 :func:`~copy.deepcopy` function " +"with the component as first argument and the *memo* dictionary as second " +"argument. The *memo* dictionary should be treated as an opaque object." +msgstr "" +"用來實作深層複製操作;它會傳遞一個引數,即 *memo* 字典。如果 " +"``__deepcopy__`` 實現需要建立一個元件的深層複製,它應當呼叫 :func:`~copy." +"deepcopy` 函式並以該元件作為第一個引數、以該 *memo* 字典作為第二個引數。*memo* " +"字典應當被當作不透明物件 (opaque object) 來處理" + +#: ../../library/copy.rst:114 +msgid "" +"Function :func:`!copy.replace` is more limited than :func:`~copy.copy` and :" +"func:`~copy.deepcopy`, and only supports named tuples created by :func:" +"`~collections.namedtuple`, :mod:`dataclasses`, and other classes which " +"define method :meth:`~object.__replace__`." +msgstr "" + +#: ../../library/copy.rst:122 +msgid "" +"This method should create a new object of the same type, replacing fields " +"with values from *changes*." +msgstr "" + +#: ../../library/copy.rst:130 msgid "Module :mod:`pickle`" msgstr ":mod:`pickle` 模組" -#: ../../library/copy.rst:95 +#: ../../library/copy.rst:131 msgid "" "Discussion of the special methods used to support object state retrieval and " "restoration." @@ -182,18 +208,22 @@ msgstr "" "支援物件之狀態檢索 (state retrieval) 和恢復 (restoration) 相關特殊方法的討" "論。" -#: ../../library/copy.rst:71 +#: ../../library/copy.rst:79 msgid "module" msgstr "module(模組)" -#: ../../library/copy.rst:71 +#: ../../library/copy.rst:79 msgid "pickle" msgstr "pickle" -#: ../../library/copy.rst:78 +#: ../../library/copy.rst:86 msgid "__copy__() (copy protocol)" msgstr "__copy__() (複製協定)" -#: ../../library/copy.rst:78 +#: ../../library/copy.rst:86 msgid "__deepcopy__() (copy protocol)" msgstr "__deepcopy__() (複製協定)" + +#: ../../library/copy.rst:111 +msgid "__replace__() (replace protocol)" +msgstr "__replace__() (取代協定)" diff --git a/library/copyreg.po b/library/copyreg.po index dfcce84f49..d0f8976f36 100644 --- a/library/copyreg.po +++ b/library/copyreg.po @@ -6,7 +6,7 @@ # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-05-09 00:03+0000\n" "PO-Revision-Date: 2023-12-29 00:29+0000\n" diff --git a/library/crypt.po b/library/crypt.po index ac517bce84..c8e1251bc0 100644 --- a/library/crypt.po +++ b/library/crypt.po @@ -1,277 +1,50 @@ # Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # -# Translators: +#, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" -"PO-Revision-Date: 2018-05-23 14:42+0000\n" -"Last-Translator: Adrian Liaw \n" +"POT-Creation-Date: 2024-11-18 00:15+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/crypt.rst:2 -msgid ":mod:`crypt` --- Function to check Unix passwords" -msgstr ":mod:`crypt` --- 用於檢查 Unix 密碼的函式" +msgid ":mod:`!crypt` --- Function to check Unix passwords" +msgstr ":mod:`!crypt` --- 用於檢查 Unix 密碼的函式" -#: ../../library/crypt.rst:13 -msgid "**Source code:** :source:`Lib/crypt.py`" -msgstr "**原始碼:**\\ :source:`Lib/crypt.py`" - -#: ../../library/crypt.rst:19 -msgid "" -"The :mod:`crypt` module is deprecated (see :pep:`PEP 594 <594#crypt>` for " -"details and alternatives). The :mod:`hashlib` module is a potential " -"replacement for certain use cases. The :pypi:`passlib` package can replace " -"all use cases of this module." -msgstr "" - -#: ../../library/crypt.rst:27 -msgid "" -"This module implements an interface to the :manpage:`crypt(3)` routine, " -"which is a one-way hash function based upon a modified DES algorithm; see " -"the Unix man page for further details. Possible uses include storing hashed " -"passwords so you can check passwords without storing the actual password, or " -"attempting to crack Unix passwords with a dictionary." -msgstr "" - -#: ../../library/crypt.rst:35 -msgid "" -"Notice that the behavior of this module depends on the actual " -"implementation of the :manpage:`crypt(3)` routine in the running system. " -"Therefore, any extensions available on the current implementation will also " -"be available on this module." -msgstr "" - -#: ../../library/crypt.rst:40 -msgid ":ref:`Availability `: Unix, not VxWorks." -msgstr ":ref:`適用 `:Unix,非 VxWorks。" - -#: ../../includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not Emscripten, not WASI." -msgstr "" - -#: ../../includes/wasm-notavail.rst:5 -msgid "" -"This module does not work or is not available on WebAssembly platforms " -"``wasm32-emscripten`` and ``wasm32-wasi``. See :ref:`wasm-availability` for " -"more information." -msgstr "" -"此模組在 WebAssembly 平台 ``wasm32-emscripten`` 和 ``wasm32-wasi`` 上無法作用" -"或無法使用。有關更多資訊,請參閱 :ref:`wasm-availability`。" - -#: ../../library/crypt.rst:45 -msgid "Hashing Methods" -msgstr "雜湊方法" - -#: ../../library/crypt.rst:49 +#: ../../library/crypt.rst:10 msgid "" -"The :mod:`crypt` module defines the list of hashing methods (not all methods " -"are available on all platforms):" +"This module is no longer part of the Python standard library. It was :ref:" +"`removed in Python 3.13 ` after being deprecated in " +"Python 3.11. The removal was decided in :pep:`594`." msgstr "" +"這個模組已不再是 Python 標準函式庫的一部分。它在 Python 3.11 中被棄用,並\\ :" +"ref:`已在 Python 3.13 中被移除 `。它的移除是在 :pep:" +"`594` 中決定的。" -#: ../../library/crypt.rst:54 -msgid "" -"A Modular Crypt Format method with 16 character salt and 86 character hash " -"based on the SHA-512 hash function. This is the strongest method." -msgstr "" - -#: ../../library/crypt.rst:59 -msgid "" -"Another Modular Crypt Format method with 16 character salt and 43 character " -"hash based on the SHA-256 hash function." -msgstr "" - -#: ../../library/crypt.rst:64 -msgid "" -"Another Modular Crypt Format method with 22 character salt and 31 character " -"hash based on the Blowfish cipher." -msgstr "" - -#: ../../library/crypt.rst:71 -msgid "" -"Another Modular Crypt Format method with 8 character salt and 22 character " -"hash based on the MD5 hash function." -msgstr "" - -#: ../../library/crypt.rst:76 -msgid "" -"The traditional method with a 2 character salt and 13 characters of hash. " -"This is the weakest method." -msgstr "" - -#: ../../library/crypt.rst:81 -msgid "Module Attributes" -msgstr "模組屬性" - -#: ../../library/crypt.rst:87 -msgid "" -"A list of available password hashing algorithms, as ``crypt.METHOD_*`` " -"objects. This list is sorted from strongest to weakest." -msgstr "" - -#: ../../library/crypt.rst:93 -msgid "Module Functions" -msgstr "模組函式" - -#: ../../library/crypt.rst:95 -msgid "The :mod:`crypt` module defines the following functions:" -msgstr ":mod:`crypt` 模組定義了以下函式:" - -#: ../../library/crypt.rst:99 +#: ../../library/crypt.rst:14 msgid "" -"*word* will usually be a user's password as typed at a prompt or in a " -"graphical interface. The optional *salt* is either a string as returned " -"from :func:`mksalt`, one of the ``crypt.METHOD_*`` values (though not all " -"may be available on all platforms), or a full encrypted password including " -"salt, as returned by this function. If *salt* is not provided, the " -"strongest method available in :attr:`methods` will be used." +"Applications can use the :mod:`hashlib` module from the standard library. " +"Other possible replacements are third-party libraries from PyPI: :pypi:" +"`legacycrypt`, :pypi:`bcrypt`, :pypi:`argon2-cffi`, or :pypi:`passlib`. " +"These are not supported or maintained by the Python core team." msgstr "" +"應用程式可以改用標準函式庫中的 :mod:`hashlib` 模組。其他可能的替代方案是 " +"PyPI 上的第三方庫::pypi:`legacycrypt`、:pypi:`bcrypt`、:pypi:`argon2-cffi` " +"或 :pypi:`passlib`。這些函式庫並不受 Python 核心團隊支援或維護。" -#: ../../library/crypt.rst:106 -msgid "" -"Checking a password is usually done by passing the plain-text password as " -"*word* and the full results of a previous :func:`crypt` call, which should " -"be the same as the results of this call." -msgstr "" - -#: ../../library/crypt.rst:110 -msgid "" -"*salt* (either a random 2 or 16 character string, possibly prefixed with " -"``$digit$`` to indicate the method) which will be used to perturb the " -"encryption algorithm. The characters in *salt* must be in the set ``[./a-zA-" -"Z0-9]``, with the exception of Modular Crypt Format which prefixes a " -"``$digit$``." -msgstr "" - -#: ../../library/crypt.rst:116 -msgid "" -"Returns the hashed password as a string, which will be composed of " -"characters from the same alphabet as the salt." -msgstr "" - -#: ../../library/crypt.rst:121 -msgid "" -"Since a few :manpage:`crypt(3)` extensions allow different values, with " -"different sizes in the *salt*, it is recommended to use the full crypted " -"password as salt when checking for a password." -msgstr "" - -#: ../../library/crypt.rst:125 -msgid "Accept ``crypt.METHOD_*`` values in addition to strings for *salt*." -msgstr "" - -#: ../../library/crypt.rst:131 -msgid "" -"Return a randomly generated salt of the specified method. If no *method* is " -"given, the strongest method available in :attr:`methods` is used." -msgstr "" - -#: ../../library/crypt.rst:135 -msgid "" -"The return value is a string suitable for passing as the *salt* argument to :" -"func:`crypt`." -msgstr "" - -#: ../../library/crypt.rst:138 -msgid "" -"*rounds* specifies the number of rounds for ``METHOD_SHA256``, " -"``METHOD_SHA512`` and ``METHOD_BLOWFISH``. For ``METHOD_SHA256`` and " -"``METHOD_SHA512`` it must be an integer between ``1000`` and " -"``999_999_999``, the default is ``5000``. For ``METHOD_BLOWFISH`` it must " -"be a power of two between ``16`` (2\\ :sup:`4`) and ``2_147_483_648`` (2\\ :" -"sup:`31`), the default is ``4096`` (2\\ :sup:`12`)." -msgstr "" - -#: ../../library/crypt.rst:148 -msgid "Added the *rounds* parameter." -msgstr "新增 *rounds* 參數。" - -#: ../../library/crypt.rst:153 -msgid "Examples" -msgstr "範例" - -#: ../../library/crypt.rst:155 -msgid "" -"A simple example illustrating typical use (a constant-time comparison " -"operation is needed to limit exposure to timing attacks. :func:`hmac." -"compare_digest` is suitable for this purpose)::" -msgstr "" - -#: ../../library/crypt.rst:159 -msgid "" -"import pwd\n" -"import crypt\n" -"import getpass\n" -"from hmac import compare_digest as compare_hash\n" -"\n" -"def login():\n" -" username = input('Python login: ')\n" -" cryptedpasswd = pwd.getpwnam(username)[1]\n" -" if cryptedpasswd:\n" -" if cryptedpasswd == 'x' or cryptedpasswd == '*':\n" -" raise ValueError('no support for shadow passwords')\n" -" cleartext = getpass.getpass()\n" -" return compare_hash(crypt.crypt(cleartext, cryptedpasswd), " -"cryptedpasswd)\n" -" else:\n" -" return True" -msgstr "" -"import pwd\n" -"import crypt\n" -"import getpass\n" -"from hmac import compare_digest as compare_hash\n" -"\n" -"def login():\n" -" username = input('Python login: ')\n" -" cryptedpasswd = pwd.getpwnam(username)[1]\n" -" if cryptedpasswd:\n" -" if cryptedpasswd == 'x' or cryptedpasswd == '*':\n" -" raise ValueError('no support for shadow passwords')\n" -" cleartext = getpass.getpass()\n" -" return compare_hash(crypt.crypt(cleartext, cryptedpasswd), " -"cryptedpasswd)\n" -" else:\n" -" return True" - -#: ../../library/crypt.rst:175 -msgid "" -"To generate a hash of a password using the strongest available method and " -"check it against the original::" -msgstr "" - -#: ../../library/crypt.rst:178 +#: ../../library/crypt.rst:19 msgid "" -"import crypt\n" -"from hmac import compare_digest as compare_hash\n" -"\n" -"hashed = crypt.crypt(plaintext)\n" -"if not compare_hash(hashed, crypt.crypt(plaintext, hashed)):\n" -" raise ValueError(\"hashed version doesn't validate against original\")" +"The last version of Python that provided the :mod:`!crypt` module was " +"`Python 3.12 `_." msgstr "" -"import crypt\n" -"from hmac import compare_digest as compare_hash\n" -"\n" -"hashed = crypt.crypt(plaintext)\n" -"if not compare_hash(hashed, crypt.crypt(plaintext, hashed)):\n" -" raise ValueError(\"hashed version doesn't validate against original\")" - -#: ../../library/crypt.rst:15 ../../library/crypt.rst:33 -#: ../../library/crypt.rst:119 -msgid "crypt(3)" -msgstr "crypt(3)" - -#: ../../library/crypt.rst:15 -msgid "cipher" -msgstr "cipher" - -#: ../../library/crypt.rst:15 -msgid "DES" -msgstr "DES" +"最後提供 :mod:`!crypt` 模組的 Python 版本是 `Python 3.12 `_。" diff --git a/library/crypto.po b/library/crypto.po index e033e505e4..acdd2c02bf 100644 --- a/library/crypto.po +++ b/library/crypto.po @@ -5,9 +5,9 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-05-09 00:15+0000\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2022-02-15 18:06+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -27,11 +27,10 @@ msgstr "加密服務" msgid "" "The modules described in this chapter implement various algorithms of a " "cryptographic nature. They are available at the discretion of the " -"installation. On Unix systems, the :mod:`crypt` module may also be " -"available. Here's an overview:" +"installation. Here's an overview:" msgstr "" -"本章所描述的模組 (module) 實作了多種加密演算法。它們可以在安裝時選擇是否一同" -"安裝。在 Unix 系統上,:mod:`crypt` 模組也有機會能夠被使用。以下為概述:" +"本章所描述的模組實作了多種加密演算法。它們可以在安裝時選擇是否一同安裝。以下" +"為概述:" #: ../../library/crypto.rst:7 msgid "cryptography" diff --git a/library/csv.po b/library/csv.po index eeed223b19..bb95db06de 100644 --- a/library/csv.po +++ b/library/csv.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-07-01 00:18+0000\n" "PO-Revision-Date: 2023-11-08 15:06+0800\n" "Last-Translator: RockLeon \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -114,12 +114,12 @@ msgstr "" #: ../../library/csv.rst:72 msgid "" "Each row read from the csv file is returned as a list of strings. No " -"automatic data type conversion is performed unless the ``QUOTE_NONNUMERIC`` " -"format option is specified (in which case unquoted fields are transformed " -"into floats)." +"automatic data type conversion is performed unless the :data:" +"`QUOTE_NONNUMERIC` format option is specified (in which case unquoted fields " +"are transformed into floats)." msgstr "" -"從 CSV 檔案讀取的每一列會回傳為一個字串列表。除非格式選項 " -"``QUOTE_NONNUMERIC`` 有被指定(在這個情況之下,沒有引號的欄位都會被轉換成浮點" +"從 CSV 檔案讀取的每一列會回傳為一個字串列表。除非格式選項 :data:" +"`QUOTE_NONNUMERIC` 有被指定(在這個情況之下,沒有引號的欄位都會被轉換成浮點" "數),否則不會進行自動資料型別轉換。" #: ../../library/csv.rst:76 ../../library/csv.rst:106 ../../library/csv.rst:181 @@ -233,7 +233,7 @@ msgid "" "Returns the current maximum field size allowed by the parser. If *new_limit* " "is given, this becomes the new limit." msgstr "" -"回傳當前的剖析器 (parser) 允許的最大字串大小。如果 *new_limit* 被給定,則會變" +"回傳目前的剖析器 (parser) 允許的最大字串大小。如果 *new_limit* 被給定,則會變" "成新的最大字串大小。" #: ../../library/csv.rst:148 @@ -486,7 +486,7 @@ msgid "" "Twenty rows after the first row are sampled; if more than half of columns + " "rows meet the criteria, :const:`True` is returned." msgstr "" -"對第一列之後的二十個列進行採樣;如果超過一半的行及列滿足條件,則返回 :const:" +"對第一列之後的二十個列進行取樣;如果超過一半的行及列滿足條件,則返回 :const:" "`True`。" #: ../../library/csv.rst:302 @@ -526,11 +526,11 @@ msgstr "引導 :class:`writer` 物件引用所有欄位。" #: ../../library/csv.rst:325 msgid "" "Instructs :class:`writer` objects to only quote those fields which contain " -"special characters such as *delimiter*, *quotechar* or any of the characters " -"in *lineterminator*." +"special characters such as *delimiter*, *quotechar*, ``'\\r'``, ``'\\n'`` or " +"any of the characters in *lineterminator*." msgstr "" -"引導 :class:`writer` 物件只引用包含特殊字元的欄位,例如:*分隔符號*、*引號*、" -"或是 *分行符號* 的其他字元。" +"引導 :class:`writer` 物件只引用包含特殊字元的欄位,例如:*delimiter*、*quotechar*、" +"``'\\r'``、``'\\n'`` 或是 *lineterminator* 的其他字元。" #: ../../library/csv.rst:332 msgid "Instructs :class:`writer` objects to quote all non-numeric fields." @@ -538,28 +538,40 @@ msgstr "引導 :class:`writer` 物件引用所有非數字的欄位。" #: ../../library/csv.rst:334 msgid "" -"Instructs :class:`reader` objects to convert all non-quoted fields to type " -"*float*." -msgstr "引導 :class:`reader` 物件轉換所有非引用的欄位為 *float*。" +"Instructs :class:`reader` objects to convert all non-quoted fields to type :" +"class:`float`." +msgstr "引導 :class:`reader` 物件轉換所有非引用的欄位為 :class:`float`。" -#: ../../library/csv.rst:339 +#: ../../library/csv.rst:337 msgid "" -"Instructs :class:`writer` objects to never quote fields. When the current " -"*delimiter* occurs in output data it is preceded by the current *escapechar* " -"character. If *escapechar* is not set, the writer will raise :exc:`Error` " -"if any characters that require escaping are encountered." +"Some numeric types, such as :class:`bool`, :class:`~fractions.Fraction`, or :" +"class:`~enum.IntEnum`, have a string representation that cannot be converted " +"to :class:`float`. They cannot be read in the :data:`QUOTE_NONNUMERIC` and :" +"data:`QUOTE_STRINGS` modes." msgstr "" -"引導 :class:`writer` 物件不得引用欄位。當前的 *分隔符號* 出現在輸出資料時,在" -"他之前的字元是當前的\\*逸出字元 (escape character)*。如果沒有設定\\*逸出字元" -"*\\,若遇到任何字元需要逸出,寫入器則會引發 :exc:`Error` 。" -#: ../../library/csv.rst:344 +#: ../../library/csv.rst:345 +msgid "" +"Instructs :class:`writer` objects to never quote fields. When the current " +"*delimiter*, *quotechar*, *escapechar*, ``'\\r'``, ``'\\n'`` or any of the " +"characters in *lineterminator* occurs in output data it is preceded by the " +"current *escapechar* character. If *escapechar* is not set, the writer will " +"raise :exc:`Error` if any characters that require escaping are encountered. " +"Set *quotechar* to ``None`` to prevent its escaping." +msgstr "" +"引導 :class:`writer` 物件不得引用欄位。當目前的 *delimiter*、*quotechar*、" +"``'\\r'``、``'\\n'`` 或是 *lineterminator* 的其他字元出現在輸出資料時,在" +"他之前的字元是目前的 *escapechar*。如果沒有設定 *escapechar*,若遇到任何字" +"元需要逸出,寫入器則會引發 :exc:`Error`。設定 *quotechar* 為 ``None`` 以防止" +"逸出。" + +#: ../../library/csv.rst:353 msgid "" "Instructs :class:`reader` objects to perform no special processing of quote " "characters." msgstr "引導 :class:`reader` 物件不對引號進行特別處理。" -#: ../../library/csv.rst:348 +#: ../../library/csv.rst:357 msgid "" "Instructs :class:`writer` objects to quote all fields which are not " "``None``. This is similar to :data:`QUOTE_ALL`, except that if a field " @@ -568,7 +580,7 @@ msgstr "" "引導 :class:`writer` 物件引用所有非 ``None`` 的欄位。這與 :data:`QUOTE_ALL` " "相似,除非如果欄位值為 ``None``,該欄位則被寫成空(沒有引號)字串。" -#: ../../library/csv.rst:352 +#: ../../library/csv.rst:361 msgid "" "Instructs :class:`reader` objects to interpret an empty (unquoted) field as " "``None`` and to otherwise behave as :data:`QUOTE_ALL`." @@ -576,7 +588,7 @@ msgstr "" "引導 :class:`reader` 物件將空(沒有引號)欄位直譯 (interpret) 為 ``None``,否" "則會和 :data:`QUOTE_ALL` 有相同的表現方式。" -#: ../../library/csv.rst:359 +#: ../../library/csv.rst:368 msgid "" "Instructs :class:`writer` objects to always place quotes around fields which " "are strings. This is similar to :data:`QUOTE_NONNUMERIC`, except that if a " @@ -586,7 +598,7 @@ msgstr "" "`QUOTE_NONNUMERIC` 相似,除非如果欄位值為 ``None``,該欄位則被寫成空(沒有引" "號)字串。" -#: ../../library/csv.rst:363 +#: ../../library/csv.rst:372 msgid "" "Instructs :class:`reader` objects to interpret an empty (unquoted) string as " "``None`` and to otherwise behave as :data:`QUOTE_NONNUMERIC`." @@ -594,19 +606,19 @@ msgstr "" "引導 :class:`reader` 物件將空(沒有引號)字串直譯為 ``None``,否則會和 :data:" "`QUOTE_ALL` 有相同的表現方式。" -#: ../../library/csv.rst:368 +#: ../../library/csv.rst:377 msgid "The :mod:`csv` module defines the following exception:" msgstr ":mod:`csv` 模組定義下列例外:" -#: ../../library/csv.rst:373 +#: ../../library/csv.rst:382 msgid "Raised by any of the functions when an error is detected." msgstr "當偵測到錯誤時,任何函式都可以引發。" -#: ../../library/csv.rst:378 +#: ../../library/csv.rst:387 msgid "Dialects and Formatting Parameters" msgstr "Dialect 與格式參數" -#: ../../library/csv.rst:380 +#: ../../library/csv.rst:389 msgid "" "To make it easier to specify the format of input and output records, " "specific formatting parameters are grouped together into dialects. A " @@ -625,16 +637,16 @@ msgstr "" "代,在\\ *dialect*\\ 參數中,程式設計師可以指定個別的格式化參數,其與 :class:" "`Dialect` 類別定義的屬性具有相同的名字。" -#: ../../library/csv.rst:390 +#: ../../library/csv.rst:399 msgid "Dialects support the following attributes:" msgstr "Dialect 支援下列屬性:" -#: ../../library/csv.rst:395 +#: ../../library/csv.rst:404 msgid "" "A one-character string used to separate fields. It defaults to ``','``." msgstr "一個單一字元 (one-character) 的字串可已用來分割欄位。預設為 ``','``。" -#: ../../library/csv.rst:400 +#: ../../library/csv.rst:409 msgid "" "Controls how instances of *quotechar* appearing inside a field should " "themselves be quoted. When :const:`True`, the character is doubled. When :" @@ -645,7 +657,7 @@ msgstr "" "為 :const:`True`,字元會是雙引號。若為 :const:`False`,在 *quotechar* 之前會" "先使用 *escapechar* 作為前綴字。預設為 :const:`True`。" -#: ../../library/csv.rst:405 +#: ../../library/csv.rst:414 msgid "" "On output, if *doublequote* is :const:`False` and no *escapechar* is set, :" "exc:`Error` is raised if a *quotechar* is found in a field." @@ -653,88 +665,111 @@ msgstr "" "在輸出時,若 *doublequote* 是 :const:`False` 且\\ *逸出字元*\\ 沒有被設定,當" "一個\\ *引號*\\ 在欄位中被發現時,:exc:`Error` 會被引發。" -#: ../../library/csv.rst:411 +#: ../../library/csv.rst:420 +msgid "" +"A one-character string used by the writer to escape characters that require " +"escaping:" +msgstr "" +"一個單一字元的字串,會被寫入器用來逸出需要逸出的字元:" + +#: ../../library/csv.rst:423 +msgid "" +"the *delimiter*, the *quotechar*, ``'\\r'``, ``'\\n'`` and any of the " +"characters in *lineterminator* are escaped if *quoting* is set to :const:" +"`QUOTE_NONE`;" +msgstr "" + +#: ../../library/csv.rst:426 +msgid "the *quotechar* is escaped if *doublequote* is :const:`False`;" +msgstr "" + +#: ../../library/csv.rst:427 +msgid "the *escapechar* itself." +msgstr "*escapechar* 本身。" + +#: ../../library/csv.rst:429 msgid "" -"A one-character string used by the writer to escape the *delimiter* if " -"*quoting* is set to :const:`QUOTE_NONE` and the *quotechar* if *doublequote* " -"is :const:`False`. On reading, the *escapechar* removes any special meaning " -"from the following character. It defaults to :const:`None`, which disables " -"escaping." +"On reading, the *escapechar* removes any special meaning from the following " +"character. It defaults to :const:`None`, which disables escaping." msgstr "" -"一個會被寫入器使用的單一字元的字串,當 *quoting* 設定為 :const:`QUOTE_NONE` " -"時逸出\\ *分隔符號*;當 *doublequote* 設定為 :const:`False` 時逸出\\ *引號*。" -"在讀取時,*逸出字元*\\ 會移除後面的字元以及任何特殊意義。預設為 :const:" +"在讀取時,*escapechar* 會移除後面字元的任何特殊意義。預設為 :const:" "`None`,表示禁止逸出。" -#: ../../library/csv.rst:416 +#: ../../library/csv.rst:432 msgid "An empty *escapechar* is not allowed." msgstr "*escapechar* 為空是不被接受的。" -#: ../../library/csv.rst:421 +#: ../../library/csv.rst:437 msgid "" "The string used to terminate lines produced by the :class:`writer`. It " "defaults to ``'\\r\\n'``." msgstr "由 :class:`writer` 產生被用來分行的字串。預設為 ``'\\r\\n'``。" -#: ../../library/csv.rst:426 +#: ../../library/csv.rst:442 msgid "" "The :class:`reader` is hard-coded to recognise either ``'\\r'`` or ``'\\n'`` " "as end-of-line, and ignores *lineterminator*. This behavior may change in " "the future." msgstr "" ":class:`reader` 是 hard-coded 辨別 ``'\\r'`` or ``'\\n'`` 作為行尾 (end-of-" -"line),並忽略\\ *分行符號*。未來可能會改變這個行為。" +"line),並忽略\\ *lineterminator*。未來可能會改變這個行為。" -#: ../../library/csv.rst:433 +#: ../../library/csv.rst:449 msgid "" "A one-character string used to quote fields containing special characters, " -"such as the *delimiter* or *quotechar*, or which contain new-line " -"characters. It defaults to ``'\"'``." +"such as the *delimiter* or the *quotechar*, or which contain new-line " +"characters (``'\\r'``, ``'\\n'`` or any of the characters in " +"*lineterminator*). It defaults to ``'\"'``. Can be set to ``None`` to " +"prevent escaping ``'\"'`` if *quoting* is set to :const:`QUOTE_NONE`." msgstr "" "一個單一字元的字串被用於引用包含特殊字元的欄位,像是 *delimiter*、" -"*quotechar* 或是換行字元。預設為 ``'\"'``。" +"*quotechar* 或是換行字元(``'\\r'``、``'\\n'`` 或是 *lineterminator* 的任" +"一字元)。預設為 ``'\"'``。如果 *quoting* 設定為 :const:`QUOTE_NONE`,可以" +"設定為 ``None`` 以防止逸出 ``'\"'``。" -#: ../../library/csv.rst:437 +#: ../../library/csv.rst:456 msgid "An empty *quotechar* is not allowed." msgstr "*quotechar* 為空是不被允許的。" -#: ../../library/csv.rst:442 +#: ../../library/csv.rst:461 msgid "" "Controls when quotes should be generated by the writer and recognised by the " "reader. It can take on any of the :ref:`QUOTE_\\* constants ` and defaults to :const:`QUOTE_MINIMAL`." +"constants>` and defaults to :const:`QUOTE_MINIMAL` if *quotechar* is not " +"``None``, and :const:`QUOTE_NONE` otherwise." msgstr "" -"控制 writer 何時產生引號,以及 reader 如何辨識引號。他可以使用任何 :ref:" -"`QUOTE_\\* 常數 `\\ 且預設為 :const:`QUOTE_MINIMAL`。" +"控制 writer 何時產生引號,以及 reader 如何辨識引號。如 *quotechar* 不為 ``None``," +"則可以使用任何 :ref:`QUOTE_\\* 常數 `\\ 且預設為 :const:" +"`QUOTE_MINIMAL`。否則預設為 :const:`QUOTE_NONE`。" -#: ../../library/csv.rst:449 +#: ../../library/csv.rst:469 msgid "" "When :const:`True`, spaces immediately following the *delimiter* are " "ignored. The default is :const:`False`." msgstr "" -"若為 :const:`True`,在緊接著\\ *分隔符號*\\ 後的空格會被忽略。預設為 :const:" +"若為 :const:`True`,在緊接著\\ *delimiter*\\ 後的空格會被忽略。預設為 :const:" "`False`。" -#: ../../library/csv.rst:455 +#: ../../library/csv.rst:475 msgid "" "When ``True``, raise exception :exc:`Error` on bad CSV input. The default is " "``False``." msgstr "" "若為 ``True``,若有錯誤的 CSV 輸入則會引發 :exc:`Error`。預設為 ``False``。" -#: ../../library/csv.rst:461 +#: ../../library/csv.rst:481 msgid "Reader Objects" msgstr "讀取器物件" -#: ../../library/csv.rst:463 +#: ../../library/csv.rst:483 msgid "" "Reader objects (:class:`DictReader` instances and objects returned by the :" "func:`reader` function) have the following public methods:" msgstr "" "讀取器物件(:func:`reader` 函式回傳的 :class:`DictReader` 實例與物件)有下列" -"公用方法 (public method):" +"公開方法 (public method):" -#: ../../library/csv.rst:468 +#: ../../library/csv.rst:488 msgid "" "Return the next row of the reader's iterable object as a list (if the object " "was returned from :func:`reader`) or a dict (if it is a :class:`DictReader` " @@ -742,28 +777,28 @@ msgid "" "should call this as ``next(reader)``." msgstr "" "回傳一個列表為讀入器的可疊代物件的下一列內容(若該物件是由 :func:`reader` 回" -"傳)或是一個 dict(若為 :class:`DictReader` 實例),會依據當前的 :class:" +"傳)或是一個 dict(若為 :class:`DictReader` 實例),會依據目前的 :class:" "`Dialect` 進行剖析。通常會用 ``next(reader)`` 來進行呼叫。" -#: ../../library/csv.rst:474 +#: ../../library/csv.rst:494 msgid "Reader objects have the following public attributes:" -msgstr "讀取器物件有下列公用屬性 (public attributes):" +msgstr "讀取器物件有下列公開屬性 (public attributes):" -#: ../../library/csv.rst:478 +#: ../../library/csv.rst:498 msgid "A read-only description of the dialect in use by the parser." msgstr "dialect 的唯讀敘述,會被剖析器使用。" -#: ../../library/csv.rst:483 +#: ../../library/csv.rst:503 msgid "" "The number of lines read from the source iterator. This is not the same as " "the number of records returned, as records can span multiple lines." msgstr "來源疊代器所讀取的行數。這與回傳的紀錄數不同,因為可以進行跨行紀錄。" -#: ../../library/csv.rst:487 +#: ../../library/csv.rst:507 msgid "DictReader objects have the following public attribute:" -msgstr "DictReader 物件有下列公用屬性:" +msgstr "DictReader 物件有下列公開屬性:" -#: ../../library/csv.rst:491 +#: ../../library/csv.rst:511 msgid "" "If not passed as a parameter when creating the object, this attribute is " "initialized upon first access or when the first record is read from the file." @@ -771,11 +806,11 @@ msgstr "" "若在建立物件時沒有作為參數傳遞,這個屬性會在第一次存取之前或是第一筆資料被讀" "取之前進行初始化 (initialize)。" -#: ../../library/csv.rst:498 +#: ../../library/csv.rst:518 msgid "Writer Objects" msgstr "寫入器物件" -#: ../../library/csv.rst:500 +#: ../../library/csv.rst:520 msgid "" ":class:`writer` objects (:class:`DictWriter` instances and objects returned " "by the :func:`writer` function) have the following public methods. A *row* " @@ -787,57 +822,57 @@ msgid "" "complex numbers at all)." msgstr "" ":class:`writer` 物件(:func:`writer` 函式回傳的 :class:`DictWriter` 實例與物" -"件)有下列公用方法。對於 :class:`writer` 物件而言,一個\\ *列*\\ 中必須為一個" +"件)有下列公開方法。對於 :class:`writer` 物件而言,一個\\ *列*\\ 中必須為一個" "可疊代的字串或是數字;對於 :class:`DictWriter` 物件而言,則必須為一個 " "dictionary ,且可以對應欄位標題至字串或數字(會先透過 :func:`str` 進行傳" "遞)。請注意,在寫入複數 (complex number) 時會用小括號 (parens) 包起來。這可" "能在其他程式讀取 CSV 檔案時導致某些問題(假設他們完全支援複雜數字)。" -#: ../../library/csv.rst:511 +#: ../../library/csv.rst:531 msgid "" "Write the *row* parameter to the writer's file object, formatted according " "to the current :class:`Dialect`. Return the return value of the call to the " "*write* method of the underlying file object." msgstr "" -"將參數 *row* 寫入至寫入器的檔案物件中,並依照當前的 :class:`Dialect` 進行格式" +"將參數 *row* 寫入至寫入器的檔案物件中,並依照目前的 :class:`Dialect` 進行格式" "化。回傳下層檔案物件 *write* 方法的回傳值。" -#: ../../library/csv.rst:515 +#: ../../library/csv.rst:535 msgid "Added support of arbitrary iterables." msgstr "新增對任意可疊代物件 (arbitrary iterables) 的支援。" -#: ../../library/csv.rst:520 +#: ../../library/csv.rst:540 msgid "" "Write all elements in *rows* (an iterable of *row* objects as described " "above) to the writer's file object, formatted according to the current " "dialect." msgstr "" "將 *rows* 中所有元素(為上述的一個可疊代的 *row* 物件)寫入至寫入器的檔案物件" -"中,並依照當前的 dialect 進行格式化。" +"中,並依照目前的 dialect 進行格式化。" -#: ../../library/csv.rst:524 +#: ../../library/csv.rst:544 msgid "Writer objects have the following public attribute:" -msgstr "寫入器物件有下列公用屬性:" +msgstr "寫入器物件有下列公開屬性:" -#: ../../library/csv.rst:529 +#: ../../library/csv.rst:549 msgid "A read-only description of the dialect in use by the writer." msgstr "dialect 的唯讀敘述,會被寫入器使用。" -#: ../../library/csv.rst:532 +#: ../../library/csv.rst:552 msgid "DictWriter objects have the following public method:" -msgstr "DictWriter 物件有下列公用方法:" +msgstr "DictWriter 物件有下列公開方法:" -#: ../../library/csv.rst:537 +#: ../../library/csv.rst:557 msgid "" "Write a row with the field names (as specified in the constructor) to the " "writer's file object, formatted according to the current dialect. Return the " "return value of the :meth:`csvwriter.writerow` call used internally." msgstr "" "將具欄位標題的一列(於建構函式 (constructor) 中指定的)寫入至寫入器的檔案物件" -"中,並依照當前的 dialect 進行格式化。回傳內部呼叫 :meth:`csvwriter.writerow` " +"中,並依照目前的 dialect 進行格式化。回傳內部呼叫 :meth:`csvwriter.writerow` " "的回傳值。" -#: ../../library/csv.rst:542 +#: ../../library/csv.rst:562 msgid "" ":meth:`writeheader` now also returns the value returned by the :meth:" "`csvwriter.writerow` method it uses internally." @@ -845,15 +880,15 @@ msgstr "" ":meth:`writeheader` 現在也會回傳內部呼叫 :meth:`csvwriter.writerow` 的回傳" "值。" -#: ../../library/csv.rst:550 +#: ../../library/csv.rst:570 msgid "Examples" msgstr "範例" -#: ../../library/csv.rst:552 +#: ../../library/csv.rst:572 msgid "The simplest example of reading a CSV file::" msgstr "最簡單的讀取 CSV 檔案範例: ::" -#: ../../library/csv.rst:554 +#: ../../library/csv.rst:574 msgid "" "import csv\n" "with open('some.csv', newline='') as f:\n" @@ -867,11 +902,11 @@ msgstr "" " for row in reader:\n" " print(row)" -#: ../../library/csv.rst:560 +#: ../../library/csv.rst:580 msgid "Reading a file with an alternate format::" msgstr "讀取一個其他格式的檔案: ::" -#: ../../library/csv.rst:562 +#: ../../library/csv.rst:582 msgid "" "import csv\n" "with open('passwd', newline='') as f:\n" @@ -885,11 +920,11 @@ msgstr "" " for row in reader:\n" " print(row)" -#: ../../library/csv.rst:568 +#: ../../library/csv.rst:588 msgid "The corresponding simplest possible writing example is::" msgstr "相對最簡單、可行的寫入範例為: ::" -#: ../../library/csv.rst:570 +#: ../../library/csv.rst:590 msgid "" "import csv\n" "with open('some.csv', 'w', newline='') as f:\n" @@ -897,7 +932,7 @@ msgid "" " writer.writerows(someiterable)" msgstr "" -#: ../../library/csv.rst:575 +#: ../../library/csv.rst:595 msgid "" "Since :func:`open` is used to open a CSV file for reading, the file will by " "default be decoded into unicode using the system default encoding (see :func:" @@ -908,7 +943,7 @@ msgstr "" "碼格式(請見 :func:`locale.getencoding`),並解碼為 unicode。若要使用不同編碼" "格式進行檔案解碼,請使用 open 函式的 ``encoding`` 引數: ::" -#: ../../library/csv.rst:580 +#: ../../library/csv.rst:600 msgid "" "import csv\n" "with open('some.csv', newline='', encoding='utf-8') as f:\n" @@ -922,7 +957,7 @@ msgstr "" " for row in reader:\n" " print(row)" -#: ../../library/csv.rst:586 +#: ../../library/csv.rst:606 msgid "" "The same applies to writing in something other than the system default " "encoding: specify the encoding argument when opening the output file." @@ -930,11 +965,11 @@ msgstr "" "同理可以應用到使用不同編碼格式進行寫入:當開啟輸出檔案時,指定 ``encoding`` " "引數。" -#: ../../library/csv.rst:589 +#: ../../library/csv.rst:609 msgid "Registering a new dialect::" msgstr "註冊一個新的 dialect : ::" -#: ../../library/csv.rst:591 +#: ../../library/csv.rst:611 msgid "" "import csv\n" "csv.register_dialect('unixpwd', delimiter=':', quoting=csv.QUOTE_NONE)\n" @@ -946,13 +981,13 @@ msgstr "" "with open('passwd', newline='') as f:\n" " reader = csv.reader(f, 'unixpwd')" -#: ../../library/csv.rst:596 +#: ../../library/csv.rst:616 msgid "" "A slightly more advanced use of the reader --- catching and reporting " "errors::" msgstr "稍微進階的讀取器用法 -- 擷取及回報錯誤: ::" -#: ../../library/csv.rst:598 +#: ../../library/csv.rst:618 msgid "" "import csv, sys\n" "filename = 'some.csv'\n" @@ -962,7 +997,7 @@ msgid "" " for row in reader:\n" " print(row)\n" " except csv.Error as e:\n" -" sys.exit('file {}, line {}: {}'.format(filename, reader.line_num, e))" +" sys.exit(f'file {filename}, line {reader.line_num}: {e}')" msgstr "" "import csv, sys\n" "filename = 'some.csv'\n" @@ -972,15 +1007,15 @@ msgstr "" " for row in reader:\n" " print(row)\n" " except csv.Error as e:\n" -" sys.exit('file {}, line {}: {}'.format(filename, reader.line_num, e))" +" sys.exit(f'file {filename}, line {reader.line_num}: {e}')" -#: ../../library/csv.rst:608 +#: ../../library/csv.rst:628 msgid "" "And while the module doesn't directly support parsing strings, it can easily " "be done::" msgstr "而當模組無法直接支援剖析字串時,仍可以輕鬆的解決: ::" -#: ../../library/csv.rst:611 +#: ../../library/csv.rst:631 msgid "" "import csv\n" "for row in csv.reader(['one,two,three']):\n" @@ -990,11 +1025,11 @@ msgstr "" "for row in csv.reader(['one,two,three']):\n" " print(row)" -#: ../../library/csv.rst:617 +#: ../../library/csv.rst:637 msgid "Footnotes" msgstr "註解" -#: ../../library/csv.rst:618 +#: ../../library/csv.rst:638 msgid "" "If ``newline=''`` is not specified, newlines embedded inside quoted fields " "will not be interpreted correctly, and on platforms that use ``\\r\\n`` " diff --git a/library/ctypes.po b/library/ctypes.po index 44e245a243..484f953dee 100644 --- a/library/ctypes.po +++ b/library/ctypes.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-14 00:04+0000\n" +"POT-Creation-Date: 2025-07-20 00:19+0000\n" "PO-Revision-Date: 2023-04-26 02:59+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -90,19 +89,19 @@ msgstr "" #: ../../library/ctypes.rst:57 msgid "" ">>> from ctypes import *\n" -">>> print(windll.kernel32) \n" +">>> print(windll.kernel32)\n" "\n" -">>> print(cdll.msvcrt) \n" +">>> print(cdll.msvcrt)\n" "\n" -">>> libc = cdll.msvcrt \n" +">>> libc = cdll.msvcrt\n" ">>>" msgstr "" ">>> from ctypes import *\n" -">>> print(windll.kernel32) \n" +">>> print(windll.kernel32)\n" "\n" -">>> print(cdll.msvcrt) \n" +">>> print(cdll.msvcrt)\n" "\n" -">>> libc = cdll.msvcrt \n" +">>> libc = cdll.msvcrt\n" ">>>" #: ../../library/ctypes.rst:65 @@ -128,17 +127,17 @@ msgstr "" #: ../../library/ctypes.rst:79 msgid "" -">>> cdll.LoadLibrary(\"libc.so.6\") \n" +">>> cdll.LoadLibrary(\"libc.so.6\")\n" "\n" -">>> libc = CDLL(\"libc.so.6\") \n" -">>> libc \n" +">>> libc = CDLL(\"libc.so.6\")\n" +">>> libc\n" "\n" ">>>" msgstr "" -">>> cdll.LoadLibrary(\"libc.so.6\") \n" +">>> cdll.LoadLibrary(\"libc.so.6\")\n" "\n" -">>> libc = CDLL(\"libc.so.6\") \n" -">>> libc \n" +">>> libc = CDLL(\"libc.so.6\")\n" +">>> libc\n" "\n" ">>>" @@ -154,9 +153,9 @@ msgstr "" msgid "" ">>> libc.printf\n" "<_FuncPtr object at 0x...>\n" -">>> print(windll.kernel32.GetModuleHandleA) \n" +">>> print(windll.kernel32.GetModuleHandleA)\n" "<_FuncPtr object at 0x...>\n" -">>> print(windll.kernel32.MyOwnFunction) \n" +">>> print(windll.kernel32.MyOwnFunction)\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" " File \"ctypes.py\", line 239, in __getattr__\n" @@ -166,9 +165,9 @@ msgid "" msgstr "" ">>> libc.printf\n" "<_FuncPtr object at 0x...>\n" -">>> print(windll.kernel32.GetModuleHandleA) \n" +">>> print(windll.kernel32.GetModuleHandleA)\n" "<_FuncPtr object at 0x...>\n" -">>> print(windll.kernel32.MyOwnFunction) \n" +">>> print(windll.kernel32.MyOwnFunction)\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" " File \"ctypes.py\", line 239, in __getattr__\n" @@ -215,11 +214,11 @@ msgstr "" #: ../../library/ctypes.rst:129 msgid "" -">>> getattr(cdll.msvcrt, \"??2@YAPAXI@Z\") \n" +">>> getattr(cdll.msvcrt, \"??2@YAPAXI@Z\")\n" "<_FuncPtr object at 0x...>\n" ">>>" msgstr "" -">>> getattr(cdll.msvcrt, \"??2@YAPAXI@Z\") \n" +">>> getattr(cdll.msvcrt, \"??2@YAPAXI@Z\")\n" "<_FuncPtr object at 0x...>\n" ">>>" @@ -232,9 +231,9 @@ msgstr "" #: ../../library/ctypes.rst:136 msgid "" -">>> cdll.kernel32[1] \n" +">>> cdll.kernel32[1]\n" "<_FuncPtr object at 0x...>\n" -">>> cdll.kernel32[0] \n" +">>> cdll.kernel32[0]\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" " File \"ctypes.py\", line 310, in __getitem__\n" @@ -242,9 +241,9 @@ msgid "" "AttributeError: function ordinal 0 not found\n" ">>>" msgstr "" -">>> cdll.kernel32[1] \n" +">>> cdll.kernel32[1]\n" "<_FuncPtr object at 0x...>\n" -">>> cdll.kernel32[0] \n" +">>> cdll.kernel32[0]\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" " File \"ctypes.py\", line 310, in __getitem__\n" @@ -265,10 +264,10 @@ msgstr "" #: ../../library/ctypes.rst:155 msgid "" -">>> print(libc.rand()) \n" +">>> print(libc.rand())\n" "1804289383" msgstr "" -">>> print(libc.rand()) \n" +">>> print(libc.rand())\n" "1804289383" #: ../../library/ctypes.rst:158 @@ -280,11 +279,11 @@ msgstr "" #: ../../library/ctypes.rst:161 msgid "" -">>> print(hex(windll.kernel32.GetModuleHandleA(None))) \n" +">>> print(hex(windll.kernel32.GetModuleHandleA(None)))\n" "0x1d000000\n" ">>>" msgstr "" -">>> print(hex(windll.kernel32.GetModuleHandleA(None))) \n" +">>> print(hex(windll.kernel32.GetModuleHandleA(None)))\n" "0x1d000000\n" ">>>" @@ -296,28 +295,28 @@ msgstr "" #: ../../library/ctypes.rst:168 msgid "" -">>> cdll.kernel32.GetModuleHandleA(None) \n" +">>> cdll.kernel32.GetModuleHandleA(None)\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" "ValueError: Procedure probably called with not enough arguments (4 bytes " "missing)\n" ">>>\n" "\n" -">>> windll.msvcrt.printf(b\"spam\") \n" +">>> windll.msvcrt.printf(b\"spam\")\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" "ValueError: Procedure probably called with too many arguments (4 bytes in " "excess)\n" ">>>" msgstr "" -">>> cdll.kernel32.GetModuleHandleA(None) \n" +">>> cdll.kernel32.GetModuleHandleA(None)\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" "ValueError: Procedure probably called with not enough arguments (4 bytes " "missing)\n" ">>>\n" "\n" -">>> windll.msvcrt.printf(b\"spam\") \n" +">>> windll.msvcrt.printf(b\"spam\")\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" "ValueError: Procedure probably called with too many arguments (4 bytes in " @@ -339,13 +338,13 @@ msgstr "" #: ../../library/ctypes.rst:187 msgid "" -">>> windll.kernel32.GetModuleHandleA(32) \n" +">>> windll.kernel32.GetModuleHandleA(32)\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" "OSError: exception: access violation reading 0x00000020\n" ">>>" msgstr "" -">>> windll.kernel32.GetModuleHandleA(32) \n" +">>> windll.kernel32.GetModuleHandleA(32)\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" "OSError: exception: access violation reading 0x00000020\n" @@ -366,7 +365,7 @@ msgid "" "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 (:c:expr:" "`char *` or :c:expr:`wchar_t *`). Python integers are passed as the " -"platforms default C :c:expr:`int` type, their value is masked to fit into " +"platform's default C :c:expr:`int` type, their value is masked to fit into " "the C type." msgstr "" @@ -376,7 +375,7 @@ msgid "" "learn more about :mod:`ctypes` data types." msgstr "" -#: ../../library/ctypes.rst:212 ../../library/ctypes.rst:2198 +#: ../../library/ctypes.rst:212 ../../library/ctypes.rst:2278 msgid "Fundamental data types" msgstr "" @@ -441,8 +440,12 @@ msgstr ":class:`c_byte`" #: ../../library/ctypes.rst:233 ../../library/ctypes.rst:235 #: ../../library/ctypes.rst:237 ../../library/ctypes.rst:239 #: ../../library/ctypes.rst:241 ../../library/ctypes.rst:243 -#: ../../library/ctypes.rst:246 ../../library/ctypes.rst:248 -#: ../../library/ctypes.rst:251 +#: ../../library/ctypes.rst:245 ../../library/ctypes.rst:247 +#: ../../library/ctypes.rst:249 ../../library/ctypes.rst:251 +#: ../../library/ctypes.rst:253 ../../library/ctypes.rst:255 +#: ../../library/ctypes.rst:257 ../../library/ctypes.rst:259 +#: ../../library/ctypes.rst:262 ../../library/ctypes.rst:264 +#: ../../library/ctypes.rst:267 msgid "int" msgstr "int" @@ -479,145 +482,209 @@ msgid ":c:expr:`int`" msgstr ":c:expr:`int`" #: ../../library/ctypes.rst:235 +msgid ":class:`c_int8`" +msgstr ":class:`c_int8`" + +#: ../../library/ctypes.rst:235 +msgid ":c:type:`int8_t`" +msgstr ":c:type:`int8_t`" + +#: ../../library/ctypes.rst:237 +msgid ":class:`c_int16`" +msgstr ":class:`c_int16`" + +#: ../../library/ctypes.rst:237 +msgid ":c:type:`int16_t`" +msgstr ":c:type:`int16_t`" + +#: ../../library/ctypes.rst:239 +msgid ":class:`c_int32`" +msgstr ":class:`c_int32`" + +#: ../../library/ctypes.rst:239 +msgid ":c:type:`int32_t`" +msgstr ":c:type:`int32_t`" + +#: ../../library/ctypes.rst:241 +msgid ":class:`c_int64`" +msgstr ":class:`c_int64`" + +#: ../../library/ctypes.rst:241 +msgid ":c:type:`int64_t`" +msgstr ":c:type:`int64_t`" + +#: ../../library/ctypes.rst:243 msgid ":class:`c_uint`" msgstr ":class:`c_uint`" -#: ../../library/ctypes.rst:235 +#: ../../library/ctypes.rst:243 msgid ":c:expr:`unsigned int`" msgstr ":c:expr:`unsigned int`" -#: ../../library/ctypes.rst:237 +#: ../../library/ctypes.rst:245 +msgid ":class:`c_uint8`" +msgstr ":class:`c_uint8`" + +#: ../../library/ctypes.rst:245 +msgid ":c:type:`uint8_t`" +msgstr ":c:type:`uint8_t`" + +#: ../../library/ctypes.rst:247 +msgid ":class:`c_uint16`" +msgstr ":class:`c_uint16`" + +#: ../../library/ctypes.rst:247 +msgid ":c:type:`uint16_t`" +msgstr ":c:type:`uint16_t`" + +#: ../../library/ctypes.rst:249 +msgid ":class:`c_uint32`" +msgstr ":class:`c_uint32`" + +#: ../../library/ctypes.rst:249 +msgid ":c:type:`uint32_t`" +msgstr ":c:type:`uint32_t`" + +#: ../../library/ctypes.rst:251 +msgid ":class:`c_uint64`" +msgstr ":class:`c_uint64`" + +#: ../../library/ctypes.rst:251 +msgid ":c:type:`uint64_t`" +msgstr ":c:type:`uint64_t`" + +#: ../../library/ctypes.rst:253 msgid ":class:`c_long`" msgstr ":class:`c_long`" -#: ../../library/ctypes.rst:237 +#: ../../library/ctypes.rst:253 msgid ":c:expr:`long`" msgstr ":c:expr:`long`" -#: ../../library/ctypes.rst:239 +#: ../../library/ctypes.rst:255 msgid ":class:`c_ulong`" msgstr ":class:`c_ulong`" -#: ../../library/ctypes.rst:239 +#: ../../library/ctypes.rst:255 msgid ":c:expr:`unsigned long`" msgstr ":c:expr:`unsigned long`" -#: ../../library/ctypes.rst:241 +#: ../../library/ctypes.rst:257 msgid ":class:`c_longlong`" msgstr ":class:`c_longlong`" -#: ../../library/ctypes.rst:241 +#: ../../library/ctypes.rst:257 msgid ":c:expr:`__int64` or :c:expr:`long long`" msgstr ":c:expr:`__int64` 或 :c:expr:`long long`" -#: ../../library/ctypes.rst:243 +#: ../../library/ctypes.rst:259 msgid ":class:`c_ulonglong`" msgstr ":class:`c_ulonglong`" -#: ../../library/ctypes.rst:243 +#: ../../library/ctypes.rst:259 msgid ":c:expr:`unsigned __int64` or :c:expr:`unsigned long long`" msgstr ":c:expr:`unsigned __int64` 或 :c:expr:`unsigned long long`" -#: ../../library/ctypes.rst:246 +#: ../../library/ctypes.rst:262 msgid ":class:`c_size_t`" msgstr ":class:`c_size_t`" -#: ../../library/ctypes.rst:246 +#: ../../library/ctypes.rst:262 msgid ":c:type:`size_t`" msgstr ":c:type:`size_t`" -#: ../../library/ctypes.rst:248 +#: ../../library/ctypes.rst:264 msgid ":class:`c_ssize_t`" msgstr ":class:`c_ssize_t`" -#: ../../library/ctypes.rst:248 +#: ../../library/ctypes.rst:264 msgid ":c:type:`ssize_t` or :c:expr:`Py_ssize_t`" msgstr ":c:type:`ssize_t` 或 :c:expr:`Py_ssize_t`" -#: ../../library/ctypes.rst:251 +#: ../../library/ctypes.rst:267 msgid ":class:`c_time_t`" msgstr ":class:`c_time_t`" -#: ../../library/ctypes.rst:251 +#: ../../library/ctypes.rst:267 msgid ":c:type:`time_t`" msgstr ":c:type:`time_t`" -#: ../../library/ctypes.rst:253 +#: ../../library/ctypes.rst:269 msgid ":class:`c_float`" msgstr ":class:`c_float`" -#: ../../library/ctypes.rst:253 +#: ../../library/ctypes.rst:269 msgid ":c:expr:`float`" msgstr ":c:expr:`float`" -#: ../../library/ctypes.rst:253 ../../library/ctypes.rst:255 -#: ../../library/ctypes.rst:257 +#: ../../library/ctypes.rst:269 ../../library/ctypes.rst:271 +#: ../../library/ctypes.rst:273 msgid "float" msgstr "float" -#: ../../library/ctypes.rst:255 +#: ../../library/ctypes.rst:271 msgid ":class:`c_double`" msgstr ":class:`c_double`" -#: ../../library/ctypes.rst:255 +#: ../../library/ctypes.rst:271 msgid ":c:expr:`double`" msgstr ":c:expr:`double`" -#: ../../library/ctypes.rst:257 +#: ../../library/ctypes.rst:273 msgid ":class:`c_longdouble`" msgstr ":class:`c_longdouble`" -#: ../../library/ctypes.rst:257 +#: ../../library/ctypes.rst:273 msgid ":c:expr:`long double`" msgstr ":c:expr:`long double`" -#: ../../library/ctypes.rst:259 +#: ../../library/ctypes.rst:275 msgid ":class:`c_char_p`" msgstr ":class:`c_char_p`" -#: ../../library/ctypes.rst:259 +#: ../../library/ctypes.rst:275 msgid ":c:expr:`char *` (NUL terminated)" msgstr "" -#: ../../library/ctypes.rst:259 +#: ../../library/ctypes.rst:275 msgid "bytes object or ``None``" -msgstr "" +msgstr "位元組物件或 ``None``" -#: ../../library/ctypes.rst:261 +#: ../../library/ctypes.rst:277 msgid ":class:`c_wchar_p`" msgstr ":class:`c_wchar_p`" -#: ../../library/ctypes.rst:261 +#: ../../library/ctypes.rst:277 msgid ":c:expr:`wchar_t *` (NUL terminated)" msgstr "" -#: ../../library/ctypes.rst:261 +#: ../../library/ctypes.rst:277 msgid "string or ``None``" msgstr "字串或 ``None``" -#: ../../library/ctypes.rst:263 +#: ../../library/ctypes.rst:279 msgid ":class:`c_void_p`" msgstr ":class:`c_void_p`" -#: ../../library/ctypes.rst:263 +#: ../../library/ctypes.rst:279 msgid ":c:expr:`void *`" msgstr ":c:expr:`void *`" -#: ../../library/ctypes.rst:263 +#: ../../library/ctypes.rst:279 msgid "int or ``None``" msgstr "" -#: ../../library/ctypes.rst:267 +#: ../../library/ctypes.rst:283 msgid "The constructor accepts any object with a truth value." msgstr "" -#: ../../library/ctypes.rst:269 +#: ../../library/ctypes.rst:285 msgid "" "All these types can be created by calling them with an optional initializer " "of the correct type and value::" msgstr "" -#: ../../library/ctypes.rst:272 +#: ../../library/ctypes.rst:288 msgid "" ">>> c_int()\n" "c_long(0)\n" @@ -635,12 +702,12 @@ msgstr "" "c_ushort(65533)\n" ">>>" -#: ../../library/ctypes.rst:280 +#: ../../library/ctypes.rst:296 msgid "" "Since these types are mutable, their value can also be changed afterwards::" msgstr "" -#: ../../library/ctypes.rst:282 +#: ../../library/ctypes.rst:298 msgid "" ">>> i = c_int(42)\n" ">>> print(i)\n" @@ -662,15 +729,15 @@ msgstr "" "-99\n" ">>>" -#: ../../library/ctypes.rst:292 +#: ../../library/ctypes.rst:308 msgid "" "Assigning a new value to instances of the pointer types :class:`c_char_p`, :" "class:`c_wchar_p`, and :class:`c_void_p` changes the *memory location* they " "point to, *not the contents* of the memory block (of course not, because " -"Python bytes objects are immutable)::" +"Python string objects are immutable)::" msgstr "" -#: ../../library/ctypes.rst:297 +#: ../../library/ctypes.rst:313 msgid "" ">>> s = \"Hello, World\"\n" ">>> c_s = c_wchar_p(s)\n" @@ -687,8 +754,22 @@ msgid "" "Hello, World\n" ">>>" msgstr "" +">>> s = \"Hello, World\"\n" +">>> c_s = c_wchar_p(s)\n" +">>> print(c_s)\n" +"c_wchar_p(139966785747344)\n" +">>> print(c_s.value)\n" +"Hello World\n" +">>> c_s.value = \"Hi, there\"\n" +">>> print(c_s) # 記憶體位置已改變\n" +"c_wchar_p(139966783348904)\n" +">>> print(c_s.value)\n" +"Hi, there\n" +">>> print(s) # 第一個物件未改變\n" +"Hello, World\n" +">>>" -#: ../../library/ctypes.rst:312 +#: ../../library/ctypes.rst:328 msgid "" "You should be careful, however, not to pass them to functions expecting " "pointers to mutable memory. If you need mutable memory blocks, ctypes has a :" @@ -698,7 +779,7 @@ msgid "" "``value`` property::" msgstr "" -#: ../../library/ctypes.rst:319 +#: ../../library/ctypes.rst:335 msgid "" ">>> from ctypes import *\n" ">>> p = create_string_buffer(3) # create a 3 byte buffer, " @@ -720,7 +801,7 @@ msgid "" ">>>" msgstr "" -#: ../../library/ctypes.rst:336 +#: ../../library/ctypes.rst:352 msgid "" "The :func:`create_string_buffer` function replaces the old :func:`!c_buffer` " "function (which is still available as an alias). To create a mutable memory " @@ -728,18 +809,18 @@ msgid "" "the :func:`create_unicode_buffer` function." msgstr "" -#: ../../library/ctypes.rst:345 +#: ../../library/ctypes.rst:361 msgid "Calling functions, continued" msgstr "" -#: ../../library/ctypes.rst:347 +#: ../../library/ctypes.rst:363 msgid "" "Note that printf prints to the real standard output channel, *not* to :data:" "`sys.stdout`, so these examples will only work at the console prompt, not " "from within *IDLE* or *PythonWin*::" msgstr "" -#: ../../library/ctypes.rst:351 +#: ../../library/ctypes.rst:367 msgid "" ">>> printf = libc.printf\n" ">>> printf(b\"Hello, %s\\n\", b\"World!\")\n" @@ -754,7 +835,8 @@ msgid "" ">>> printf(b\"%f bottles of beer\\n\", 42.5)\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" -"ArgumentError: argument 2: TypeError: Don't know how to convert parameter 2\n" +"ctypes.ArgumentError: argument 2: TypeError: Don't know how to convert " +"parameter 2\n" ">>>" msgstr "" ">>> printf = libc.printf\n" @@ -770,17 +852,18 @@ msgstr "" ">>> printf(b\"%f bottles of beer\\n\", 42.5)\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" -"ArgumentError: argument 2: TypeError: Don't know how to convert parameter 2\n" +"ctypes.ArgumentError: argument 2: TypeError: Don't know how to convert " +"parameter 2\n" ">>>" -#: ../../library/ctypes.rst:367 +#: ../../library/ctypes.rst:383 msgid "" "As has been mentioned before, all Python types except integers, strings, and " "bytes objects have to be wrapped in their corresponding :mod:`ctypes` type, " "so that they can be converted to the required C data type::" msgstr "" -#: ../../library/ctypes.rst:371 +#: ../../library/ctypes.rst:387 msgid "" ">>> printf(b\"An int %d, a double %f\\n\", 1234, c_double(3.14))\n" "An int 1234, a double 3.140000\n" @@ -792,11 +875,11 @@ msgstr "" "31\n" ">>>" -#: ../../library/ctypes.rst:379 +#: ../../library/ctypes.rst:395 msgid "Calling variadic functions" msgstr "" -#: ../../library/ctypes.rst:381 +#: ../../library/ctypes.rst:397 msgid "" "On a lot of platforms calling variadic functions through ctypes is exactly " "the same as calling functions with a fixed number of parameters. On some " @@ -805,27 +888,27 @@ msgid "" "functions." msgstr "" -#: ../../library/ctypes.rst:386 +#: ../../library/ctypes.rst:402 msgid "" -"On those platforms it is required to specify the :attr:`~_FuncPtr.argtypes` " +"On those platforms it is required to specify the :attr:`~_CFuncPtr.argtypes` " "attribute for the regular, non-variadic, function arguments:" msgstr "" -#: ../../library/ctypes.rst:389 +#: ../../library/ctypes.rst:405 msgid "libc.printf.argtypes = [ctypes.c_char_p]" msgstr "libc.printf.argtypes = [ctypes.c_char_p]" -#: ../../library/ctypes.rst:393 +#: ../../library/ctypes.rst:409 msgid "" "Because specifying the attribute does not inhibit portability it is advised " -"to always specify :attr:`~_FuncPtr.argtypes` for all variadic functions." +"to always specify :attr:`~_CFuncPtr.argtypes` for all variadic functions." msgstr "" -#: ../../library/ctypes.rst:400 +#: ../../library/ctypes.rst:416 msgid "Calling functions with your own custom data types" msgstr "" -#: ../../library/ctypes.rst:402 +#: ../../library/ctypes.rst:418 msgid "" "You can also customize :mod:`ctypes` argument conversion to allow instances " "of your own classes be used as function arguments. :mod:`ctypes` looks for " @@ -834,7 +917,7 @@ msgid "" "or an object with an :attr:`!_as_parameter_` attribute::" msgstr "" -#: ../../library/ctypes.rst:408 +#: ../../library/ctypes.rst:424 msgid "" ">>> class Bottles:\n" "... def __init__(self, number):\n" @@ -856,33 +939,33 @@ msgstr "" "19\n" ">>>" -#: ../../library/ctypes.rst:418 +#: ../../library/ctypes.rst:434 msgid "" "If you don't want to store the instance's data in the :attr:`!" "_as_parameter_` instance variable, you could define a :class:`property` " "which makes the attribute available on request." msgstr "" -#: ../../library/ctypes.rst:426 +#: ../../library/ctypes.rst:442 msgid "Specifying the required argument types (function prototypes)" msgstr "" -#: ../../library/ctypes.rst:428 +#: ../../library/ctypes.rst:444 msgid "" "It is possible to specify the required argument types of functions exported " -"from DLLs by setting the :attr:`~_FuncPtr.argtypes` attribute." +"from DLLs by setting the :attr:`~_CFuncPtr.argtypes` attribute." msgstr "" -#: ../../library/ctypes.rst:431 +#: ../../library/ctypes.rst:447 msgid "" -":attr:`~_FuncPtr.argtypes` must be a sequence of C data types (the :func:`!" +":attr:`~_CFuncPtr.argtypes` must be a sequence of C data types (the :func:`!" "printf` function is probably not a good example here, because it takes a " "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)::" msgstr "" -#: ../../library/ctypes.rst:436 +#: ../../library/ctypes.rst:452 msgid "" ">>> printf.argtypes = [c_char_p, c_char_p, c_int, c_double]\n" ">>> printf(b\"String '%s', Int %d, Double %f\\n\", b\"Hi\", 10, 2.2)\n" @@ -896,19 +979,20 @@ msgstr "" "37\n" ">>>" -#: ../../library/ctypes.rst:442 +#: ../../library/ctypes.rst:458 msgid "" "Specifying a format protects against incompatible argument types (just as a " "prototype for a C function), and tries to convert the arguments to valid " "types::" msgstr "" -#: ../../library/ctypes.rst:445 +#: ../../library/ctypes.rst:461 msgid "" ">>> printf(b\"%d %d %d\", 1, 2, 3)\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" -"ArgumentError: argument 2: TypeError: wrong type\n" +"ctypes.ArgumentError: argument 2: TypeError: 'int' object cannot be " +"interpreted as ctypes.c_char_p\n" ">>> printf(b\"%s %d %f\\n\", b\"X\", 2, 3)\n" "X 2 3.000000\n" "13\n" @@ -917,17 +1001,18 @@ msgstr "" ">>> printf(b\"%d %d %d\", 1, 2, 3)\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" -"ArgumentError: argument 2: TypeError: wrong type\n" +"ctypes.ArgumentError: argument 2: TypeError: 'int' object cannot be " +"interpreted as ctypes.c_char_p\n" ">>> printf(b\"%s %d %f\\n\", b\"X\", 2, 3)\n" "X 2 3.000000\n" "13\n" ">>>" -#: ../../library/ctypes.rst:454 +#: ../../library/ctypes.rst:470 msgid "" "If you have defined your own classes which you pass to function calls, you " "have to implement a :meth:`~_CData.from_param` class method for them to be " -"able to use them in the :attr:`~_FuncPtr.argtypes` sequence. The :meth:" +"able to use them in the :attr:`~_CFuncPtr.argtypes` sequence. The :meth:" "`~_CData.from_param` 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 :attr:`!" @@ -937,60 +1022,60 @@ msgid "" "_as_parameter_` attribute." msgstr "" -#: ../../library/ctypes.rst:468 +#: ../../library/ctypes.rst:484 msgid "Return types" msgstr "" -#: ../../library/ctypes.rst:478 +#: ../../library/ctypes.rst:494 msgid "" "By default functions are assumed to return the C :c:expr:`int` type. Other " -"return types can be specified by setting the :attr:`~_FuncPtr.restype` " +"return types can be specified by setting the :attr:`~_CFuncPtr.restype` " "attribute of the function object." msgstr "" -#: ../../library/ctypes.rst:482 +#: ../../library/ctypes.rst:498 msgid "" "The C prototype of :c:func:`time` is ``time_t time(time_t *)``. Because :c:" "type:`time_t` might be of a different type than the default return type :c:" "expr:`int`, you should specify the :attr:`!restype` attribute::" msgstr "" -#: ../../library/ctypes.rst:486 +#: ../../library/ctypes.rst:502 msgid ">>> libc.time.restype = c_time_t" msgstr ">>> libc.time.restype = c_time_t" -#: ../../library/ctypes.rst:488 -msgid "The argument types can be specified using :attr:`~_FuncPtr.argtypes`::" +#: ../../library/ctypes.rst:504 +msgid "The argument types can be specified using :attr:`~_CFuncPtr.argtypes`::" msgstr "" -#: ../../library/ctypes.rst:490 +#: ../../library/ctypes.rst:506 msgid ">>> libc.time.argtypes = (POINTER(c_time_t),)" msgstr ">>> libc.time.argtypes = (POINTER(c_time_t),)" -#: ../../library/ctypes.rst:492 +#: ../../library/ctypes.rst:508 msgid "" "To call the function with a ``NULL`` pointer as first argument, use " "``None``::" msgstr "" -#: ../../library/ctypes.rst:494 +#: ../../library/ctypes.rst:510 msgid "" -">>> print(libc.time(None)) \n" +">>> print(libc.time(None))\n" "1150640792" msgstr "" -">>> print(libc.time(None)) \n" +">>> print(libc.time(None))\n" "1150640792" -#: ../../library/ctypes.rst:497 +#: ../../library/ctypes.rst:513 msgid "" "Here is a more advanced example, it uses the :func:`!strchr` function, which " "expects a string pointer and a char, and returns a pointer to a string::" msgstr "" -#: ../../library/ctypes.rst:500 +#: ../../library/ctypes.rst:516 msgid "" ">>> strchr = libc.strchr\n" -">>> strchr(b\"abcdef\", ord(\"d\")) \n" +">>> strchr(b\"abcdef\", ord(\"d\"))\n" "8059983\n" ">>> strchr.restype = c_char_p # c_char_p is a pointer to a string\n" ">>> strchr(b\"abcdef\", ord(\"d\"))\n" @@ -1000,7 +1085,7 @@ msgid "" ">>>" msgstr "" ">>> strchr = libc.strchr\n" -">>> strchr(b\"abcdef\", ord(\"d\")) \n" +">>> strchr(b\"abcdef\", ord(\"d\"))\n" "8059983\n" ">>> strchr.restype = c_char_p # c_char_p 一個字串的指標\n" ">>> strchr(b\"abcdef\", ord(\"d\"))\n" @@ -1009,14 +1094,14 @@ msgstr "" "None\n" ">>>" -#: ../../library/ctypes.rst:510 +#: ../../library/ctypes.rst:526 msgid "" "If you want to avoid the :func:`ord(\"x\") ` calls above, you can set " -"the :attr:`~_FuncPtr.argtypes` attribute, and the second argument will be " +"the :attr:`~_CFuncPtr.argtypes` attribute, and the second argument will be " "converted from a single character Python bytes object into a C char:" msgstr "" -#: ../../library/ctypes.rst:514 +#: ../../library/ctypes.rst:530 msgid "" ">>> strchr.restype = c_char_p\n" ">>> strchr.argtypes = [c_char_p, c_char]\n" @@ -1046,53 +1131,53 @@ msgstr "" "b'def'\n" ">>>" -#: ../../library/ctypes.rst:529 +#: ../../library/ctypes.rst:545 msgid "" "You can also use a callable Python object (a function or a class for " -"example) as the :attr:`~_FuncPtr.restype` 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::" +"example) as the :attr:`~_CFuncPtr.restype` 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::" msgstr "" -#: ../../library/ctypes.rst:535 +#: ../../library/ctypes.rst:551 msgid "" -">>> GetModuleHandle = windll.kernel32.GetModuleHandleA \n" +">>> GetModuleHandle = windll.kernel32.GetModuleHandleA\n" ">>> def ValidHandle(value):\n" "... if value == 0:\n" "... raise WinError()\n" "... return value\n" "...\n" ">>>\n" -">>> GetModuleHandle.restype = ValidHandle \n" -">>> GetModuleHandle(None) \n" +">>> GetModuleHandle.restype = ValidHandle\n" +">>> GetModuleHandle(None)\n" "486539264\n" -">>> GetModuleHandle(\"something silly\") \n" +">>> GetModuleHandle(\"something silly\")\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" " File \"\", line 3, in ValidHandle\n" "OSError: [Errno 126] The specified module could not be found.\n" ">>>" msgstr "" -">>> GetModuleHandle = windll.kernel32.GetModuleHandleA \n" +">>> GetModuleHandle = windll.kernel32.GetModuleHandleA\n" ">>> def ValidHandle(value):\n" "... if value == 0:\n" "... raise WinError()\n" "... return value\n" "...\n" ">>>\n" -">>> GetModuleHandle.restype = ValidHandle \n" -">>> GetModuleHandle(None) \n" +">>> GetModuleHandle.restype = ValidHandle\n" +">>> GetModuleHandle(None)\n" "486539264\n" -">>> GetModuleHandle(\"something silly\") \n" +">>> GetModuleHandle(\"something silly\")\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" " File \"\", line 3, in ValidHandle\n" "OSError: [Errno 126] The specified module could not be found.\n" ">>>" -#: ../../library/ctypes.rst:552 +#: ../../library/ctypes.rst:568 msgid "" "``WinError`` is a function which will call Windows ``FormatMessage()`` api " "to get the string representation of an error code, and *returns* an " @@ -1100,18 +1185,18 @@ msgid "" "used, it calls :func:`GetLastError` to retrieve it." msgstr "" -#: ../../library/ctypes.rst:557 +#: ../../library/ctypes.rst:573 msgid "" "Please note that a much more powerful error checking mechanism is available " -"through the :attr:`~_FuncPtr.errcheck` attribute; see the reference manual " +"through the :attr:`~_CFuncPtr.errcheck` attribute; see the reference manual " "for details." msgstr "" -#: ../../library/ctypes.rst:565 +#: ../../library/ctypes.rst:581 msgid "Passing pointers (or: passing parameters by reference)" msgstr "" -#: ../../library/ctypes.rst:567 +#: ../../library/ctypes.rst:583 msgid "" "Sometimes a C api function expects a *pointer* to a data type as parameter, " "probably to write into the corresponding location, or if the data is too " @@ -1119,7 +1204,7 @@ msgid "" "reference*." msgstr "" -#: ../../library/ctypes.rst:571 +#: ../../library/ctypes.rst:587 msgid "" ":mod:`ctypes` exports the :func:`byref` function which is used to pass " "parameters by reference. The same effect can be achieved with the :func:" @@ -1128,7 +1213,7 @@ msgid "" "you don't need the pointer object in Python itself::" msgstr "" -#: ../../library/ctypes.rst:577 +#: ../../library/ctypes.rst:593 msgid "" ">>> i = c_int()\n" ">>> f = c_float()\n" @@ -1154,11 +1239,11 @@ msgstr "" "1 3.1400001049 b'Hello'\n" ">>>" -#: ../../library/ctypes.rst:593 +#: ../../library/ctypes.rst:609 msgid "Structures and unions" msgstr "" -#: ../../library/ctypes.rst:595 +#: ../../library/ctypes.rst:611 msgid "" "Structures and unions must derive from the :class:`Structure` and :class:" "`Union` base classes which are defined in the :mod:`ctypes` module. Each " @@ -1167,20 +1252,20 @@ msgid "" "*field type*." msgstr "" -#: ../../library/ctypes.rst:600 +#: ../../library/ctypes.rst:616 msgid "" "The field type must be a :mod:`ctypes` type like :class:`c_int`, or any " "other derived :mod:`ctypes` type: structure, union, array, pointer." msgstr "" -#: ../../library/ctypes.rst:603 +#: ../../library/ctypes.rst:619 msgid "" "Here is a simple example of a POINT structure, which contains two integers " "named *x* and *y*, and also shows how to initialize a structure in the " "constructor::" msgstr "" -#: ../../library/ctypes.rst:606 +#: ../../library/ctypes.rst:622 msgid "" ">>> from ctypes import *\n" ">>> class POINT(Structure):\n" @@ -1216,19 +1301,19 @@ msgstr "" "TypeError: too many initializers\n" ">>>" -#: ../../library/ctypes.rst:623 +#: ../../library/ctypes.rst:639 msgid "" "You can, however, build much more complicated structures. A structure can " "itself contain other structures by using a structure as a field type." msgstr "" -#: ../../library/ctypes.rst:626 +#: ../../library/ctypes.rst:642 msgid "" "Here is a RECT structure which contains two POINTs named *upperleft* and " "*lowerright*::" msgstr "" -#: ../../library/ctypes.rst:629 +#: ../../library/ctypes.rst:645 msgid "" ">>> class RECT(Structure):\n" "... _fields_ = [(\"upperleft\", POINT),\n" @@ -1252,13 +1337,13 @@ msgstr "" "0 0\n" ">>>" -#: ../../library/ctypes.rst:640 +#: ../../library/ctypes.rst:656 msgid "" "Nested structures can also be initialized in the constructor in several " "ways::" msgstr "" -#: ../../library/ctypes.rst:642 +#: ../../library/ctypes.rst:658 msgid "" ">>> r = RECT(POINT(1, 2), POINT(3, 4))\n" ">>> r = RECT((1, 2), (3, 4))" @@ -1266,13 +1351,13 @@ msgstr "" ">>> r = RECT(POINT(1, 2), POINT(3, 4))\n" ">>> r = RECT((1, 2), (3, 4))" -#: ../../library/ctypes.rst:645 +#: ../../library/ctypes.rst:661 msgid "" "Field :term:`descriptor`\\s can be retrieved from the *class*, they are " "useful for debugging because they can provide useful information::" msgstr "" -#: ../../library/ctypes.rst:648 +#: ../../library/ctypes.rst:664 msgid "" ">>> print(POINT.x)\n" "\n" @@ -1286,7 +1371,7 @@ msgstr "" "\n" ">>>" -#: ../../library/ctypes.rst:659 +#: ../../library/ctypes.rst:675 msgid "" ":mod:`ctypes` does not support passing unions or structures with bit-fields " "to functions by value. While this may work on 32-bit x86, it's not " @@ -1294,20 +1379,24 @@ msgid "" "structures with bit-fields should always be passed to functions by pointer." msgstr "" -#: ../../library/ctypes.rst:665 +#: ../../library/ctypes.rst:681 msgid "Structure/union alignment and byte order" msgstr "" -#: ../../library/ctypes.rst:667 +#: ../../library/ctypes.rst:683 msgid "" "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 :" "attr:`~Structure._pack_` 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." +"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 :attr:`~Structure._align_` class attribute in the subclass " +"definition." msgstr "" -#: ../../library/ctypes.rst:673 +#: ../../library/ctypes.rst:693 msgid "" ":mod:`ctypes` uses the native byte order for Structures and Unions. To " "build structures with non-native byte order, you can use one of the :class:" @@ -1316,18 +1405,18 @@ msgid "" "classes cannot contain pointer fields." msgstr "" -#: ../../library/ctypes.rst:683 +#: ../../library/ctypes.rst:703 msgid "Bit fields in structures and unions" msgstr "" -#: ../../library/ctypes.rst:685 +#: ../../library/ctypes.rst:705 msgid "" "It is possible to create structures and unions containing bit fields. Bit " "fields are only possible for integer fields, the bit width is specified as " "the third item in the :attr:`~Structure._fields_` tuples::" msgstr "" -#: ../../library/ctypes.rst:689 +#: ../../library/ctypes.rst:709 msgid "" ">>> class Int(Structure):\n" "... _fields_ = [(\"first_16\", c_int, 16),\n" @@ -1349,33 +1438,33 @@ msgstr "" "\n" ">>>" -#: ../../library/ctypes.rst:703 +#: ../../library/ctypes.rst:723 msgid "Arrays" msgstr "" -#: ../../library/ctypes.rst:705 +#: ../../library/ctypes.rst:725 msgid "" "Arrays are sequences, containing a fixed number of instances of the same " "type." msgstr "" -#: ../../library/ctypes.rst:707 +#: ../../library/ctypes.rst:727 msgid "" "The recommended way to create array types is by multiplying a data type with " "a positive integer::" msgstr "" -#: ../../library/ctypes.rst:710 +#: ../../library/ctypes.rst:730 msgid "TenPointsArrayType = POINT * 10" msgstr "" -#: ../../library/ctypes.rst:712 +#: ../../library/ctypes.rst:732 msgid "" "Here is an example of a somewhat artificial data type, a structure " "containing 4 POINTs among other stuff::" msgstr "" -#: ../../library/ctypes.rst:715 +#: ../../library/ctypes.rst:735 msgid "" ">>> from ctypes import *\n" ">>> class POINT(Structure):\n" @@ -1403,28 +1492,31 @@ msgstr "" "4\n" ">>>" -#: ../../library/ctypes.rst:728 +#: ../../library/ctypes.rst:748 msgid "Instances are created in the usual way, by calling the class::" msgstr "" -#: ../../library/ctypes.rst:730 +#: ../../library/ctypes.rst:750 msgid "" "arr = TenPointsArrayType()\n" "for pt in arr:\n" " print(pt.x, pt.y)" msgstr "" +"arr = TenPointsArrayType()\n" +"for pt in arr:\n" +" print(pt.x, pt.y)" -#: ../../library/ctypes.rst:734 +#: ../../library/ctypes.rst:754 msgid "" "The above code print a series of ``0 0`` lines, because the array contents " "is initialized to zeros." msgstr "" -#: ../../library/ctypes.rst:737 +#: ../../library/ctypes.rst:757 msgid "Initializers of the correct type can also be specified::" msgstr "" -#: ../../library/ctypes.rst:739 +#: ../../library/ctypes.rst:759 msgid "" ">>> from ctypes import *\n" ">>> TenIntegers = c_int * 10\n" @@ -1446,17 +1538,17 @@ msgstr "" "1 2 3 4 5 6 7 8 9 10\n" ">>>" -#: ../../library/ctypes.rst:753 +#: ../../library/ctypes.rst:773 msgid "Pointers" -msgstr "" +msgstr "指標" -#: ../../library/ctypes.rst:755 +#: ../../library/ctypes.rst:775 msgid "" "Pointer instances are created by calling the :func:`pointer` function on a :" "mod:`ctypes` type::" msgstr "" -#: ../../library/ctypes.rst:758 +#: ../../library/ctypes.rst:778 msgid "" ">>> from ctypes import *\n" ">>> i = c_int(42)\n" @@ -1468,13 +1560,13 @@ msgstr "" ">>> pi = pointer(i)\n" ">>>" -#: ../../library/ctypes.rst:763 +#: ../../library/ctypes.rst:783 msgid "" "Pointer instances have a :attr:`~_Pointer.contents` attribute which returns " "the object to which the pointer points, the ``i`` object above::" msgstr "" -#: ../../library/ctypes.rst:766 +#: ../../library/ctypes.rst:786 msgid "" ">>> pi.contents\n" "c_long(42)\n" @@ -1484,13 +1576,13 @@ msgstr "" "c_long(42)\n" ">>>" -#: ../../library/ctypes.rst:770 +#: ../../library/ctypes.rst:790 msgid "" "Note that :mod:`ctypes` does not have OOR (original object return), it " "constructs a new, equivalent object each time you retrieve an attribute::" msgstr "" -#: ../../library/ctypes.rst:773 +#: ../../library/ctypes.rst:793 msgid "" ">>> pi.contents is i\n" "False\n" @@ -1504,14 +1596,14 @@ msgstr "" "False\n" ">>>" -#: ../../library/ctypes.rst:779 +#: ../../library/ctypes.rst:799 msgid "" "Assigning another :class:`c_int` instance to the pointer's contents " "attribute would cause the pointer to point to the memory location where this " "is stored::" msgstr "" -#: ../../library/ctypes.rst:782 +#: ../../library/ctypes.rst:802 msgid "" ">>> i = c_int(99)\n" ">>> pi.contents = i\n" @@ -1525,11 +1617,11 @@ msgstr "" "c_long(99)\n" ">>>" -#: ../../library/ctypes.rst:791 +#: ../../library/ctypes.rst:811 msgid "Pointer instances can also be indexed with integers::" msgstr "" -#: ../../library/ctypes.rst:793 +#: ../../library/ctypes.rst:813 msgid "" ">>> pi[0]\n" "99\n" @@ -1539,11 +1631,11 @@ msgstr "" "99\n" ">>>" -#: ../../library/ctypes.rst:797 +#: ../../library/ctypes.rst:817 msgid "Assigning to an integer index changes the pointed to value::" msgstr "" -#: ../../library/ctypes.rst:799 +#: ../../library/ctypes.rst:819 msgid "" ">>> print(i)\n" "c_long(99)\n" @@ -1559,7 +1651,7 @@ msgstr "" "c_long(22)\n" ">>>" -#: ../../library/ctypes.rst:806 +#: ../../library/ctypes.rst:826 msgid "" "It is also possible to use indexes different from 0, but you must know what " "you're doing, just as in C: You can access or change arbitrary memory " @@ -1568,7 +1660,7 @@ msgid "" "instead of a single item." msgstr "" -#: ../../library/ctypes.rst:812 +#: ../../library/ctypes.rst:832 msgid "" "Behind the scenes, the :func:`pointer` function does more than simply create " "pointer instances, it has to create pointer *types* first. This is done with " @@ -1576,7 +1668,7 @@ msgid "" "returns a new type::" msgstr "" -#: ../../library/ctypes.rst:817 +#: ../../library/ctypes.rst:837 msgid "" ">>> PI = POINTER(c_int)\n" ">>> PI\n" @@ -1600,13 +1692,13 @@ msgstr "" "\n" ">>>" -#: ../../library/ctypes.rst:828 +#: ../../library/ctypes.rst:848 msgid "" "Calling the pointer type without an argument creates a ``NULL`` pointer. " "``NULL`` pointers have a ``False`` boolean value::" msgstr "" -#: ../../library/ctypes.rst:831 +#: ../../library/ctypes.rst:851 msgid "" ">>> null_ptr = POINTER(c_int)()\n" ">>> print(bool(null_ptr))\n" @@ -1618,13 +1710,13 @@ msgstr "" "False\n" ">>>" -#: ../../library/ctypes.rst:836 +#: ../../library/ctypes.rst:856 msgid "" ":mod:`ctypes` checks for ``NULL`` when dereferencing pointers (but " "dereferencing invalid non-\\ ``NULL`` pointers would crash Python)::" msgstr "" -#: ../../library/ctypes.rst:839 +#: ../../library/ctypes.rst:859 msgid "" ">>> null_ptr[0]\n" "Traceback (most recent call last):\n" @@ -1650,14 +1742,14 @@ msgstr "" "ValueError: NULL pointer access\n" ">>>" -#: ../../library/ctypes.rst:855 +#: ../../library/ctypes.rst:875 msgid "Type conversions" msgstr "" -#: ../../library/ctypes.rst:857 +#: ../../library/ctypes.rst:877 msgid "" "Usually, ctypes does strict type checking. This means, if you have " -"``POINTER(c_int)`` in the :attr:`~_FuncPtr.argtypes` list of a function or " +"``POINTER(c_int)`` in the :attr:`~_CFuncPtr.argtypes` 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 " @@ -1665,7 +1757,7 @@ msgid "" "ctypes accepts an array of c_int::" msgstr "" -#: ../../library/ctypes.rst:864 +#: ../../library/ctypes.rst:884 msgid "" ">>> class Bar(Structure):\n" "... _fields_ = [(\"count\", c_int), (\"values\", POINTER(c_int))]\n" @@ -1695,20 +1787,20 @@ msgstr "" "3\n" ">>>" -#: ../../library/ctypes.rst:878 +#: ../../library/ctypes.rst:898 msgid "" "In addition, if a function argument is explicitly declared to be a pointer " -"type (such as ``POINTER(c_int)``) in :attr:`~_FuncPtr.argtypes`, an object " +"type (such as ``POINTER(c_int)``) in :attr:`~_CFuncPtr.argtypes`, an object " "of the pointed type (``c_int`` in this case) can be passed to the function. " "ctypes will apply the required :func:`byref` conversion in this case " "automatically." msgstr "" -#: ../../library/ctypes.rst:883 +#: ../../library/ctypes.rst:903 msgid "To set a POINTER type field to ``NULL``, you can assign ``None``::" msgstr "" -#: ../../library/ctypes.rst:885 +#: ../../library/ctypes.rst:905 msgid "" ">>> bar.values = None\n" ">>>" @@ -1716,7 +1808,7 @@ msgstr "" ">>> bar.values = None\n" ">>>" -#: ../../library/ctypes.rst:890 +#: ../../library/ctypes.rst:910 msgid "" "Sometimes you have instances of incompatible types. In C, you can cast one " "type into another type. :mod:`ctypes` provides a :func:`cast` function " @@ -1725,7 +1817,7 @@ msgid "" "``values`` field, but not instances of other types::" msgstr "" -#: ../../library/ctypes.rst:896 +#: ../../library/ctypes.rst:916 msgid "" ">>> bar.values = (c_byte * 4)()\n" "Traceback (most recent call last):\n" @@ -1741,11 +1833,11 @@ msgstr "" "instance\n" ">>>" -#: ../../library/ctypes.rst:902 +#: ../../library/ctypes.rst:922 msgid "For these cases, the :func:`cast` function is handy." msgstr "" -#: ../../library/ctypes.rst:904 +#: ../../library/ctypes.rst:924 msgid "" "The :func:`cast` function can be used to cast a ctypes instance into a " "pointer to a different ctypes data type. :func:`cast` takes two parameters, " @@ -1754,7 +1846,7 @@ msgid "" "references the same memory block as the first argument::" msgstr "" -#: ../../library/ctypes.rst:910 +#: ../../library/ctypes.rst:930 msgid "" ">>> a = (c_byte * 4)()\n" ">>> cast(a, POINTER(c_int))\n" @@ -1766,13 +1858,13 @@ msgstr "" "\n" ">>>" -#: ../../library/ctypes.rst:915 +#: ../../library/ctypes.rst:935 msgid "" "So, :func:`cast` can be used to assign to the ``values`` field of ``Bar`` " "the structure::" msgstr "" -#: ../../library/ctypes.rst:918 +#: ../../library/ctypes.rst:938 msgid "" ">>> bar = Bar()\n" ">>> bar.values = cast((c_byte * 4)(), POINTER(c_int))\n" @@ -1786,18 +1878,18 @@ msgstr "" "0\n" ">>>" -#: ../../library/ctypes.rst:928 +#: ../../library/ctypes.rst:948 msgid "Incomplete Types" msgstr "" -#: ../../library/ctypes.rst:930 +#: ../../library/ctypes.rst:950 msgid "" "*Incomplete Types* are structures, unions or arrays whose members are not " "yet specified. In C, they are specified by forward declarations, which are " "defined later::" msgstr "" -#: ../../library/ctypes.rst:934 +#: ../../library/ctypes.rst:954 msgid "" "struct cell; /* forward declaration */\n" "\n" @@ -1807,13 +1899,13 @@ msgid "" "};" msgstr "" -#: ../../library/ctypes.rst:941 +#: ../../library/ctypes.rst:961 msgid "" "The straightforward translation into ctypes code would be this, but it does " "not work::" msgstr "" -#: ../../library/ctypes.rst:944 +#: ../../library/ctypes.rst:964 msgid "" ">>> class cell(Structure):\n" "... _fields_ = [(\"name\", c_char_p),\n" @@ -1835,14 +1927,14 @@ msgstr "" "NameError: name 'cell' is not defined\n" ">>>" -#: ../../library/ctypes.rst:954 +#: ../../library/ctypes.rst:974 msgid "" "because the new ``class cell`` is not available in the class statement " "itself. In :mod:`ctypes`, we can define the ``cell`` class and set the :attr:" "`~Structure._fields_` attribute later, after the class statement::" msgstr "" -#: ../../library/ctypes.rst:958 +#: ../../library/ctypes.rst:978 msgid "" ">>> from ctypes import *\n" ">>> class cell(Structure):\n" @@ -1860,13 +1952,13 @@ msgstr "" "... (\"next\", POINTER(cell))]\n" ">>>" -#: ../../library/ctypes.rst:966 +#: ../../library/ctypes.rst:986 msgid "" "Let's try it. We create two instances of ``cell``, and let them point to " "each other, and finally follow the pointer chain a few times::" msgstr "" -#: ../../library/ctypes.rst:969 +#: ../../library/ctypes.rst:989 msgid "" ">>> c1 = cell()\n" ">>> c1.name = b\"foo\"\n" @@ -1896,24 +1988,24 @@ msgstr "" "foo bar foo bar foo bar foo bar\n" ">>>" -#: ../../library/ctypes.rst:987 +#: ../../library/ctypes.rst:1007 msgid "Callback functions" msgstr "回呼函式" -#: ../../library/ctypes.rst:989 +#: ../../library/ctypes.rst:1009 msgid "" ":mod:`ctypes` allows creating C callable function pointers from Python " "callables. These are sometimes called *callback functions*." msgstr "" -#: ../../library/ctypes.rst:992 +#: ../../library/ctypes.rst:1012 msgid "" "First, you must create a class for the callback function. The class knows " "the calling convention, the return type, and the number and types of " "arguments this function will receive." msgstr "" -#: ../../library/ctypes.rst:996 +#: ../../library/ctypes.rst:1016 msgid "" "The :func:`CFUNCTYPE` factory function creates types for callback functions " "using the ``cdecl`` calling convention. On Windows, the :func:`WINFUNCTYPE` " @@ -1921,21 +2013,21 @@ msgid "" "calling convention." msgstr "" -#: ../../library/ctypes.rst:1001 +#: ../../library/ctypes.rst:1021 msgid "" "Both of these factory functions are called with the result type as first " "argument, and the callback functions expected argument types as the " "remaining arguments." msgstr "" -#: ../../library/ctypes.rst:1005 +#: ../../library/ctypes.rst:1025 msgid "" "I will present an example here which uses the standard C library's :c:func:`!" "qsort` function, that is used to sort items with the help of a callback " "function. :c:func:`!qsort` will be used to sort an array of integers::" msgstr "" -#: ../../library/ctypes.rst:1009 +#: ../../library/ctypes.rst:1029 msgid "" ">>> IntArray5 = c_int * 5\n" ">>> ia = IntArray5(5, 1, 7, 33, 99)\n" @@ -1949,7 +2041,7 @@ msgstr "" ">>> qsort.restype = None\n" ">>>" -#: ../../library/ctypes.rst:1015 +#: ../../library/ctypes.rst:1035 msgid "" ":func:`!qsort` must be called with a pointer to the data to sort, the number " "of items in the data array, the size of one item, and a pointer to the " @@ -1959,13 +2051,13 @@ msgid "" "otherwise." msgstr "" -#: ../../library/ctypes.rst:1021 +#: ../../library/ctypes.rst:1041 msgid "" "So our callback function receives pointers to integers, and must return an " "integer. First we create the ``type`` for the callback function::" msgstr "" -#: ../../library/ctypes.rst:1024 +#: ../../library/ctypes.rst:1044 msgid "" ">>> CMPFUNC = CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))\n" ">>>" @@ -1973,13 +2065,13 @@ msgstr "" ">>> CMPFUNC = CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))\n" ">>>" -#: ../../library/ctypes.rst:1027 +#: ../../library/ctypes.rst:1047 msgid "" "To get started, here is a simple callback that shows the values it gets " "passed::" msgstr "" -#: ../../library/ctypes.rst:1030 +#: ../../library/ctypes.rst:1050 msgid "" ">>> def py_cmp_func(a, b):\n" "... print(\"py_cmp_func\", a[0], b[0])\n" @@ -1995,13 +2087,13 @@ msgstr "" ">>> cmp_func = CMPFUNC(py_cmp_func)\n" ">>>" -#: ../../library/ctypes.rst:1037 +#: ../../library/ctypes.rst:1057 msgid "The result::" msgstr "結果為: ::" -#: ../../library/ctypes.rst:1039 +#: ../../library/ctypes.rst:1059 msgid "" -">>> qsort(ia, len(ia), sizeof(c_int), cmp_func) \n" +">>> qsort(ia, len(ia), sizeof(c_int), cmp_func)\n" "py_cmp_func 5 1\n" "py_cmp_func 33 99\n" "py_cmp_func 7 33\n" @@ -2009,7 +2101,7 @@ msgid "" "py_cmp_func 1 7\n" ">>>" msgstr "" -">>> qsort(ia, len(ia), sizeof(c_int), cmp_func) \n" +">>> qsort(ia, len(ia), sizeof(c_int), cmp_func)\n" "py_cmp_func 5 1\n" "py_cmp_func 33 99\n" "py_cmp_func 7 33\n" @@ -2017,18 +2109,18 @@ msgstr "" "py_cmp_func 1 7\n" ">>>" -#: ../../library/ctypes.rst:1047 +#: ../../library/ctypes.rst:1067 msgid "Now we can actually compare the two items and return a useful result::" msgstr "" -#: ../../library/ctypes.rst:1049 +#: ../../library/ctypes.rst:1069 msgid "" ">>> def py_cmp_func(a, b):\n" "... print(\"py_cmp_func\", a[0], b[0])\n" "... return a[0] - b[0]\n" "...\n" ">>>\n" -">>> qsort(ia, len(ia), sizeof(c_int), CMPFUNC(py_cmp_func)) \n" +">>> qsort(ia, len(ia), sizeof(c_int), CMPFUNC(py_cmp_func))\n" "py_cmp_func 5 1\n" "py_cmp_func 33 99\n" "py_cmp_func 7 33\n" @@ -2041,7 +2133,7 @@ msgstr "" "... return a[0] - b[0]\n" "...\n" ">>>\n" -">>> qsort(ia, len(ia), sizeof(c_int), CMPFUNC(py_cmp_func)) \n" +">>> qsort(ia, len(ia), sizeof(c_int), CMPFUNC(py_cmp_func))\n" "py_cmp_func 5 1\n" "py_cmp_func 33 99\n" "py_cmp_func 7 33\n" @@ -2049,11 +2141,11 @@ msgstr "" "py_cmp_func 5 7\n" ">>>" -#: ../../library/ctypes.rst:1062 +#: ../../library/ctypes.rst:1082 msgid "As we can easily check, our array is sorted now::" msgstr "" -#: ../../library/ctypes.rst:1064 +#: ../../library/ctypes.rst:1084 msgid "" ">>> for i in ia: print(i, end=\" \")\n" "...\n" @@ -2065,13 +2157,13 @@ msgstr "" "1 5 7 33 99\n" ">>>" -#: ../../library/ctypes.rst:1069 +#: ../../library/ctypes.rst:1089 msgid "" "The function factories can be used as decorator factories, so we may as well " "write::" msgstr "" -#: ../../library/ctypes.rst:1072 +#: ../../library/ctypes.rst:1092 msgid "" ">>> @CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))\n" "... def py_cmp_func(a, b):\n" @@ -2099,14 +2191,14 @@ msgstr "" "py_cmp_func 5 7\n" ">>>" -#: ../../library/ctypes.rst:1087 +#: ../../library/ctypes.rst:1107 msgid "" "Make sure you keep references to :func:`CFUNCTYPE` objects as long as they " "are used from C code. :mod:`ctypes` doesn't, and if you don't, they may be " "garbage collected, crashing your program when a callback is made." msgstr "" -#: ../../library/ctypes.rst:1091 +#: ../../library/ctypes.rst:1111 msgid "" "Also, note that if the callback function is called in a thread created " "outside of Python's control (e.g. by the foreign code that calls the " @@ -2116,25 +2208,25 @@ msgid "" "even when those calls are made from the same C thread." msgstr "" -#: ../../library/ctypes.rst:1101 +#: ../../library/ctypes.rst:1121 msgid "Accessing values exported from dlls" msgstr "" -#: ../../library/ctypes.rst:1103 +#: ../../library/ctypes.rst:1123 msgid "" "Some shared libraries not only export functions, they also export variables. " "An example in the Python library itself is the :c:data:`Py_Version`, Python " "runtime version number encoded in a single constant integer." msgstr "" -#: ../../library/ctypes.rst:1107 +#: ../../library/ctypes.rst:1127 msgid "" ":mod:`ctypes` can access values like this with the :meth:`~_CData.in_dll` " "class methods of the type. *pythonapi* is a predefined symbol giving access " "to the Python C api::" msgstr "" -#: ../../library/ctypes.rst:1111 +#: ../../library/ctypes.rst:1131 msgid "" ">>> version = ctypes.c_int.in_dll(ctypes.pythonapi, \"Py_Version\")\n" ">>> print(hex(version.value))\n" @@ -2144,17 +2236,17 @@ msgstr "" ">>> print(hex(version.value))\n" "0x30c00a0" -#: ../../library/ctypes.rst:1115 +#: ../../library/ctypes.rst:1135 msgid "" "An extended example which also demonstrates the use of pointers accesses " "the :c:data:`PyImport_FrozenModules` pointer exported by Python." msgstr "" -#: ../../library/ctypes.rst:1118 +#: ../../library/ctypes.rst:1138 msgid "Quoting the docs for that value:" msgstr "" -#: ../../library/ctypes.rst:1120 +#: ../../library/ctypes.rst:1140 msgid "" "This pointer is initialized to point to an array of :c:struct:`_frozen` " "records, terminated by one whose members are all ``NULL`` or zero. When a " @@ -2163,13 +2255,13 @@ msgid "" "frozen modules." msgstr "" -#: ../../library/ctypes.rst:1125 +#: ../../library/ctypes.rst:1145 msgid "" "So manipulating this pointer could even prove useful. To restrict the " "example size, we show only how this table can be read with :mod:`ctypes`::" msgstr "" -#: ../../library/ctypes.rst:1128 +#: ../../library/ctypes.rst:1148 msgid "" ">>> from ctypes import *\n" ">>>\n" @@ -2193,13 +2285,13 @@ msgstr "" "...\n" ">>>" -#: ../../library/ctypes.rst:1139 +#: ../../library/ctypes.rst:1159 msgid "" "We have defined the :c:struct:`_frozen` data type, so we can get the pointer " "to the table::" msgstr "" -#: ../../library/ctypes.rst:1142 +#: ../../library/ctypes.rst:1162 msgid "" ">>> FrozenTable = POINTER(struct_frozen)\n" ">>> table = FrozenTable.in_dll(pythonapi, \"_PyImport_FrozenBootstrap\")\n" @@ -2209,7 +2301,7 @@ msgstr "" ">>> table = FrozenTable.in_dll(pythonapi, \"_PyImport_FrozenBootstrap\")\n" ">>>" -#: ../../library/ctypes.rst:1146 +#: ../../library/ctypes.rst:1166 msgid "" "Since ``table`` is a ``pointer`` to the array of ``struct_frozen`` records, " "we can iterate over it, but we just have to make sure that our loop " @@ -2218,7 +2310,7 @@ msgid "" "the loop when we hit the ``NULL`` entry::" msgstr "" -#: ../../library/ctypes.rst:1152 +#: ../../library/ctypes.rst:1172 msgid "" ">>> for item in table:\n" "... if item.name is None:\n" @@ -2240,28 +2332,28 @@ msgstr "" "zipimport 12345\n" ">>>" -#: ../../library/ctypes.rst:1162 +#: ../../library/ctypes.rst:1182 msgid "" "The fact that standard Python has a frozen module and a frozen package " "(indicated by the negative ``size`` member) is not well known, it is only " "used for testing. Try it out with ``import __hello__`` for example." msgstr "" -#: ../../library/ctypes.rst:1170 +#: ../../library/ctypes.rst:1190 msgid "Surprises" msgstr "" -#: ../../library/ctypes.rst:1172 +#: ../../library/ctypes.rst:1192 msgid "" "There are some edges in :mod:`ctypes` where you might expect something other " "than what actually happens." msgstr "" -#: ../../library/ctypes.rst:1175 +#: ../../library/ctypes.rst:1195 msgid "Consider the following example::" msgstr "" -#: ../../library/ctypes.rst:1177 +#: ../../library/ctypes.rst:1197 msgid "" ">>> from ctypes import *\n" ">>> class POINT(Structure):\n" @@ -2299,13 +2391,13 @@ msgstr "" "3 4 3 4\n" ">>>" -#: ../../library/ctypes.rst:1195 +#: ../../library/ctypes.rst:1215 msgid "" "Hm. We certainly expected the last statement to print ``3 4 1 2``. What " "happened? Here are the steps of the ``rc.a, rc.b = rc.b, rc.a`` line above::" msgstr "" -#: ../../library/ctypes.rst:1198 +#: ../../library/ctypes.rst:1218 msgid "" ">>> temp0, temp1 = rc.b, rc.a\n" ">>> rc.a = temp0\n" @@ -2317,7 +2409,7 @@ msgstr "" ">>> rc.b = temp1\n" ">>>" -#: ../../library/ctypes.rst:1203 +#: ../../library/ctypes.rst:1223 msgid "" "Note that ``temp0`` and ``temp1`` are objects still using the internal " "buffer of the ``rc`` object above. So executing ``rc.a = temp0`` copies the " @@ -2326,20 +2418,20 @@ msgid "" "have the expected effect." msgstr "" -#: ../../library/ctypes.rst:1209 +#: ../../library/ctypes.rst:1229 msgid "" "Keep in mind that retrieving sub-objects from Structure, Unions, and Arrays " "doesn't *copy* the sub-object, instead it retrieves a wrapper object " "accessing the root-object's underlying buffer." msgstr "" -#: ../../library/ctypes.rst:1213 +#: ../../library/ctypes.rst:1233 msgid "" "Another example that may behave differently from what one would expect is " "this::" msgstr "" -#: ../../library/ctypes.rst:1215 +#: ../../library/ctypes.rst:1235 msgid "" ">>> s = c_char_p()\n" ">>> s.value = b\"abc def ghi\"\n" @@ -2357,13 +2449,13 @@ msgstr "" "False\n" ">>>" -#: ../../library/ctypes.rst:1225 +#: ../../library/ctypes.rst:1245 msgid "" "Objects instantiated from :class:`c_char_p` can only have their value set to " "bytes or integers." msgstr "" -#: ../../library/ctypes.rst:1228 +#: ../../library/ctypes.rst:1248 msgid "" "Why is it printing ``False``? ctypes instances are objects containing a " "memory block plus some :term:`descriptor`\\s accessing the contents of the " @@ -2372,16 +2464,16 @@ msgid "" "the contents again constructs a new Python object each time!" msgstr "" -#: ../../library/ctypes.rst:1238 +#: ../../library/ctypes.rst:1258 msgid "Variable-sized data types" msgstr "" -#: ../../library/ctypes.rst:1240 +#: ../../library/ctypes.rst:1260 msgid "" ":mod:`ctypes` provides some support for variable-sized arrays and structures." msgstr "" -#: ../../library/ctypes.rst:1242 +#: ../../library/ctypes.rst:1262 msgid "" "The :func:`resize` function can be used to resize the memory buffer of an " "existing ctypes object. The function takes the object as first argument, " @@ -2390,7 +2482,7 @@ msgid "" "objects type, a :exc:`ValueError` is raised if this is tried::" msgstr "" -#: ../../library/ctypes.rst:1248 +#: ../../library/ctypes.rst:1268 msgid "" ">>> short_array = (c_short * 4)()\n" ">>> print(sizeof(short_array))\n" @@ -2420,14 +2512,14 @@ msgstr "" "8\n" ">>>" -#: ../../library/ctypes.rst:1262 +#: ../../library/ctypes.rst:1282 msgid "" "This is nice and fine, but how would one access the additional elements " "contained in this array? Since the type still only knows about 4 elements, " "we get errors accessing other elements::" msgstr "" -#: ../../library/ctypes.rst:1266 +#: ../../library/ctypes.rst:1286 msgid "" ">>> short_array[:]\n" "[0, 0, 0, 0]\n" @@ -2445,28 +2537,28 @@ msgstr "" "IndexError: invalid index\n" ">>>" -#: ../../library/ctypes.rst:1274 +#: ../../library/ctypes.rst:1294 msgid "" "Another way to use variable-sized data types with :mod:`ctypes` is to use " "the dynamic nature of Python, and (re-)define the data type after the " "required size is already known, on a case by case basis." msgstr "" -#: ../../library/ctypes.rst:1282 +#: ../../library/ctypes.rst:1302 msgid "ctypes reference" msgstr "" -#: ../../library/ctypes.rst:1288 +#: ../../library/ctypes.rst:1308 msgid "Finding shared libraries" msgstr "" -#: ../../library/ctypes.rst:1290 +#: ../../library/ctypes.rst:1310 msgid "" "When programming in a compiled language, shared libraries are accessed when " "compiling/linking a program, and when the program is run." msgstr "" -#: ../../library/ctypes.rst:1293 +#: ../../library/ctypes.rst:1313 msgid "" "The purpose of the :func:`~ctypes.util.find_library` function is to locate a " "library in a way similar to what the compiler or runtime loader does (on " @@ -2475,13 +2567,13 @@ msgid "" "and call the runtime loader directly." msgstr "" -#: ../../library/ctypes.rst:1299 +#: ../../library/ctypes.rst:1319 msgid "" "The :mod:`!ctypes.util` module provides a function which can help to " "determine the library to load." msgstr "" -#: ../../library/ctypes.rst:1307 +#: ../../library/ctypes.rst:1327 msgid "" "Try to find a library and return a pathname. *name* is the library name " "without any prefix like *lib*, suffix like ``.so``, ``.dylib`` or version " @@ -2489,29 +2581,29 @@ msgid "" "If no library can be found, returns ``None``." msgstr "" -#: ../../library/ctypes.rst:1312 ../../library/ctypes.rst:1972 +#: ../../library/ctypes.rst:1332 ../../library/ctypes.rst:2038 msgid "The exact functionality is system dependent." msgstr "" -#: ../../library/ctypes.rst:1314 +#: ../../library/ctypes.rst:1334 msgid "" "On Linux, :func:`~ctypes.util.find_library` tries to run external programs " "(``/sbin/ldconfig``, ``gcc``, ``objdump`` and ``ld``) to find the library " "file. It returns the filename of the library file." msgstr "" -#: ../../library/ctypes.rst:1318 +#: ../../library/ctypes.rst:1338 msgid "" "On Linux, the value of the environment variable ``LD_LIBRARY_PATH`` is used " "when searching for libraries, if a library cannot be found by any other " "means." msgstr "" -#: ../../library/ctypes.rst:1322 +#: ../../library/ctypes.rst:1342 msgid "Here are some examples::" msgstr "以下是一些範例: ::" -#: ../../library/ctypes.rst:1324 +#: ../../library/ctypes.rst:1344 msgid "" ">>> from ctypes.util import find_library\n" ">>> find_library(\"m\")\n" @@ -2531,14 +2623,14 @@ msgstr "" "'libbz2.so.1.0'\n" ">>>" -#: ../../library/ctypes.rst:1333 +#: ../../library/ctypes.rst:1353 msgid "" -"On macOS, :func:`~ctypes.util.find_library` tries several predefined naming " -"schemes and paths to locate the library, and returns a full pathname if " -"successful::" +"On macOS and Android, :func:`~ctypes.util.find_library` uses the system's " +"standard naming schemes and paths to locate the library, and returns a full " +"pathname if successful::" msgstr "" -#: ../../library/ctypes.rst:1336 +#: ../../library/ctypes.rst:1357 msgid "" ">>> from ctypes.util import find_library\n" ">>> find_library(\"c\")\n" @@ -2562,7 +2654,7 @@ msgstr "" "'/System/Library/Frameworks/AGL.framework/AGL'\n" ">>>" -#: ../../library/ctypes.rst:1347 +#: ../../library/ctypes.rst:1368 msgid "" "On Windows, :func:`~ctypes.util.find_library` searches along the system " "search path, and returns the full pathname, but since there is no predefined " @@ -2570,7 +2662,7 @@ msgid "" "``None``." msgstr "" -#: ../../library/ctypes.rst:1351 +#: ../../library/ctypes.rst:1372 msgid "" "If wrapping a shared library with :mod:`ctypes`, it *may* be better to " "determine the shared library name at development time, and hardcode that " @@ -2578,24 +2670,24 @@ msgid "" "to locate the library at runtime." msgstr "" -#: ../../library/ctypes.rst:1359 +#: ../../library/ctypes.rst:1380 msgid "Loading shared libraries" msgstr "" -#: ../../library/ctypes.rst:1361 +#: ../../library/ctypes.rst:1382 msgid "" "There are several ways to load shared libraries into the Python process. " "One way is to instantiate one of the following classes:" msgstr "" -#: ../../library/ctypes.rst:1367 +#: ../../library/ctypes.rst:1388 msgid "" "Instances of this class represent loaded shared libraries. Functions in " "these libraries use the standard C calling convention, and are assumed to " "return :c:expr:`int`." msgstr "" -#: ../../library/ctypes.rst:1371 +#: ../../library/ctypes.rst:1392 msgid "" "On Windows creating a :class:`CDLL` instance may fail even if the DLL name " "exists. When a dependent DLL of the loaded DLL is not found, a :exc:" @@ -2607,47 +2699,57 @@ msgid "" "determine which one is not found using Windows debugging and tracing tools." msgstr "" -#: ../../library/ctypes.rst:1383 ../../library/ctypes.rst:1406 -#: ../../library/ctypes.rst:1417 ../../library/ctypes.rst:1434 +#: ../../library/ctypes.rst:1404 ../../library/ctypes.rst:1429 +#: ../../library/ctypes.rst:1442 ../../library/ctypes.rst:1460 msgid "The *name* parameter can now be a :term:`path-like object`." msgstr "" -#: ../../library/ctypes.rst:1387 +#: ../../library/ctypes.rst:1408 msgid "" "`Microsoft DUMPBIN tool `_ -- A tool to find DLL dependents." msgstr "" -#: ../../library/ctypes.rst:1393 +#: ../../library/ctypes.rst:1414 msgid "" -"Windows only: Instances of this class represent loaded shared libraries, " -"functions in these libraries use the ``stdcall`` calling convention, and are " -"assumed to return the windows specific :class:`HRESULT` code. :class:" -"`HRESULT` values contain information specifying whether the function call " -"failed or succeeded, together with additional error code. If the return " -"value signals a failure, an :class:`OSError` is automatically raised." +"Instances of this class represent loaded shared libraries, functions in " +"these libraries use the ``stdcall`` calling convention, and are assumed to " +"return the windows specific :class:`HRESULT` code. :class:`HRESULT` values " +"contain information specifying whether the function call failed or " +"succeeded, together with additional error code. If the return value signals " +"a failure, an :class:`OSError` is automatically raised." msgstr "" -#: ../../library/ctypes.rst:1400 +#: ../../library/ctypes.rst:1421 ../../library/ctypes.rst:1438 +#: ../../library/ctypes.rst:1582 ../../library/ctypes.rst:1590 +#: ../../library/ctypes.rst:1767 ../../library/ctypes.rst:2018 +#: ../../library/ctypes.rst:2027 ../../library/ctypes.rst:2052 +#: ../../library/ctypes.rst:2061 ../../library/ctypes.rst:2070 +#: ../../library/ctypes.rst:2085 ../../library/ctypes.rst:2142 +#: ../../library/ctypes.rst:2170 ../../library/ctypes.rst:2514 +msgid "Availability" +msgstr "可用性" + +#: ../../library/ctypes.rst:1423 msgid "" ":exc:`WindowsError` used to be raised, which is now an alias of :exc:" "`OSError`." msgstr "" -#: ../../library/ctypes.rst:1411 +#: ../../library/ctypes.rst:1434 msgid "" -"Windows only: Instances of this class represent loaded shared libraries, " -"functions in these libraries use the ``stdcall`` calling convention, and are " -"assumed to return :c:expr:`int` by default." +"Instances of this class represent loaded shared libraries, functions in " +"these libraries use the ``stdcall`` calling convention, and are assumed to " +"return :c:expr:`int` by default." msgstr "" -#: ../../library/ctypes.rst:1419 +#: ../../library/ctypes.rst:1445 msgid "" "The Python :term:`global interpreter lock` is released before calling any " "function exported by these libraries, and reacquired afterwards." msgstr "" -#: ../../library/ctypes.rst:1425 +#: ../../library/ctypes.rst:1451 msgid "" "Instances of this class behave like :class:`CDLL` instances, except that the " "Python GIL is *not* released during the function call, and after the " @@ -2655,21 +2757,21 @@ msgid "" "set, a Python exception is raised." msgstr "" -#: ../../library/ctypes.rst:1430 +#: ../../library/ctypes.rst:1456 msgid "Thus, this is only useful to call Python C api functions directly." msgstr "" -#: ../../library/ctypes.rst:1436 +#: ../../library/ctypes.rst:1462 msgid "" "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 platforms :c:func:`!" +"``handle`` named parameter, otherwise the underlying platform's :c:func:`!" "dlopen` or :c:func:`!LoadLibrary` function is used to load the library into " "the process, and to get a handle to it." msgstr "" -#: ../../library/ctypes.rst:1443 +#: ../../library/ctypes.rst:1469 msgid "" "The *mode* parameter can be used to specify how the library is loaded. For " "details, consult the :manpage:`dlopen(3)` manpage. On Windows, *mode* is " @@ -2677,24 +2779,24 @@ msgid "" "configurable." msgstr "" -#: ../../library/ctypes.rst:1448 +#: ../../library/ctypes.rst:1474 msgid "" "The *use_errno* parameter, when set to true, enables a ctypes mechanism that " "allows accessing the system :data:`errno` error number in a safe way. :mod:" -"`ctypes` maintains a thread-local copy of the systems :data:`errno` " +"`ctypes` maintains a thread-local copy of the system's :data:`errno` " "variable; if you call foreign functions created with ``use_errno=True`` then " "the :data:`errno` value before the function call is swapped with the ctypes " "private copy, the same happens immediately after the function call." msgstr "" -#: ../../library/ctypes.rst:1455 +#: ../../library/ctypes.rst:1481 msgid "" "The function :func:`ctypes.get_errno` returns the value of the ctypes " "private copy, and the function :func:`ctypes.set_errno` changes the ctypes " "private copy to a new value and returns the former value." msgstr "" -#: ../../library/ctypes.rst:1459 +#: ../../library/ctypes.rst:1485 msgid "" "The *use_last_error* parameter, when set to true, enables the same mechanism " "for the Windows error code which is managed by the :func:`GetLastError` and :" @@ -2703,7 +2805,7 @@ msgid "" "private copy of the windows error code." msgstr "" -#: ../../library/ctypes.rst:1465 +#: ../../library/ctypes.rst:1491 msgid "" "The *winmode* parameter is used on Windows to specify how the library is " "loaded (since *mode* is ignored). It takes any value that is valid for the " @@ -2713,29 +2815,29 @@ msgid "" "ensure the correct library and dependencies are loaded." msgstr "" -#: ../../library/ctypes.rst:1472 +#: ../../library/ctypes.rst:1498 msgid "Added *winmode* parameter." msgstr "新增 *winmode* 參數。" -#: ../../library/ctypes.rst:1479 +#: ../../library/ctypes.rst:1505 msgid "" "Flag to use as *mode* parameter. On platforms where this flag is not " "available, it is defined as the integer zero." msgstr "" -#: ../../library/ctypes.rst:1486 +#: ../../library/ctypes.rst:1512 msgid "" "Flag to use as *mode* parameter. On platforms where this is not available, " "it is the same as *RTLD_GLOBAL*." msgstr "" -#: ../../library/ctypes.rst:1493 +#: ../../library/ctypes.rst:1519 msgid "" "The default mode which is used to load shared libraries. On OSX 10.3, this " "is *RTLD_GLOBAL*, otherwise it is the same as *RTLD_LOCAL*." msgstr "" -#: ../../library/ctypes.rst:1496 +#: ../../library/ctypes.rst:1522 msgid "" "Instances of these classes have no public methods. Functions exported by " "the shared library can be accessed as attributes or by index. Please note " @@ -2744,7 +2846,7 @@ msgid "" "other hand, accessing it through an index returns a new object each time::" msgstr "" -#: ../../library/ctypes.rst:1502 +#: ../../library/ctypes.rst:1528 msgid "" ">>> from ctypes import CDLL\n" ">>> libc = CDLL(\"libc.so.6\") # On Linux\n" @@ -2760,21 +2862,21 @@ msgstr "" ">>> libc['time'] == libc['time']\n" "False" -#: ../../library/ctypes.rst:1509 +#: ../../library/ctypes.rst:1535 msgid "" "The following public attributes are available, their name starts with an " "underscore to not clash with exported function names:" msgstr "" -#: ../../library/ctypes.rst:1515 +#: ../../library/ctypes.rst:1541 msgid "The system handle used to access the library." msgstr "" -#: ../../library/ctypes.rst:1520 +#: ../../library/ctypes.rst:1546 msgid "The name of the library passed in the constructor." msgstr "" -#: ../../library/ctypes.rst:1522 +#: ../../library/ctypes.rst:1548 msgid "" "Shared libraries can also be loaded by using one of the prefabricated " "objects, which are instances of the :class:`LibraryLoader` class, either by " @@ -2782,13 +2884,13 @@ msgid "" "library as attribute of the loader instance." msgstr "" -#: ../../library/ctypes.rst:1530 +#: ../../library/ctypes.rst:1556 msgid "" "Class which loads shared libraries. *dlltype* should be one of the :class:" "`CDLL`, :class:`PyDLL`, :class:`WinDLL`, or :class:`OleDLL` types." msgstr "" -#: ../../library/ctypes.rst:1533 +#: ../../library/ctypes.rst:1559 msgid "" ":meth:`!__getattr__` has special behavior: It allows loading a shared " "library by accessing it as attribute of a library loader instance. The " @@ -2796,39 +2898,39 @@ msgid "" "each time." msgstr "" -#: ../../library/ctypes.rst:1539 +#: ../../library/ctypes.rst:1565 msgid "" "Load a shared library into the process and return it. This method always " "returns a new instance of the library." msgstr "" -#: ../../library/ctypes.rst:1543 +#: ../../library/ctypes.rst:1569 msgid "These prefabricated library loaders are available:" msgstr "" -#: ../../library/ctypes.rst:1548 +#: ../../library/ctypes.rst:1574 msgid "Creates :class:`CDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1554 -msgid "Windows only: Creates :class:`WinDLL` instances." +#: ../../library/ctypes.rst:1580 +msgid "Creates :class:`WinDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1560 -msgid "Windows only: Creates :class:`OleDLL` instances." +#: ../../library/ctypes.rst:1588 +msgid "Creates :class:`OleDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1566 +#: ../../library/ctypes.rst:1596 msgid "Creates :class:`PyDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1569 +#: ../../library/ctypes.rst:1599 msgid "" "For accessing the C Python api directly, a ready-to-use Python shared " "library object is available:" msgstr "" -#: ../../library/ctypes.rst:1575 +#: ../../library/ctypes.rst:1605 msgid "" "An instance of :class:`PyDLL` that exposes Python C API functions as " "attributes. Note that all these functions are assumed to return C :c:expr:" @@ -2836,63 +2938,79 @@ msgid "" "correct :attr:`!restype` attribute to use these functions." msgstr "" -#: ../../library/ctypes.rst:1580 ../../library/ctypes.rst:1582 +#: ../../library/ctypes.rst:1610 ../../library/ctypes.rst:1612 msgid "" "Loading a library through any of these objects raises an :ref:`auditing " "event ` ``ctypes.dlopen`` with string argument ``name``, the name " "used to load the library." msgstr "" -#: ../../library/ctypes.rst:1586 ../../library/ctypes.rst:1588 +#: ../../library/ctypes.rst:1616 ../../library/ctypes.rst:1618 msgid "" "Accessing a function on a loaded library raises an auditing event ``ctypes." "dlsym`` with arguments ``library`` (the library object) and ``name`` (the " "symbol's name as a string or integer)." msgstr "" -#: ../../library/ctypes.rst:1592 ../../library/ctypes.rst:1594 +#: ../../library/ctypes.rst:1622 ../../library/ctypes.rst:1624 msgid "" "In cases when only the library handle is available rather than the object, " "accessing a function raises an auditing event ``ctypes.dlsym/handle`` with " "arguments ``handle`` (the raw library handle) and ``name``." msgstr "" -#: ../../library/ctypes.rst:1601 +#: ../../library/ctypes.rst:1631 msgid "Foreign functions" msgstr "" -#: ../../library/ctypes.rst:1603 +#: ../../library/ctypes.rst:1633 msgid "" "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 class:" +"library loader." msgstr "" -#: ../../library/ctypes.rst:1612 +#: ../../library/ctypes.rst:1638 +msgid "" +"They are instances of a private local class :class:`!_FuncPtr` (not exposed " +"in :mod:`!ctypes`) which inherits from the private :class:`_CFuncPtr` class:" +msgstr "" + +#: ../../library/ctypes.rst:1641 +msgid "" +">>> import ctypes\n" +">>> lib = ctypes.CDLL(None)\n" +">>> issubclass(lib._FuncPtr, ctypes._CFuncPtr)\n" +"True\n" +">>> lib._FuncPtr is ctypes._CFuncPtr\n" +"False" +msgstr "" + +#: ../../library/ctypes.rst:1652 msgid "Base class for C callable foreign functions." msgstr "" -#: ../../library/ctypes.rst:1614 +#: ../../library/ctypes.rst:1654 msgid "" "Instances of foreign functions are also C compatible data types; they " "represent C function pointers." msgstr "" -#: ../../library/ctypes.rst:1617 +#: ../../library/ctypes.rst:1657 msgid "" "This behavior can be customized by assigning to special attributes of the " "foreign function object." msgstr "" -#: ../../library/ctypes.rst:1622 +#: ../../library/ctypes.rst:1662 msgid "" "Assign a ctypes type to specify the result type of the foreign function. Use " "``None`` for :c:expr:`void`, a function not returning anything." msgstr "" -#: ../../library/ctypes.rst:1625 +#: ../../library/ctypes.rst:1665 msgid "" "It is possible to assign a callable Python object that is not a ctypes type, " "in this case the function is assumed to return a C :c:expr:`int`, and the " @@ -2902,7 +3020,7 @@ msgid "" "callable to the :attr:`errcheck` attribute." msgstr "" -#: ../../library/ctypes.rst:1634 +#: ../../library/ctypes.rst:1674 msgid "" "Assign a tuple of ctypes types to specify the argument types that the " "function accepts. Functions using the ``stdcall`` calling convention can " @@ -2911,7 +3029,7 @@ msgid "" "unspecified arguments as well." msgstr "" -#: ../../library/ctypes.rst:1640 +#: ../../library/ctypes.rst:1680 msgid "" "When a foreign function is called, each actual argument is passed to the :" "meth:`~_CData.from_param` class method of the items in the :attr:`argtypes` " @@ -2921,7 +3039,7 @@ msgid "" "object using ctypes conversion rules." msgstr "" -#: ../../library/ctypes.rst:1647 +#: ../../library/ctypes.rst:1687 msgid "" "New: It is now possible to put items in argtypes which are not ctypes types, " "but each item must have a :meth:`~_CData.from_param` method which returns a " @@ -2929,44 +3047,44 @@ msgid "" "defining adapters that can adapt custom objects as function parameters." msgstr "" -#: ../../library/ctypes.rst:1654 +#: ../../library/ctypes.rst:1694 msgid "" "Assign a Python function or another callable to this attribute. The callable " "will be called with three or more arguments:" msgstr "" -#: ../../library/ctypes.rst:1661 +#: ../../library/ctypes.rst:1701 msgid "" "*result* is what the foreign function returns, as specified by the :attr:`!" "restype` attribute." msgstr "" -#: ../../library/ctypes.rst:1664 +#: ../../library/ctypes.rst:1704 msgid "" "*func* is the foreign function object itself, this allows reusing the same " "callable object to check or post process the results of several functions." msgstr "" -#: ../../library/ctypes.rst:1668 +#: ../../library/ctypes.rst:1708 msgid "" "*arguments* is a tuple containing the parameters originally passed to the " "function call, this allows specializing the behavior on the arguments used." msgstr "" -#: ../../library/ctypes.rst:1672 +#: ../../library/ctypes.rst:1712 msgid "" "The object that this function returns will be returned from the foreign " "function call, but it can also check the result value and raise an exception " "if the foreign function call failed." msgstr "" -#: ../../library/ctypes.rst:1679 +#: ../../library/ctypes.rst:1719 msgid "" "This exception is raised when a foreign function call cannot convert one of " "the passed arguments." msgstr "" -#: ../../library/ctypes.rst:1683 ../../library/ctypes.rst:1685 +#: ../../library/ctypes.rst:1723 ../../library/ctypes.rst:1725 msgid "" "On Windows, when a foreign function call raises a system exception (for " "example, due to an access violation), it will be captured and replaced with " @@ -2975,18 +3093,18 @@ msgid "" "hook to replace the exception with its own." msgstr "" -#: ../../library/ctypes.rst:1691 ../../library/ctypes.rst:1693 +#: ../../library/ctypes.rst:1731 ../../library/ctypes.rst:1733 msgid "" "Some ways to invoke foreign function calls may raise an auditing event " "``ctypes.call_function`` with arguments ``function pointer`` and " "``arguments``." msgstr "" -#: ../../library/ctypes.rst:1699 +#: ../../library/ctypes.rst:1739 msgid "Function prototypes" msgstr "" -#: ../../library/ctypes.rst:1701 +#: ../../library/ctypes.rst:1741 msgid "" "Foreign functions can also be created by instantiating function prototypes. " "Function prototypes are similar to function prototypes in C; they describe a " @@ -2997,7 +3115,7 @@ msgid "" "``@wrapper`` syntax. See :ref:`ctypes-callback-functions` for examples." msgstr "" -#: ../../library/ctypes.rst:1712 +#: ../../library/ctypes.rst:1752 msgid "" "The returned function prototype creates functions that use the standard C " "calling convention. The function will release the GIL during the call. If " @@ -3006,37 +3124,37 @@ msgid "" "after the call; *use_last_error* does the same for the Windows error code." msgstr "" -#: ../../library/ctypes.rst:1722 +#: ../../library/ctypes.rst:1762 msgid "" -"Windows only: The returned function prototype creates functions that use the " -"``stdcall`` calling convention. The function will release the GIL during " -"the call. *use_errno* and *use_last_error* have the same meaning as above." +"The returned function prototype creates functions that use the ``stdcall`` " +"calling convention. The function will release the GIL during the call. " +"*use_errno* and *use_last_error* have the same meaning as above." msgstr "" -#: ../../library/ctypes.rst:1730 +#: ../../library/ctypes.rst:1772 msgid "" "The returned function prototype creates functions that use the Python " "calling convention. The function will *not* release the GIL during the call." msgstr "" -#: ../../library/ctypes.rst:1733 +#: ../../library/ctypes.rst:1775 msgid "" "Function prototypes created by these factory functions can be instantiated " "in different ways, depending on the type and number of the parameters in the " "call:" msgstr "" -#: ../../library/ctypes.rst:1740 +#: ../../library/ctypes.rst:1782 msgid "" "Returns a foreign function at the specified address which must be an integer." msgstr "" -#: ../../library/ctypes.rst:1747 +#: ../../library/ctypes.rst:1789 msgid "" "Create a C callable function (a callback function) from a Python *callable*." msgstr "" -#: ../../library/ctypes.rst:1754 +#: ../../library/ctypes.rst:1796 msgid "" "Returns a foreign function exported by a shared library. *func_spec* must be " "a 2-tuple ``(name_or_ordinal, library)``. The first item is the name of the " @@ -3044,7 +3162,7 @@ msgid "" "small integer. The second item is the shared library instance." msgstr "" -#: ../../library/ctypes.rst:1764 +#: ../../library/ctypes.rst:1806 msgid "" "Returns a foreign function that will call a COM method. *vtbl_index* is the " "index into the virtual function table, a small non-negative integer. *name* " @@ -3052,79 +3170,79 @@ msgid "" "identifier which is used in extended error reporting." msgstr "" -#: ../../library/ctypes.rst:1769 +#: ../../library/ctypes.rst:1811 msgid "" "COM methods use a special calling convention: They require a pointer to the " "COM interface as first argument, in addition to those parameters that are " "specified in the :attr:`!argtypes` tuple." msgstr "" -#: ../../library/ctypes.rst:1773 +#: ../../library/ctypes.rst:1815 msgid "" "The optional *paramflags* parameter creates foreign function wrappers with " "much more functionality than the features described above." msgstr "" -#: ../../library/ctypes.rst:1776 +#: ../../library/ctypes.rst:1818 msgid "" -"*paramflags* must be a tuple of the same length as :attr:`~_FuncPtr." +"*paramflags* must be a tuple of the same length as :attr:`~_CFuncPtr." "argtypes`." msgstr "" -#: ../../library/ctypes.rst:1778 +#: ../../library/ctypes.rst:1820 msgid "" "Each item in this tuple contains further information about a parameter, it " "must be a tuple containing one, two, or three items." msgstr "" -#: ../../library/ctypes.rst:1781 +#: ../../library/ctypes.rst:1823 msgid "" "The first item is an integer containing a combination of direction flags for " "the parameter:" msgstr "" -#: ../../library/ctypes.rst:1784 +#: ../../library/ctypes.rst:1826 msgid "1" msgstr "1" -#: ../../library/ctypes.rst:1785 +#: ../../library/ctypes.rst:1827 msgid "Specifies an input parameter to the function." msgstr "" -#: ../../library/ctypes.rst:1787 +#: ../../library/ctypes.rst:1829 msgid "2" msgstr "2" -#: ../../library/ctypes.rst:1788 +#: ../../library/ctypes.rst:1830 msgid "Output parameter. The foreign function fills in a value." msgstr "" -#: ../../library/ctypes.rst:1790 +#: ../../library/ctypes.rst:1832 msgid "4" msgstr "4" -#: ../../library/ctypes.rst:1791 +#: ../../library/ctypes.rst:1833 msgid "Input parameter which defaults to the integer zero." msgstr "" -#: ../../library/ctypes.rst:1793 +#: ../../library/ctypes.rst:1835 msgid "" "The optional second item is the parameter name as string. If this is " "specified, the foreign function can be called with named parameters." msgstr "" -#: ../../library/ctypes.rst:1796 +#: ../../library/ctypes.rst:1838 msgid "The optional third item is the default value for this parameter." msgstr "" -#: ../../library/ctypes.rst:1799 +#: ../../library/ctypes.rst:1841 msgid "" "The following example demonstrates how to wrap the Windows ``MessageBoxW`` " "function so that it supports default parameters and named arguments. The C " "declaration from the windows header file is this::" msgstr "" -#: ../../library/ctypes.rst:1803 +#: ../../library/ctypes.rst:1845 msgid "" "WINUSERAPI int WINAPI\n" "MessageBoxW(\n" @@ -3140,11 +3258,11 @@ msgstr "" " LPCWSTR lpCaption,\n" " UINT uType);" -#: ../../library/ctypes.rst:1810 ../../library/ctypes.rst:1833 +#: ../../library/ctypes.rst:1852 ../../library/ctypes.rst:1875 msgid "Here is the wrapping with :mod:`ctypes`::" msgstr "" -#: ../../library/ctypes.rst:1812 +#: ../../library/ctypes.rst:1854 msgid "" ">>> from ctypes import c_int, WINFUNCTYPE, windll\n" ">>> from ctypes.wintypes import HWND, LPCWSTR, UINT\n" @@ -3160,11 +3278,11 @@ msgstr "" "\"Hello from ctypes\"), (1, \"flags\", 0)\n" ">>> MessageBox = prototype((\"MessageBoxW\", windll.user32), paramflags)" -#: ../../library/ctypes.rst:1818 +#: ../../library/ctypes.rst:1860 msgid "The ``MessageBox`` foreign function can now be called in these ways::" msgstr "" -#: ../../library/ctypes.rst:1820 +#: ../../library/ctypes.rst:1862 msgid "" ">>> MessageBox()\n" ">>> MessageBox(text=\"Spam, spam, spam\")\n" @@ -3174,7 +3292,7 @@ msgstr "" ">>> MessageBox(text=\"Spam, spam, spam\")\n" ">>> MessageBox(flags=2, text=\"foo bar\")" -#: ../../library/ctypes.rst:1824 +#: ../../library/ctypes.rst:1866 msgid "" "A second example demonstrates output parameters. The win32 " "``GetWindowRect`` function retrieves the dimensions of a specified window by " @@ -3182,7 +3300,7 @@ msgid "" "the C declaration::" msgstr "" -#: ../../library/ctypes.rst:1828 +#: ../../library/ctypes.rst:1870 msgid "" "WINUSERAPI BOOL WINAPI\n" "GetWindowRect(\n" @@ -3194,7 +3312,7 @@ msgstr "" " HWND hWnd,\n" " LPRECT lpRect);" -#: ../../library/ctypes.rst:1835 +#: ../../library/ctypes.rst:1877 msgid "" ">>> from ctypes import POINTER, WINFUNCTYPE, windll, WinError\n" ">>> from ctypes.wintypes import BOOL, HWND, RECT\n" @@ -3212,7 +3330,7 @@ msgstr "" "paramflags)\n" ">>>" -#: ../../library/ctypes.rst:1842 +#: ../../library/ctypes.rst:1884 msgid "" "Functions with output parameters will automatically return the output " "parameter value if there is a single one, or a tuple containing the output " @@ -3220,16 +3338,16 @@ msgid "" "now returns a RECT instance, when called." msgstr "" -#: ../../library/ctypes.rst:1847 +#: ../../library/ctypes.rst:1889 msgid "" -"Output parameters can be combined with the :attr:`~_FuncPtr.errcheck` " +"Output parameters can be combined with the :attr:`~_CFuncPtr.errcheck` " "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::" msgstr "" -#: ../../library/ctypes.rst:1852 +#: ../../library/ctypes.rst:1894 msgid "" ">>> def errcheck(result, func, args):\n" "... if not result:\n" @@ -3247,16 +3365,16 @@ msgstr "" ">>> GetWindowRect.errcheck = errcheck\n" ">>>" -#: ../../library/ctypes.rst:1860 +#: ../../library/ctypes.rst:1902 msgid "" -"If the :attr:`~_FuncPtr.errcheck` function returns the argument tuple it " +"If the :attr:`~_CFuncPtr.errcheck` function returns the argument tuple it " "receives unchanged, :mod:`ctypes` 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::" msgstr "" -#: ../../library/ctypes.rst:1866 +#: ../../library/ctypes.rst:1908 msgid "" ">>> def errcheck(result, func, args):\n" "... if not result:\n" @@ -3276,17 +3394,17 @@ msgstr "" ">>> GetWindowRect.errcheck = errcheck\n" ">>>" -#: ../../library/ctypes.rst:1879 +#: ../../library/ctypes.rst:1921 msgid "Utility functions" msgstr "" -#: ../../library/ctypes.rst:1883 +#: ../../library/ctypes.rst:1925 msgid "" "Returns the address of the memory buffer as integer. *obj* must be an " "instance of a ctypes type." msgstr "" -#: ../../library/ctypes.rst:1886 +#: ../../library/ctypes.rst:1928 msgid "" "Raises an :ref:`auditing event ` ``ctypes.addressof`` with " "argument ``obj``." @@ -3294,34 +3412,34 @@ msgstr "" "引發一個附帶引數 ``obj`` 的\\ :ref:`稽核事件 ` ``ctypes." "addressof``。" -#: ../../library/ctypes.rst:1891 +#: ../../library/ctypes.rst:1933 msgid "" "Returns the alignment requirements of a ctypes type. *obj_or_type* must be a " "ctypes type or instance." msgstr "" -#: ../../library/ctypes.rst:1897 +#: ../../library/ctypes.rst:1939 msgid "" "Returns a light-weight pointer to *obj*, which must be an instance of a " "ctypes type. *offset* defaults to zero, and must be an integer that will be " "added to the internal pointer value." msgstr "" -#: ../../library/ctypes.rst:1901 +#: ../../library/ctypes.rst:1943 msgid "``byref(obj, offset)`` corresponds to this C code::" msgstr "" -#: ../../library/ctypes.rst:1903 +#: ../../library/ctypes.rst:1945 msgid "(((char *)&obj) + offset)" msgstr "(((char *)&obj) + offset)" -#: ../../library/ctypes.rst:1905 +#: ../../library/ctypes.rst:1947 msgid "" "The returned object can only be used as a foreign function call parameter. " "It behaves similar to ``pointer(obj)``, but the construction is a lot faster." msgstr "" -#: ../../library/ctypes.rst:1911 +#: ../../library/ctypes.rst:1953 msgid "" "This function is similar to the cast operator in C. It returns a new " "instance of *type* which points to the same memory block as *obj*. *type* " @@ -3329,28 +3447,63 @@ msgid "" "as a pointer." msgstr "" -#: ../../library/ctypes.rst:1919 +#: ../../library/ctypes.rst:1962 msgid "" "This function creates a mutable character buffer. The returned object is a " "ctypes array of :class:`c_char`." msgstr "" -#: ../../library/ctypes.rst:1922 +#: ../../library/ctypes.rst:1965 msgid "" -"*init_or_size* must be an integer which specifies the size of the array, or " -"a bytes object which will be used to initialize the array items." +"If *size* is given (and not ``None``), it must be an :class:`int`. It " +"specifies the size of the returned array." msgstr "" -#: ../../library/ctypes.rst:1925 +#: ../../library/ctypes.rst:1968 +msgid "" +"If the *init* argument is given, it must be :class:`bytes`. It is used to " +"initialize the array items. Bytes not initialized this way are set to zero " +"(NUL)." +msgstr "" + +#: ../../library/ctypes.rst:1972 msgid "" -"If a bytes object is specified as first argument, the buffer is made one " -"item larger than its length so that the last element in the array is a NUL " -"termination character. An integer can be passed as second argument which " -"allows specifying the size of the array if the length of the bytes should " -"not be used." +"If *size* is not given (or if it is ``None``), the buffer is made one " +"element larger than *init*, effectively adding a NUL terminator." msgstr "" -#: ../../library/ctypes.rst:1930 +#: ../../library/ctypes.rst:1975 +msgid "" +"If both arguments are given, *size* must not be less than ``len(init)``." +msgstr "" + +#: ../../library/ctypes.rst:1979 +msgid "" +"If *size* is equal to ``len(init)``, a NUL terminator is not added. Do not " +"treat such a buffer as a C string." +msgstr "" + +#: ../../library/ctypes.rst:1982 +msgid "For example::" +msgstr "" + +#: ../../library/ctypes.rst:1984 +msgid "" +">>> bytes(create_string_buffer(2))\n" +"b'\\x00\\x00'\n" +">>> bytes(create_string_buffer(b'ab'))\n" +"b'ab\\x00'\n" +">>> bytes(create_string_buffer(b'ab', 2))\n" +"b'ab'\n" +">>> bytes(create_string_buffer(b'ab', 4))\n" +"b'ab\\x00\\x00'\n" +">>> bytes(create_string_buffer(b'abcdef', 2))\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: byte string too long" +msgstr "" + +#: ../../library/ctypes.rst:1997 msgid "" "Raises an :ref:`auditing event ` ``ctypes.create_string_buffer`` " "with arguments ``init``, ``size``." @@ -3358,28 +3511,19 @@ msgstr "" "引發一個附帶引數 ``init`` 與 ``size`` 的\\ :ref:`稽核事件 ` " "``ctypes.create_string_buffer``。" -#: ../../library/ctypes.rst:1935 +#: ../../library/ctypes.rst:2003 msgid "" "This function creates a mutable unicode character buffer. The returned " "object is a ctypes array of :class:`c_wchar`." msgstr "" -#: ../../library/ctypes.rst:1938 -msgid "" -"*init_or_size* must be an integer which specifies the size of the array, or " -"a string which will be used to initialize the array items." -msgstr "" - -#: ../../library/ctypes.rst:1941 +#: ../../library/ctypes.rst:2006 msgid "" -"If a string is specified as first argument, the buffer is made one item " -"larger than the length of the string so that the last element in the array " -"is a NUL termination character. An integer can be passed as second argument " -"which allows specifying the size of the array if the length of the string " -"should not be used." +"The function takes the same arguments as :func:`~create_string_buffer` " +"except *init* must be a string and *size* counts :class:`c_wchar`." msgstr "" -#: ../../library/ctypes.rst:1947 +#: ../../library/ctypes.rst:2009 msgid "" "Raises an :ref:`auditing event ` ``ctypes.create_unicode_buffer`` " "with arguments ``init``, ``size``." @@ -3387,21 +3531,21 @@ msgstr "" "引發一個附帶引數 ``init`` 與 ``size`` 的\\ :ref:`稽核事件 ` " "``ctypes.create_unicode_buffer``。" -#: ../../library/ctypes.rst:1952 +#: ../../library/ctypes.rst:2014 msgid "" -"Windows only: This function is a hook which allows implementing in-process " -"COM servers with ctypes. It is called from the DllCanUnloadNow function " -"that the _ctypes extension dll exports." +"This function is a hook which allows implementing in-process COM servers " +"with ctypes. It is called from the DllCanUnloadNow function that the " +"_ctypes extension dll exports." msgstr "" -#: ../../library/ctypes.rst:1959 +#: ../../library/ctypes.rst:2023 msgid "" -"Windows only: This function is a hook which allows implementing in-process " -"COM servers with ctypes. It is called from the DllGetClassObject function " -"that the ``_ctypes`` extension dll exports." +"This function is a hook which allows implementing in-process COM servers " +"with ctypes. It is called from the DllGetClassObject function that the " +"``_ctypes`` extension dll exports." msgstr "" -#: ../../library/ctypes.rst:1967 +#: ../../library/ctypes.rst:2033 msgid "" "Try to find a library and return a pathname. *name* is the library name " "without any prefix like ``lib``, suffix like ``.so``, ``.dylib`` or version " @@ -3409,94 +3553,94 @@ msgid "" "If no library can be found, returns ``None``." msgstr "" -#: ../../library/ctypes.rst:1978 +#: ../../library/ctypes.rst:2044 msgid "" -"Windows only: return the filename of the VC runtime library used by Python, " -"and by the extension modules. If the name of the library cannot be " -"determined, ``None`` is returned." +"Returns the filename of the VC runtime library used by Python, and by the " +"extension modules. If the name of the library cannot be determined, " +"``None`` is returned." msgstr "" -#: ../../library/ctypes.rst:1982 +#: ../../library/ctypes.rst:2048 msgid "" "If you need to free memory, for example, allocated by an extension module " "with a call to the ``free(void *)``, it is important that you use the " "function in the same library that allocated the memory." msgstr "" -#: ../../library/ctypes.rst:1989 +#: ../../library/ctypes.rst:2057 msgid "" -"Windows only: Returns a textual description of the error code *code*. If no " -"error code is specified, the last error code is used by calling the Windows " -"api function GetLastError." +"Returns a textual description of the error code *code*. If no error code is " +"specified, the last error code is used by calling the Windows api function " +"GetLastError." msgstr "" -#: ../../library/ctypes.rst:1996 +#: ../../library/ctypes.rst:2066 msgid "" -"Windows only: Returns the last error code set by Windows in the calling " -"thread. This function calls the Windows ``GetLastError()`` function " -"directly, it does not return the ctypes-private copy of the error code." +"Returns the last error code set by Windows in the calling thread. This " +"function calls the Windows ``GetLastError()`` function directly, it does not " +"return the ctypes-private copy of the error code." msgstr "" -#: ../../library/ctypes.rst:2002 +#: ../../library/ctypes.rst:2075 msgid "" "Returns the current value of the ctypes-private copy of the system :data:" "`errno` variable in the calling thread." msgstr "" -#: ../../library/ctypes.rst:2005 +#: ../../library/ctypes.rst:2078 msgid "" "Raises an :ref:`auditing event ` ``ctypes.get_errno`` with no " "arguments." msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``ctypes.get_errno``。" -#: ../../library/ctypes.rst:2009 +#: ../../library/ctypes.rst:2082 msgid "" -"Windows only: returns the current value of the ctypes-private copy of the " -"system :data:`!LastError` variable in the calling thread." +"Returns the current value of the ctypes-private copy of the system :data:`!" +"LastError` variable in the calling thread." msgstr "" -#: ../../library/ctypes.rst:2012 +#: ../../library/ctypes.rst:2087 msgid "" "Raises an :ref:`auditing event ` ``ctypes.get_last_error`` with no " "arguments." msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``ctypes.get_last_error``。" -#: ../../library/ctypes.rst:2016 +#: ../../library/ctypes.rst:2092 msgid "" "Same as the standard C memmove library function: copies *count* bytes from " "*src* to *dst*. *dst* and *src* must be integers or ctypes instances that " "can be converted to pointers." msgstr "" -#: ../../library/ctypes.rst:2023 +#: ../../library/ctypes.rst:2099 msgid "" "Same as the standard C memset library function: fills the memory block at " "address *dst* with *count* bytes of value *c*. *dst* must be an integer " "specifying an address, or a ctypes instance." msgstr "" -#: ../../library/ctypes.rst:2030 +#: ../../library/ctypes.rst:2106 msgid "" "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." msgstr "" -#: ../../library/ctypes.rst:2037 +#: ../../library/ctypes.rst:2113 msgid "" "Create a new pointer instance, pointing to *obj*. The returned object is of " "the type ``POINTER(type(obj))``." msgstr "" -#: ../../library/ctypes.rst:2040 +#: ../../library/ctypes.rst:2116 msgid "" "Note: If you just want to pass a pointer to an object to a foreign function " "call, you should use ``byref(obj)`` which is much faster." msgstr "" -#: ../../library/ctypes.rst:2046 +#: ../../library/ctypes.rst:2122 msgid "" "This function resizes the internal memory buffer of *obj*, which must be an " "instance of a ctypes type. It is not possible to make the buffer smaller " @@ -3504,13 +3648,13 @@ msgid "" "but it is possible to enlarge the buffer." msgstr "" -#: ../../library/ctypes.rst:2054 +#: ../../library/ctypes.rst:2130 msgid "" "Set the current value of the ctypes-private copy of the system :data:`errno` " "variable in the calling thread to *value* and return the previous value." msgstr "" -#: ../../library/ctypes.rst:2057 +#: ../../library/ctypes.rst:2133 msgid "" "Raises an :ref:`auditing event ` ``ctypes.set_errno`` with " "argument ``errno``." @@ -3518,14 +3662,14 @@ msgstr "" "引發一個附帶引數 ``errno`` 的\\ :ref:`稽核事件 ` ``ctypes." "set_errno``。" -#: ../../library/ctypes.rst:2062 +#: ../../library/ctypes.rst:2138 msgid "" -"Windows only: set the current value of the ctypes-private copy of the " -"system :data:`!LastError` variable in the calling thread to *value* and " -"return the previous value." +"Sets the current value of the ctypes-private copy of the system :data:`!" +"LastError` variable in the calling thread to *value* and return the previous " +"value." msgstr "" -#: ../../library/ctypes.rst:2066 +#: ../../library/ctypes.rst:2144 msgid "" "Raises an :ref:`auditing event ` ``ctypes.set_last_error`` with " "argument ``error``." @@ -3533,19 +3677,19 @@ msgstr "" "引發一個附帶引數 ``error`` 的\\ :ref:`稽核事件 ` ``ctypes." "set_last_error``。" -#: ../../library/ctypes.rst:2071 +#: ../../library/ctypes.rst:2149 msgid "" "Returns the size in bytes of a ctypes type or instance memory buffer. Does " "the same as the C ``sizeof`` operator." msgstr "" -#: ../../library/ctypes.rst:2077 +#: ../../library/ctypes.rst:2155 msgid "" "Return the byte string at *void \\*ptr*. If *size* is specified, it is used " "as size, otherwise the string is assumed to be zero-terminated." msgstr "" -#: ../../library/ctypes.rst:2081 +#: ../../library/ctypes.rst:2159 msgid "" "Raises an :ref:`auditing event ` ``ctypes.string_at`` with " "arguments ``ptr``, ``size``." @@ -3553,29 +3697,28 @@ msgstr "" "引發一個附帶引數 ``ptr``、``size`` 的\\ :ref:`稽核事件 ` ``ctypes." "string_at``。" -#: ../../library/ctypes.rst:2086 +#: ../../library/ctypes.rst:2164 msgid "" -"Windows only: this function is probably the worst-named thing in ctypes. It " -"creates an instance of :exc:`OSError`. If *code* is not specified, " -"``GetLastError`` is called to determine the error code. If *descr* is not " -"specified, :func:`FormatError` is called to get a textual description of the " -"error." +"This function is probably the worst-named thing in ctypes. It creates an " +"instance of :exc:`OSError`. If *code* is not specified, ``GetLastError`` is " +"called to determine the error code. If *descr* is not specified, :func:" +"`FormatError` is called to get a textual description of the error." msgstr "" -#: ../../library/ctypes.rst:2092 +#: ../../library/ctypes.rst:2172 msgid "" "An instance of :exc:`WindowsError` used to be created, which is now an alias " "of :exc:`OSError`." msgstr "" -#: ../../library/ctypes.rst:2099 +#: ../../library/ctypes.rst:2179 msgid "" "Return the wide-character string at *void \\*ptr*. If *size* is specified, " "it is used as the number of characters of the string, otherwise the string " "is assumed to be zero-terminated." msgstr "" -#: ../../library/ctypes.rst:2104 +#: ../../library/ctypes.rst:2184 msgid "" "Raises an :ref:`auditing event ` ``ctypes.wstring_at`` with " "arguments ``ptr``, ``size``." @@ -3583,11 +3726,11 @@ msgstr "" "引發一個附帶引數 ``ptr``、``size`` 的\\ :ref:`稽核事件 ` ``ctypes." "wstring_at``。" -#: ../../library/ctypes.rst:2110 +#: ../../library/ctypes.rst:2190 msgid "Data types" msgstr "" -#: ../../library/ctypes.rst:2115 +#: ../../library/ctypes.rst:2195 msgid "" "This non-public class is the common base class of all ctypes data types. " "Among other things, all ctypes type instances contain a memory block that " @@ -3597,13 +3740,13 @@ msgid "" "alive in case the memory block contains pointers." msgstr "" -#: ../../library/ctypes.rst:2122 +#: ../../library/ctypes.rst:2202 msgid "" "Common methods of ctypes data types, these are all class methods (to be " "exact, they are methods of the :term:`metaclass`):" msgstr "" -#: ../../library/ctypes.rst:2127 +#: ../../library/ctypes.rst:2207 msgid "" "This method returns a ctypes instance that shares the buffer of the *source* " "object. The *source* object must support the writeable buffer interface. " @@ -3612,7 +3755,7 @@ msgid "" "exc:`ValueError` is raised." msgstr "" -#: ../../library/ctypes.rst:2133 ../../library/ctypes.rst:2143 +#: ../../library/ctypes.rst:2213 ../../library/ctypes.rst:2223 msgid "" "Raises an :ref:`auditing event ` ``ctypes.cdata/buffer`` with " "arguments ``pointer``, ``size``, ``offset``." @@ -3620,7 +3763,7 @@ msgstr "" "引發一個附帶引數 ``pointer``、``size``、``offset`` 的\\ :ref:`稽核事件 " "` ``ctypes.cdata/buffer``。" -#: ../../library/ctypes.rst:2137 +#: ../../library/ctypes.rst:2217 msgid "" "This method creates a ctypes instance, copying the buffer from the *source* " "object buffer which must be readable. The optional *offset* parameter " @@ -3628,45 +3771,45 @@ msgid "" "If the source buffer is not large enough a :exc:`ValueError` is raised." msgstr "" -#: ../../library/ctypes.rst:2147 +#: ../../library/ctypes.rst:2227 msgid "" "This method returns a ctypes type instance using the memory specified by " "*address* which must be an integer." msgstr "" -#: ../../library/ctypes.rst:2150 ../../library/ctypes.rst:2152 +#: ../../library/ctypes.rst:2230 ../../library/ctypes.rst:2232 msgid "" "This method, and others that indirectly call this method, raises an :ref:" "`auditing event ` ``ctypes.cdata`` with argument ``address``." msgstr "" -#: ../../library/ctypes.rst:2158 +#: ../../library/ctypes.rst:2238 msgid "" "This method adapts *obj* to a ctypes type. It is called with the actual " "object used in a foreign function call when the type is present in the " -"foreign function's :attr:`~_FuncPtr.argtypes` tuple; it must return an " +"foreign function's :attr:`~_CFuncPtr.argtypes` tuple; it must return an " "object that can be used as a function call parameter." msgstr "" -#: ../../library/ctypes.rst:2163 +#: ../../library/ctypes.rst:2243 msgid "" "All ctypes data types have a default implementation of this classmethod that " "normally returns *obj* if that is an instance of the type. Some types " "accept other objects as well." msgstr "" -#: ../../library/ctypes.rst:2169 +#: ../../library/ctypes.rst:2249 msgid "" "This method returns a ctypes type instance exported by a shared library. " "*name* is the name of the symbol that exports the data, *library* is the " "loaded shared library." msgstr "" -#: ../../library/ctypes.rst:2173 +#: ../../library/ctypes.rst:2253 msgid "Common instance variables of ctypes data types:" msgstr "" -#: ../../library/ctypes.rst:2177 +#: ../../library/ctypes.rst:2257 msgid "" "Sometimes ctypes data instances do not own the memory block they contain, " "instead they share part of the memory block of a base object. The :attr:" @@ -3674,13 +3817,13 @@ msgid "" "block." msgstr "" -#: ../../library/ctypes.rst:2184 +#: ../../library/ctypes.rst:2264 msgid "" "This read-only variable is true when the ctypes data instance has allocated " "the memory block itself, false otherwise." msgstr "" -#: ../../library/ctypes.rst:2189 +#: ../../library/ctypes.rst:2269 msgid "" "This member is either ``None`` or a dictionary containing Python objects " "that need to be kept alive so that the memory block contents is kept valid. " @@ -3688,7 +3831,7 @@ msgid "" "dictionary." msgstr "" -#: ../../library/ctypes.rst:2202 +#: ../../library/ctypes.rst:2282 msgid "" "This non-public class is the base class of all fundamental ctypes data " "types. It is mentioned here because it contains the common attributes of the " @@ -3697,11 +3840,11 @@ msgid "" "types that are not and do not contain pointers can now be pickled." msgstr "" -#: ../../library/ctypes.rst:2208 +#: ../../library/ctypes.rst:2288 msgid "Instances have a single attribute:" msgstr "" -#: ../../library/ctypes.rst:2212 +#: ../../library/ctypes.rst:2292 msgid "" "This attribute contains the actual value of the instance. For integer and " "pointer types, it is an integer, for character types, it is a single " @@ -3709,7 +3852,7 @@ msgid "" "bytes object or string." msgstr "" -#: ../../library/ctypes.rst:2217 +#: ../../library/ctypes.rst:2297 msgid "" "When the ``value`` attribute is retrieved from a ctypes instance, usually a " "new object is returned each time. :mod:`ctypes` does *not* implement " @@ -3717,17 +3860,17 @@ msgid "" "true for all other ctypes object instances." msgstr "" -#: ../../library/ctypes.rst:2223 +#: ../../library/ctypes.rst:2303 msgid "" "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 :attr:`~_FuncPtr.restype` of :class:`c_char_p`, you " +"foreign function has a :attr:`~_CFuncPtr.restype` of :class:`c_char_p`, you " "will always receive a Python bytes object, *not* a :class:`c_char_p` " "instance." msgstr "" -#: ../../library/ctypes.rst:2231 +#: ../../library/ctypes.rst:2311 msgid "" "Subclasses of fundamental data types do *not* inherit this behavior. So, if " "a foreign functions :attr:`!restype` is a subclass of :class:`c_void_p`, you " @@ -3735,25 +3878,25 @@ msgid "" "you can get the value of the pointer by accessing the ``value`` attribute." msgstr "" -#: ../../library/ctypes.rst:2236 +#: ../../library/ctypes.rst:2316 msgid "These are the fundamental ctypes data types:" msgstr "" -#: ../../library/ctypes.rst:2240 +#: ../../library/ctypes.rst:2320 msgid "" "Represents the C :c:expr:`signed char` datatype, and interprets the value as " "small integer. The constructor accepts an optional integer initializer; no " "overflow checking is done." msgstr "" -#: ../../library/ctypes.rst:2247 +#: ../../library/ctypes.rst:2327 msgid "" "Represents the C :c:expr:`char` datatype, and interprets the value as a " "single character. The constructor accepts an optional string initializer, " "the length of the string must be exactly one character." msgstr "" -#: ../../library/ctypes.rst:2254 +#: ../../library/ctypes.rst:2334 msgid "" "Represents the C :c:expr:`char *` datatype when it points to a zero-" "terminated string. For a general character pointer that may also point to " @@ -3761,182 +3904,182 @@ msgid "" "integer address, or a bytes object." msgstr "" -#: ../../library/ctypes.rst:2262 +#: ../../library/ctypes.rst:2342 msgid "" "Represents the C :c:expr:`double` datatype. The constructor accepts an " "optional float initializer." msgstr "" -#: ../../library/ctypes.rst:2268 +#: ../../library/ctypes.rst:2348 msgid "" "Represents the C :c:expr:`long double` datatype. The constructor accepts an " "optional float initializer. On platforms where ``sizeof(long double) == " "sizeof(double)`` it is an alias to :class:`c_double`." msgstr "" -#: ../../library/ctypes.rst:2274 +#: ../../library/ctypes.rst:2354 msgid "" "Represents the C :c:expr:`float` datatype. The constructor accepts an " "optional float initializer." msgstr "" -#: ../../library/ctypes.rst:2280 +#: ../../library/ctypes.rst:2360 msgid "" "Represents the C :c:expr:`signed int` datatype. The constructor accepts an " "optional integer initializer; no overflow checking is done. On platforms " "where ``sizeof(int) == sizeof(long)`` it is an alias to :class:`c_long`." msgstr "" -#: ../../library/ctypes.rst:2287 +#: ../../library/ctypes.rst:2367 msgid "" -"Represents the C 8-bit :c:expr:`signed int` datatype. Usually an alias for :" +"Represents the C 8-bit :c:expr:`signed int` datatype. It is an alias for :" "class:`c_byte`." msgstr "" -#: ../../library/ctypes.rst:2293 +#: ../../library/ctypes.rst:2373 msgid "" "Represents the C 16-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_short`." msgstr "" -#: ../../library/ctypes.rst:2299 +#: ../../library/ctypes.rst:2379 msgid "" "Represents the C 32-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_int`." msgstr "" -#: ../../library/ctypes.rst:2305 +#: ../../library/ctypes.rst:2385 msgid "" "Represents the C 64-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_longlong`." msgstr "" -#: ../../library/ctypes.rst:2311 +#: ../../library/ctypes.rst:2391 msgid "" "Represents the C :c:expr:`signed long` datatype. The constructor accepts an " "optional integer initializer; no overflow checking is done." msgstr "" -#: ../../library/ctypes.rst:2317 +#: ../../library/ctypes.rst:2397 msgid "" "Represents the C :c:expr:`signed long long` datatype. The constructor " "accepts an optional integer initializer; no overflow checking is done." msgstr "" -#: ../../library/ctypes.rst:2323 +#: ../../library/ctypes.rst:2403 msgid "" "Represents the C :c:expr:`signed short` datatype. The constructor accepts " "an optional integer initializer; no overflow checking is done." msgstr "" -#: ../../library/ctypes.rst:2329 +#: ../../library/ctypes.rst:2409 msgid "Represents the C :c:type:`size_t` datatype." msgstr "" -#: ../../library/ctypes.rst:2334 +#: ../../library/ctypes.rst:2414 msgid "Represents the C :c:type:`ssize_t` datatype." msgstr "" -#: ../../library/ctypes.rst:2341 +#: ../../library/ctypes.rst:2421 msgid "Represents the C :c:type:`time_t` datatype." msgstr "" -#: ../../library/ctypes.rst:2348 +#: ../../library/ctypes.rst:2428 msgid "" "Represents the C :c:expr:`unsigned char` datatype, it interprets the value " "as small integer. The constructor accepts an optional integer initializer; " "no overflow checking is done." msgstr "" -#: ../../library/ctypes.rst:2355 +#: ../../library/ctypes.rst:2435 msgid "" "Represents the C :c:expr:`unsigned int` datatype. The constructor accepts " "an optional integer initializer; no overflow checking is done. On platforms " "where ``sizeof(int) == sizeof(long)`` it is an alias for :class:`c_ulong`." msgstr "" -#: ../../library/ctypes.rst:2362 +#: ../../library/ctypes.rst:2442 msgid "" -"Represents the C 8-bit :c:expr:`unsigned int` datatype. Usually an alias " -"for :class:`c_ubyte`." +"Represents the C 8-bit :c:expr:`unsigned int` datatype. It is an alias for :" +"class:`c_ubyte`." msgstr "" -#: ../../library/ctypes.rst:2368 +#: ../../library/ctypes.rst:2448 msgid "" "Represents the C 16-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_ushort`." msgstr "" -#: ../../library/ctypes.rst:2374 +#: ../../library/ctypes.rst:2454 msgid "" "Represents the C 32-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_uint`." msgstr "" -#: ../../library/ctypes.rst:2380 +#: ../../library/ctypes.rst:2460 msgid "" "Represents the C 64-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_ulonglong`." msgstr "" -#: ../../library/ctypes.rst:2386 +#: ../../library/ctypes.rst:2466 msgid "" "Represents the C :c:expr:`unsigned long` datatype. The constructor accepts " "an optional integer initializer; no overflow checking is done." msgstr "" -#: ../../library/ctypes.rst:2392 +#: ../../library/ctypes.rst:2472 msgid "" "Represents the C :c:expr:`unsigned long long` datatype. The constructor " "accepts an optional integer initializer; no overflow checking is done." msgstr "" -#: ../../library/ctypes.rst:2398 +#: ../../library/ctypes.rst:2478 msgid "" "Represents the C :c:expr:`unsigned short` datatype. The constructor accepts " "an optional integer initializer; no overflow checking is done." msgstr "" -#: ../../library/ctypes.rst:2404 +#: ../../library/ctypes.rst:2484 msgid "" "Represents the C :c:expr:`void *` type. The value is represented as " "integer. The constructor accepts an optional integer initializer." msgstr "" -#: ../../library/ctypes.rst:2410 +#: ../../library/ctypes.rst:2490 msgid "" "Represents the C :c:type:`wchar_t` datatype, and interprets the value as a " "single character unicode string. The constructor accepts an optional string " "initializer, the length of the string must be exactly one character." msgstr "" -#: ../../library/ctypes.rst:2417 +#: ../../library/ctypes.rst:2497 msgid "" "Represents the C :c:expr:`wchar_t *` datatype, which must be a pointer to a " "zero-terminated wide character string. The constructor accepts an integer " "address, or a string." msgstr "" -#: ../../library/ctypes.rst:2424 +#: ../../library/ctypes.rst:2504 msgid "" "Represent the C :c:expr:`bool` datatype (more accurately, :c:expr:`_Bool` " "from C99). Its value can be ``True`` or ``False``, and the constructor " "accepts any object that has a truth value." msgstr "" -#: ../../library/ctypes.rst:2431 +#: ../../library/ctypes.rst:2511 msgid "" -"Windows only: Represents a :c:type:`!HRESULT` value, which contains success " -"or error information for a function or method call." +"Represents a :c:type:`!HRESULT` value, which contains success or error " +"information for a function or method call." msgstr "" -#: ../../library/ctypes.rst:2437 +#: ../../library/ctypes.rst:2519 msgid "" "Represents the C :c:expr:`PyObject *` datatype. Calling this without an " "argument creates a ``NULL`` :c:expr:`PyObject *` pointer." msgstr "" -#: ../../library/ctypes.rst:2440 +#: ../../library/ctypes.rst:2522 msgid "" "The :mod:`!ctypes.wintypes` module provides quite some other Windows " "specific data types, for example :c:type:`!HWND`, :c:type:`!WPARAM`, or :c:" @@ -3944,41 +4087,41 @@ msgid "" "are also defined." msgstr "" -#: ../../library/ctypes.rst:2448 +#: ../../library/ctypes.rst:2530 msgid "Structured data types" msgstr "" -#: ../../library/ctypes.rst:2453 +#: ../../library/ctypes.rst:2535 msgid "Abstract base class for unions in native byte order." msgstr "" -#: ../../library/ctypes.rst:2458 +#: ../../library/ctypes.rst:2540 msgid "Abstract base class for unions in *big endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2464 +#: ../../library/ctypes.rst:2546 msgid "Abstract base class for unions in *little endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2470 +#: ../../library/ctypes.rst:2552 msgid "Abstract base class for structures in *big endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2475 +#: ../../library/ctypes.rst:2557 msgid "Abstract base class for structures in *little endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2477 +#: ../../library/ctypes.rst:2559 msgid "" "Structures and unions with non-native byte order cannot contain pointer type " "fields, or any other data types containing pointer type fields." msgstr "" -#: ../../library/ctypes.rst:2483 +#: ../../library/ctypes.rst:2565 msgid "Abstract base class for structures in *native* byte order." msgstr "" -#: ../../library/ctypes.rst:2485 +#: ../../library/ctypes.rst:2567 msgid "" "Concrete structure and union types must be created by subclassing one of " "these types, and at least define a :attr:`_fields_` class variable. :mod:" @@ -3986,34 +4129,34 @@ msgid "" "the fields by direct attribute accesses. These are the" msgstr "" -#: ../../library/ctypes.rst:2493 +#: ../../library/ctypes.rst:2575 msgid "" "A sequence defining the structure fields. The items must be 2-tuples or 3-" "tuples. The first item is the name of the field, the second item specifies " "the type of the field; it can be any ctypes data type." msgstr "" -#: ../../library/ctypes.rst:2497 +#: ../../library/ctypes.rst:2579 msgid "" "For integer type fields like :class:`c_int`, a third optional item can be " "given. It must be a small positive integer defining the bit width of the " "field." msgstr "" -#: ../../library/ctypes.rst:2501 +#: ../../library/ctypes.rst:2583 msgid "" "Field names must be unique within one structure or union. This is not " "checked, only one field can be accessed when names are repeated." msgstr "" -#: ../../library/ctypes.rst:2504 +#: ../../library/ctypes.rst:2586 msgid "" "It is possible to define the :attr:`_fields_` class variable *after* the " "class statement that defines the Structure subclass, this allows creating " "data types that directly or indirectly reference themselves::" msgstr "" -#: ../../library/ctypes.rst:2508 +#: ../../library/ctypes.rst:2590 msgid "" "class List(Structure):\n" " pass\n" @@ -4027,7 +4170,7 @@ msgstr "" " ...\n" " ]" -#: ../../library/ctypes.rst:2514 +#: ../../library/ctypes.rst:2596 msgid "" "The :attr:`_fields_` class variable must, however, be defined before the " "type is first used (an instance is created, :func:`sizeof` is called on it, " @@ -4035,14 +4178,14 @@ msgid "" "raise an AttributeError." msgstr "" -#: ../../library/ctypes.rst:2519 +#: ../../library/ctypes.rst:2601 msgid "" "It is possible to define sub-subclasses of structure types, they inherit the " "fields of the base class plus the :attr:`_fields_` defined in the sub-" "subclass, if any." msgstr "" -#: ../../library/ctypes.rst:2526 +#: ../../library/ctypes.rst:2608 msgid "" "An optional small integer that allows overriding the alignment of structure " "fields in the instance. :attr:`_pack_` must already be defined when :attr:" @@ -4050,14 +4193,21 @@ msgid "" "attribute to 0 is the same as not setting it at all." msgstr "" -#: ../../library/ctypes.rst:2534 +#: ../../library/ctypes.rst:2616 +msgid "" +"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." +msgstr "" + +#: ../../library/ctypes.rst:2624 msgid "" "An optional sequence that lists the names of unnamed (anonymous) fields. :" "attr:`_anonymous_` must be already defined when :attr:`_fields_` is " "assigned, otherwise it will have no effect." msgstr "" -#: ../../library/ctypes.rst:2538 +#: ../../library/ctypes.rst:2628 msgid "" "The fields listed in this variable must be structure or union type fields. :" "mod:`ctypes` will create descriptors in the structure type that allows " @@ -4065,11 +4215,11 @@ msgid "" "structure or union field." msgstr "" -#: ../../library/ctypes.rst:2543 +#: ../../library/ctypes.rst:2633 msgid "Here is an example type (Windows)::" msgstr "" -#: ../../library/ctypes.rst:2545 +#: ../../library/ctypes.rst:2635 msgid "" "class _U(Union):\n" " _fields_ = [(\"lptdesc\", POINTER(TYPEDESC)),\n" @@ -4091,7 +4241,7 @@ msgstr "" " _fields_ = [(\"u\", _U),\n" " (\"vt\", VARTYPE)]" -#: ../../library/ctypes.rst:2556 +#: ../../library/ctypes.rst:2646 msgid "" "The ``TYPEDESC`` structure describes a COM data type, the ``vt`` field " "specifies which one of the union fields is valid. Since the ``u`` field is " @@ -4101,7 +4251,7 @@ msgid "" "temporary union instance::" msgstr "" -#: ../../library/ctypes.rst:2563 +#: ../../library/ctypes.rst:2653 msgid "" "td = TYPEDESC()\n" "td.vt = VT_PTR\n" @@ -4113,7 +4263,7 @@ msgstr "" "td.lptdesc = POINTER(some_type)\n" "td.u.lptdesc = POINTER(some_type)" -#: ../../library/ctypes.rst:2568 +#: ../../library/ctypes.rst:2658 msgid "" "It is possible to define sub-subclasses of structures, they inherit the " "fields of the base class. If the subclass definition has a separate :attr:" @@ -4121,7 +4271,7 @@ msgid "" "of the base class." msgstr "" -#: ../../library/ctypes.rst:2573 +#: ../../library/ctypes.rst:2663 msgid "" "Structure and union constructors accept both positional and keyword " "arguments. Positional arguments are used to initialize member fields in the " @@ -4131,15 +4281,15 @@ msgid "" "names not present in :attr:`_fields_`." msgstr "" -#: ../../library/ctypes.rst:2584 +#: ../../library/ctypes.rst:2674 msgid "Arrays and pointers" msgstr "" -#: ../../library/ctypes.rst:2588 +#: ../../library/ctypes.rst:2678 msgid "Abstract base class for arrays." msgstr "" -#: ../../library/ctypes.rst:2590 +#: ../../library/ctypes.rst:2680 msgid "" "The recommended way to create concrete array types is by multiplying any :" "mod:`ctypes` data type with a non-negative integer. Alternatively, you can " @@ -4149,34 +4299,46 @@ msgid "" "an :class:`Array`." msgstr "" -#: ../../library/ctypes.rst:2600 +#: ../../library/ctypes.rst:2690 msgid "" "A positive integer specifying the number of elements in the array. Out-of-" "range subscripts result in an :exc:`IndexError`. Will be returned by :func:" "`len`." msgstr "" -#: ../../library/ctypes.rst:2607 +#: ../../library/ctypes.rst:2697 msgid "Specifies the type of each element in the array." msgstr "" -#: ../../library/ctypes.rst:2610 +#: ../../library/ctypes.rst:2700 msgid "" "Array subclass constructors accept positional arguments, used to initialize " "the elements in order." msgstr "" -#: ../../library/ctypes.rst:2616 +#: ../../library/ctypes.rst:2705 +msgid "" +"Create an array. Equivalent to ``type * length``, where *type* is a :mod:" +"`ctypes` data type and *length* an integer." +msgstr "" + +#: ../../library/ctypes.rst:2709 +msgid "" +"This function is :term:`soft deprecated` in favor of multiplication. There " +"are no plans to remove it." +msgstr "" + +#: ../../library/ctypes.rst:2715 msgid "Private, abstract base class for pointers." msgstr "" -#: ../../library/ctypes.rst:2618 +#: ../../library/ctypes.rst:2717 msgid "" "Concrete pointer types are created by calling :func:`POINTER` with the type " "that will be pointed to; this is done automatically by :func:`pointer`." msgstr "" -#: ../../library/ctypes.rst:2622 +#: ../../library/ctypes.rst:2721 msgid "" "If a pointer points to an array, its elements can be read and written using " "standard subscript and slice accesses. Pointer objects have no size, so :" @@ -4185,11 +4347,11 @@ msgid "" "probably crash with an access violation (if you're lucky)." msgstr "" -#: ../../library/ctypes.rst:2632 +#: ../../library/ctypes.rst:2731 msgid "Specifies the type pointed to." msgstr "" -#: ../../library/ctypes.rst:2636 +#: ../../library/ctypes.rst:2735 msgid "" "Returns the object to which to pointer points. Assigning to this attribute " "changes the pointer to point to the assigned object." diff --git a/library/curses.ascii.po b/library/curses.ascii.po index a57da1b4cd..9c57ae467b 100644 --- a/library/curses.ascii.po +++ b/library/curses.ascii.po @@ -5,7 +5,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-05-09 00:03+0000\n" "PO-Revision-Date: 2018-05-23 14:42+0000\n" diff --git a/library/curses.panel.po b/library/curses.panel.po index 056c06f519..4419591d4d 100644 --- a/library/curses.panel.po +++ b/library/curses.panel.po @@ -5,7 +5,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-05-09 00:03+0000\n" "PO-Revision-Date: 2018-05-23 14:42+0000\n" @@ -35,7 +35,7 @@ msgstr "函式" #: ../../library/curses.panel.rst:21 msgid "The module :mod:`curses.panel` defines the following functions:" -msgstr "" +msgstr ":mod:`curses.panel` 模組定義了以下函式:" #: ../../library/curses.panel.rst:26 msgid "Returns the bottom panel in the panel stack." diff --git a/library/curses.po b/library/curses.po index bb5c9bc23c..9bb373d7b3 100644 --- a/library/curses.po +++ b/library/curses.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-27 00:03+0000\n" +"POT-Creation-Date: 2024-10-11 00:13+0000\n" "PO-Revision-Date: 2018-05-23 14:42+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -40,80 +40,92 @@ msgid "" "curses library hosted on Linux and the BSD variants of Unix." msgstr "" -#: ../../library/curses.rst:26 +#: ../../includes/wasm-mobile-notavail.rst:3 +msgid "Availability" +msgstr "可用性" + +#: ../../includes/wasm-mobile-notavail.rst:5 +msgid "" +"This module is not supported on :ref:`mobile platforms ` or :ref:`WebAssembly platforms `." +msgstr "" +"此模組在\\ :ref:`行動平台 `\\ 或\\ :ref:`WebAssembly 平" +"台 `\\ 上不支援。" + +#: ../../library/curses.rst:28 msgid "" "Whenever the documentation mentions a *character* it can be specified as an " "integer, a one-character Unicode string or a one-byte byte string." msgstr "" -#: ../../library/curses.rst:29 +#: ../../library/curses.rst:31 msgid "" "Whenever the documentation mentions a *character string* it can be specified " "as a Unicode string or a byte string." msgstr "" -#: ../../library/curses.rst:34 +#: ../../library/curses.rst:36 msgid "Module :mod:`curses.ascii`" msgstr ":mod:`curses.ascii` 模組" -#: ../../library/curses.rst:35 +#: ../../library/curses.rst:37 msgid "" "Utilities for working with ASCII characters, regardless of your locale " "settings." msgstr "" -#: ../../library/curses.rst:37 +#: ../../library/curses.rst:39 msgid "Module :mod:`curses.panel`" msgstr ":mod:`curses.panel` 模組" -#: ../../library/curses.rst:38 +#: ../../library/curses.rst:40 msgid "A panel stack extension that adds depth to curses windows." msgstr "" -#: ../../library/curses.rst:40 +#: ../../library/curses.rst:42 msgid "Module :mod:`curses.textpad`" msgstr ":mod:`curses.textpad` 模組" -#: ../../library/curses.rst:41 +#: ../../library/curses.rst:43 msgid "" "Editable text widget for curses supporting :program:`Emacs`\\ -like " "bindings." msgstr "" -#: ../../library/curses.rst:43 +#: ../../library/curses.rst:45 msgid ":ref:`curses-howto`" msgstr ":ref:`curses-howto`" -#: ../../library/curses.rst:44 +#: ../../library/curses.rst:46 msgid "" "Tutorial material on using curses with Python, by Andrew Kuchling and Eric " "Raymond." msgstr "" -#: ../../library/curses.rst:51 +#: ../../library/curses.rst:53 msgid "Functions" msgstr "函式" -#: ../../library/curses.rst:53 +#: ../../library/curses.rst:55 msgid "The module :mod:`curses` defines the following exception:" -msgstr "" +msgstr ":mod:`curses` 模組定義了以下例外:" -#: ../../library/curses.rst:58 +#: ../../library/curses.rst:60 msgid "Exception raised when a curses library function returns an error." msgstr "" -#: ../../library/curses.rst:62 +#: ../../library/curses.rst:64 msgid "" "Whenever *x* or *y* arguments to a function or a method are optional, they " "default to the current cursor location. Whenever *attr* is optional, it " "defaults to :const:`A_NORMAL`." msgstr "" -#: ../../library/curses.rst:66 +#: ../../library/curses.rst:68 msgid "The module :mod:`curses` defines the following functions:" -msgstr "" +msgstr ":mod:`curses` 模組定義了以下函式:" -#: ../../library/curses.rst:71 +#: ../../library/curses.rst:73 msgid "" "Return the output speed of the terminal in bits per second. On software " "terminal emulators it will have a fixed high value. Included for historical " @@ -121,17 +133,17 @@ msgid "" "and occasionally to change interfaces depending on the line speed." msgstr "" -#: ../../library/curses.rst:79 +#: ../../library/curses.rst:81 msgid "Emit a short attention sound." msgstr "" -#: ../../library/curses.rst:84 +#: ../../library/curses.rst:86 msgid "" "Return ``True`` or ``False``, depending on whether the programmer can change " "the colors displayed by the terminal." msgstr "" -#: ../../library/curses.rst:90 +#: ../../library/curses.rst:92 msgid "" "Enter cbreak mode. In cbreak mode (sometimes called \"rare\" mode) normal " "tty line buffering is turned off and characters are available to be read one " @@ -141,7 +153,7 @@ msgid "" "terminal in cbreak mode." msgstr "" -#: ../../library/curses.rst:99 +#: ../../library/curses.rst:101 msgid "" "Return the intensity of the red, green, and blue (RGB) components in the " "color *color_number*, which must be between ``0`` and ``COLORS - 1``. " @@ -150,7 +162,7 @@ msgid "" "component)." msgstr "" -#: ../../library/curses.rst:107 +#: ../../library/curses.rst:109 msgid "" "Return the attribute value for displaying text in the specified color pair. " "Only the first 256 color pairs are supported. This attribute value can be " @@ -159,7 +171,7 @@ msgid "" "function." msgstr "" -#: ../../library/curses.rst:116 +#: ../../library/curses.rst:118 msgid "" "Set the cursor state. *visibility* can be set to ``0``, ``1``, or ``2``, " "for invisible, normal, or very visible. If the terminal supports the " @@ -168,7 +180,7 @@ msgid "" "and the \"very visible\" mode is a block cursor." msgstr "" -#: ../../library/curses.rst:125 +#: ../../library/curses.rst:127 msgid "" "Save the current terminal mode as the \"program\" mode, the mode when the " "running program is using curses. (Its counterpart is the \"shell\" mode, " @@ -176,7 +188,7 @@ msgid "" "`reset_prog_mode` will restore this mode." msgstr "" -#: ../../library/curses.rst:133 +#: ../../library/curses.rst:135 msgid "" "Save the current terminal mode as the \"shell\" mode, the mode when the " "running program is not using curses. (Its counterpart is the \"program\" " @@ -184,11 +196,11 @@ msgid "" "func:`reset_shell_mode` will restore this mode." msgstr "" -#: ../../library/curses.rst:141 +#: ../../library/curses.rst:143 msgid "Insert an *ms* millisecond pause in output." msgstr "" -#: ../../library/curses.rst:146 +#: ../../library/curses.rst:148 msgid "" "Update the physical screen. The curses library keeps two data structures, " "one representing the current physical screen contents and a virtual screen " @@ -196,7 +208,7 @@ msgid "" "the physical screen to match the virtual screen." msgstr "" -#: ../../library/curses.rst:151 +#: ../../library/curses.rst:153 msgid "" "The virtual screen may be updated by a :meth:`~window.noutrefresh` call " "after write operations such as :meth:`~window.addstr` have been performed on " @@ -207,24 +219,24 @@ msgid "" "func:`!doupdate`." msgstr "" -#: ../../library/curses.rst:161 +#: ../../library/curses.rst:163 msgid "" "Enter echo mode. In echo mode, each character input is echoed to the screen " "as it is entered." msgstr "" -#: ../../library/curses.rst:167 +#: ../../library/curses.rst:169 msgid "De-initialize the library, and return terminal to normal status." msgstr "" -#: ../../library/curses.rst:172 +#: ../../library/curses.rst:174 msgid "" "Return the user's current erase character as a one-byte bytes object. Under " "Unix operating systems this is a property of the controlling tty of the " "curses program, and is not set by the curses library itself." msgstr "" -#: ../../library/curses.rst:179 +#: ../../library/curses.rst:181 msgid "" "The :func:`.filter` routine, if used, must be called before :func:`initscr` " "is called. The effect is that, during those calls, :envvar:`LINES` is set " @@ -235,20 +247,20 @@ msgid "" "time line editing without touching the rest of the screen." msgstr "" -#: ../../library/curses.rst:189 +#: ../../library/curses.rst:191 msgid "" "Flash the screen. That is, change it to reverse-video and then change it " "back in a short interval. Some people prefer such as 'visible bell' to the " "audible attention signal produced by :func:`beep`." msgstr "" -#: ../../library/curses.rst:196 +#: ../../library/curses.rst:198 msgid "" "Flush all input buffers. This throws away any typeahead that has been " "typed by the user and has not yet been processed by the program." msgstr "" -#: ../../library/curses.rst:202 +#: ../../library/curses.rst:204 msgid "" "After :meth:`~window.getch` returns :const:`KEY_MOUSE` to signal a mouse " "event, this method should be called to retrieve the queued mouse event, " @@ -263,51 +275,51 @@ msgid "" "const:`BUTTON_ALT`." msgstr "" -#: ../../library/curses.rst:213 ../../library/curses.rst:1774 +#: ../../library/curses.rst:215 ../../library/curses.rst:1776 msgid "" "The ``BUTTON5_*`` constants are now exposed if they are provided by the " "underlying curses library." msgstr "" -#: ../../library/curses.rst:220 +#: ../../library/curses.rst:222 msgid "" "Return the current coordinates of the virtual screen cursor as a tuple ``(y, " "x)``. If :meth:`leaveok ` is currently ``True``, then " "return ``(-1, -1)``." msgstr "" -#: ../../library/curses.rst:226 +#: ../../library/curses.rst:228 msgid "" "Read window related data stored in the file by an earlier :func:`window." "putwin` call. The routine then creates and initializes a new window using " "that data, returning the new window object." msgstr "" -#: ../../library/curses.rst:233 +#: ../../library/curses.rst:235 msgid "" "Return ``True`` if the terminal can display colors; otherwise, return " "``False``." msgstr "" -#: ../../library/curses.rst:237 +#: ../../library/curses.rst:239 msgid "" "Return ``True`` if the module supports extended colors; otherwise, return " "``False``. Extended color support allows more than 256 color pairs for " "terminals that support more than 16 colors (e.g. xterm-256color)." msgstr "" -#: ../../library/curses.rst:241 +#: ../../library/curses.rst:243 msgid "Extended color support requires ncurses version 6.1 or later." msgstr "" -#: ../../library/curses.rst:247 +#: ../../library/curses.rst:249 msgid "" "Return ``True`` if the terminal has insert- and delete-character " "capabilities. This function is included for historical reasons only, as all " "modern software terminal emulators have such capabilities." msgstr "" -#: ../../library/curses.rst:254 +#: ../../library/curses.rst:256 msgid "" "Return ``True`` if the terminal has insert- and delete-line capabilities, or " "can simulate them using scrolling regions. This function is included for " @@ -315,13 +327,13 @@ msgid "" "capabilities." msgstr "" -#: ../../library/curses.rst:262 +#: ../../library/curses.rst:264 msgid "" "Take a key value *ch*, and return ``True`` if the current terminal type " "recognizes a key with that value." msgstr "" -#: ../../library/curses.rst:268 +#: ../../library/curses.rst:270 msgid "" "Used for half-delay mode, which is similar to cbreak mode in that characters " "typed by the user are immediately available to the program. However, after " @@ -330,7 +342,7 @@ msgid "" "``255``. Use :func:`nocbreak` to leave half-delay mode." msgstr "" -#: ../../library/curses.rst:277 +#: ../../library/curses.rst:279 msgid "" "Change the definition of a color, taking the number of the color to be " "changed followed by three RGB values (for the amounts of red, green, and " @@ -342,7 +354,7 @@ msgid "" "``True``." msgstr "" -#: ../../library/curses.rst:288 +#: ../../library/curses.rst:290 msgid "" "Change the definition of a color-pair. It takes three arguments: the number " "of the color-pair to be changed, the foreground color number, and the " @@ -355,31 +367,31 @@ msgid "" "definition." msgstr "" -#: ../../library/curses.rst:301 +#: ../../library/curses.rst:303 msgid "" "Initialize the library. Return a :ref:`window ` " "object which represents the whole screen." msgstr "" -#: ../../library/curses.rst:306 +#: ../../library/curses.rst:308 msgid "" "If there is an error opening the terminal, the underlying curses library may " "cause the interpreter to exit." msgstr "" -#: ../../library/curses.rst:312 +#: ../../library/curses.rst:314 msgid "" "Return ``True`` if :func:`resize_term` would modify the window structure, " "``False`` otherwise." msgstr "" -#: ../../library/curses.rst:318 +#: ../../library/curses.rst:320 msgid "" "Return ``True`` if :func:`endwin` has been called (that is, the curses " "library has been deinitialized)." msgstr "" -#: ../../library/curses.rst:324 +#: ../../library/curses.rst:326 msgid "" "Return the name of the key numbered *k* as a bytes object. The name of a " "key generating printable ASCII character is the key's character. The name " @@ -390,27 +402,27 @@ msgid "" "character." msgstr "" -#: ../../library/curses.rst:334 +#: ../../library/curses.rst:336 msgid "" "Return the user's current line kill character as a one-byte bytes object. " "Under Unix operating systems this is a property of the controlling tty of " "the curses program, and is not set by the curses library itself." msgstr "" -#: ../../library/curses.rst:341 +#: ../../library/curses.rst:343 msgid "" "Return a bytes object containing the terminfo long name field describing the " "current terminal. The maximum length of a verbose description is 128 " "characters. It is defined only after the call to :func:`initscr`." msgstr "" -#: ../../library/curses.rst:348 +#: ../../library/curses.rst:350 msgid "" "If *flag* is ``True``, allow 8-bit characters to be input. If *flag* is " "``False``, allow only 7-bit chars." msgstr "" -#: ../../library/curses.rst:354 +#: ../../library/curses.rst:356 msgid "" "Set the maximum time in milliseconds that can elapse between press and " "release events in order for them to be recognized as a click, and return the " @@ -418,7 +430,7 @@ msgid "" "fifth of a second." msgstr "" -#: ../../library/curses.rst:361 +#: ../../library/curses.rst:363 msgid "" "Set the mouse events to be reported, and return a tuple ``(availmask, " "oldmask)``. *availmask* indicates which of the specified mouse events can " @@ -427,17 +439,17 @@ msgid "" "never called, no mouse events are ever reported." msgstr "" -#: ../../library/curses.rst:370 +#: ../../library/curses.rst:372 msgid "Sleep for *ms* milliseconds." msgstr "" -#: ../../library/curses.rst:375 +#: ../../library/curses.rst:377 msgid "" "Create and return a pointer to a new pad data structure with the given " "number of lines and columns. Return a pad as a window object." msgstr "" -#: ../../library/curses.rst:378 +#: ../../library/curses.rst:380 msgid "" "A pad is like a window, except that it is not restricted by the screen size, " "and is not necessarily associated with a particular part of the screen. " @@ -453,35 +465,35 @@ msgid "" "to be displayed." msgstr "" -#: ../../library/curses.rst:394 +#: ../../library/curses.rst:396 msgid "" "Return a new :ref:`window `, whose left-upper corner " "is at ``(begin_y, begin_x)``, and whose height/width is *nlines*/*ncols*." msgstr "" -#: ../../library/curses.rst:397 +#: ../../library/curses.rst:399 msgid "" "By default, the window will extend from the specified position to the lower " "right corner of the screen." msgstr "" -#: ../../library/curses.rst:403 +#: ../../library/curses.rst:405 msgid "" "Enter newline mode. This mode translates the return key into newline on " "input, and translates newline into return and line-feed on output. Newline " "mode is initially on." msgstr "" -#: ../../library/curses.rst:410 +#: ../../library/curses.rst:412 msgid "" "Leave cbreak mode. Return to normal \"cooked\" mode with line buffering." msgstr "" -#: ../../library/curses.rst:415 +#: ../../library/curses.rst:417 msgid "Leave echo mode. Echoing of input characters is turned off." msgstr "" -#: ../../library/curses.rst:420 +#: ../../library/curses.rst:422 msgid "" "Leave newline mode. Disable translation of return into newline on input, " "and disable low-level translation of newline into newline/return on output " @@ -491,7 +503,7 @@ msgid "" "also, it will be able to detect the return key on input." msgstr "" -#: ../../library/curses.rst:430 +#: ../../library/curses.rst:432 msgid "" "When the :func:`!noqiflush` routine is used, normal flush of input and " "output queues associated with the ``INTR``, ``QUIT`` and ``SUSP`` characters " @@ -500,63 +512,63 @@ msgid "" "occurred, after the handler exits." msgstr "" -#: ../../library/curses.rst:438 +#: ../../library/curses.rst:440 msgid "Leave raw mode. Return to normal \"cooked\" mode with line buffering." msgstr "" -#: ../../library/curses.rst:443 +#: ../../library/curses.rst:445 msgid "" "Return a tuple ``(fg, bg)`` containing the colors for the requested color " "pair. The value of *pair_number* must be between ``0`` and ``COLOR_PAIRS - " "1``." msgstr "" -#: ../../library/curses.rst:449 +#: ../../library/curses.rst:451 msgid "" "Return the number of the color-pair set by the attribute value *attr*. :func:" "`color_pair` is the counterpart to this function." msgstr "" -#: ../../library/curses.rst:455 +#: ../../library/curses.rst:457 msgid "" "Equivalent to ``tputs(str, 1, putchar)``; emit the value of a specified " "terminfo capability for the current terminal. Note that the output of :func:" "`putp` always goes to standard output." msgstr "" -#: ../../library/curses.rst:462 +#: ../../library/curses.rst:464 msgid "" "If *flag* is ``False``, the effect is the same as calling :func:`noqiflush`. " "If *flag* is ``True``, or no argument is provided, the queues will be " "flushed when these control characters are read." msgstr "" -#: ../../library/curses.rst:469 +#: ../../library/curses.rst:471 msgid "" "Enter raw mode. In raw mode, normal line buffering and processing of " "interrupt, quit, suspend, and flow control keys are turned off; characters " "are presented to curses input functions one by one." msgstr "" -#: ../../library/curses.rst:476 +#: ../../library/curses.rst:478 msgid "" "Restore the terminal to \"program\" mode, as previously saved by :func:" "`def_prog_mode`." msgstr "" -#: ../../library/curses.rst:482 +#: ../../library/curses.rst:484 msgid "" "Restore the terminal to \"shell\" mode, as previously saved by :func:" "`def_shell_mode`." msgstr "" -#: ../../library/curses.rst:488 +#: ../../library/curses.rst:490 msgid "" "Restore the state of the terminal modes to what it was at the last call to :" "func:`savetty`." msgstr "" -#: ../../library/curses.rst:494 +#: ../../library/curses.rst:496 msgid "" "Backend function used by :func:`resizeterm`, performing most of the work; " "when resizing the windows, :func:`resize_term` blank-fills the areas that " @@ -566,47 +578,47 @@ msgid "" "to resize these without additional interaction with the application." msgstr "" -#: ../../library/curses.rst:504 +#: ../../library/curses.rst:506 msgid "" "Resize the standard and current windows to the specified dimensions, and " "adjusts other bookkeeping data used by the curses library that record the " "window dimensions (in particular the SIGWINCH handler)." msgstr "" -#: ../../library/curses.rst:511 +#: ../../library/curses.rst:513 msgid "" "Save the current state of the terminal modes in a buffer, usable by :func:" "`resetty`." msgstr "" -#: ../../library/curses.rst:516 +#: ../../library/curses.rst:518 msgid "Retrieves the value set by :func:`set_escdelay`." msgstr "" -#: ../../library/curses.rst:522 +#: ../../library/curses.rst:524 msgid "" "Sets the number of milliseconds to wait after reading an escape character, " "to distinguish between an individual escape character entered on the " "keyboard from escape sequences sent by cursor and function keys." msgstr "" -#: ../../library/curses.rst:530 +#: ../../library/curses.rst:532 msgid "Retrieves the value set by :func:`set_tabsize`." msgstr "" -#: ../../library/curses.rst:536 +#: ../../library/curses.rst:538 msgid "" "Sets the number of columns used by the curses library when converting a tab " "character to spaces as it adds the tab to a window." msgstr "" -#: ../../library/curses.rst:543 +#: ../../library/curses.rst:545 msgid "" "Set the virtual screen cursor to *y*, *x*. If *y* and *x* are both ``-1``, " "then :meth:`leaveok ` is set ``True``." msgstr "" -#: ../../library/curses.rst:549 +#: ../../library/curses.rst:551 msgid "" "Initialize the terminal. *term* is a string giving the terminal name, or " "``None``; if omitted or ``None``, the value of the :envvar:`TERM` " @@ -615,14 +627,14 @@ msgid "" "descriptor for ``sys.stdout`` will be used." msgstr "" -#: ../../library/curses.rst:558 +#: ../../library/curses.rst:560 msgid "" "Must be called if the programmer wants to use colors, and before any other " "color manipulation routine is called. It is good practice to call this " "routine right after :func:`initscr`." msgstr "" -#: ../../library/curses.rst:562 +#: ../../library/curses.rst:564 msgid "" ":func:`start_color` initializes eight basic colors (black, red, green, " "yellow, blue, magenta, cyan, and white), and two global variables in the :" @@ -632,20 +644,20 @@ msgid "" "terminal was just turned on." msgstr "" -#: ../../library/curses.rst:571 +#: ../../library/curses.rst:573 msgid "" "Return a logical OR of all video attributes supported by the terminal. This " "information is useful when a curses program needs complete control over the " "appearance of the screen." msgstr "" -#: ../../library/curses.rst:578 +#: ../../library/curses.rst:580 msgid "" "Return the value of the environment variable :envvar:`TERM`, as a bytes " "object, truncated to 14 characters." msgstr "" -#: ../../library/curses.rst:584 +#: ../../library/curses.rst:586 msgid "" "Return the value of the Boolean capability corresponding to the terminfo " "capability name *capname* as an integer. Return the value ``-1`` if " @@ -653,7 +665,7 @@ msgid "" "from the terminal description." msgstr "" -#: ../../library/curses.rst:592 +#: ../../library/curses.rst:594 msgid "" "Return the value of the numeric capability corresponding to the terminfo " "capability name *capname* as an integer. Return the value ``-2`` if " @@ -661,7 +673,7 @@ msgid "" "from the terminal description." msgstr "" -#: ../../library/curses.rst:600 +#: ../../library/curses.rst:602 msgid "" "Return the value of the string capability corresponding to the terminfo " "capability name *capname* as a bytes object. Return ``None`` if *capname* " @@ -669,7 +681,7 @@ msgid "" "terminal description." msgstr "" -#: ../../library/curses.rst:608 +#: ../../library/curses.rst:610 msgid "" "Instantiate the bytes object *str* with the supplied parameters, where *str* " "should be a parameterized string obtained from the terminfo database. E.g. " @@ -677,13 +689,13 @@ msgid "" "exact result depending on terminal type." msgstr "" -#: ../../library/curses.rst:616 +#: ../../library/curses.rst:618 msgid "" "Specify that the file descriptor *fd* be used for typeahead checking. If " "*fd* is ``-1``, then no typeahead checking is done." msgstr "" -#: ../../library/curses.rst:619 +#: ../../library/curses.rst:621 msgid "" "The curses library does \"line-breakout optimization\" by looking for " "typeahead periodically while updating the screen. If input is found, and it " @@ -693,7 +705,7 @@ msgid "" "typeahead checking." msgstr "" -#: ../../library/curses.rst:628 +#: ../../library/curses.rst:630 msgid "" "Return a bytes object which is a printable representation of the character " "*ch*. Control characters are represented as a caret followed by the " @@ -701,35 +713,35 @@ msgid "" "are." msgstr "" -#: ../../library/curses.rst:635 +#: ../../library/curses.rst:637 msgid "Push *ch* so the next :meth:`~window.getch` will return it." msgstr "" -#: ../../library/curses.rst:639 +#: ../../library/curses.rst:641 msgid "Only one *ch* can be pushed before :meth:`!getch` is called." msgstr "" -#: ../../library/curses.rst:644 +#: ../../library/curses.rst:646 msgid "" "Update the :const:`LINES` and :const:`COLS` module variables. Useful for " "detecting manual screen resize." msgstr "" -#: ../../library/curses.rst:652 +#: ../../library/curses.rst:654 msgid "Push *ch* so the next :meth:`~window.get_wch` will return it." msgstr "" -#: ../../library/curses.rst:656 +#: ../../library/curses.rst:658 msgid "Only one *ch* can be pushed before :meth:`!get_wch` is called." msgstr "" -#: ../../library/curses.rst:663 +#: ../../library/curses.rst:665 msgid "" "Push a :const:`KEY_MOUSE` event onto the input queue, associating the given " "state data with it." msgstr "" -#: ../../library/curses.rst:669 +#: ../../library/curses.rst:671 msgid "" "If used, this function should be called before :func:`initscr` or newterm " "are called. When *flag* is ``False``, the values of lines and columns " @@ -739,7 +751,7 @@ msgid "" "to use the window size if :envvar:`LINES` and :envvar:`COLUMNS` are not set)." msgstr "" -#: ../../library/curses.rst:679 +#: ../../library/curses.rst:681 msgid "" "Allow use of default values for colors on terminals supporting this feature. " "Use this to support transparency in your application. The default color is " @@ -748,7 +760,7 @@ msgid "" "*x* to a red foreground color on the default background." msgstr "" -#: ../../library/curses.rst:688 +#: ../../library/curses.rst:690 msgid "" "Initialize curses and call another callable object, *func*, which should be " "the rest of your curses-using application. If the application raises an " @@ -762,50 +774,50 @@ msgid "" "echo, and disables the terminal keypad." msgstr "" -#: ../../library/curses.rst:702 +#: ../../library/curses.rst:704 msgid "Window Objects" msgstr "" -#: ../../library/curses.rst:704 +#: ../../library/curses.rst:706 msgid "" "Window objects, as returned by :func:`initscr` and :func:`newwin` above, " "have the following methods and attributes:" msgstr "" -#: ../../library/curses.rst:711 +#: ../../library/curses.rst:713 msgid "" "Paint character *ch* at ``(y, x)`` with attributes *attr*, overwriting any " "character previously painted at that location. By default, the character " "position and attributes are the current settings for the window object." msgstr "" -#: ../../library/curses.rst:717 +#: ../../library/curses.rst:719 msgid "" "Writing outside the window, subwindow, or pad raises a :exc:`curses.error`. " "Attempting to write to the lower right corner of a window, subwindow, or pad " "will cause an exception to be raised after the character is printed." msgstr "" -#: ../../library/curses.rst:725 +#: ../../library/curses.rst:727 msgid "" "Paint at most *n* characters of the character string *str* at ``(y, x)`` " "with attributes *attr*, overwriting anything previously on the display." msgstr "" -#: ../../library/curses.rst:733 +#: ../../library/curses.rst:735 msgid "" "Paint the character string *str* at ``(y, x)`` with attributes *attr*, " "overwriting anything previously on the display." msgstr "" -#: ../../library/curses.rst:738 +#: ../../library/curses.rst:740 msgid "" "Writing outside the window, subwindow, or pad raises :exc:`curses.error`. " "Attempting to write to the lower right corner of a window, subwindow, or pad " "will cause an exception to be raised after the string is printed." msgstr "" -#: ../../library/curses.rst:742 +#: ../../library/curses.rst:744 msgid "" "A `bug in ncurses `_, the backend for " "this Python module, can cause SegFaults when resizing windows. This is fixed " @@ -815,44 +827,44 @@ msgid "" "line." msgstr "" -#: ../../library/curses.rst:752 +#: ../../library/curses.rst:754 msgid "" "Remove attribute *attr* from the \"background\" set applied to all writes to " "the current window." msgstr "" -#: ../../library/curses.rst:758 +#: ../../library/curses.rst:760 msgid "" "Add attribute *attr* from the \"background\" set applied to all writes to " "the current window." msgstr "" -#: ../../library/curses.rst:764 +#: ../../library/curses.rst:766 msgid "" "Set the \"background\" set of attributes to *attr*. This set is initially " "``0`` (no attributes)." msgstr "" -#: ../../library/curses.rst:770 +#: ../../library/curses.rst:772 msgid "" "Set the background property of the window to the character *ch*, with " "attributes *attr*. The change is then applied to every character position " "in that window:" msgstr "" -#: ../../library/curses.rst:774 +#: ../../library/curses.rst:776 msgid "" "The attribute of every character in the window is changed to the new " "background attribute." msgstr "" -#: ../../library/curses.rst:777 +#: ../../library/curses.rst:779 msgid "" "Wherever the former background character appears, it is changed to the new " "background character." msgstr "" -#: ../../library/curses.rst:783 +#: ../../library/curses.rst:785 msgid "" "Set the window's background. A window's background consists of a character " "and any combination of attributes. The attribute part of the background is " @@ -863,128 +875,128 @@ msgid "" "delete line/character operations." msgstr "" -#: ../../library/curses.rst:793 +#: ../../library/curses.rst:795 msgid "" "Draw a border around the edges of the window. Each parameter specifies the " "character to use for a specific part of the border; see the table below for " "more details." msgstr "" -#: ../../library/curses.rst:799 +#: ../../library/curses.rst:801 msgid "" "A ``0`` value for any parameter will cause the default character to be used " "for that parameter. Keyword parameters can *not* be used. The defaults are " "listed in this table:" msgstr "" -#: ../../library/curses.rst:804 +#: ../../library/curses.rst:806 msgid "Parameter" msgstr "參數" -#: ../../library/curses.rst:804 +#: ../../library/curses.rst:806 msgid "Description" msgstr "描述" -#: ../../library/curses.rst:804 +#: ../../library/curses.rst:806 msgid "Default value" msgstr "" -#: ../../library/curses.rst:806 +#: ../../library/curses.rst:808 msgid "*ls*" msgstr "*ls*" -#: ../../library/curses.rst:806 +#: ../../library/curses.rst:808 msgid "Left side" msgstr "" -#: ../../library/curses.rst:806 ../../library/curses.rst:808 +#: ../../library/curses.rst:808 ../../library/curses.rst:810 msgid ":const:`ACS_VLINE`" msgstr ":const:`ACS_VLINE`" -#: ../../library/curses.rst:808 +#: ../../library/curses.rst:810 msgid "*rs*" msgstr "*rs*" -#: ../../library/curses.rst:808 +#: ../../library/curses.rst:810 msgid "Right side" msgstr "" -#: ../../library/curses.rst:810 +#: ../../library/curses.rst:812 msgid "*ts*" msgstr "*ts*" -#: ../../library/curses.rst:810 +#: ../../library/curses.rst:812 msgid "Top" msgstr "" -#: ../../library/curses.rst:810 ../../library/curses.rst:812 +#: ../../library/curses.rst:812 ../../library/curses.rst:814 msgid ":const:`ACS_HLINE`" msgstr ":const:`ACS_HLINE`" -#: ../../library/curses.rst:812 +#: ../../library/curses.rst:814 msgid "*bs*" msgstr "*bs*" -#: ../../library/curses.rst:812 +#: ../../library/curses.rst:814 msgid "Bottom" msgstr "" -#: ../../library/curses.rst:814 +#: ../../library/curses.rst:816 msgid "*tl*" msgstr "*tl*" -#: ../../library/curses.rst:814 +#: ../../library/curses.rst:816 msgid "Upper-left corner" msgstr "" -#: ../../library/curses.rst:814 +#: ../../library/curses.rst:816 msgid ":const:`ACS_ULCORNER`" msgstr ":const:`ACS_ULCORNER`" -#: ../../library/curses.rst:816 +#: ../../library/curses.rst:818 msgid "*tr*" msgstr "*tr*" -#: ../../library/curses.rst:816 +#: ../../library/curses.rst:818 msgid "Upper-right corner" msgstr "" -#: ../../library/curses.rst:816 +#: ../../library/curses.rst:818 msgid ":const:`ACS_URCORNER`" msgstr ":const:`ACS_URCORNER`" -#: ../../library/curses.rst:818 +#: ../../library/curses.rst:820 msgid "*bl*" msgstr "*bl*" -#: ../../library/curses.rst:818 +#: ../../library/curses.rst:820 msgid "Bottom-left corner" msgstr "" -#: ../../library/curses.rst:818 +#: ../../library/curses.rst:820 msgid ":const:`ACS_LLCORNER`" msgstr ":const:`ACS_LLCORNER`" -#: ../../library/curses.rst:820 +#: ../../library/curses.rst:822 msgid "*br*" msgstr "*br*" -#: ../../library/curses.rst:820 +#: ../../library/curses.rst:822 msgid "Bottom-right corner" msgstr "" -#: ../../library/curses.rst:820 +#: ../../library/curses.rst:822 msgid ":const:`ACS_LRCORNER`" msgstr ":const:`ACS_LRCORNER`" -#: ../../library/curses.rst:826 +#: ../../library/curses.rst:828 msgid "" "Similar to :meth:`border`, but both *ls* and *rs* are *vertch* and both *ts* " "and *bs* are *horch*. The default corner characters are always used by this " "function." msgstr "" -#: ../../library/curses.rst:835 +#: ../../library/curses.rst:837 msgid "" "Set the attributes of *num* characters at the current cursor position, or at " "position ``(y, x)`` if supplied. If *num* is not given or is ``-1``, the " @@ -994,45 +1006,45 @@ msgid "" "be redisplayed by the next window refresh." msgstr "" -#: ../../library/curses.rst:845 +#: ../../library/curses.rst:847 msgid "" "Like :meth:`erase`, but also cause the whole window to be repainted upon " "next call to :meth:`refresh`." msgstr "" -#: ../../library/curses.rst:851 +#: ../../library/curses.rst:853 msgid "" "If *flag* is ``True``, the next call to :meth:`refresh` will clear the " "window completely." msgstr "" -#: ../../library/curses.rst:857 +#: ../../library/curses.rst:859 msgid "" "Erase from cursor to the end of the window: all lines below the cursor are " "deleted, and then the equivalent of :meth:`clrtoeol` is performed." msgstr "" -#: ../../library/curses.rst:863 +#: ../../library/curses.rst:865 msgid "Erase from cursor to the end of the line." msgstr "" -#: ../../library/curses.rst:868 +#: ../../library/curses.rst:870 msgid "" "Update the current cursor position of all the ancestors of the window to " "reflect the current cursor position of the window." msgstr "" -#: ../../library/curses.rst:874 +#: ../../library/curses.rst:876 msgid "Delete any character at ``(y, x)``." msgstr "" -#: ../../library/curses.rst:879 +#: ../../library/curses.rst:881 msgid "" "Delete the line under the cursor. All following lines are moved up by one " "line." msgstr "" -#: ../../library/curses.rst:885 +#: ../../library/curses.rst:887 msgid "" "An abbreviation for \"derive window\", :meth:`derwin` is the same as " "calling :meth:`subwin`, except that *begin_y* and *begin_x* are relative to " @@ -1040,13 +1052,13 @@ msgid "" "a window object for the derived window." msgstr "" -#: ../../library/curses.rst:893 +#: ../../library/curses.rst:895 msgid "" "Add character *ch* with attribute *attr*, and immediately call :meth:" "`refresh` on the window." msgstr "" -#: ../../library/curses.rst:899 +#: ../../library/curses.rst:901 msgid "" "Test whether the given pair of screen-relative character-cell coordinates " "are enclosed by the given window, returning ``True`` or ``False``. It is " @@ -1054,11 +1066,11 @@ msgid "" "location of a mouse event." msgstr "" -#: ../../library/curses.rst:904 +#: ../../library/curses.rst:906 msgid "Previously it returned ``1`` or ``0`` instead of ``True`` or ``False``." msgstr "" -#: ../../library/curses.rst:910 +#: ../../library/curses.rst:912 msgid "" "Encoding used to encode method arguments (Unicode strings and characters). " "The encoding attribute is inherited from the parent window when a subwindow " @@ -1066,19 +1078,19 @@ msgid "" "locale encoding is used (see :func:`locale.getencoding`)." msgstr "" -#: ../../library/curses.rst:920 +#: ../../library/curses.rst:922 msgid "Clear the window." msgstr "" -#: ../../library/curses.rst:925 +#: ../../library/curses.rst:927 msgid "Return a tuple ``(y, x)`` of coordinates of upper-left corner." msgstr "" -#: ../../library/curses.rst:930 +#: ../../library/curses.rst:932 msgid "Return the given window's current background character/attribute pair." msgstr "" -#: ../../library/curses.rst:935 +#: ../../library/curses.rst:937 msgid "" "Get a character. Note that the integer returned does *not* have to be in " "ASCII range: function keys, keypad keys and so on are represented by numbers " @@ -1086,14 +1098,14 @@ msgid "" "otherwise wait until a key is pressed." msgstr "" -#: ../../library/curses.rst:943 +#: ../../library/curses.rst:945 msgid "" "Get a wide character. Return a character for most keys, or an integer for " "function keys, keypad keys, and other special keys. In no-delay mode, raise " "an exception if there is no input." msgstr "" -#: ../../library/curses.rst:952 +#: ../../library/curses.rst:954 msgid "" "Get a character, returning a string instead of an integer, as :meth:`getch` " "does. Function keys, keypad keys and other special keys return a multibyte " @@ -1101,35 +1113,35 @@ msgid "" "there is no input." msgstr "" -#: ../../library/curses.rst:960 +#: ../../library/curses.rst:962 msgid "Return a tuple ``(y, x)`` of the height and width of the window." msgstr "" -#: ../../library/curses.rst:965 +#: ../../library/curses.rst:967 msgid "" "Return the beginning coordinates of this window relative to its parent " "window as a tuple ``(y, x)``. Return ``(-1, -1)`` if this window has no " "parent." msgstr "" -#: ../../library/curses.rst:975 +#: ../../library/curses.rst:977 msgid "" "Read a bytes object from the user, with primitive line editing capacity." msgstr "" -#: ../../library/curses.rst:980 +#: ../../library/curses.rst:982 msgid "" "Return a tuple ``(y, x)`` of current cursor position relative to the " "window's upper-left corner." msgstr "" -#: ../../library/curses.rst:987 +#: ../../library/curses.rst:989 msgid "" "Display a horizontal line starting at ``(y, x)`` with length *n* consisting " "of the character *ch*." msgstr "" -#: ../../library/curses.rst:993 +#: ../../library/curses.rst:995 msgid "" "If *flag* is ``False``, curses no longer considers using the hardware insert/" "delete character feature of the terminal; if *flag* is ``True``, use of " @@ -1137,13 +1149,13 @@ msgid "" "initialized, use of character insert/delete is enabled by default." msgstr "" -#: ../../library/curses.rst:1001 +#: ../../library/curses.rst:1003 msgid "" "If *flag* is ``True``, :mod:`curses` will try and use hardware line editing " "facilities. Otherwise, line insertion/deletion are disabled." msgstr "" -#: ../../library/curses.rst:1007 +#: ../../library/curses.rst:1009 msgid "" "If *flag* is ``True``, any change in the window image automatically causes " "the window to be refreshed; you no longer have to call :meth:`refresh` " @@ -1151,19 +1163,19 @@ msgid "" "calls to wrefresh. This option is disabled by default." msgstr "" -#: ../../library/curses.rst:1015 +#: ../../library/curses.rst:1017 msgid "" "Return the character at the given position in the window. The bottom 8 bits " "are the character proper, and upper bits are the attributes." msgstr "" -#: ../../library/curses.rst:1022 +#: ../../library/curses.rst:1024 msgid "" "Paint character *ch* at ``(y, x)`` with attributes *attr*, moving the line " "from position *x* right by one character." msgstr "" -#: ../../library/curses.rst:1028 +#: ../../library/curses.rst:1030 msgid "" "Insert *nlines* lines into the specified window above the current line. The " "*nlines* bottom lines are lost. For negative *nlines*, delete *nlines* " @@ -1172,13 +1184,13 @@ msgid "" "remains the same." msgstr "" -#: ../../library/curses.rst:1037 +#: ../../library/curses.rst:1039 msgid "" "Insert a blank line under the cursor. All following lines are moved down by " "one line." msgstr "" -#: ../../library/curses.rst:1044 +#: ../../library/curses.rst:1046 msgid "" "Insert a character string (as many characters as will fit on the line) " "before the character under the cursor, up to *n* characters. If *n* is " @@ -1188,7 +1200,7 @@ msgid "" "if specified)." msgstr "" -#: ../../library/curses.rst:1054 +#: ../../library/curses.rst:1056 msgid "" "Insert a character string (as many characters as will fit on the line) " "before the character under the cursor. All characters to the right of the " @@ -1197,7 +1209,7 @@ msgid "" "specified)." msgstr "" -#: ../../library/curses.rst:1063 +#: ../../library/curses.rst:1065 msgid "" "Return a bytes object of characters, extracted from the window starting at " "the current cursor position, or at *y*, *x* if specified. Attributes are " @@ -1205,76 +1217,76 @@ msgid "" "string at most *n* characters long (exclusive of the trailing NUL)." msgstr "" -#: ../../library/curses.rst:1071 +#: ../../library/curses.rst:1073 msgid "" "Return ``True`` if the specified line was modified since the last call to :" "meth:`refresh`; otherwise return ``False``. Raise a :exc:`curses.error` " "exception if *line* is not valid for the given window." msgstr "" -#: ../../library/curses.rst:1078 +#: ../../library/curses.rst:1080 msgid "" "Return ``True`` if the specified window was modified since the last call to :" "meth:`refresh`; otherwise return ``False``." msgstr "" -#: ../../library/curses.rst:1084 +#: ../../library/curses.rst:1086 msgid "" "If *flag* is ``True``, escape sequences generated by some keys (keypad, " "function keys) will be interpreted by :mod:`curses`. If *flag* is ``False``, " "escape sequences will be left as is in the input stream." msgstr "" -#: ../../library/curses.rst:1091 +#: ../../library/curses.rst:1093 msgid "" "If *flag* is ``True``, cursor is left where it is on update, instead of " "being at \"cursor position.\" This reduces cursor movement where possible. " "If possible the cursor will be made invisible." msgstr "" -#: ../../library/curses.rst:1095 +#: ../../library/curses.rst:1097 msgid "" "If *flag* is ``False``, cursor will always be at \"cursor position\" after " "an update." msgstr "" -#: ../../library/curses.rst:1100 +#: ../../library/curses.rst:1102 msgid "Move cursor to ``(new_y, new_x)``." msgstr "" -#: ../../library/curses.rst:1105 +#: ../../library/curses.rst:1107 msgid "" "Move the window inside its parent window. The screen-relative parameters of " "the window are not changed. This routine is used to display different parts " "of the parent window at the same physical position on the screen." msgstr "" -#: ../../library/curses.rst:1112 +#: ../../library/curses.rst:1114 msgid "Move the window so its upper-left corner is at ``(new_y, new_x)``." msgstr "" -#: ../../library/curses.rst:1117 +#: ../../library/curses.rst:1119 msgid "If *flag* is ``True``, :meth:`getch` will be non-blocking." msgstr "" -#: ../../library/curses.rst:1122 +#: ../../library/curses.rst:1124 msgid "If *flag* is ``True``, escape sequences will not be timed out." msgstr "" -#: ../../library/curses.rst:1124 +#: ../../library/curses.rst:1126 msgid "" "If *flag* is ``False``, after a few milliseconds, an escape sequence will " "not be interpreted, and will be left in the input stream as is." msgstr "" -#: ../../library/curses.rst:1130 +#: ../../library/curses.rst:1132 msgid "" "Mark for refresh but wait. This function updates the data structure " "representing the desired state of the window, but does not force an update " "of the physical screen. To accomplish that, call :func:`doupdate`." msgstr "" -#: ../../library/curses.rst:1137 +#: ../../library/curses.rst:1139 msgid "" "Overlay the window on top of *destwin*. The windows need not be the same " "size, only the overlapping region is copied. This copy is non-destructive, " @@ -1282,7 +1294,7 @@ msgid "" "contents of *destwin*." msgstr "" -#: ../../library/curses.rst:1142 +#: ../../library/curses.rst:1144 msgid "" "To get fine-grained control over the copied region, the second form of :meth:" "`overlay` can be used. *sminrow* and *smincol* are the upper-left " @@ -1290,7 +1302,7 @@ msgid "" "in the destination window." msgstr "" -#: ../../library/curses.rst:1150 +#: ../../library/curses.rst:1152 msgid "" "Overwrite the window on top of *destwin*. The windows need not be the same " "size, in which case only the overlapping region is copied. This copy is " @@ -1298,7 +1310,7 @@ msgid "" "the old contents of *destwin*." msgstr "" -#: ../../library/curses.rst:1155 +#: ../../library/curses.rst:1157 msgid "" "To get fine-grained control over the copied region, the second form of :meth:" "`overwrite` can be used. *sminrow* and *smincol* are the upper-left " @@ -1306,31 +1318,31 @@ msgid "" "the destination window." msgstr "" -#: ../../library/curses.rst:1163 +#: ../../library/curses.rst:1165 msgid "" "Write all data associated with the window into the provided file object. " "This information can be later retrieved using the :func:`getwin` function." msgstr "" -#: ../../library/curses.rst:1169 +#: ../../library/curses.rst:1171 msgid "" "Indicate that the *num* screen lines, starting at line *beg*, are corrupted " "and should be completely redrawn on the next :meth:`refresh` call." msgstr "" -#: ../../library/curses.rst:1175 +#: ../../library/curses.rst:1177 msgid "" "Touch the entire window, causing it to be completely redrawn on the next :" "meth:`refresh` call." msgstr "" -#: ../../library/curses.rst:1181 +#: ../../library/curses.rst:1183 msgid "" "Update the display immediately (sync actual screen with previous drawing/" "deleting methods)." msgstr "" -#: ../../library/curses.rst:1184 +#: ../../library/curses.rst:1186 msgid "" "The 6 optional arguments can only be specified when the window is a pad " "created with :func:`newpad`. The additional parameters are needed to " @@ -1345,7 +1357,7 @@ msgid "" "*smincol* are treated as if they were zero." msgstr "" -#: ../../library/curses.rst:1198 +#: ../../library/curses.rst:1200 msgid "" "Reallocate storage for a curses window to adjust its dimensions to the " "specified values. If either dimension is larger than the current values, " @@ -1353,11 +1365,11 @@ msgid "" "rendition (as set by :meth:`bkgdset`) merged into them." msgstr "" -#: ../../library/curses.rst:1206 +#: ../../library/curses.rst:1208 msgid "Scroll the screen or scrolling region upward by *lines* lines." msgstr "" -#: ../../library/curses.rst:1211 +#: ../../library/curses.rst:1213 msgid "" "Control what happens when the cursor of a window is moved off the edge of " "the window or scrolling region, either as a result of a newline action on " @@ -1367,54 +1379,54 @@ msgid "" "scrolling effect on the terminal, it is also necessary to call :meth:`idlok`." msgstr "" -#: ../../library/curses.rst:1221 +#: ../../library/curses.rst:1223 msgid "" "Set the scrolling region from line *top* to line *bottom*. All scrolling " "actions will take place in this region." msgstr "" -#: ../../library/curses.rst:1227 +#: ../../library/curses.rst:1229 msgid "" "Turn off the standout attribute. On some terminals this has the side effect " "of turning off all attributes." msgstr "" -#: ../../library/curses.rst:1233 +#: ../../library/curses.rst:1235 msgid "Turn on attribute *A_STANDOUT*." msgstr "" -#: ../../library/curses.rst:1239 ../../library/curses.rst:1246 +#: ../../library/curses.rst:1241 ../../library/curses.rst:1248 msgid "" "Return a sub-window, whose upper-left corner is at ``(begin_y, begin_x)``, " "and whose width/height is *ncols*/*nlines*." msgstr "" -#: ../../library/curses.rst:1249 +#: ../../library/curses.rst:1251 msgid "" "By default, the sub-window will extend from the specified position to the " "lower right corner of the window." msgstr "" -#: ../../library/curses.rst:1255 +#: ../../library/curses.rst:1257 msgid "" "Touch each location in the window that has been touched in any of its " "ancestor windows. This routine is called by :meth:`refresh`, so it should " "almost never be necessary to call it manually." msgstr "" -#: ../../library/curses.rst:1262 +#: ../../library/curses.rst:1264 msgid "" "If *flag* is ``True``, then :meth:`syncup` is called automatically whenever " "there is a change in the window." msgstr "" -#: ../../library/curses.rst:1268 +#: ../../library/curses.rst:1270 msgid "" "Touch all locations in ancestors of the window that have been changed in " "the window." msgstr "" -#: ../../library/curses.rst:1274 +#: ../../library/curses.rst:1276 msgid "" "Set blocking or non-blocking read behavior for the window. If *delay* is " "negative, blocking read is used (which will wait indefinitely for input). " @@ -1424,7 +1436,7 @@ msgid "" "still no input at the end of that time." msgstr "" -#: ../../library/curses.rst:1284 +#: ../../library/curses.rst:1286 msgid "" "Pretend *count* lines have been changed, starting with line *start*. If " "*changed* is supplied, it specifies whether the affected lines are marked as " @@ -1432,49 +1444,49 @@ msgid "" "``=False``)." msgstr "" -#: ../../library/curses.rst:1291 +#: ../../library/curses.rst:1293 msgid "" "Pretend the whole window has been changed, for purposes of drawing " "optimizations." msgstr "" -#: ../../library/curses.rst:1297 +#: ../../library/curses.rst:1299 msgid "" "Mark all lines in the window as unchanged since the last call to :meth:" "`refresh`." msgstr "" -#: ../../library/curses.rst:1304 +#: ../../library/curses.rst:1306 msgid "" "Display a vertical line starting at ``(y, x)`` with length *n* consisting of " "the character *ch* with attributes *attr*." msgstr "" -#: ../../library/curses.rst:1309 +#: ../../library/curses.rst:1311 msgid "Constants" msgstr "" -#: ../../library/curses.rst:1311 +#: ../../library/curses.rst:1313 msgid "The :mod:`curses` module defines the following data members:" -msgstr "" +msgstr ":mod:`curses` 模組定義了以下資料成員:" -#: ../../library/curses.rst:1316 +#: ../../library/curses.rst:1318 msgid "" "Some curses routines that return an integer, such as :meth:`~window." "getch`, return :const:`ERR` upon failure." msgstr "" -#: ../../library/curses.rst:1322 +#: ../../library/curses.rst:1324 msgid "" "Some curses routines that return an integer, such as :func:`napms`, " "return :const:`OK` upon success." msgstr "" -#: ../../library/curses.rst:1329 +#: ../../library/curses.rst:1331 msgid "A bytes object representing the current version of the module." msgstr "" -#: ../../library/curses.rst:1334 +#: ../../library/curses.rst:1336 msgid "" "A named tuple containing the three components of the ncurses library " "version: *major*, *minor*, and *patch*. All values are integers. The " @@ -1482,536 +1494,536 @@ msgid "" "is equivalent to ``curses.ncurses_version.major`` and so on." msgstr "" -#: ../../library/curses.rst:1339 +#: ../../library/curses.rst:1341 msgid "Availability: if the ncurses library is used." msgstr "" -#: ../../library/curses.rst:1345 +#: ../../library/curses.rst:1347 msgid "" "The maximum number of colors the terminal can support. It is defined only " "after the call to :func:`start_color`." msgstr "" -#: ../../library/curses.rst:1350 +#: ../../library/curses.rst:1352 msgid "" "The maximum number of color pairs the terminal can support. It is defined " "only after the call to :func:`start_color`." msgstr "" -#: ../../library/curses.rst:1355 +#: ../../library/curses.rst:1357 msgid "" "The width of the screen, i.e., the number of columns. It is defined only " "after the call to :func:`initscr`. Updated by :func:`update_lines_cols`, :" "func:`resizeterm` and :func:`resize_term`." msgstr "" -#: ../../library/curses.rst:1362 +#: ../../library/curses.rst:1364 msgid "" "The height of the screen, i.e., the number of lines. It is defined only " "after the call to :func:`initscr`. Updated by :func:`update_lines_cols`, :" "func:`resizeterm` and :func:`resize_term`." msgstr "" -#: ../../library/curses.rst:1368 +#: ../../library/curses.rst:1370 msgid "" "Some constants are available to specify character cell attributes. The exact " "constants available are system dependent." msgstr "" -#: ../../library/curses.rst:1372 +#: ../../library/curses.rst:1374 msgid "Attribute" msgstr "" -#: ../../library/curses.rst:1372 ../../library/curses.rst:1417 -#: ../../library/curses.rst:1663 ../../library/curses.rst:1755 +#: ../../library/curses.rst:1374 ../../library/curses.rst:1419 +#: ../../library/curses.rst:1665 ../../library/curses.rst:1757 msgid "Meaning" msgstr "含義" -#: ../../library/curses.rst:1374 +#: ../../library/curses.rst:1376 msgid "Alternate character set mode" msgstr "" -#: ../../library/curses.rst:1376 +#: ../../library/curses.rst:1378 msgid "Blink mode" msgstr "" -#: ../../library/curses.rst:1378 +#: ../../library/curses.rst:1380 msgid "Bold mode" msgstr "" -#: ../../library/curses.rst:1380 +#: ../../library/curses.rst:1382 msgid "Dim mode" msgstr "" -#: ../../library/curses.rst:1382 +#: ../../library/curses.rst:1384 msgid "Invisible or blank mode" msgstr "" -#: ../../library/curses.rst:1384 +#: ../../library/curses.rst:1386 msgid "Italic mode" msgstr "" -#: ../../library/curses.rst:1386 +#: ../../library/curses.rst:1388 msgid "Normal attribute" msgstr "" -#: ../../library/curses.rst:1388 +#: ../../library/curses.rst:1390 msgid "Protected mode" msgstr "" -#: ../../library/curses.rst:1390 +#: ../../library/curses.rst:1392 msgid "Reverse background and foreground colors" msgstr "" -#: ../../library/curses.rst:1393 +#: ../../library/curses.rst:1395 msgid "Standout mode" msgstr "" -#: ../../library/curses.rst:1395 +#: ../../library/curses.rst:1397 msgid "Underline mode" msgstr "" -#: ../../library/curses.rst:1397 +#: ../../library/curses.rst:1399 msgid "Horizontal highlight" msgstr "" -#: ../../library/curses.rst:1399 +#: ../../library/curses.rst:1401 msgid "Left highlight" msgstr "" -#: ../../library/curses.rst:1401 +#: ../../library/curses.rst:1403 msgid "Low highlight" msgstr "" -#: ../../library/curses.rst:1403 +#: ../../library/curses.rst:1405 msgid "Right highlight" msgstr "" -#: ../../library/curses.rst:1405 +#: ../../library/curses.rst:1407 msgid "Top highlight" msgstr "" -#: ../../library/curses.rst:1407 +#: ../../library/curses.rst:1409 msgid "Vertical highlight" msgstr "" -#: ../../library/curses.rst:1410 +#: ../../library/curses.rst:1412 msgid "``A_ITALIC`` was added." msgstr "" -#: ../../library/curses.rst:1413 +#: ../../library/curses.rst:1415 msgid "" "Several constants are available to extract corresponding attributes returned " "by some methods." msgstr "" -#: ../../library/curses.rst:1417 +#: ../../library/curses.rst:1419 msgid "Bit-mask" msgstr "" -#: ../../library/curses.rst:1419 +#: ../../library/curses.rst:1421 msgid "Bit-mask to extract attributes" msgstr "" -#: ../../library/curses.rst:1422 +#: ../../library/curses.rst:1424 msgid "Bit-mask to extract a character" msgstr "" -#: ../../library/curses.rst:1425 +#: ../../library/curses.rst:1427 msgid "Bit-mask to extract color-pair field information" msgstr "" -#: ../../library/curses.rst:1429 +#: ../../library/curses.rst:1431 msgid "" "Keys are referred to by integer constants with names starting with " "``KEY_``. The exact keycaps available are system dependent." msgstr "" -#: ../../library/curses.rst:1435 +#: ../../library/curses.rst:1437 msgid "Key constant" msgstr "" -#: ../../library/curses.rst:1435 +#: ../../library/curses.rst:1437 msgid "Key" msgstr "" -#: ../../library/curses.rst:1437 +#: ../../library/curses.rst:1439 msgid "Minimum key value" msgstr "" -#: ../../library/curses.rst:1439 +#: ../../library/curses.rst:1441 msgid "Break key (unreliable)" msgstr "" -#: ../../library/curses.rst:1441 +#: ../../library/curses.rst:1443 msgid "Down-arrow" msgstr "" -#: ../../library/curses.rst:1443 +#: ../../library/curses.rst:1445 msgid "Up-arrow" msgstr "" -#: ../../library/curses.rst:1445 +#: ../../library/curses.rst:1447 msgid "Left-arrow" msgstr "" -#: ../../library/curses.rst:1447 +#: ../../library/curses.rst:1449 msgid "Right-arrow" msgstr "" -#: ../../library/curses.rst:1449 +#: ../../library/curses.rst:1451 msgid "Home key (upward+left arrow)" msgstr "" -#: ../../library/curses.rst:1451 +#: ../../library/curses.rst:1453 msgid "Backspace (unreliable)" msgstr "" -#: ../../library/curses.rst:1453 +#: ../../library/curses.rst:1455 msgid "Function keys. Up to 64 function keys are supported." msgstr "" -#: ../../library/curses.rst:1456 +#: ../../library/curses.rst:1458 msgid "Value of function key *n*" msgstr "" -#: ../../library/curses.rst:1458 +#: ../../library/curses.rst:1460 msgid "Delete line" msgstr "" -#: ../../library/curses.rst:1460 +#: ../../library/curses.rst:1462 msgid "Insert line" msgstr "" -#: ../../library/curses.rst:1462 +#: ../../library/curses.rst:1464 msgid "Delete character" msgstr "" -#: ../../library/curses.rst:1464 +#: ../../library/curses.rst:1466 msgid "Insert char or enter insert mode" msgstr "" -#: ../../library/curses.rst:1466 +#: ../../library/curses.rst:1468 msgid "Exit insert char mode" msgstr "" -#: ../../library/curses.rst:1468 +#: ../../library/curses.rst:1470 msgid "Clear screen" msgstr "" -#: ../../library/curses.rst:1470 +#: ../../library/curses.rst:1472 msgid "Clear to end of screen" msgstr "" -#: ../../library/curses.rst:1472 +#: ../../library/curses.rst:1474 msgid "Clear to end of line" msgstr "" -#: ../../library/curses.rst:1474 +#: ../../library/curses.rst:1476 msgid "Scroll 1 line forward" msgstr "" -#: ../../library/curses.rst:1476 +#: ../../library/curses.rst:1478 msgid "Scroll 1 line backward (reverse)" msgstr "" -#: ../../library/curses.rst:1478 +#: ../../library/curses.rst:1480 msgid "Next page" msgstr "" -#: ../../library/curses.rst:1480 +#: ../../library/curses.rst:1482 msgid "Previous page" msgstr "" -#: ../../library/curses.rst:1482 +#: ../../library/curses.rst:1484 msgid "Set tab" msgstr "" -#: ../../library/curses.rst:1484 +#: ../../library/curses.rst:1486 msgid "Clear tab" msgstr "" -#: ../../library/curses.rst:1486 +#: ../../library/curses.rst:1488 msgid "Clear all tabs" msgstr "" -#: ../../library/curses.rst:1488 +#: ../../library/curses.rst:1490 msgid "Enter or send (unreliable)" msgstr "" -#: ../../library/curses.rst:1490 +#: ../../library/curses.rst:1492 msgid "Soft (partial) reset (unreliable)" msgstr "" -#: ../../library/curses.rst:1492 +#: ../../library/curses.rst:1494 msgid "Reset or hard reset (unreliable)" msgstr "" -#: ../../library/curses.rst:1494 +#: ../../library/curses.rst:1496 msgid "Print" msgstr "" -#: ../../library/curses.rst:1496 +#: ../../library/curses.rst:1498 msgid "Home down or bottom (lower left)" msgstr "" -#: ../../library/curses.rst:1498 +#: ../../library/curses.rst:1500 msgid "Upper left of keypad" msgstr "" -#: ../../library/curses.rst:1500 +#: ../../library/curses.rst:1502 msgid "Upper right of keypad" msgstr "" -#: ../../library/curses.rst:1502 +#: ../../library/curses.rst:1504 msgid "Center of keypad" msgstr "" -#: ../../library/curses.rst:1504 +#: ../../library/curses.rst:1506 msgid "Lower left of keypad" msgstr "" -#: ../../library/curses.rst:1506 +#: ../../library/curses.rst:1508 msgid "Lower right of keypad" msgstr "" -#: ../../library/curses.rst:1508 +#: ../../library/curses.rst:1510 msgid "Back tab" msgstr "" -#: ../../library/curses.rst:1510 +#: ../../library/curses.rst:1512 msgid "Beg (beginning)" msgstr "" -#: ../../library/curses.rst:1512 +#: ../../library/curses.rst:1514 msgid "Cancel" msgstr "" -#: ../../library/curses.rst:1514 +#: ../../library/curses.rst:1516 msgid "Close" msgstr "" -#: ../../library/curses.rst:1516 +#: ../../library/curses.rst:1518 msgid "Cmd (command)" msgstr "" -#: ../../library/curses.rst:1518 +#: ../../library/curses.rst:1520 msgid "Copy" msgstr "" -#: ../../library/curses.rst:1520 +#: ../../library/curses.rst:1522 msgid "Create" msgstr "" -#: ../../library/curses.rst:1522 +#: ../../library/curses.rst:1524 msgid "End" msgstr "" -#: ../../library/curses.rst:1524 +#: ../../library/curses.rst:1526 msgid "Exit" msgstr "" -#: ../../library/curses.rst:1526 +#: ../../library/curses.rst:1528 msgid "Find" msgstr "" -#: ../../library/curses.rst:1528 +#: ../../library/curses.rst:1530 msgid "Help" msgstr "" -#: ../../library/curses.rst:1530 +#: ../../library/curses.rst:1532 msgid "Mark" msgstr "" -#: ../../library/curses.rst:1532 +#: ../../library/curses.rst:1534 msgid "Message" msgstr "" -#: ../../library/curses.rst:1534 +#: ../../library/curses.rst:1536 msgid "Move" msgstr "" -#: ../../library/curses.rst:1536 +#: ../../library/curses.rst:1538 msgid "Next" msgstr "" -#: ../../library/curses.rst:1538 +#: ../../library/curses.rst:1540 msgid "Open" msgstr "" -#: ../../library/curses.rst:1540 +#: ../../library/curses.rst:1542 msgid "Options" msgstr "" -#: ../../library/curses.rst:1542 +#: ../../library/curses.rst:1544 msgid "Prev (previous)" msgstr "" -#: ../../library/curses.rst:1544 +#: ../../library/curses.rst:1546 msgid "Redo" msgstr "" -#: ../../library/curses.rst:1546 +#: ../../library/curses.rst:1548 msgid "Ref (reference)" msgstr "" -#: ../../library/curses.rst:1548 +#: ../../library/curses.rst:1550 msgid "Refresh" msgstr "" -#: ../../library/curses.rst:1550 +#: ../../library/curses.rst:1552 msgid "Replace" msgstr "" -#: ../../library/curses.rst:1552 +#: ../../library/curses.rst:1554 msgid "Restart" msgstr "" -#: ../../library/curses.rst:1554 +#: ../../library/curses.rst:1556 msgid "Resume" msgstr "" -#: ../../library/curses.rst:1556 +#: ../../library/curses.rst:1558 msgid "Save" msgstr "" -#: ../../library/curses.rst:1558 +#: ../../library/curses.rst:1560 msgid "Shifted Beg (beginning)" msgstr "" -#: ../../library/curses.rst:1560 +#: ../../library/curses.rst:1562 msgid "Shifted Cancel" msgstr "" -#: ../../library/curses.rst:1562 +#: ../../library/curses.rst:1564 msgid "Shifted Command" msgstr "" -#: ../../library/curses.rst:1564 +#: ../../library/curses.rst:1566 msgid "Shifted Copy" msgstr "" -#: ../../library/curses.rst:1566 +#: ../../library/curses.rst:1568 msgid "Shifted Create" msgstr "" -#: ../../library/curses.rst:1568 +#: ../../library/curses.rst:1570 msgid "Shifted Delete char" msgstr "" -#: ../../library/curses.rst:1570 +#: ../../library/curses.rst:1572 msgid "Shifted Delete line" msgstr "" -#: ../../library/curses.rst:1572 +#: ../../library/curses.rst:1574 msgid "Select" msgstr "" -#: ../../library/curses.rst:1574 +#: ../../library/curses.rst:1576 msgid "Shifted End" msgstr "" -#: ../../library/curses.rst:1576 +#: ../../library/curses.rst:1578 msgid "Shifted Clear line" msgstr "" -#: ../../library/curses.rst:1578 +#: ../../library/curses.rst:1580 msgid "Shifted Exit" msgstr "" -#: ../../library/curses.rst:1580 +#: ../../library/curses.rst:1582 msgid "Shifted Find" msgstr "" -#: ../../library/curses.rst:1582 +#: ../../library/curses.rst:1584 msgid "Shifted Help" msgstr "" -#: ../../library/curses.rst:1584 +#: ../../library/curses.rst:1586 msgid "Shifted Home" msgstr "" -#: ../../library/curses.rst:1586 +#: ../../library/curses.rst:1588 msgid "Shifted Input" msgstr "" -#: ../../library/curses.rst:1588 +#: ../../library/curses.rst:1590 msgid "Shifted Left arrow" msgstr "" -#: ../../library/curses.rst:1590 +#: ../../library/curses.rst:1592 msgid "Shifted Message" msgstr "" -#: ../../library/curses.rst:1592 +#: ../../library/curses.rst:1594 msgid "Shifted Move" msgstr "" -#: ../../library/curses.rst:1594 +#: ../../library/curses.rst:1596 msgid "Shifted Next" msgstr "" -#: ../../library/curses.rst:1596 +#: ../../library/curses.rst:1598 msgid "Shifted Options" msgstr "" -#: ../../library/curses.rst:1598 +#: ../../library/curses.rst:1600 msgid "Shifted Prev" msgstr "" -#: ../../library/curses.rst:1600 +#: ../../library/curses.rst:1602 msgid "Shifted Print" msgstr "" -#: ../../library/curses.rst:1602 +#: ../../library/curses.rst:1604 msgid "Shifted Redo" msgstr "" -#: ../../library/curses.rst:1604 +#: ../../library/curses.rst:1606 msgid "Shifted Replace" msgstr "" -#: ../../library/curses.rst:1606 +#: ../../library/curses.rst:1608 msgid "Shifted Right arrow" msgstr "" -#: ../../library/curses.rst:1608 +#: ../../library/curses.rst:1610 msgid "Shifted Resume" msgstr "" -#: ../../library/curses.rst:1610 +#: ../../library/curses.rst:1612 msgid "Shifted Save" msgstr "" -#: ../../library/curses.rst:1612 +#: ../../library/curses.rst:1614 msgid "Shifted Suspend" msgstr "" -#: ../../library/curses.rst:1614 +#: ../../library/curses.rst:1616 msgid "Shifted Undo" msgstr "" -#: ../../library/curses.rst:1616 +#: ../../library/curses.rst:1618 msgid "Suspend" msgstr "" -#: ../../library/curses.rst:1618 +#: ../../library/curses.rst:1620 msgid "Undo" msgstr "" -#: ../../library/curses.rst:1620 +#: ../../library/curses.rst:1622 msgid "Mouse event has occurred" msgstr "" -#: ../../library/curses.rst:1622 +#: ../../library/curses.rst:1624 msgid "Terminal resize event" msgstr "" -#: ../../library/curses.rst:1624 +#: ../../library/curses.rst:1626 msgid "Maximum key value" msgstr "" -#: ../../library/curses.rst:1627 +#: ../../library/curses.rst:1629 msgid "" "On VT100s and their software emulations, such as X terminal emulators, there " "are normally at least four function keys (:const:`KEY_F1 `, :const:" @@ -2023,64 +2035,64 @@ msgid "" "keypad mappings are standard:" msgstr "" -#: ../../library/curses.rst:1636 +#: ../../library/curses.rst:1638 msgid "Keycap" msgstr "" -#: ../../library/curses.rst:1636 ../../library/curses.rst:1781 -#: ../../library/curses.rst:1905 +#: ../../library/curses.rst:1638 ../../library/curses.rst:1783 +#: ../../library/curses.rst:1907 msgid "Constant" msgstr "" -#: ../../library/curses.rst:1638 +#: ../../library/curses.rst:1640 msgid ":kbd:`Insert`" msgstr ":kbd:`Insert`" -#: ../../library/curses.rst:1638 +#: ../../library/curses.rst:1640 msgid "KEY_IC" msgstr "KEY_IC" -#: ../../library/curses.rst:1640 +#: ../../library/curses.rst:1642 msgid ":kbd:`Delete`" msgstr ":kbd:`Delete`" -#: ../../library/curses.rst:1640 +#: ../../library/curses.rst:1642 msgid "KEY_DC" msgstr "KEY_DC" -#: ../../library/curses.rst:1642 +#: ../../library/curses.rst:1644 msgid ":kbd:`Home`" msgstr ":kbd:`Home`" -#: ../../library/curses.rst:1642 +#: ../../library/curses.rst:1644 msgid "KEY_HOME" msgstr "KEY_HOME" -#: ../../library/curses.rst:1644 +#: ../../library/curses.rst:1646 msgid ":kbd:`End`" msgstr ":kbd:`End`" -#: ../../library/curses.rst:1644 +#: ../../library/curses.rst:1646 msgid "KEY_END" msgstr "KEY_END" -#: ../../library/curses.rst:1646 +#: ../../library/curses.rst:1648 msgid ":kbd:`Page Up`" msgstr ":kbd:`Page Up`" -#: ../../library/curses.rst:1646 +#: ../../library/curses.rst:1648 msgid "KEY_PPAGE" msgstr "KEY_PPAGE" -#: ../../library/curses.rst:1648 +#: ../../library/curses.rst:1650 msgid ":kbd:`Page Down`" msgstr ":kbd:`Page Down`" -#: ../../library/curses.rst:1648 +#: ../../library/curses.rst:1650 msgid "KEY_NPAGE" msgstr "KEY_NPAGE" -#: ../../library/curses.rst:1653 +#: ../../library/curses.rst:1655 msgid "" "The following table lists characters from the alternate character set. These " "are inherited from the VT100 terminal, and will generally be available on " @@ -2088,268 +2100,268 @@ msgid "" "available, curses falls back on a crude printable ASCII approximation." msgstr "" -#: ../../library/curses.rst:1660 +#: ../../library/curses.rst:1662 msgid "These are available only after :func:`initscr` has been called." msgstr "" -#: ../../library/curses.rst:1663 +#: ../../library/curses.rst:1665 msgid "ACS code" msgstr "" -#: ../../library/curses.rst:1665 +#: ../../library/curses.rst:1667 msgid "alternate name for upper right corner" msgstr "" -#: ../../library/curses.rst:1667 +#: ../../library/curses.rst:1669 msgid "solid square block" msgstr "" -#: ../../library/curses.rst:1669 +#: ../../library/curses.rst:1671 msgid "board of squares" msgstr "" -#: ../../library/curses.rst:1671 +#: ../../library/curses.rst:1673 msgid "alternate name for horizontal line" msgstr "" -#: ../../library/curses.rst:1673 +#: ../../library/curses.rst:1675 msgid "alternate name for upper left corner" msgstr "" -#: ../../library/curses.rst:1675 +#: ../../library/curses.rst:1677 msgid "alternate name for top tee" msgstr "" -#: ../../library/curses.rst:1677 +#: ../../library/curses.rst:1679 msgid "bottom tee" msgstr "" -#: ../../library/curses.rst:1679 +#: ../../library/curses.rst:1681 msgid "bullet" msgstr "" -#: ../../library/curses.rst:1681 +#: ../../library/curses.rst:1683 msgid "checker board (stipple)" msgstr "" -#: ../../library/curses.rst:1683 +#: ../../library/curses.rst:1685 msgid "arrow pointing down" msgstr "" -#: ../../library/curses.rst:1685 +#: ../../library/curses.rst:1687 msgid "degree symbol" msgstr "" -#: ../../library/curses.rst:1687 +#: ../../library/curses.rst:1689 msgid "diamond" msgstr "" -#: ../../library/curses.rst:1689 +#: ../../library/curses.rst:1691 msgid "greater-than-or-equal-to" msgstr "" -#: ../../library/curses.rst:1691 +#: ../../library/curses.rst:1693 msgid "horizontal line" msgstr "" -#: ../../library/curses.rst:1693 +#: ../../library/curses.rst:1695 msgid "lantern symbol" msgstr "" -#: ../../library/curses.rst:1695 +#: ../../library/curses.rst:1697 msgid "left arrow" msgstr "" -#: ../../library/curses.rst:1697 +#: ../../library/curses.rst:1699 msgid "less-than-or-equal-to" msgstr "" -#: ../../library/curses.rst:1699 +#: ../../library/curses.rst:1701 msgid "lower left-hand corner" msgstr "" -#: ../../library/curses.rst:1701 +#: ../../library/curses.rst:1703 msgid "lower right-hand corner" msgstr "" -#: ../../library/curses.rst:1703 +#: ../../library/curses.rst:1705 msgid "left tee" msgstr "" -#: ../../library/curses.rst:1705 +#: ../../library/curses.rst:1707 msgid "not-equal sign" msgstr "" -#: ../../library/curses.rst:1707 +#: ../../library/curses.rst:1709 msgid "letter pi" msgstr "" -#: ../../library/curses.rst:1709 +#: ../../library/curses.rst:1711 msgid "plus-or-minus sign" msgstr "" -#: ../../library/curses.rst:1711 +#: ../../library/curses.rst:1713 msgid "big plus sign" msgstr "" -#: ../../library/curses.rst:1713 +#: ../../library/curses.rst:1715 msgid "right arrow" msgstr "" -#: ../../library/curses.rst:1715 +#: ../../library/curses.rst:1717 msgid "right tee" msgstr "" -#: ../../library/curses.rst:1717 +#: ../../library/curses.rst:1719 msgid "scan line 1" msgstr "" -#: ../../library/curses.rst:1719 +#: ../../library/curses.rst:1721 msgid "scan line 3" msgstr "" -#: ../../library/curses.rst:1721 +#: ../../library/curses.rst:1723 msgid "scan line 7" msgstr "" -#: ../../library/curses.rst:1723 +#: ../../library/curses.rst:1725 msgid "scan line 9" msgstr "" -#: ../../library/curses.rst:1725 +#: ../../library/curses.rst:1727 msgid "alternate name for lower right corner" msgstr "" -#: ../../library/curses.rst:1727 +#: ../../library/curses.rst:1729 msgid "alternate name for vertical line" msgstr "" -#: ../../library/curses.rst:1729 +#: ../../library/curses.rst:1731 msgid "alternate name for right tee" msgstr "" -#: ../../library/curses.rst:1731 +#: ../../library/curses.rst:1733 msgid "alternate name for lower left corner" msgstr "" -#: ../../library/curses.rst:1733 +#: ../../library/curses.rst:1735 msgid "alternate name for bottom tee" msgstr "" -#: ../../library/curses.rst:1735 +#: ../../library/curses.rst:1737 msgid "alternate name for left tee" msgstr "" -#: ../../library/curses.rst:1737 +#: ../../library/curses.rst:1739 msgid "alternate name for crossover or big plus" msgstr "" -#: ../../library/curses.rst:1739 +#: ../../library/curses.rst:1741 msgid "pound sterling" msgstr "" -#: ../../library/curses.rst:1741 +#: ../../library/curses.rst:1743 msgid "top tee" msgstr "" -#: ../../library/curses.rst:1743 +#: ../../library/curses.rst:1745 msgid "up arrow" msgstr "" -#: ../../library/curses.rst:1745 +#: ../../library/curses.rst:1747 msgid "upper left corner" msgstr "" -#: ../../library/curses.rst:1747 +#: ../../library/curses.rst:1749 msgid "upper right corner" msgstr "" -#: ../../library/curses.rst:1749 +#: ../../library/curses.rst:1751 msgid "vertical line" msgstr "" -#: ../../library/curses.rst:1752 +#: ../../library/curses.rst:1754 msgid "" "The following table lists mouse button constants used by :meth:`getmouse`:" msgstr "" -#: ../../library/curses.rst:1755 +#: ../../library/curses.rst:1757 msgid "Mouse button constant" msgstr "" -#: ../../library/curses.rst:1757 +#: ../../library/curses.rst:1759 msgid "Mouse button *n* pressed" msgstr "" -#: ../../library/curses.rst:1759 +#: ../../library/curses.rst:1761 msgid "Mouse button *n* released" msgstr "" -#: ../../library/curses.rst:1761 +#: ../../library/curses.rst:1763 msgid "Mouse button *n* clicked" msgstr "" -#: ../../library/curses.rst:1763 +#: ../../library/curses.rst:1765 msgid "Mouse button *n* double clicked" msgstr "" -#: ../../library/curses.rst:1765 +#: ../../library/curses.rst:1767 msgid "Mouse button *n* triple clicked" msgstr "" -#: ../../library/curses.rst:1767 +#: ../../library/curses.rst:1769 msgid "Shift was down during button state change" msgstr "" -#: ../../library/curses.rst:1769 ../../library/curses.rst:1771 +#: ../../library/curses.rst:1771 ../../library/curses.rst:1773 msgid "Control was down during button state change" msgstr "" -#: ../../library/curses.rst:1778 +#: ../../library/curses.rst:1780 msgid "The following table lists the predefined colors:" msgstr "" -#: ../../library/curses.rst:1781 +#: ../../library/curses.rst:1783 msgid "Color" msgstr "顏色" -#: ../../library/curses.rst:1783 +#: ../../library/curses.rst:1785 msgid "Black" msgstr "黑" -#: ../../library/curses.rst:1785 +#: ../../library/curses.rst:1787 msgid "Blue" msgstr "藍" -#: ../../library/curses.rst:1787 +#: ../../library/curses.rst:1789 msgid "Cyan (light greenish blue)" msgstr "" -#: ../../library/curses.rst:1789 +#: ../../library/curses.rst:1791 msgid "Green" msgstr "綠" -#: ../../library/curses.rst:1791 +#: ../../library/curses.rst:1793 msgid "Magenta (purplish red)" msgstr "" -#: ../../library/curses.rst:1793 +#: ../../library/curses.rst:1795 msgid "Red" msgstr "紅" -#: ../../library/curses.rst:1795 +#: ../../library/curses.rst:1797 msgid "White" msgstr "白" -#: ../../library/curses.rst:1797 +#: ../../library/curses.rst:1799 msgid "Yellow" msgstr "" -#: ../../library/curses.rst:1802 +#: ../../library/curses.rst:1804 msgid ":mod:`curses.textpad` --- Text input widget for curses programs" msgstr "" -#: ../../library/curses.rst:1810 +#: ../../library/curses.rst:1812 msgid "" "The :mod:`curses.textpad` module provides a :class:`Textbox` class that " "handles elementary text editing in a curses window, supporting a set of " @@ -2359,11 +2371,11 @@ msgid "" "purposes." msgstr "" -#: ../../library/curses.rst:1816 +#: ../../library/curses.rst:1818 msgid "The module :mod:`curses.textpad` defines the following function:" -msgstr "" +msgstr ":mod:`curses.textpad` 模組定義了以下函式:" -#: ../../library/curses.rst:1821 +#: ../../library/curses.rst:1823 msgid "" "Draw a rectangle. The first argument must be a window object; the remaining " "arguments are coordinates relative to that window. The second and third " @@ -2375,15 +2387,15 @@ msgid "" "will be drawn with ASCII dashes, vertical bars, and plus signs." msgstr "" -#: ../../library/curses.rst:1834 +#: ../../library/curses.rst:1836 msgid "Textbox objects" msgstr "" -#: ../../library/curses.rst:1836 +#: ../../library/curses.rst:1838 msgid "You can instantiate a :class:`Textbox` object as follows:" msgstr "" -#: ../../library/curses.rst:1841 +#: ../../library/curses.rst:1843 msgid "" "Return a textbox widget object. The *win* argument should be a curses :ref:" "`window ` object in which the textbox is to be " @@ -2392,11 +2404,11 @@ msgid "" "instance's :attr:`stripspaces` flag is initially on." msgstr "" -#: ../../library/curses.rst:1847 +#: ../../library/curses.rst:1849 msgid ":class:`Textbox` objects have the following methods:" msgstr "" -#: ../../library/curses.rst:1852 +#: ../../library/curses.rst:1854 msgid "" "This is the entry point you will normally use. It accepts editing " "keystrokes until one of the termination keystrokes is entered. If " @@ -2407,167 +2419,167 @@ msgid "" "`stripspaces` attribute." msgstr "" -#: ../../library/curses.rst:1863 +#: ../../library/curses.rst:1865 msgid "" "Process a single command keystroke. Here are the supported special " "keystrokes:" msgstr "" -#: ../../library/curses.rst:1867 ../../library/curses.rst:1905 +#: ../../library/curses.rst:1869 ../../library/curses.rst:1907 msgid "Keystroke" msgstr "" -#: ../../library/curses.rst:1867 +#: ../../library/curses.rst:1869 msgid "Action" msgstr "" -#: ../../library/curses.rst:1869 +#: ../../library/curses.rst:1871 msgid ":kbd:`Control-A`" msgstr ":kbd:`Control-A`" -#: ../../library/curses.rst:1869 +#: ../../library/curses.rst:1871 msgid "Go to left edge of window." msgstr "" -#: ../../library/curses.rst:1871 ../../library/curses.rst:1907 +#: ../../library/curses.rst:1873 ../../library/curses.rst:1909 msgid ":kbd:`Control-B`" msgstr ":kbd:`Control-B`" -#: ../../library/curses.rst:1871 +#: ../../library/curses.rst:1873 msgid "Cursor left, wrapping to previous line if appropriate." msgstr "" -#: ../../library/curses.rst:1874 +#: ../../library/curses.rst:1876 msgid ":kbd:`Control-D`" msgstr ":kbd:`Control-D`" -#: ../../library/curses.rst:1874 +#: ../../library/curses.rst:1876 msgid "Delete character under cursor." msgstr "" -#: ../../library/curses.rst:1876 +#: ../../library/curses.rst:1878 msgid ":kbd:`Control-E`" msgstr ":kbd:`Control-E`" -#: ../../library/curses.rst:1876 +#: ../../library/curses.rst:1878 msgid "Go to right edge (stripspaces off) or end of line (stripspaces on)." msgstr "" -#: ../../library/curses.rst:1879 ../../library/curses.rst:1909 +#: ../../library/curses.rst:1881 ../../library/curses.rst:1911 msgid ":kbd:`Control-F`" msgstr ":kbd:`Control-F`" -#: ../../library/curses.rst:1879 +#: ../../library/curses.rst:1881 msgid "Cursor right, wrapping to next line when appropriate." msgstr "" -#: ../../library/curses.rst:1882 +#: ../../library/curses.rst:1884 msgid ":kbd:`Control-G`" msgstr ":kbd:`Control-G`" -#: ../../library/curses.rst:1882 +#: ../../library/curses.rst:1884 msgid "Terminate, returning the window contents." msgstr "" -#: ../../library/curses.rst:1884 +#: ../../library/curses.rst:1886 msgid ":kbd:`Control-H`" msgstr ":kbd:`Control-H`" -#: ../../library/curses.rst:1884 +#: ../../library/curses.rst:1886 msgid "Delete character backward." msgstr "" -#: ../../library/curses.rst:1886 +#: ../../library/curses.rst:1888 msgid ":kbd:`Control-J`" msgstr ":kbd:`Control-J`" -#: ../../library/curses.rst:1886 +#: ../../library/curses.rst:1888 msgid "Terminate if the window is 1 line, otherwise insert newline." msgstr "" -#: ../../library/curses.rst:1889 +#: ../../library/curses.rst:1891 msgid ":kbd:`Control-K`" msgstr ":kbd:`Control-K`" -#: ../../library/curses.rst:1889 +#: ../../library/curses.rst:1891 msgid "If line is blank, delete it, otherwise clear to end of line." msgstr "" -#: ../../library/curses.rst:1892 +#: ../../library/curses.rst:1894 msgid ":kbd:`Control-L`" msgstr ":kbd:`Control-L`" -#: ../../library/curses.rst:1892 +#: ../../library/curses.rst:1894 msgid "Refresh screen." msgstr "" -#: ../../library/curses.rst:1894 ../../library/curses.rst:1913 +#: ../../library/curses.rst:1896 ../../library/curses.rst:1915 msgid ":kbd:`Control-N`" msgstr ":kbd:`Control-N`" -#: ../../library/curses.rst:1894 +#: ../../library/curses.rst:1896 msgid "Cursor down; move down one line." msgstr "" -#: ../../library/curses.rst:1896 +#: ../../library/curses.rst:1898 msgid ":kbd:`Control-O`" msgstr ":kbd:`Control-O`" -#: ../../library/curses.rst:1896 +#: ../../library/curses.rst:1898 msgid "Insert a blank line at cursor location." msgstr "" -#: ../../library/curses.rst:1898 ../../library/curses.rst:1911 +#: ../../library/curses.rst:1900 ../../library/curses.rst:1913 msgid ":kbd:`Control-P`" msgstr ":kbd:`Control-P`" -#: ../../library/curses.rst:1898 +#: ../../library/curses.rst:1900 msgid "Cursor up; move up one line." msgstr "" -#: ../../library/curses.rst:1901 +#: ../../library/curses.rst:1903 msgid "" "Move operations do nothing if the cursor is at an edge where the movement is " "not possible. The following synonyms are supported where possible:" msgstr "" -#: ../../library/curses.rst:1907 +#: ../../library/curses.rst:1909 msgid ":const:`~curses.KEY_LEFT`" msgstr ":const:`~curses.KEY_LEFT`" -#: ../../library/curses.rst:1909 +#: ../../library/curses.rst:1911 msgid ":const:`~curses.KEY_RIGHT`" msgstr ":const:`~curses.KEY_RIGHT`" -#: ../../library/curses.rst:1911 +#: ../../library/curses.rst:1913 msgid ":const:`~curses.KEY_UP`" msgstr ":const:`~curses.KEY_UP`" -#: ../../library/curses.rst:1913 +#: ../../library/curses.rst:1915 msgid ":const:`~curses.KEY_DOWN`" msgstr ":const:`~curses.KEY_DOWN`" -#: ../../library/curses.rst:1915 +#: ../../library/curses.rst:1917 msgid ":const:`~curses.KEY_BACKSPACE`" msgstr ":const:`~curses.KEY_BACKSPACE`" -#: ../../library/curses.rst:1915 +#: ../../library/curses.rst:1917 msgid ":kbd:`Control-h`" msgstr ":kbd:`Control-h`" -#: ../../library/curses.rst:1918 +#: ../../library/curses.rst:1920 msgid "" "All other keystrokes are treated as a command to insert the given character " "and move right (with line wrapping)." msgstr "" -#: ../../library/curses.rst:1924 +#: ../../library/curses.rst:1926 msgid "" "Return the window contents as a string; whether blanks in the window are " "included is affected by the :attr:`stripspaces` member." msgstr "" -#: ../../library/curses.rst:1930 +#: ../../library/curses.rst:1932 msgid "" "This attribute is a flag which controls the interpretation of blanks in the " "window. When it is on, trailing blanks on each line are ignored; any cursor " diff --git a/library/custominterp.po b/library/custominterp.po index c3d74e02e4..ddfef2e275 100644 --- a/library/custominterp.po +++ b/library/custominterp.po @@ -3,12 +3,13 @@ # This file is distributed under the same license as the Python package. # # Translators: +# Weilin Du, 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2022-07-06 00:17+0000\n" -"PO-Revision-Date: 2015-12-09 17:51+0000\n" +"PO-Revision-Date: 2025-06-28 10:57+0800\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -30,6 +31,9 @@ msgid "" "look at the :mod:`code` module. (The :mod:`codeop` module is lower-level, " "used to support compiling a possibly incomplete chunk of Python code.)" msgstr "" +"本章介紹的模組可用於編寫類似於 Python 交互式直譯器的介面。如果你需要一個在 " +"Python 語言基礎上支援某些特殊功能的直譯器,可以參考 :mod:`code` 模組。(" +" :mod:`codeop` 模組屬於底層工具,用於支援編譯可能不完整的 Python 程式碼。)" #: ../../library/custominterp.rst:13 msgid "The full list of modules described in this chapter is:" diff --git a/library/dataclasses.po b/library/dataclasses.po index 3cfb596bad..b1863227bc 100644 --- a/library/dataclasses.po +++ b/library/dataclasses.po @@ -2,9 +2,9 @@ # This file is distributed under the same license as the Python package. msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2023-02-11 15:02+0800\n" "Last-Translator: \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -33,7 +33,7 @@ msgid "" msgstr "" "該模組提供了一個裝飾器和函式,用於自動新增生成的\\ :term:`特殊方法 `,例如 :meth:`~object.__init__` 和 :meth:`~object.__repr__` 到使用者" -"定義的類。它最初在 :pep:`557` 中描述。" +"定義的類別。它最初在 :pep:`557` 中描述。" #: ../../library/dataclasses.rst:19 #, fuzzy @@ -79,8 +79,8 @@ msgid "" "Note that this method is automatically added to the class: it is not " "directly specified in the :class:`!InventoryItem` definition shown above." msgstr "" -"請注意,此方法會自動新增到類中:它不會在上面顯示的“InventoryItem”定義中直接指" -"定。" +"請注意,此方法會自動新增到類別中:它不會在上面顯示的 :class:`!InventoryItem` " +"定義中直接指定。" #: ../../library/dataclasses.rst:47 msgid "Module contents" @@ -103,8 +103,8 @@ msgid "" "`. With two exceptions described below, nothing in " "``@dataclass`` examines the type specified in the variable annotation." msgstr "" -"``@dataclass`` 裝飾器檢查類以找到 ``field``\\s。 ``field`` 被定義為具有 :" -"term:`type annotation ` 的類變數。除了下面描述的兩個例" +"``@dataclass`` 裝飾器檢查類別以找到 ``field``\\s。 ``field`` 被定義為具有 :" +"term:`type annotation ` 的類別變數。除了下面描述的兩個例" "外,``@dataclass`` 中沒有任何內容檢查變數註釋中指定的型別。" #: ../../library/dataclasses.rst:60 @@ -112,10 +112,9 @@ msgstr "" msgid "" "The order of the fields in all of the generated methods is the order in " "which they appear in the class definition." -msgstr "所有生成的方法中欄位的順序是它們在類定義中出現的順序。" +msgstr "所有生成的方法中欄位的順序是它們在類別定義中出現的順序。" #: ../../library/dataclasses.rst:63 -#, fuzzy msgid "" "The ``@dataclass`` decorator will add various \"dunder\" methods to the " "class, described below. If any of the added methods already exist in the " @@ -123,9 +122,9 @@ msgid "" "decorator returns the same class that it is called on; no new class is " "created." msgstr "" -"``@dataclass`` 裝飾器將向類新增各種“dunder”方法,如下所述。如果類中已存在任何" -"新增的方法,則行為取決於參數,如下所述。裝飾器回傳呼叫它的同一個類;沒有建立" -"新類。" +"如下所述,``@dataclass`` 裝飾器會向類別新增各種 \"dunder\" 方法。如果類別中已" +"存在任何新增的方法,則行為會取決於參數,如下方文件所述。裝飾器會回傳呼叫它的" +"同一個類別;不會建立新類別。" #: ../../library/dataclasses.rst:69 #, fuzzy @@ -153,6 +152,19 @@ msgid "" "class C:\n" " ..." msgstr "" +"@dataclass\n" +"class C:\n" +" ...\n" +"\n" +"@dataclass()\n" +"class C:\n" +" ...\n" +"\n" +"@dataclass(init=True, repr=True, eq=True, order=False, unsafe_hash=False, " +"frozen=False,\n" +" match_args=True, kw_only=False, slots=False, weakref_slot=False)\n" +"class C:\n" +" ..." #: ../../library/dataclasses.rst:87 msgid "The parameters to ``@dataclass`` are:" @@ -169,7 +181,7 @@ msgstr "*init*:如果為真(預設值),將生成一個 :meth:`~object.__ #, fuzzy msgid "" "If the class already defines :meth:`!__init__`, this parameter is ignored." -msgstr "如果該類已經定義了 :meth:`!__init__`,則忽略此參數。" +msgstr "如果該類別已經定義了 :meth:`!__init__`,則忽略此參數。" #: ../../library/dataclasses.rst:95 #, fuzzy @@ -182,15 +194,14 @@ msgid "" "quantity_on_hand=10)``." msgstr "" "*repr*:如果為真(預設值),將生成一個 :meth:`__repr__` 方法。生成的 repr 字" -"串將包含類名以及每個欄位的名稱和 repr,按照它們在類中定義的順序排列。不包括標" -"記為從 repr 中排除的欄位。例如:``InventoryItem(name='widget', " +"串將包含類別名稱以及每個欄位的名稱和 repr,按照它們在類別中定義的順序排列。不" +"包括標記為從 repr 中排除的欄位。例如:``InventoryItem(name='widget', " "unit_price=3.0, quantity_on_hand=10)``。" #: ../../library/dataclasses.rst:102 -#, fuzzy msgid "" "If the class already defines :meth:`!__repr__`, this parameter is ignored." -msgstr "如果該類已經定義了 :meth:`!__repr__`,則忽略此參數。" +msgstr "如果該類別已經定義了 :meth:`!__repr__`,則此參數會被忽略。" #: ../../library/dataclasses.rst:105 #, fuzzy @@ -201,13 +212,12 @@ msgid "" "type." msgstr "" "*eq*:如果為真(預設值),將生成一個 :meth:`~object.__eq__` 方法。此方法按順" -"序比較類,就好像它是其欄位的元組一樣。比較中的兩個實例必須屬於同一型別。" +"序比較類別,就好像它是其欄位的元組一樣。比較中的兩個實例必須屬於同一型別。" #: ../../library/dataclasses.rst:110 -#, fuzzy msgid "" "If the class already defines :meth:`!__eq__`, this parameter is ignored." -msgstr "如果該類已經定義了 :meth:`!__eq__`,則忽略此參數。" +msgstr "如果該類別已經定義了 :meth:`!__eq__`,則此參數會被忽略。" #: ../../library/dataclasses.rst:113 #, fuzzy @@ -220,28 +230,29 @@ msgid "" msgstr "" "*order*:如果為真(預設為 ``False``),:meth:`~object.__lt__`、:meth:" "`~object.__le__`、:meth:`~object.__gt__` 和 :meth:`~object.__ge__` 方法將是產" -"生。它們按順序比較類,就好像它是其欄位的元組一樣。比較中的兩個實例必須屬於同" -"一型別。如果 *order* 為真且 *eq* 為假,則會引發 :exc:`ValueError`。" +"生。它們按順序比較類別,就好像它是其欄位的元組一樣。比較中的兩個實例必須屬於" +"同一型別。如果 *order* 為真且 *eq* 為假,則會引發 :exc:`ValueError`。" #: ../../library/dataclasses.rst:120 -#, fuzzy msgid "" "If the class already defines any of :meth:`!__lt__`, :meth:`!__le__`, :meth:" "`!__gt__`, or :meth:`!__ge__`, then :exc:`TypeError` is raised." msgstr "" -"如果該類已經定義了 :meth:`!__lt__`、:meth:`!__le__`、:meth:`!__gt__` 或 :" +"如果該類別已經定義了 :meth:`!__lt__`、:meth:`!__le__`、:meth:`!__gt__` 或 :" "meth:`!__ge__` 中的任何一個,則引發 :exc:`TypeError`。" #: ../../library/dataclasses.rst:124 #, fuzzy msgid "" -"*unsafe_hash*: If ``False`` (the default), a :meth:`~object.__hash__` method " -"is generated according to how *eq* and *frozen* are set." +"*unsafe_hash*: If true, force ``dataclasses`` to create a :meth:`~object." +"__hash__` method, even though it may not be safe to do so. Otherwise, " +"generate a :meth:`~object.__hash__` method according to how *eq* and " +"*frozen* are set. The default value is ``False``." msgstr "" "*unsafe_hash*:如果 ``False``(預設值),將根據 *eq* 和 *frozen* 的設定生成一" "個 :meth:`~object.__hash__` 方法。" -#: ../../library/dataclasses.rst:127 +#: ../../library/dataclasses.rst:130 #, fuzzy msgid "" ":meth:`!__hash__` is used by built-in :meth:`hash`, and when objects are " @@ -252,11 +263,11 @@ msgid "" "flags in the ``@dataclass`` decorator." msgstr "" ":meth:`!__hash__` 由內建的 :meth:`hash` 使用,當對像被新增到散列集合(如字典" -"和集合)時。擁有 :meth:`!__hash__` 意味著該類的實例是不可變的。可變性是一個複" -"雜的屬性,它取決於程序員的意圖 :meth:`!__eq__` 的存在和行為,以及 dataclass " -"裝飾器中的 *eq* 和 *frozen* 旗標的值." +"和集合)時。擁有 :meth:`!__hash__` 意味著該類別的實例是不可變的。可變性是一個" +"複雜的屬性,它取決於程序員的意圖 :meth:`!__eq__` 的存在和行為,以及 " +"dataclass 裝飾器中的 *eq* 和 *frozen* 旗標的值." -#: ../../library/dataclasses.rst:134 +#: ../../library/dataclasses.rst:137 #, fuzzy msgid "" "By default, ``@dataclass`` will not implicitly add a :meth:`~object." @@ -267,10 +278,10 @@ msgid "" msgstr "" "預設情況下,``@dataclass`` 不會隱式新增 :meth:`~object.__hash__` 方法,除非這" "樣做是安全的。它也不會新增或更改現有的明確定義的 :meth:`!__hash__` 方法。設定" -"類屬性 ``__hash__ = None`` 對 Python 具有特定含義,如 :meth:`!__hash__` 文檔" -"中所述。" +"類別屬性 ``__hash__ = None`` 對 Python 具有特定含義,如 :meth:`!__hash__` 文" +"件中所述。" -#: ../../library/dataclasses.rst:140 +#: ../../library/dataclasses.rst:143 #, fuzzy msgid "" "If :meth:`!__hash__` is not explicitly defined, or if it is set to ``None``, " @@ -283,10 +294,10 @@ msgstr "" "如果 :meth:`!__hash__` 沒有明確定義,或者如果它被設定為 ``None``,那麼 " "``@dataclass`` *可能* 新增一個隱式的 :meth:`!__hash__` 方法。雖然不推薦,但你" "可以強制 ``@dataclass`` 使用 ``unsafe_hash=True`` 建立一個 :meth:`!__hash__` " -"方法。如果你的類在邏輯上是不可變的但仍然可以改變,則可能是這種情況。這是一個" -"特殊的用例,應該仔細考慮。" +"方法。如果你的類別在邏輯上是不可變的但仍然可以改變,則可能是這種情況。這是一" +"個特殊的用例,應該仔細考慮。" -#: ../../library/dataclasses.rst:147 +#: ../../library/dataclasses.rst:150 #, fuzzy msgid "" "Here are the rules governing implicit creation of a :meth:`!__hash__` " @@ -298,7 +309,7 @@ msgstr "" "有顯式的 :meth:`!__hash__` 方法又設定 ``unsafe_hash=True``;這將導致 :exc:" "`TypeError`。" -#: ../../library/dataclasses.rst:152 +#: ../../library/dataclasses.rst:155 #, fuzzy msgid "" "If *eq* and *frozen* are both true, by default ``@dataclass`` will generate " @@ -312,11 +323,11 @@ msgstr "" "如果 *eq* 和 *frozen* 都為真,預設情況下 ``@dataclass`` 會為你生成一個:meth:" "`!__hash__` 方法。如果 ``eq`` 為真且 ``frozen`` 為假,:meth:`!__hash__` 將被" "設定為 ``None``,將其標記為不可散列(它是不可散列的,因為它是可變的)。如果 " -"``eq`` 為假,:meth:`!__hash__` 將保持不變,這意味著將使用超類的 :meth:`!" -"__hash__` 方法(如果超類是 :class:`object`,這意味著它將回退到基於 id 的散" +"``eq`` 為假,:meth:`!__hash__` 將保持不變,這意味著將使用超類別的 :meth:`!" +"__hash__` 方法(如果超類別是 :class:`object`,這意味著它將回退到基於 id 的散" "列)。" -#: ../../library/dataclasses.rst:160 +#: ../../library/dataclasses.rst:163 #, fuzzy msgid "" "*frozen*: If true (the default is ``False``), assigning to fields will " @@ -326,32 +337,32 @@ msgid "" msgstr "" "*frozen*:如果為真(預設為 ``False``),分配給欄位將產生例外。這模擬了只讀的" "凍結實例。如果 :meth:`~object.__setattr__` 或 :meth:`~object.__delattr__` 在" -"類中定義,則 :exc:`TypeError` 被引發。請參閱下面的討論。" +"類別中定義,則 :exc:`TypeError` 被引發。請參閱下面的討論。" -#: ../../library/dataclasses.rst:165 +#: ../../library/dataclasses.rst:168 #, fuzzy msgid "" "*match_args*: If true (the default is ``True``), the :attr:`~object." -"__match_args__` tuple will be created from the list of parameters to the " -"generated :meth:`~object.__init__` method (even if :meth:`!__init__` is not " -"generated, see above). If false, or if :attr:`!__match_args__` is already " -"defined in the class, then :attr:`!__match_args__` will not be generated." +"__match_args__` tuple will be created from the list of non keyword-only " +"parameters to the generated :meth:`~object.__init__` method (even if :meth:`!" +"__init__` is not generated, see above). If false, or if :attr:`!" +"__match_args__` is already defined in the class, then :attr:`!" +"__match_args__` will not be generated." msgstr "" "*match_args*:如果為真(預設為 ``True``),``__match_args__`` 元組將從參數列" "表建立到生成的 :meth:`~object.__init__` 方法(即使 :meth: `!__init__` 未生" -"成,見上文)。如果為 false,或者類中已經定義了 :attr:`!__match_args__`,則不" -"會生成 :attr:`!__match_args__`。" +"成,見上文)。如果為 false,或者類別中已經定義了 :attr:`!__match_args__`,則" +"不會生成 :attr:`!__match_args__`。" -#: ../../library/dataclasses.rst:174 +#: ../../library/dataclasses.rst:177 #, fuzzy msgid "" "*kw_only*: If true (the default value is ``False``), then all fields will be " "marked as keyword-only. If a field is marked as keyword-only, then the only " "effect is that the :meth:`~object.__init__` parameter generated from a " "keyword-only field must be specified with a keyword when :meth:`!__init__` " -"is called. There is no effect on any other aspect of dataclasses. See the :" -"term:`parameter` glossary entry for details. Also see the :const:`KW_ONLY` " -"section." +"is called. See the :term:`parameter` glossary entry for details. Also see " +"the :const:`KW_ONLY` section." msgstr "" "``kw_only``:如果為 true(預設值為 ``False``),則所有欄位將被標記為僅限關鍵" "字。如果一個欄位被標記為僅限關鍵字,那麼唯一的影響是從僅限關鍵字欄位生成的 :" @@ -360,6 +371,10 @@ msgstr "" "目。另請參閱 :const:`KW_ONLY` 部分。" #: ../../library/dataclasses.rst:185 +msgid "Keyword-only fields are not included in :attr:`!__match_args__`." +msgstr "" + +#: ../../library/dataclasses.rst:189 #, fuzzy msgid "" "*slots*: If true (the default is ``False``), :attr:`~object.__slots__` " @@ -368,10 +383,10 @@ msgid "" "exc:`TypeError` is raised." msgstr "" "``slots``:如果為 true(預設為 ``False``),將生成 :attr:`~object.__slots__` " -"屬性並回傳新類而不是原始類。如果 :attr:`!__slots__` 已經在類中定義,則 :exc:" -"`TypeError` 被引發。" +"屬性並回傳新類別而不是原始類別。如果 :attr:`!__slots__` 已經在類別中定義," +"則 :exc:`TypeError` 被引發。" -#: ../../library/dataclasses.rst:191 +#: ../../library/dataclasses.rst:195 #, fuzzy msgid "" "Calling no-arg :func:`super` in dataclasses using ``slots=True`` will result " @@ -380,10 +395,10 @@ msgid "" "valid workaround. See :gh:`90562` for full details." msgstr "" "``slots``:如果為 true(預設為 ``False``),將生成 :attr:`~object.__slots__` " -"屬性並回傳新類而不是原始類。如果 :attr:`!__slots__` 已經在類中定義,則 :exc:" -"`TypeError` 被引發。" +"屬性並回傳新類別而不是原始類別。如果 :attr:`!__slots__` 已經在類別中定義," +"則 :exc:`TypeError` 被引發。" -#: ../../library/dataclasses.rst:198 +#: ../../library/dataclasses.rst:202 msgid "" "Passing parameters to a base class :meth:`~object.__init_subclass__` when " "using ``slots=True`` will result in a :exc:`TypeError`. Either use " @@ -391,7 +406,7 @@ msgid "" "workaround. See :gh:`91126` for full details." msgstr "" -#: ../../library/dataclasses.rst:206 +#: ../../library/dataclasses.rst:210 #, fuzzy msgid "" "If a field name is already included in the :attr:`!__slots__` of a base " @@ -407,7 +422,7 @@ msgstr "" "夠確定繼承的插槽,基底類別 :attr:`!__slots__` 可以是任何可疊代的,但*不是*疊" "代器。" -#: ../../library/dataclasses.rst:216 +#: ../../library/dataclasses.rst:220 #, fuzzy msgid "" "*weakref_slot*: If true (the default is ``False``), add a slot named " @@ -419,14 +434,14 @@ msgstr "" "插槽,這是使實例可弱引用所必需的。在沒有指定 ``slots=True`` 的情況下指定 " "``weakref_slot=True`` 是錯誤的。" -#: ../../library/dataclasses.rst:224 +#: ../../library/dataclasses.rst:228 #, fuzzy msgid "" "``field``\\s may optionally specify a default value, using normal Python " "syntax::" msgstr "``field``\\s 可以選擇指定一個預設值,使用普通的 Python 語法: ::" -#: ../../library/dataclasses.rst:227 +#: ../../library/dataclasses.rst:231 msgid "" "@dataclass\n" "class C:\n" @@ -434,7 +449,7 @@ msgid "" " b: int = 0 # assign a default value for 'b'" msgstr "" -#: ../../library/dataclasses.rst:232 +#: ../../library/dataclasses.rst:236 #, fuzzy msgid "" "In this example, both :attr:`!a` and :attr:`!b` will be included in the " @@ -443,11 +458,11 @@ msgstr "" "在此示例中,:attr:`!a` 和 :attr:`!b` 都將包含在新增的 :meth:`~object." "__init__` 方法中,該方法將定義為: ::" -#: ../../library/dataclasses.rst:235 +#: ../../library/dataclasses.rst:239 msgid "def __init__(self, a: int, b: int = 0):" -msgstr "" +msgstr "def __init__(self, a: int, b: int = 0):" -#: ../../library/dataclasses.rst:237 +#: ../../library/dataclasses.rst:241 #, fuzzy msgid "" ":exc:`TypeError` will be raised if a field without a default value follows a " @@ -455,9 +470,9 @@ msgid "" "class, or as a result of class inheritance." msgstr "" ":exc:`TypeError` 如果沒有預設值的欄位跟在具有預設值的欄位之後,將引發。無論這" -"發生在單個類中還是作為類繼承的結果,都是如此。" +"發生在單個類別中還是作為類別繼承的結果,都是如此。" -#: ../../library/dataclasses.rst:243 +#: ../../library/dataclasses.rst:247 #, fuzzy msgid "" "For common and simple use cases, no other functionality is required. There " @@ -470,7 +485,7 @@ msgstr "" "位資訊。為了滿足這種對附加資訊的需求,你可以通過呼叫提供的 :func:`!field` 函" "式來替換預設欄位值。例如: ::" -#: ../../library/dataclasses.rst:249 +#: ../../library/dataclasses.rst:253 msgid "" "@dataclass\n" "class C:\n" @@ -479,8 +494,14 @@ msgid "" "c = C()\n" "c.mylist += [1, 2, 3]" msgstr "" +"@dataclass\n" +"class C:\n" +" mylist: list[int] = field(default_factory=list)\n" +"\n" +"c = C()\n" +"c.mylist += [1, 2, 3]" -#: ../../library/dataclasses.rst:256 +#: ../../library/dataclasses.rst:260 #, fuzzy msgid "" "As shown above, the :const:`MISSING` value is a sentinel object used to " @@ -489,14 +510,14 @@ msgid "" "meaning. No code should directly use the :const:`MISSING` value." msgstr "" "如上所示,:const:`MISSING` 值是一個哨兵物件,用於檢測某些參數是否由使用者提" -"供。使用此標記是因為“None”對於某些具有不同含義的參數是有效值。任何程式碼都不" -"應直接使用 :const:`MISSING` 值。" +"供。使用此標記是因為 ``None`` 對於某些具有不同含義的參數是有效值。任何程式碼" +"都不應直接使用 :const:`MISSING` 值。" -#: ../../library/dataclasses.rst:261 +#: ../../library/dataclasses.rst:265 msgid "The parameters to :func:`!field` are:" msgstr ":func:`!field` 的參數是:" -#: ../../library/dataclasses.rst:263 +#: ../../library/dataclasses.rst:267 #, fuzzy msgid "" "*default*: If provided, this will be the default value for this field. This " @@ -506,7 +527,7 @@ msgstr "" "*default*:如果提供,這將是該欄位的預設值。這是必需的,因為 :meth:`!field` 呼" "叫本身會替換預設值的正常位置。" -#: ../../library/dataclasses.rst:267 +#: ../../library/dataclasses.rst:271 #, fuzzy msgid "" "*default_factory*: If provided, it must be a zero-argument callable that " @@ -519,7 +540,7 @@ msgstr "" "時將被呼叫。除其他用途外,這可用於指定具有可變預設值的欄位,如下所述。同時指" "定 *default* 和 *default_factory* 是錯誤的。" -#: ../../library/dataclasses.rst:273 +#: ../../library/dataclasses.rst:277 #, fuzzy msgid "" "*init*: If true (the default), this field is included as a parameter to the " @@ -528,7 +549,7 @@ msgstr "" "*init*:如果為 true(預設值),則此欄位將作為生成的 :meth:`~object.__init__` " "方法的參數包含在內。" -#: ../../library/dataclasses.rst:276 +#: ../../library/dataclasses.rst:280 #, fuzzy msgid "" "*repr*: If true (the default), this field is included in the string returned " @@ -537,21 +558,23 @@ msgstr "" "*repr*:如果為真(預設值),則此欄位包含在生成的 :meth:`~object.__repr__` 方" "法回傳的字串中。" -#: ../../library/dataclasses.rst:279 +#: ../../library/dataclasses.rst:283 #, fuzzy msgid "" "*hash*: This can be a bool or ``None``. If true, this field is included in " -"the generated :meth:`~object.__hash__` 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." +"the generated :meth:`~object.__hash__` method. If false, this field is " +"excluded from the generated :meth:`~object.__hash__`. If ``None`` (the " +"default), use the value of *compare*: this would normally be the expected " +"behavior, since a field should be included in the hash if it's used for " +"comparisons. Setting this value to anything other than ``None`` is " +"discouraged." msgstr "" "*hash*:這可以是 bool 或 ``None``。如果為真,則此欄位包含在生成的 :meth:" -"`__hash__` 方法中。如果“無”(預設值),則使用“比較”的值:這通常是預期的行為。" -"如果一個欄位用於比較,則應在雜湊中考慮該欄位。不鼓勵將此值設定為“無”以外的任" -"何值。" +"`__hash__` 方法中。如果 ``None``\\ (預設值),則使用\\ *比較*\\ 的值:這通常" +"是預期的行為。如果一個欄位用於比較,則應在雜湊中考慮該欄位。不鼓勵將此值設定" +"為 ``None`` 以外的任何值。" -#: ../../library/dataclasses.rst:286 +#: ../../library/dataclasses.rst:291 #, fuzzy msgid "" "One possible reason to set ``hash=False`` but ``compare=True`` would be if a " @@ -564,7 +587,7 @@ msgstr "" "湊值的成本很高,則需要該欄位進行相等性測試,並且還有其他欄位有助於型別的雜湊" "值。即使一個欄位被排除在雜湊之外,它仍然會被用於比較。" -#: ../../library/dataclasses.rst:292 +#: ../../library/dataclasses.rst:297 #, fuzzy msgid "" "*compare*: If true (the default), this field is included in the generated " @@ -574,7 +597,7 @@ msgstr "" "*compare*:如果為真(預設值),則此欄位包含在生成的相等和比較方法中(:meth:" "`~object.__eq__`、:meth:`~object.__gt__` 等)。" -#: ../../library/dataclasses.rst:296 +#: ../../library/dataclasses.rst:301 #, fuzzy msgid "" "*metadata*: This can be a mapping or ``None``. ``None`` is treated as an " @@ -584,12 +607,12 @@ msgid "" "mechanism. Multiple third-parties can each have their own key, to use as a " "namespace in the metadata." msgstr "" -"*metadata*:這可以是映射或無。 None 被視為空字典。此值包含在 :func:`~types." +"*metadata*:這可以是對映或無。 None 被視為空字典。此值包含在 :func:`~types." "MappingProxyType` 中以使其成為只讀的,並暴露在 :class:`Field` 對像上。它根本" "不被資料類別使用,而是作為第三方擴充機制提供的。多個第三方可以各自擁有自己的" "密鑰,用作元資料中的命名空間。" -#: ../../library/dataclasses.rst:304 +#: ../../library/dataclasses.rst:309 #, fuzzy msgid "" "*kw_only*: If true, this field will be marked as keyword-only. This is used " @@ -598,7 +621,11 @@ msgstr "" "*kw_only*:如果為真,該欄位將被標記為僅限關鍵字。這在計算生成的 :meth:" "`~object.__init__` 方法的參數時使用。" -#: ../../library/dataclasses.rst:310 +#: ../../library/dataclasses.rst:313 +msgid "Keyword-only fields are also not included in :attr:`!__match_args__`." +msgstr "" + +#: ../../library/dataclasses.rst:317 #, fuzzy msgid "" "If the default value of a field is specified by a call to :func:`!field`, " @@ -614,7 +641,7 @@ msgstr "" "在 :func:`@dataclass ` 裝飾器運行後,類別屬性將全部包含欄位的預設" "值,就像預設值本身已指定一樣。例如,在: ::" -#: ../../library/dataclasses.rst:319 +#: ../../library/dataclasses.rst:326 msgid "" "@dataclass\n" "class C:\n" @@ -623,8 +650,14 @@ msgid "" " z: int = field(repr=False, default=10)\n" " t: int = 20" msgstr "" +"@dataclass\n" +"class C:\n" +" x: int\n" +" y: int = field(repr=False)\n" +" z: int = field(repr=False, default=10)\n" +" t: int = 20" -#: ../../library/dataclasses.rst:326 +#: ../../library/dataclasses.rst:333 #, fuzzy msgid "" "The class attribute :attr:`!C.z` will be ``10``, the class attribute :attr:`!" @@ -634,7 +667,7 @@ msgstr "" "類別屬性 :attr:`!C.z` 將為 ``10``,類別屬性 :attr:`!C.t` 將為 ``20``,類別屬" "性 :attr:`!C.x` 和 :attr:`!C.y` 將不會放。" -#: ../../library/dataclasses.rst:332 +#: ../../library/dataclasses.rst:339 #, fuzzy msgid "" ":class:`!Field` objects describe each defined field. These objects are " @@ -646,15 +679,15 @@ msgstr "" "`fields` 模組級方法回傳(見下文)。使用者不應該直接實例化 :class:`!Field` 物" "件。它記錄的屬性是:" -#: ../../library/dataclasses.rst:337 +#: ../../library/dataclasses.rst:344 msgid ":attr:`!name`: The name of the field." msgstr ":attr:`!name`:欄位的名稱。" -#: ../../library/dataclasses.rst:338 +#: ../../library/dataclasses.rst:345 msgid ":attr:`!type`: The type of the field." msgstr ":attr:`!type`:欄位的型別。" -#: ../../library/dataclasses.rst:339 +#: ../../library/dataclasses.rst:346 #, fuzzy msgid "" ":attr:`!default`, :attr:`!default_factory`, :attr:`!init`, :attr:`!repr`, :" @@ -665,14 +698,23 @@ msgstr "" "attr:`!hash`、:attr:`!compare`, :attr:`!metadata` 和 :attr:`!kw_only` 有與它" "們在 :func:`field` 函式中的含義和值相同。" -#: ../../library/dataclasses.rst:343 +#: ../../library/dataclasses.rst:350 #, fuzzy msgid "" "Other attributes may exist, but they are private and must not be inspected " "or relied on." msgstr "可能存在其他屬性,但它們是私有的,不得檢查或依賴。" -#: ../../library/dataclasses.rst:348 +#: ../../library/dataclasses.rst:355 +msgid "" +"``InitVar[T]`` type annotations describe variables that are :ref:`init-only " +"`. Fields annotated with :class:`!InitVar` " +"are considered pseudo-fields, and thus are neither returned by the :func:" +"`fields` function nor used in any way except adding them as parameters to :" +"meth:`~object.__init__` and an optional :meth:`__post_init__`." +msgstr "" + +#: ../../library/dataclasses.rst:364 #, fuzzy msgid "" "Returns a tuple of :class:`Field` objects that define the fields for this " @@ -684,7 +726,7 @@ msgstr "" "實例。如果未傳遞資料類別或其中一個實例,則引發 :exc:`TypeError`。不回傳 " "``ClassVar`` 或 ``InitVar`` 的偽欄位。" -#: ../../library/dataclasses.rst:355 +#: ../../library/dataclasses.rst:371 #, fuzzy msgid "" "Converts the dataclass *obj* to a dict (by using the factory function " @@ -696,12 +738,12 @@ msgstr "" "都被轉換為其欄位的字典,作為 ``name: value`` 對。資料類別、字典、列表和元組被" "遞迴到。其他物件使用 :func:`copy.deepcopy` 複製。" -#: ../../library/dataclasses.rst:361 +#: ../../library/dataclasses.rst:377 #, fuzzy msgid "Example of using :func:`!asdict` on nested dataclasses::" msgstr "在嵌套資料類別上使用 :func:`!asdict` 的範例: ::" -#: ../../library/dataclasses.rst:363 +#: ../../library/dataclasses.rst:379 msgid "" "@dataclass\n" "class Point:\n" @@ -718,23 +760,37 @@ msgid "" "c = C([Point(0, 0), Point(10, 4)])\n" "assert asdict(c) == {'mylist': [{'x': 0, 'y': 0}, {'x': 10, 'y': 4}]}" msgstr "" +"@dataclass\n" +"class Point:\n" +" x: int\n" +" y: int\n" +"\n" +"@dataclass\n" +"class C:\n" +" mylist: list[Point]\n" +"\n" +"p = Point(10, 20)\n" +"assert asdict(p) == {'x': 10, 'y': 20}\n" +"\n" +"c = C([Point(0, 0), Point(10, 4)])\n" +"assert asdict(c) == {'mylist': [{'x': 0, 'y': 0}, {'x': 10, 'y': 4}]}" -#: ../../library/dataclasses.rst:378 ../../library/dataclasses.rst:398 +#: ../../library/dataclasses.rst:394 ../../library/dataclasses.rst:414 #, fuzzy msgid "To create a shallow copy, the following workaround may be used::" msgstr "要建立淺複製,可以使用以下解決方法:" -#: ../../library/dataclasses.rst:380 +#: ../../library/dataclasses.rst:396 msgid "{field.name: getattr(obj, field.name) for field in fields(obj)}" msgstr "" -#: ../../library/dataclasses.rst:382 +#: ../../library/dataclasses.rst:398 #, fuzzy msgid "" ":func:`!asdict` raises :exc:`TypeError` if *obj* is not a dataclass instance." msgstr ":func:`!asdict` 如果 *obj* 不是資料類別實例,則引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:387 +#: ../../library/dataclasses.rst:403 #, fuzzy msgid "" "Converts the dataclass *obj* to a tuple (by using the factory function " @@ -746,21 +802,23 @@ msgstr "" "都被轉換為其欄位值的元組。資料類別、字典、列表和元組被遞迴到。其他物件使用 :" "func:`copy.deepcopy` 複製。" -#: ../../library/dataclasses.rst:393 +#: ../../library/dataclasses.rst:409 msgid "Continuing from the previous example::" msgstr "從前面的例子繼續: ::" -#: ../../library/dataclasses.rst:395 +#: ../../library/dataclasses.rst:411 msgid "" "assert astuple(p) == (10, 20)\n" "assert astuple(c) == ([(0, 0), (10, 4)],)" msgstr "" +"assert astuple(p) == (10, 20)\n" +"assert astuple(c) == ([(0, 0), (10, 4)],)" -#: ../../library/dataclasses.rst:400 +#: ../../library/dataclasses.rst:416 msgid "tuple(getattr(obj, field.name) for field in dataclasses.fields(obj))" -msgstr "" +msgstr "tuple(getattr(obj, field.name) for field in dataclasses.fields(obj))" -#: ../../library/dataclasses.rst:402 +#: ../../library/dataclasses.rst:418 #, fuzzy msgid "" ":func:`!astuple` raises :exc:`TypeError` if *obj* is not a dataclass " @@ -768,7 +826,7 @@ msgid "" msgstr "" ":func:`!astuple` 如果 *obj* 不是資料類別實例,則引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:407 +#: ../../library/dataclasses.rst:423 #, fuzzy msgid "" "Creates a new dataclass with name *cls_name*, fields as defined in *fields*, " @@ -788,13 +846,13 @@ msgstr "" "``kw_only`` 的值, ``slots`` 和 ``weakref_slot`` 與它們在 :func:`dataclass` 中" "的含義相同。" -#: ../../library/dataclasses.rst:417 +#: ../../library/dataclasses.rst:433 msgid "" "If *module* is defined, the :attr:`!__module__` attribute of the dataclass " "is set to that value. By default, it is set to the module name of the caller." msgstr "" -#: ../../library/dataclasses.rst:421 +#: ../../library/dataclasses.rst:437 #, fuzzy msgid "" "This function is not strictly required, because any Python mechanism for " @@ -802,11 +860,11 @@ msgid "" "`@dataclass ` function to convert that class to a dataclass. " "This function is provided as a convenience. For example::" msgstr "" -"這個函式不是嚴格要求的,因為任何使用 ``__annotations__`` 建立新類的 Python 機" -"制都可以應用 :func:`dataclass` 函式將該類轉換為資料類別。提供此功能是為了方" -"便。例如: ::" +"這個函式不是嚴格要求的,因為任何使用 ``__annotations__`` 建立新類別的 Python " +"機制都可以應用 :func:`dataclass` 函式將該類別轉換為資料類別。提供此功能是為了" +"方便。例如: ::" -#: ../../library/dataclasses.rst:427 +#: ../../library/dataclasses.rst:443 msgid "" "C = make_dataclass('C',\n" " [('x', int),\n" @@ -814,12 +872,17 @@ msgid "" " ('z', int, field(default=5))],\n" " namespace={'add_one': lambda self: self.x + 1})" msgstr "" +"C = make_dataclass('C',\n" +" [('x', int),\n" +" 'y',\n" +" ('z', int, field(default=5))],\n" +" namespace={'add_one': lambda self: self.x + 1})" -#: ../../library/dataclasses.rst:433 +#: ../../library/dataclasses.rst:449 msgid "Is equivalent to::" msgstr "相當於: ::" -#: ../../library/dataclasses.rst:435 +#: ../../library/dataclasses.rst:451 msgid "" "@dataclass\n" "class C:\n" @@ -831,7 +894,7 @@ msgid "" " return self.x + 1" msgstr "" -#: ../../library/dataclasses.rst:446 +#: ../../library/dataclasses.rst:462 #, fuzzy msgid "" "Creates a new object of the same type as *obj*, replacing fields with values " @@ -843,7 +906,7 @@ msgstr "" "``obj`` 不是資料類別,則引發 :exc:`TypeError`。如果 ``changes`` 中的值未指定" "欄位,則引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:451 +#: ../../library/dataclasses.rst:467 #, fuzzy msgid "" "The newly returned object is created by calling the :meth:`~object.__init__` " @@ -853,7 +916,7 @@ msgstr "" "新回傳的對像是通過呼叫資料類別的 :meth:`~object.__init__` 方法建立的。這確" "保 :meth:`__post_init__`(如果存在)也被呼叫。" -#: ../../library/dataclasses.rst:455 +#: ../../library/dataclasses.rst:471 #, fuzzy msgid "" "Init-only variables without default values, if any exist, must be specified " @@ -863,7 +926,7 @@ msgstr "" "沒有預設值的僅初始化變數(如果存在)必須在呼叫 :func:`replace` 時指定,以便它" "們可以傳遞給 :meth:`__init__` 和 :meth:`__post_init__`。" -#: ../../library/dataclasses.rst:459 +#: ../../library/dataclasses.rst:475 #, fuzzy msgid "" "It is an error for *changes* to contain any fields that are defined as " @@ -872,7 +935,7 @@ msgstr "" "*changes* 包含任何定義為具有 ``init=False`` 的欄位是錯誤的。在這種情況下將引" "發 :exc:`ValueError`。" -#: ../../library/dataclasses.rst:463 +#: ../../library/dataclasses.rst:479 #, fuzzy msgid "" "Be forewarned about how ``init=False`` fields work during a call to :func:`!" @@ -885,11 +948,17 @@ msgid "" msgstr "" "預先警告 ``init=False`` 欄位在呼叫 :func:`!replace` 期間是如何工作的。它們不" "是從源物件複製的,而是在 :meth:`__post_init__` 中初始化的,如果它們被初始化的" -"話。預計 ``init=False`` 欄位將很少被明智地使用。如果使用它們,使用替代的類構" -"造函式可能是明智的,或者可能是處理實例複製的自定義:func:`!replace` (或類似命" -"名的)方法。" +"話。預計 ``init=False`` 欄位將很少被明智地使用。如果使用它們,使用替代的類別" +"建構函式可能是明智的,或者可能是處理實例複製的自定義:func:`!replace` (或類似" +"命名的)方法。" -#: ../../library/dataclasses.rst:474 +#: ../../library/dataclasses.rst:488 +msgid "" +"Dataclass instances are also supported by generic function :func:`copy." +"replace`." +msgstr "" + +#: ../../library/dataclasses.rst:492 #, fuzzy msgid "" "Return ``True`` if its parameter is a dataclass (including subclasses of a " @@ -897,28 +966,28 @@ msgid "" msgstr "" "如果它的參數是一個資料類別或一個實例,則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/dataclasses.rst:477 +#: ../../library/dataclasses.rst:495 #, fuzzy msgid "" "If you need to know if a class is an instance of a dataclass (and not a " "dataclass itself), then add a further check for ``not isinstance(obj, " "type)``::" msgstr "" -"如果你需要知道一個類是否是資料類別的實例(而不是資料類別本身),那麼新增一個" -"進一步的檢查 ``not isinstance(obj, type)``: ::" +"如果你需要知道一個類別是否是資料類別的實例(而不是資料類別本身),那麼新增一" +"個進一步的檢查 ``not isinstance(obj, type)``: ::" -#: ../../library/dataclasses.rst:481 +#: ../../library/dataclasses.rst:499 msgid "" "def is_dataclass_instance(obj):\n" " return is_dataclass(obj) and not isinstance(obj, type)" msgstr "" -#: ../../library/dataclasses.rst:486 +#: ../../library/dataclasses.rst:504 #, fuzzy msgid "A sentinel value signifying a missing default or default_factory." msgstr "表示缺少 default 或 default_factory 的標記值。" -#: ../../library/dataclasses.rst:490 +#: ../../library/dataclasses.rst:508 #, fuzzy msgid "" "A sentinel value used as a type annotation. Any fields after a pseudo-field " @@ -932,16 +1001,16 @@ msgstr "" "用作型別註釋的標記值。型別為 :const:`!KW_ONLY` 的偽欄位之後的任何欄位都被標記" "為僅關鍵字欄位。請注意,:const:`!KW_ONLY` 型別的偽欄位將被完全忽略。這包括此" "類欄位的名稱。按照慣例,名稱 ``_`` 用於 :const:`!KW_ONLY` 欄位。僅關鍵字欄位" -"表示 :meth:`~object.__init__` 參數,在實例化類時必須將其指定為關鍵字。" +"表示 :meth:`~object.__init__` 參數,在實例化類別時必須將其指定為關鍵字。" -#: ../../library/dataclasses.rst:499 +#: ../../library/dataclasses.rst:517 #, fuzzy msgid "" "In this example, the fields ``y`` and ``z`` will be marked as keyword-only " "fields::" msgstr "在此示例中,欄位 ``y`` 和 ``z`` 將被標記為僅關鍵字欄位: ::" -#: ../../library/dataclasses.rst:501 +#: ../../library/dataclasses.rst:519 msgid "" "@dataclass\n" "class Point:\n" @@ -952,15 +1021,23 @@ msgid "" "\n" "p = Point(0, y=1.5, z=2.0)" msgstr "" +"@dataclass\n" +"class Point:\n" +" x: float\n" +" _: KW_ONLY\n" +" y: float\n" +" z: float\n" +"\n" +"p = Point(0, y=1.5, z=2.0)" -#: ../../library/dataclasses.rst:510 +#: ../../library/dataclasses.rst:528 #, fuzzy msgid "" "In a single dataclass, it is an error to specify more than one field whose " "type is :const:`!KW_ONLY`." msgstr "在單個資料類別中,指定多個型別為 :const:`!KW_ONLY` 的欄位是錯誤的。" -#: ../../library/dataclasses.rst:517 +#: ../../library/dataclasses.rst:535 #, fuzzy msgid "" "Raised when an implicitly defined :meth:`~object.__setattr__` or :meth:" @@ -970,12 +1047,12 @@ msgstr "" "當在使用 frozen=True 定義的資料類別上呼叫隱式定義的 :meth:`__setattr__` 或 :" "meth:`__delattr__` 時引發。它是 :exc:`AttributeError` 的子類別。" -#: ../../library/dataclasses.rst:524 +#: ../../library/dataclasses.rst:542 #, fuzzy msgid "Post-init processing" msgstr "初始化後處理" -#: ../../library/dataclasses.rst:528 +#: ../../library/dataclasses.rst:546 #, fuzzy msgid "" "When defined on the class, it will be called by the generated :meth:`~object." @@ -986,19 +1063,19 @@ msgid "" "automatically be called." msgstr "" "生成的 :meth:`~object.__init__` 程式碼將呼叫一個名為 :meth:`!self." -"__post_init__` 的方法,如果 :meth:`!__post_init__` 是在類上定義的。它通常被稱" -"為 ``self.!__post_init__()``。但是,如果定義了任何 ``InitVar`` 欄位,它們也將" -"按照它們在類中定義的順序傳遞給 :meth:`!__post_init__` 。如果沒有生成 :meth:`!" -"__init__` 方法,那麼 :meth:`!__post_init__` 將不會被自動呼叫。" +"__post_init__` 的方法,如果 :meth:`!__post_init__` 是在類別上定義的。它通常被" +"稱為 ``self.!__post_init__()``。但是,如果定義了任何 ``InitVar`` 欄位,它們也" +"將按照它們在類別中定義的順序傳遞給 :meth:`!__post_init__` 。如果沒有生成 :" +"meth:`!__init__` 方法,那麼 :meth:`!__post_init__` 將不會被自動呼叫。" -#: ../../library/dataclasses.rst:535 +#: ../../library/dataclasses.rst:553 #, fuzzy msgid "" "Among other uses, this allows for initializing field values that depend on " "one or more other fields. For example::" msgstr "在其他用途中,這允許初始化依賴於一個或多個其他欄位的欄位值。例如: ::" -#: ../../library/dataclasses.rst:538 +#: ../../library/dataclasses.rst:556 msgid "" "@dataclass\n" "class C:\n" @@ -1009,8 +1086,16 @@ msgid "" " def __post_init__(self):\n" " self.c = self.a + self.b" msgstr "" +"@dataclass\n" +"class C:\n" +" a: float\n" +" b: float\n" +" c: float = field(init=False)\n" +"\n" +" def __post_init__(self):\n" +" self.c = self.a + self.b" -#: ../../library/dataclasses.rst:547 +#: ../../library/dataclasses.rst:565 #, fuzzy msgid "" "The :meth:`~object.__init__` method generated by :func:`@dataclass " @@ -1022,12 +1107,12 @@ msgstr "" "類別 :meth:`!__init__` 方法。如果基底類別有一個必須呼叫的 :meth:`!__init__` " "方法,通常在 :meth:`__post_init__` 方法中呼叫此方法: ::" -#: ../../library/dataclasses.rst:552 +#: ../../library/dataclasses.rst:570 msgid "" "class Rectangle:\n" " def __init__(self, height, width):\n" -" self.height = height\n" -" self.width = width\n" +" self.height = height\n" +" self.width = width\n" "\n" "@dataclass\n" "class Square(Rectangle):\n" @@ -1036,18 +1121,29 @@ msgid "" " def __post_init__(self):\n" " super().__init__(self.side, self.side)" msgstr "" +"class Rectangle:\n" +" def __init__(self, height, width):\n" +" self.height = height\n" +" self.width = width\n" +"\n" +"@dataclass\n" +"class Square(Rectangle):\n" +" side: float\n" +"\n" +" def __post_init__(self):\n" +" super().__init__(self.side, self.side)" -#: ../../library/dataclasses.rst:564 +#: ../../library/dataclasses.rst:582 #, fuzzy msgid "" "Note, however, that in general the dataclass-generated :meth:`!__init__` " "methods don't need to be called, since the derived dataclass will take care " "of initializing all fields of any base class that is a dataclass itself." msgstr "" -"但是請注意,通常不需要呼叫資料類別生成的 :meth:`!__init__` 方法,因為派生資料" +"但是請注意,通常不需要呼叫資料類別生成的 :meth:`!__init__` 方法,因為衍生資料" "類別將負責初始化作為資料類別本身的任何基底類別的所有欄位。" -#: ../../library/dataclasses.rst:568 +#: ../../library/dataclasses.rst:586 #, fuzzy msgid "" "See the section below on init-only variables for ways to pass parameters to :" @@ -1057,11 +1153,11 @@ msgstr "" "請參閱下面有關僅初始化變數的部分,了解將參數傳遞給 :meth:`!__post_init__` 的" "方法。另請參閱有關 :func:`replace` 如何處理 ``init=False`` 欄位的警告。" -#: ../../library/dataclasses.rst:575 +#: ../../library/dataclasses.rst:593 msgid "Class variables" msgstr "類別變數" -#: ../../library/dataclasses.rst:577 +#: ../../library/dataclasses.rst:595 #, fuzzy msgid "" "One of the few places where :func:`@dataclass ` actually inspects " @@ -1073,23 +1169,23 @@ msgid "" "`fields` function." msgstr "" ":func:`@dataclass ` 實際檢查欄位型別的少數地方之一是確定欄位是否" -"是 :pep:`526` 中定義的類變數。它通過檢查欄位的型別是否為 :data:`typing." +"是 :pep:`526` 中定義的類別變數。它通過檢查欄位的型別是否為 :data:`typing." "ClassVar` 來做到這一點。如果一個欄位是一個 ``ClassVar``,它就被排除在考慮之" "外,並被資料類別機制忽略。模組級 :func:`fields` 函式不會回傳此類別 " "``ClassVar`` 偽欄位。" -#: ../../library/dataclasses.rst:588 +#: ../../library/dataclasses.rst:606 #, fuzzy msgid "Init-only variables" msgstr "僅初始化變數" -#: ../../library/dataclasses.rst:590 +#: ../../library/dataclasses.rst:608 #, fuzzy msgid "" "Another place where :func:`@dataclass ` 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-" +"this by seeing if the type of a field is of type :class:`InitVar`. If a " +"field is an :class:`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 :func:`fields` function. Init-only fields are added as parameters to " "the generated :meth:`~object.__init__` method, and are passed to the " @@ -1101,16 +1197,16 @@ msgstr "" "是一個 ``InitVar``,它被認為是一個偽欄位,稱為 init-only 欄位。由於它不是真正" "的欄位,因此它不會由模組級 fields 函式回傳。 Init-only 欄位作為參數新增到生成" "的 :meth:`~object.__init__` 方法,並傳遞給可選的 :meth:`__post_init__` 方法。" -"它們不被資料類使用。" +"它們不被資料類別使用。" -#: ../../library/dataclasses.rst:600 +#: ../../library/dataclasses.rst:618 #, fuzzy msgid "" "For example, suppose a field will be initialized from a database, if a value " "is not provided when creating the class::" -msgstr "例如,假設一個欄位將從資料庫中初始化,如果在建立類時沒有提供值: ::" +msgstr "例如,假設一個欄位將從資料庫中初始化,如果在建立類別時沒有提供值: ::" -#: ../../library/dataclasses.rst:603 +#: ../../library/dataclasses.rst:621 msgid "" "@dataclass\n" "class C:\n" @@ -1124,8 +1220,19 @@ msgid "" "\n" "c = C(10, database=my_database)" msgstr "" +"@dataclass\n" +"class C:\n" +" i: int\n" +" j: int | None = None\n" +" database: InitVar[DatabaseType | None] = None\n" +"\n" +" def __post_init__(self, database):\n" +" if self.j is None and database is not None:\n" +" self.j = database.lookup('j')\n" +"\n" +"c = C(10, database=my_database)" -#: ../../library/dataclasses.rst:615 +#: ../../library/dataclasses.rst:633 #, fuzzy msgid "" "In this case, :func:`fields` will return :class:`Field` objects for :attr:`!" @@ -1134,11 +1241,11 @@ msgstr "" "在這種情況下,:func:`fields` 將為 :attr:`!i` 和 :attr:`!j` 回傳 :class:" "`Field` 物件,但不會為 :attr:`!database` 回傳。" -#: ../../library/dataclasses.rst:621 +#: ../../library/dataclasses.rst:639 msgid "Frozen instances" msgstr "凍結實例" -#: ../../library/dataclasses.rst:623 +#: ../../library/dataclasses.rst:641 #, fuzzy msgid "" "It is not possible to create truly immutable Python objects. However, by " @@ -1149,10 +1256,10 @@ msgid "" msgstr "" "不可能建立真正不可變的 Python 物件。但是,通過將 ``frozen=True`` 傳遞給 :" "func:`@dataclass ` 裝飾器,你可以模擬不變性。在這種情況下,資料類" -"別將向類新增 :meth:`~object.__setattr__` 和 :meth:`~object.__delattr__` 方" -"法。這些方法在呼叫時會引發 :exc:`FrozenInstanceError`。" +"別將向類別新增 :meth:`~object.__setattr__` 和 :meth:`~object.__delattr__` 方" +"法。這些方法在叫用時會引發 :exc:`FrozenInstanceError`。" -#: ../../library/dataclasses.rst:629 +#: ../../library/dataclasses.rst:647 #, fuzzy msgid "" "There is a tiny performance penalty when using ``frozen=True``: :meth:" @@ -1162,11 +1269,11 @@ msgstr "" "使用 ``frozen=True`` 時有一個微小的性能損失::meth:`~object.__init__` 不能使" "用簡單賦值來初始化欄位,必須使用 :meth:`!object.__setattr__`。" -#: ../../library/dataclasses.rst:638 +#: ../../library/dataclasses.rst:656 msgid "Inheritance" msgstr "繼承" -#: ../../library/dataclasses.rst:640 +#: ../../library/dataclasses.rst:658 #, fuzzy msgid "" "When the dataclass is being created by the :func:`@dataclass ` " @@ -1179,12 +1286,12 @@ msgid "" "order, derived classes override base classes. An example::" msgstr "" "當 :func:`@dataclass ` 裝飾器建立資料類別時,它會以反向 MRO(即" -"從 :class:`object` 開始)查看該類的所有基底類別,並且對於它找到的每個資料類" -"別,將該基底類別中的欄位新增到欄位的有序映射中。新增所有基底類別欄位後,它會" -"將自己的欄位新增到有序映射中。所有生成的方法都將使用這種組合的、計算的有序欄" -"位映射。因為欄位是按插入順序排列的,所以派生類會覆蓋基底類別。一個例子: ::" +"從 :class:`object` 開始)查看該類別的所有基底類別,並且對於它找到的每個資料類" +"別,將該基底類別中的欄位新增到欄位的有序對映中。新增所有基底類別欄位後,它會" +"將自己的欄位新增到有序對映中。所有生成的方法都將使用這種組合的、計算的有序欄" +"位對映。因為欄位是按插入順序排列的,所以衍生類別會覆蓋基底類別。一個例子: ::" -#: ../../library/dataclasses.rst:650 +#: ../../library/dataclasses.rst:668 msgid "" "@dataclass\n" "class Base:\n" @@ -1196,8 +1303,17 @@ msgid "" " z: int = 10\n" " x: int = 15" msgstr "" +"@dataclass\n" +"class Base:\n" +" x: Any = 15.0\n" +" y: int = 0\n" +"\n" +"@dataclass\n" +"class C(Base):\n" +" z: int = 10\n" +" x: int = 15" -#: ../../library/dataclasses.rst:660 +#: ../../library/dataclasses.rst:678 #, fuzzy msgid "" "The final list of fields is, in order, :attr:`!x`, :attr:`!y`, :attr:`!z`. " @@ -1207,23 +1323,23 @@ msgstr "" "最終的欄位列表按順序為 :attr:`!x`、:attr:`!y`、:attr:`!z`。:attr:`!x` 的最終" "型別是 :class:`int`,如類別 :class:`!C` 中指定的那樣。" -#: ../../library/dataclasses.rst:663 +#: ../../library/dataclasses.rst:681 #, fuzzy msgid "" "The generated :meth:`~object.__init__` method for :class:`!C` will look " "like::" msgstr "為 :class:`!C` 生成的 :meth:`~object.__init__` 方法將如下所示: ::" -#: ../../library/dataclasses.rst:665 +#: ../../library/dataclasses.rst:683 msgid "def __init__(self, x: int = 15, y: int = 0, z: int = 10):" -msgstr "" +msgstr "def __init__(self, x: int = 15, y: int = 0, z: int = 10):" -#: ../../library/dataclasses.rst:668 +#: ../../library/dataclasses.rst:686 #, fuzzy msgid "Re-ordering of keyword-only parameters in :meth:`!__init__`" msgstr ":meth:`!__init__` 中僅關鍵字參數的重新排序" -#: ../../library/dataclasses.rst:670 +#: ../../library/dataclasses.rst:688 #, fuzzy msgid "" "After the parameters needed for :meth:`~object.__init__` are computed, any " @@ -1235,7 +1351,7 @@ msgstr "" "僅關鍵字)參數之後。這是如何在 Python 中實作僅關鍵字參數的要求:它們必須位於" "非僅關鍵字參數之後。" -#: ../../library/dataclasses.rst:676 +#: ../../library/dataclasses.rst:694 #, fuzzy msgid "" "In this example, :attr:`!Base.y`, :attr:`!Base.w`, and :attr:`!D.t` are " @@ -1245,7 +1361,7 @@ msgstr "" "在此示例中,:attr:`!Base.y`、:attr:`!Base.w` 和 :attr:`!D.t` 是僅限關鍵字的欄" "位,:attr:`!Base.x` 和 :attr:`!D.z` 是常規欄位: ::" -#: ../../library/dataclasses.rst:679 +#: ../../library/dataclasses.rst:697 msgid "" "@dataclass\n" "class Base:\n" @@ -1259,40 +1375,53 @@ msgid "" " z: int = 10\n" " t: int = field(kw_only=True, default=0)" msgstr "" +"@dataclass\n" +"class Base:\n" +" x: Any = 15.0\n" +" _: KW_ONLY\n" +" y: int = 0\n" +" w: int = 1\n" +"\n" +"@dataclass\n" +"class D(Base):\n" +" z: int = 10\n" +" t: int = field(kw_only=True, default=0)" -#: ../../library/dataclasses.rst:691 +#: ../../library/dataclasses.rst:709 #, fuzzy msgid "The generated :meth:`!__init__` method for :class:`!D` will look like::" msgstr "為 :class:`!D` 生成的 :meth:`!__init__` 方法將如下所示: ::" -#: ../../library/dataclasses.rst:693 +#: ../../library/dataclasses.rst:711 msgid "" "def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: " "int = 0):" msgstr "" +"def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: " +"int = 0):" -#: ../../library/dataclasses.rst:695 +#: ../../library/dataclasses.rst:713 #, fuzzy msgid "" "Note that the parameters have been re-ordered from how they appear in the " "list of fields: parameters derived from regular fields are followed by " "parameters derived from keyword-only fields." msgstr "" -"請注意,參數已根據它們在欄位列表中的顯示方式重新排序:從常規欄位派生的參數後" -"跟從僅關鍵字欄位派生的參數。" +"請注意,參數已根據它們在欄位列表中的顯示方式重新排序:從常規欄位衍生的參數後" +"跟從僅關鍵字欄位衍生的參數。" -#: ../../library/dataclasses.rst:699 +#: ../../library/dataclasses.rst:717 #, fuzzy msgid "" "The relative ordering of keyword-only parameters is maintained in the re-" "ordered :meth:`!__init__` parameter list." msgstr "僅關鍵字參數的相對順序在重新排序的 :meth:`!__init__` 參數列表中維護。" -#: ../../library/dataclasses.rst:704 +#: ../../library/dataclasses.rst:722 msgid "Default factory functions" msgstr "預設工廠函式" -#: ../../library/dataclasses.rst:706 +#: ../../library/dataclasses.rst:724 #, fuzzy msgid "" "If a :func:`field` specifies a *default_factory*, it is called with zero " @@ -1302,11 +1431,11 @@ msgstr "" "如果 :func:`field` 指定了 *default_factory*,當需要該欄位的預設值時,它會以零" "引數呼叫。例如,要建立列表的新實例,請使用: ::" -#: ../../library/dataclasses.rst:710 +#: ../../library/dataclasses.rst:728 msgid "mylist: list = field(default_factory=list)" -msgstr "" +msgstr "mylist: list = field(default_factory=list)" -#: ../../library/dataclasses.rst:712 +#: ../../library/dataclasses.rst:730 #, fuzzy msgid "" "If a field is excluded from :meth:`~object.__init__` (using ``init=False``) " @@ -1319,19 +1448,19 @@ msgstr "" "位還指定了 ``default_factory``,那麼預設工廠函式將始終從生成的 :meth:" "`__init__ 中呼叫`功能。發生這種情況是因為沒有其他方法可以為該欄位賦予初始值。" -#: ../../library/dataclasses.rst:719 +#: ../../library/dataclasses.rst:737 msgid "Mutable default values" msgstr "可變預設值" -#: ../../library/dataclasses.rst:721 +#: ../../library/dataclasses.rst:739 #, fuzzy msgid "" "Python stores default member variable values in class attributes. Consider " "this example, not using dataclasses::" msgstr "" -"Python 將預設成員變數值存儲在類別屬性中。考慮這個例子,不使用資料類別: ::" +"Python 將預設成員變數值儲存在類別屬性中。考慮這個例子,不使用資料類別: ::" -#: ../../library/dataclasses.rst:724 +#: ../../library/dataclasses.rst:742 msgid "" "class C:\n" " x = []\n" @@ -1345,8 +1474,19 @@ msgid "" "assert o1.x == [1, 2]\n" "assert o1.x is o2.x" msgstr "" +"class C:\n" +" x = []\n" +" def add(self, element):\n" +" self.x.append(element)\n" +"\n" +"o1 = C()\n" +"o2 = C()\n" +"o1.add(1)\n" +"o2.add(2)\n" +"assert o1.x == [1, 2]\n" +"assert o1.x is o2.x" -#: ../../library/dataclasses.rst:736 +#: ../../library/dataclasses.rst:754 #, fuzzy msgid "" "Note that the two instances of class :class:`!C` share the same class " @@ -1355,12 +1495,12 @@ msgstr "" "請注意,類別 :class:`!C` 的兩個實例共享同一個類別變數 :attr:`!x`,正如預期的" "那樣。" -#: ../../library/dataclasses.rst:739 +#: ../../library/dataclasses.rst:757 #, fuzzy msgid "Using dataclasses, *if* this code was valid::" msgstr "使用資料類別,*如果*此程式碼有效: ::" -#: ../../library/dataclasses.rst:741 +#: ../../library/dataclasses.rst:759 msgid "" "@dataclass\n" "class D:\n" @@ -1368,12 +1508,17 @@ msgid "" " def add(self, element):\n" " self.x.append(element)" msgstr "" +"@dataclass\n" +"class D:\n" +" x: list = [] # 這段程式碼會引發 ValueError\n" +" def add(self, element):\n" +" self.x.append(element)" -#: ../../library/dataclasses.rst:747 +#: ../../library/dataclasses.rst:765 msgid "it would generate code similar to::" msgstr "它會生成類似的程式碼: ::" -#: ../../library/dataclasses.rst:749 +#: ../../library/dataclasses.rst:767 msgid "" "class D:\n" " x = []\n" @@ -1384,8 +1529,16 @@ msgid "" "\n" "assert D().x is D().x" msgstr "" +"class D:\n" +" x = []\n" +" def __init__(self, x=x):\n" +" self.x = x\n" +" def add(self, element):\n" +" self.x.append(element)\n" +"\n" +"assert D().x is D().x" -#: ../../library/dataclasses.rst:758 +#: ../../library/dataclasses.rst:776 #, fuzzy msgid "" "This has the same issue as the original example using class :class:`!C`. " @@ -1399,20 +1552,20 @@ msgid "" "partial solution, but it does protect against many common errors." msgstr "" "這與使用類別 :class:`!C` 的原始示例存在相同的問題。也就是說,類別 :class:`!" -"D` 的兩個實例在建立類實例時沒有為 :attr:`!x` 指定值,它們將共享 :attr:`!x` 的" -"同一個副本。因為資料類別只是使用普通的 Python 類建立,所以它們也有這種行為。" -"資料類別沒有通用的方法來檢測這種情況。相反,如果 :func:`dataclass` 裝飾器檢測" -"到不可散列的預設參數,它將引發 :exc:`TypeError`。假設是如果一個值是不可散列" -"的,那麼它就是可變的。這是一個部分解決方案,但它確實可以防止許多常見錯誤。" +"D` 的兩個實例在建立類別實例時沒有為 :attr:`!x` 指定值,它們將共享 :attr:`!x` " +"的同一個副本。因為資料類別只是使用普通的 Python 類別建立,所以它們也有這種行" +"為。資料類別沒有通用的方法來檢測這種情況。相反,如果 :func:`dataclass` 裝飾器" +"檢測到不可散列的預設參數,它將引發 :exc:`TypeError`。假設是如果一個值是不可散" +"列的,那麼它就是可變的。這是一個部分解決方案,但它確實可以防止許多常見錯誤。" -#: ../../library/dataclasses.rst:769 +#: ../../library/dataclasses.rst:787 #, fuzzy msgid "" "Using default factory functions is a way to create new instances of mutable " "types as default values for fields::" msgstr "使用預設工廠函式是一種建立可變型別的新實例作為欄位預設值的方法: ::" -#: ../../library/dataclasses.rst:772 +#: ../../library/dataclasses.rst:790 msgid "" "@dataclass\n" "class D:\n" @@ -1420,8 +1573,13 @@ msgid "" "\n" "assert D().x is not D().x" msgstr "" +"@dataclass\n" +"class D:\n" +" x: list = field(default_factory=list)\n" +"\n" +"assert D().x is not D().x" -#: ../../library/dataclasses.rst:778 +#: ../../library/dataclasses.rst:796 #, fuzzy msgid "" "Instead of looking for and disallowing objects of type :class:`list`, :class:" @@ -1431,12 +1589,12 @@ msgstr "" "不再查找和禁止型別為 :class:`list`、:class:`dict` 或 :class:`set` 的物件,現" "在不允許使用不可散列的對像作為預設值。不可散列性用於近似可變性。" -#: ../../library/dataclasses.rst:785 +#: ../../library/dataclasses.rst:803 #, fuzzy msgid "Descriptor-typed fields" msgstr "描述器型別的欄位" -#: ../../library/dataclasses.rst:787 +#: ../../library/dataclasses.rst:805 #, fuzzy msgid "" "Fields that are assigned :ref:`descriptor objects ` as their " @@ -1444,7 +1602,7 @@ msgid "" msgstr "" "指定為\\ :ref:`描述器物件 `\\ 作為預設值的欄位具有以下特殊行為:" -#: ../../library/dataclasses.rst:790 +#: ../../library/dataclasses.rst:808 #, fuzzy msgid "" "The value for the field passed to the dataclass's :meth:`~object.__init__` " @@ -1454,17 +1612,17 @@ msgstr "" "傳遞給資料類別的 :meth:`~object.__init__` 方法的欄位值被傳遞給描述器的 :meth:" "`~object.__set__` 方法,而不是覆蓋描述器物件。" -#: ../../library/dataclasses.rst:794 +#: ../../library/dataclasses.rst:812 #, fuzzy msgid "" "Similarly, when getting or setting the field, the descriptor's :meth:" "`~object.__get__` or :meth:`!__set__` method is called rather than returning " "or overwriting the descriptor object." msgstr "" -"同樣,在獲取或設定欄位時,將呼叫描述器的 :meth:`~object.__get__` 或 :meth:`!" +"同樣,在取得或設定欄位時,將呼叫描述器的 :meth:`~object.__get__` 或 :meth:`!" "__set__` 方法,而不是回傳或覆蓋描述器物件。" -#: ../../library/dataclasses.rst:798 +#: ../../library/dataclasses.rst:816 #, fuzzy msgid "" "To determine whether a field contains a default value, :func:`@dataclass " @@ -1474,13 +1632,13 @@ msgid "" "default. On the other hand, if the descriptor raises :exc:`AttributeError` " "in this situation, no default value will be provided for the field." msgstr "" -"為了確定一個欄位是否包含預設值,:func:`@dataclass ` 將使用其類訪問" -"形式呼叫描述器的 :meth:`!__get__` 方法(即 ``descriptor.__get__(obj=None, " +"為了確定一個欄位是否包含預設值,:func:`@dataclass ` 將使用其類別存" +"取形式呼叫描述器的 :meth:`!__get__` 方法(即 ``descriptor.__get__(obj=None, " "type=cls)``。如果在這種情況下,描述器回傳一個值,它將用作欄位的預設值。另一方" "面,如果描述器在這種情況下引發 :exc:`AttributeError`,則不會為該欄位提供預設" "值。" -#: ../../library/dataclasses.rst:808 +#: ../../library/dataclasses.rst:826 msgid "" "class IntConversionDescriptor:\n" " def __init__(self, *, default):\n" @@ -1508,8 +1666,33 @@ msgid "" "i.quantity_on_hand = 2.5 # calls __set__ with 2.5\n" "print(i.quantity_on_hand) # 2" msgstr "" +"class IntConversionDescriptor:\n" +" def __init__(self, *, default):\n" +" self._default = default\n" +"\n" +" def __set_name__(self, owner, name):\n" +" self._name = \"_\" + name\n" +"\n" +" def __get__(self, obj, type):\n" +" if obj is None:\n" +" return self._default\n" +"\n" +" return getattr(obj, self._name, self._default)\n" +"\n" +" def __set__(self, obj, value):\n" +" setattr(obj, self._name, int(value))\n" +"\n" +"@dataclass\n" +"class InventoryItem:\n" +" quantity_on_hand: IntConversionDescriptor = " +"IntConversionDescriptor(default=100)\n" +"\n" +"i = InventoryItem()\n" +"print(i.quantity_on_hand) # 100\n" +"i.quantity_on_hand = 2.5 # 以 2.5 呼叫 __set__\n" +"print(i.quantity_on_hand) # 2" -#: ../../library/dataclasses.rst:833 +#: ../../library/dataclasses.rst:851 #, fuzzy msgid "" "Note that if a field is annotated with a descriptor type, but is not " diff --git a/library/datatypes.po b/library/datatypes.po index 03aca0edd2..82edc28c58 100644 --- a/library/datatypes.po +++ b/library/datatypes.po @@ -4,7 +4,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-06-20 18:08+0800\n" "PO-Revision-Date: 2022-02-11 12:12+0800\n" diff --git a/library/datetime.po b/library/datetime.po index cb850b9d8b..5078659845 100644 --- a/library/datetime.po +++ b/library/datetime.po @@ -4,9 +4,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-07 03:11+0800\n" +"POT-Creation-Date: 2025-05-11 00:17+0000\n" "PO-Revision-Date: 2023-08-07 10:20+0800\n" "Last-Translator: Griiid \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -270,7 +270,8 @@ msgid "" msgstr "" #: ../../library/datetime.rst:183 -msgid "A :class:`.datetime` object *d* is aware if both of the following hold:" +msgid "" +"A :class:`.datetime` object ``d`` is aware if both of the following hold:" msgstr "" #: ../../library/datetime.rst:185 @@ -282,11 +283,11 @@ msgid "``d.tzinfo.utcoffset(d)`` does not return ``None``" msgstr "``d.tzinfo.utcoffset(d)`` 不會回傳 ``None``" #: ../../library/datetime.rst:188 -msgid "Otherwise, *d* is naive." -msgstr "否則 *d* 會是 naive 的。" +msgid "Otherwise, ``d`` is naive." +msgstr "否則 ``d`` 會是 naive 的。" #: ../../library/datetime.rst:190 -msgid "A :class:`.time` object *t* is aware if both of the following hold:" +msgid "A :class:`.time` object ``t`` is aware if both of the following hold:" msgstr "" #: ../../library/datetime.rst:192 @@ -298,8 +299,8 @@ msgid "``t.tzinfo.utcoffset(None)`` does not return ``None``." msgstr "``t.tzinfo.utcoffset(None)`` 沒有回傳 ``None``。" #: ../../library/datetime.rst:195 -msgid "Otherwise, *t* is naive." -msgstr "" +msgid "Otherwise, ``t`` is naive." +msgstr "否則 ``t`` 會是 naive 的。" #: ../../library/datetime.rst:197 msgid "" @@ -422,236 +423,281 @@ msgstr "" ">>> (d.days, d.seconds, d.microseconds)\n" "(-1, 86399, 999999)" -#: ../../library/datetime.rst:265 ../../library/datetime.rst:552 -#: ../../library/datetime.rst:1071 ../../library/datetime.rst:1702 -#: ../../library/datetime.rst:2304 +#: ../../library/datetime.rst:264 +msgid "" +"Since the string representation of :class:`!timedelta` objects can be " +"confusing, use the following recipe to produce a more readable format:" +msgstr "" + +#: ../../library/datetime.rst:267 +msgid "" +">>> def pretty_timedelta(td):\n" +"... if td.days >= 0:\n" +"... return str(td)\n" +"... return f'-({-td!s})'\n" +"...\n" +">>> d = timedelta(hours=-1)\n" +">>> str(d) # not human-friendly\n" +"'-1 day, 23:00:00'\n" +">>> pretty_timedelta(d)\n" +"'-(1:00:00)'" +msgstr "" + +#: ../../library/datetime.rst:281 ../../library/datetime.rst:582 +#: ../../library/datetime.rst:1142 ../../library/datetime.rst:1780 +#: ../../library/datetime.rst:2385 msgid "Class attributes:" msgstr "類別屬性:" -#: ../../library/datetime.rst:269 +#: ../../library/datetime.rst:285 msgid "The most negative :class:`timedelta` object, ``timedelta(-999999999)``." msgstr "" -#: ../../library/datetime.rst:274 +#: ../../library/datetime.rst:290 msgid "" "The most positive :class:`timedelta` object, ``timedelta(days=999999999, " "hours=23, minutes=59, seconds=59, microseconds=999999)``." msgstr "" -#: ../../library/datetime.rst:280 +#: ../../library/datetime.rst:296 msgid "" "The smallest possible difference between non-equal :class:`timedelta` " "objects, ``timedelta(microseconds=1)``." msgstr "" -#: ../../library/datetime.rst:283 +#: ../../library/datetime.rst:299 msgid "" "Note that, because of normalization, ``timedelta.max`` is greater than ``-" "timedelta.min``. ``-timedelta.max`` is not representable as a :class:" "`timedelta` object." msgstr "" -#: ../../library/datetime.rst:287 ../../library/datetime.rst:570 -#: ../../library/datetime.rst:1091 ../../library/datetime.rst:1722 +#: ../../library/datetime.rst:303 ../../library/datetime.rst:600 +#: ../../library/datetime.rst:1162 ../../library/datetime.rst:1800 msgid "Instance attributes (read-only):" msgstr "" -#: ../../library/datetime.rst:291 +#: ../../library/datetime.rst:307 msgid "Between -999,999,999 and 999,999,999 inclusive." msgstr "在 -999,999,999 到 999,999,999 (含)之間" -#: ../../library/datetime.rst:296 +#: ../../library/datetime.rst:312 msgid "Between 0 and 86,399 inclusive." msgstr "在 0 到 86,399 (含)之間" -#: ../../library/datetime.rst:301 +#: ../../library/datetime.rst:316 +msgid "" +"It is a somewhat common bug for code to unintentionally use this attribute " +"when it is actually intended to get a :meth:`~timedelta.total_seconds` value " +"instead:" +msgstr "" + +#: ../../library/datetime.rst:320 +msgid "" +">>> from datetime import timedelta\n" +">>> duration = timedelta(seconds=11235813)\n" +">>> duration.days, duration.seconds\n" +"(130, 3813)\n" +">>> duration.total_seconds()\n" +"11235813.0" +msgstr "" +">>> from datetime import timedelta\n" +">>> duration = timedelta(seconds=11235813)\n" +">>> duration.days, duration.seconds\n" +"(130, 3813)\n" +">>> duration.total_seconds()\n" +"11235813.0" + +#: ../../library/datetime.rst:331 msgid "Between 0 and 999,999 inclusive." msgstr "在 0 到 999,999 (含)之間" -#: ../../library/datetime.rst:304 ../../library/datetime.rst:587 -#: ../../library/datetime.rst:1144 +#: ../../library/datetime.rst:334 ../../library/datetime.rst:617 +#: ../../library/datetime.rst:1215 msgid "Supported operations:" msgstr "" -#: ../../library/datetime.rst:309 ../../library/datetime.rst:590 -#: ../../library/datetime.rst:1147 +#: ../../library/datetime.rst:339 ../../library/datetime.rst:620 +#: ../../library/datetime.rst:1218 msgid "Operation" msgstr "" -#: ../../library/datetime.rst:309 ../../library/datetime.rst:590 -#: ../../library/datetime.rst:1147 +#: ../../library/datetime.rst:339 ../../library/datetime.rst:620 +#: ../../library/datetime.rst:1218 msgid "Result" msgstr "" -#: ../../library/datetime.rst:311 +#: ../../library/datetime.rst:341 msgid "``t1 = t2 + t3``" msgstr "``t1 = t2 + t3``" -#: ../../library/datetime.rst:311 +#: ../../library/datetime.rst:341 msgid "" "Sum of ``t2`` and ``t3``. Afterwards ``t1 - t2 == t3`` and ``t1 - t3 == t2`` " "are true. (1)" msgstr "" -#: ../../library/datetime.rst:315 +#: ../../library/datetime.rst:345 msgid "``t1 = t2 - t3``" msgstr "``t1 = t2 - t3``" -#: ../../library/datetime.rst:315 +#: ../../library/datetime.rst:345 msgid "" "Difference of ``t2`` and ``t3``. Afterwards ``t1 == t2 - t3`` and ``t2 == " "t1 + t3`` are true. (1)(6)" msgstr "" -#: ../../library/datetime.rst:319 +#: ../../library/datetime.rst:349 msgid "``t1 = t2 * i or t1 = i * t2``" msgstr "``t1 = t2 * i or t1 = i * t2``" -#: ../../library/datetime.rst:319 +#: ../../library/datetime.rst:349 msgid "" "Delta multiplied by an integer. Afterwards ``t1 // i == t2`` is true, " "provided ``i != 0``." msgstr "" -#: ../../library/datetime.rst:323 +#: ../../library/datetime.rst:353 msgid "In general, ``t1 * i == t1 * (i-1) + t1`` is true. (1)" msgstr "" -#: ../../library/datetime.rst:326 +#: ../../library/datetime.rst:356 msgid "``t1 = t2 * f or t1 = f * t2``" msgstr "``t1 = t2 * f or t1 = f * t2``" -#: ../../library/datetime.rst:326 +#: ../../library/datetime.rst:356 msgid "" "Delta multiplied by a float. The result is rounded to the nearest multiple " "of timedelta.resolution using round-half-to-even." msgstr "" -#: ../../library/datetime.rst:330 +#: ../../library/datetime.rst:360 msgid "``f = t2 / t3``" msgstr "``f = t2 / t3``" -#: ../../library/datetime.rst:330 +#: ../../library/datetime.rst:360 msgid "" "Division (3) of overall duration ``t2`` by interval unit ``t3``. Returns a :" "class:`float` object." msgstr "" -#: ../../library/datetime.rst:334 +#: ../../library/datetime.rst:364 msgid "``t1 = t2 / f or t1 = t2 / i``" msgstr "``t1 = t2 / f or t1 = t2 / i``" -#: ../../library/datetime.rst:334 +#: ../../library/datetime.rst:364 msgid "" "Delta divided by a float or an int. The result is rounded to the nearest " "multiple of timedelta.resolution using round-half-to-even." msgstr "" -#: ../../library/datetime.rst:338 +#: ../../library/datetime.rst:368 msgid "``t1 = t2 // i`` or ``t1 = t2 // t3``" msgstr "``t1 = t2 // i`` or ``t1 = t2 // t3``" -#: ../../library/datetime.rst:338 +#: ../../library/datetime.rst:368 msgid "" "The floor is computed and the remainder (if any) is thrown away. In the " "second case, an integer is returned. (3)" msgstr "" -#: ../../library/datetime.rst:342 +#: ../../library/datetime.rst:372 msgid "``t1 = t2 % t3``" msgstr "``t1 = t2 % t3``" -#: ../../library/datetime.rst:342 +#: ../../library/datetime.rst:372 msgid "The remainder is computed as a :class:`timedelta` object. (3)" msgstr "" -#: ../../library/datetime.rst:345 +#: ../../library/datetime.rst:375 msgid "``q, r = divmod(t1, t2)``" msgstr "``q, r = divmod(t1, t2)``" -#: ../../library/datetime.rst:345 +#: ../../library/datetime.rst:375 msgid "" "Computes the quotient and the remainder: ``q = t1 // t2`` (3) and ``r = t1 % " -"t2``. q is an integer and r is a :class:`timedelta` object." +"t2``. ``q`` is an integer and ``r`` is a :class:`timedelta` object." msgstr "" -#: ../../library/datetime.rst:350 +#: ../../library/datetime.rst:380 msgid "``+t1``" msgstr "``+t1``" -#: ../../library/datetime.rst:350 +#: ../../library/datetime.rst:380 msgid "Returns a :class:`timedelta` object with the same value. (2)" msgstr "" -#: ../../library/datetime.rst:353 +#: ../../library/datetime.rst:383 msgid "``-t1``" msgstr "``-t1``" -#: ../../library/datetime.rst:353 +#: ../../library/datetime.rst:383 msgid "" -"Equivalent to ``timedelta(-t1.days, -t1.seconds*, -t1.microseconds)``, and " -"to ``t1 * -1``. (1)(4)" +"Equivalent to ``timedelta(-t1.days, -t1.seconds, -t1.microseconds)``, and to " +"``t1 * -1``. (1)(4)" msgstr "" +"等價於 ``timedelta(-t1.days, -t1.seconds, -t1.microseconds)``,也等價於 ``t1 " +"* -1``。 (1)(4)" -#: ../../library/datetime.rst:357 +#: ../../library/datetime.rst:387 msgid "``abs(t)``" msgstr "``abs(t)``" -#: ../../library/datetime.rst:357 +#: ../../library/datetime.rst:387 msgid "" "Equivalent to ``+t`` when ``t.days >= 0``, and to ``-t`` when ``t.days < " "0``. (2)" msgstr "" -#: ../../library/datetime.rst:360 +#: ../../library/datetime.rst:390 msgid "``str(t)``" msgstr "``str(t)``" -#: ../../library/datetime.rst:360 +#: ../../library/datetime.rst:390 msgid "" "Returns a string in the form ``[D day[s], ][H]H:MM:SS[.UUUUUU]``, where D is " "negative for negative ``t``. (5)" msgstr "" -#: ../../library/datetime.rst:364 +#: ../../library/datetime.rst:394 msgid "``repr(t)``" msgstr "``repr(t)``" -#: ../../library/datetime.rst:364 +#: ../../library/datetime.rst:394 msgid "" "Returns a string representation of the :class:`timedelta` object as a " "constructor call with canonical attribute values." msgstr "" -#: ../../library/datetime.rst:370 ../../library/datetime.rst:609 -#: ../../library/datetime.rst:2535 +#: ../../library/datetime.rst:400 ../../library/datetime.rst:639 +#: ../../library/datetime.rst:2616 msgid "Notes:" msgstr "註解:" -#: ../../library/datetime.rst:373 +#: ../../library/datetime.rst:403 msgid "This is exact but may overflow." msgstr "這是精確的,但可能會溢位。" -#: ../../library/datetime.rst:376 +#: ../../library/datetime.rst:406 msgid "This is exact and cannot overflow." msgstr "這是精確的,且不會溢位。" -#: ../../library/datetime.rst:379 +#: ../../library/datetime.rst:409 msgid "Division by zero raises :exc:`ZeroDivisionError`." msgstr "" -#: ../../library/datetime.rst:382 +#: ../../library/datetime.rst:412 msgid "``-timedelta.max`` is not representable as a :class:`timedelta` object." msgstr "" -#: ../../library/datetime.rst:385 +#: ../../library/datetime.rst:415 msgid "" "String representations of :class:`timedelta` objects are normalized " "similarly to their internal representation. This leads to somewhat unusual " "results for negative timedeltas. For example::" msgstr "" -#: ../../library/datetime.rst:389 +#: ../../library/datetime.rst:419 msgid "" ">>> timedelta(hours=-5)\n" "datetime.timedelta(days=-1, seconds=68400)\n" @@ -663,21 +709,21 @@ msgstr "" ">>> print(_)\n" "-1 day, 19:00:00" -#: ../../library/datetime.rst:395 +#: ../../library/datetime.rst:425 msgid "" "The expression ``t2 - t3`` will always be equal to the expression ``t2 + (-" "t3)`` except when t3 is equal to ``timedelta.max``; in that case the former " "will produce a result while the latter will overflow." msgstr "" -#: ../../library/datetime.rst:399 +#: ../../library/datetime.rst:429 msgid "" "In addition to the operations listed above, :class:`timedelta` objects " "support certain additions and subtractions with :class:`date` and :class:`." "datetime` objects (see below)." msgstr "" -#: ../../library/datetime.rst:403 +#: ../../library/datetime.rst:433 msgid "" "Floor division and true division of a :class:`timedelta` object by another :" "class:`timedelta` object are now supported, as are remainder operations and " @@ -685,43 +731,43 @@ msgid "" "`timedelta` object by a :class:`float` object are now supported." msgstr "" -#: ../../library/datetime.rst:409 +#: ../../library/datetime.rst:439 msgid ":class:`timedelta` objects support equality and order comparisons." msgstr "" -#: ../../library/datetime.rst:411 +#: ../../library/datetime.rst:441 msgid "" "In Boolean contexts, a :class:`timedelta` object is considered to be true if " "and only if it isn't equal to ``timedelta(0)``." msgstr "" -#: ../../library/datetime.rst:414 ../../library/datetime.rst:635 -#: ../../library/datetime.rst:1230 ../../library/datetime.rst:1829 +#: ../../library/datetime.rst:444 ../../library/datetime.rst:681 +#: ../../library/datetime.rst:1305 ../../library/datetime.rst:1907 msgid "Instance methods:" msgstr "實例方法:" -#: ../../library/datetime.rst:418 +#: ../../library/datetime.rst:448 msgid "" "Return the total number of seconds contained in the duration. Equivalent to " "``td / timedelta(seconds=1)``. For interval units other than seconds, use " "the division form directly (e.g. ``td / timedelta(microseconds=1)``)." msgstr "" -#: ../../library/datetime.rst:422 +#: ../../library/datetime.rst:452 msgid "" "Note that for very large time intervals (greater than 270 years on most " "platforms) this method will lose microsecond accuracy." msgstr "" -#: ../../library/datetime.rst:428 +#: ../../library/datetime.rst:458 msgid "Examples of usage: :class:`timedelta`" msgstr "用法範例::class:`timedelta`" -#: ../../library/datetime.rst:430 +#: ../../library/datetime.rst:460 msgid "An additional example of normalization::" msgstr "" -#: ../../library/datetime.rst:432 +#: ../../library/datetime.rst:462 msgid "" ">>> # Components of another_year add up to exactly 365 days\n" ">>> from datetime import timedelta\n" @@ -734,11 +780,11 @@ msgid "" "31536000.0" msgstr "" -#: ../../library/datetime.rst:442 +#: ../../library/datetime.rst:472 msgid "Examples of :class:`timedelta` arithmetic::" msgstr "" -#: ../../library/datetime.rst:444 +#: ../../library/datetime.rst:474 msgid "" ">>> from datetime import timedelta\n" ">>> year = timedelta(days=365)\n" @@ -768,65 +814,65 @@ msgstr "" ">>> three_years, three_years.days // 365\n" "(datetime.timedelta(days=1095), 3)" -#: ../../library/datetime.rst:461 +#: ../../library/datetime.rst:491 msgid ":class:`date` Objects" msgstr ":class:`date` 物件" -#: ../../library/datetime.rst:463 +#: ../../library/datetime.rst:493 msgid "" "A :class:`date` object represents a date (year, month and day) in an " "idealized calendar, the current Gregorian calendar indefinitely extended in " "both directions." msgstr "" -#: ../../library/datetime.rst:467 +#: ../../library/datetime.rst:497 msgid "" "January 1 of year 1 is called day number 1, January 2 of year 1 is called " "day number 2, and so on. [#]_" msgstr "" -#: ../../library/datetime.rst:472 +#: ../../library/datetime.rst:502 msgid "" "All arguments are required. Arguments must be integers, in the following " "ranges:" msgstr "" -#: ../../library/datetime.rst:475 +#: ../../library/datetime.rst:505 msgid "``MINYEAR <= year <= MAXYEAR``" msgstr "``MINYEAR <= year <= MAXYEAR``" -#: ../../library/datetime.rst:476 +#: ../../library/datetime.rst:506 msgid "``1 <= month <= 12``" msgstr "``1 <= month <= 12``" -#: ../../library/datetime.rst:477 +#: ../../library/datetime.rst:507 msgid "``1 <= day <= number of days in the given month and year``" msgstr "" -#: ../../library/datetime.rst:479 ../../library/datetime.rst:850 +#: ../../library/datetime.rst:509 ../../library/datetime.rst:899 msgid "" "If an argument outside those ranges is given, :exc:`ValueError` is raised." msgstr "" -#: ../../library/datetime.rst:482 ../../library/datetime.rst:855 +#: ../../library/datetime.rst:512 ../../library/datetime.rst:904 msgid "Other constructors, all class methods:" msgstr "" -#: ../../library/datetime.rst:486 +#: ../../library/datetime.rst:516 msgid "Return the current local date." msgstr "回傳目前的本地日期。" -#: ../../library/datetime.rst:488 +#: ../../library/datetime.rst:518 msgid "This is equivalent to ``date.fromtimestamp(time.time())``." msgstr "這等同於 ``date.fromtimestamp(time.time())``。" -#: ../../library/datetime.rst:492 +#: ../../library/datetime.rst:522 msgid "" "Return the local date corresponding to the POSIX timestamp, such as is " "returned by :func:`time.time`." msgstr "" -#: ../../library/datetime.rst:495 +#: ../../library/datetime.rst:525 msgid "" "This may raise :exc:`OverflowError`, if the timestamp is out of the range of " "values supported by the platform C :c:func:`localtime` function, and :exc:" @@ -836,7 +882,7 @@ msgid "" "ignored by :meth:`fromtimestamp`." msgstr "" -#: ../../library/datetime.rst:502 +#: ../../library/datetime.rst:532 msgid "" "Raise :exc:`OverflowError` instead of :exc:`ValueError` if the timestamp is " "out of the range of values supported by the platform C :c:func:`localtime` " @@ -844,45 +890,45 @@ msgid "" "`localtime` failure." msgstr "" -#: ../../library/datetime.rst:511 +#: ../../library/datetime.rst:541 msgid "" "Return the date corresponding to the proleptic Gregorian ordinal, where " "January 1 of year 1 has ordinal 1." msgstr "" -#: ../../library/datetime.rst:514 +#: ../../library/datetime.rst:544 msgid "" ":exc:`ValueError` is raised unless ``1 <= ordinal <= date.max.toordinal()``. " -"For any date *d*, ``date.fromordinal(d.toordinal()) == d``." +"For any date ``d``, ``date.fromordinal(d.toordinal()) == d``." msgstr "" -#: ../../library/datetime.rst:521 +#: ../../library/datetime.rst:551 msgid "" "Return a :class:`date` corresponding to a *date_string* given in any valid " "ISO 8601 format, with the following exceptions:" msgstr "" -#: ../../library/datetime.rst:524 ../../library/datetime.rst:1011 +#: ../../library/datetime.rst:554 ../../library/datetime.rst:1064 msgid "" "Reduced precision dates are not currently supported (``YYYY-MM``, ``YYYY``)." msgstr "" -#: ../../library/datetime.rst:526 ../../library/datetime.rst:1013 +#: ../../library/datetime.rst:556 ../../library/datetime.rst:1066 msgid "" "Extended date representations are not currently supported (``±YYYYYY-MM-" "DD``)." msgstr "" -#: ../../library/datetime.rst:528 ../../library/datetime.rst:1015 +#: ../../library/datetime.rst:558 ../../library/datetime.rst:1068 msgid "Ordinal dates are not currently supported (``YYYY-OOO``)." msgstr "" -#: ../../library/datetime.rst:530 ../../library/datetime.rst:1017 -#: ../../library/datetime.rst:1458 +#: ../../library/datetime.rst:560 ../../library/datetime.rst:1070 +#: ../../library/datetime.rst:1536 msgid "Examples::" msgstr "範例: ::" -#: ../../library/datetime.rst:532 +#: ../../library/datetime.rst:562 msgid "" ">>> from datetime import date\n" ">>> date.fromisoformat('2019-12-04')\n" @@ -900,64 +946,64 @@ msgstr "" ">>> date.fromisoformat('2021-W01-1')\n" "datetime.date(2021, 1, 4)" -#: ../../library/datetime.rst:541 +#: ../../library/datetime.rst:571 msgid "Previously, this method only supported the format ``YYYY-MM-DD``." msgstr "" -#: ../../library/datetime.rst:546 +#: ../../library/datetime.rst:576 msgid "" "Return a :class:`date` corresponding to the ISO calendar date specified by " "year, week and day. This is the inverse of the function :meth:`date." "isocalendar`." msgstr "" -#: ../../library/datetime.rst:556 +#: ../../library/datetime.rst:586 msgid "The earliest representable date, ``date(MINYEAR, 1, 1)``." msgstr "" -#: ../../library/datetime.rst:561 +#: ../../library/datetime.rst:591 msgid "The latest representable date, ``date(MAXYEAR, 12, 31)``." msgstr "" -#: ../../library/datetime.rst:566 +#: ../../library/datetime.rst:596 msgid "" "The smallest possible difference between non-equal date objects, " "``timedelta(days=1)``." msgstr "" -#: ../../library/datetime.rst:574 ../../library/datetime.rst:1095 +#: ../../library/datetime.rst:604 ../../library/datetime.rst:1166 msgid "Between :const:`MINYEAR` and :const:`MAXYEAR` inclusive." msgstr "" -#: ../../library/datetime.rst:579 ../../library/datetime.rst:1100 +#: ../../library/datetime.rst:609 ../../library/datetime.rst:1171 msgid "Between 1 and 12 inclusive." msgstr "在 1 到 12 (含)之間。" -#: ../../library/datetime.rst:584 ../../library/datetime.rst:1105 +#: ../../library/datetime.rst:614 ../../library/datetime.rst:1176 msgid "Between 1 and the number of days in the given month of the given year." msgstr "" -#: ../../library/datetime.rst:592 +#: ../../library/datetime.rst:622 msgid "``date2 = date1 + timedelta``" msgstr "``date2 = date1 + timedelta``" -#: ../../library/datetime.rst:592 +#: ../../library/datetime.rst:622 msgid "``date2`` will be ``timedelta.days`` days after ``date1``. (1)" msgstr "" -#: ../../library/datetime.rst:595 +#: ../../library/datetime.rst:625 msgid "``date2 = date1 - timedelta``" msgstr "``date2 = date1 - timedelta``" -#: ../../library/datetime.rst:595 +#: ../../library/datetime.rst:625 msgid "Computes ``date2`` such that ``date2 + timedelta == date1``. (2)" msgstr "" -#: ../../library/datetime.rst:598 +#: ../../library/datetime.rst:628 msgid "``timedelta = date1 - date2``" msgstr "``timedelta = date1 - date2``" -#: ../../library/datetime.rst:598 ../../library/datetime.rst:1153 +#: ../../library/datetime.rst:628 ../../library/datetime.rst:1224 msgid "\\(3)" msgstr "\\(3)" @@ -969,7 +1015,7 @@ msgstr "``date1 == date2``" msgid "``date1 != date2``" msgstr "``date1 != date2``" -#: ../../library/datetime.rst:600 ../../library/datetime.rst:1155 +#: ../../library/datetime.rst:630 ../../library/datetime.rst:1226 msgid "Equality comparison. (4)" msgstr "" @@ -989,11 +1035,11 @@ msgstr "``date1 <= date2``" msgid "``date1 >= date2``" msgstr "``date1 >= date2``" -#: ../../library/datetime.rst:603 ../../library/datetime.rst:1158 +#: ../../library/datetime.rst:633 ../../library/datetime.rst:1229 msgid "Order comparison. (5)" msgstr "" -#: ../../library/datetime.rst:612 +#: ../../library/datetime.rst:642 msgid "" "*date2* is moved forward in time if ``timedelta.days > 0``, or backward if " "``timedelta.days < 0``. Afterward ``date2 - date1 == timedelta.days``. " @@ -1002,43 +1048,65 @@ msgid "" "`MINYEAR` or larger than :const:`MAXYEAR`." msgstr "" -#: ../../library/datetime.rst:619 +#: ../../library/datetime.rst:649 msgid "``timedelta.seconds`` and ``timedelta.microseconds`` are ignored." msgstr "``timedelta.seconds`` 和 ``timedelta.microseconds`` 被忽略。" -#: ../../library/datetime.rst:622 +#: ../../library/datetime.rst:652 msgid "" "This is exact, and cannot overflow. ``timedelta.seconds`` and ``timedelta." "microseconds`` are 0, and ``date2 + timedelta == date1`` after." msgstr "" -#: ../../library/datetime.rst:626 +#: ../../library/datetime.rst:656 msgid ":class:`date` objects are equal if they represent the same date." msgstr "" -#: ../../library/datetime.rst:629 +#: ../../library/datetime.rst:658 +msgid "" +":class:`!date` objects that are not also :class:`.datetime` instances are " +"never equal to :class:`!datetime` objects, even if they represent the same " +"date." +msgstr "" + +#: ../../library/datetime.rst:663 msgid "" "*date1* is considered less than *date2* when *date1* precedes *date2* in " "time. In other words, ``date1 < date2`` if and only if ``date1.toordinal() < " "date2.toordinal()``." msgstr "" -#: ../../library/datetime.rst:633 +#: ../../library/datetime.rst:667 +msgid "" +"Order comparison between a :class:`!date` object that is not also a :class:`." +"datetime` instance and a :class:`!datetime` object raises :exc:`TypeError`." +msgstr "" + +#: ../../library/datetime.rst:671 ../../library/datetime.rst:1297 +msgid "" +"Comparison between :class:`.datetime` object and an instance of the :class:" +"`date` subclass that is not a :class:`!datetime` subclass no longer converts " +"the latter to :class:`!date`, ignoring the time part and the time zone. The " +"default behavior can be changed by overriding the special comparison methods " +"in subclasses." +msgstr "" + +#: ../../library/datetime.rst:679 msgid "" "In Boolean contexts, all :class:`date` objects are considered to be true." msgstr "" -#: ../../library/datetime.rst:639 +#: ../../library/datetime.rst:685 msgid "" -"Return a date with the same value, except for those parameters given new " -"values by whichever keyword arguments are specified." +"Return a new :class:`date` object with the same values, but with specified " +"parameters updated." msgstr "" -#: ../../library/datetime.rst:642 ../../library/datetime.rst:1872 +#: ../../library/datetime.rst:688 ../../library/datetime.rst:1953 msgid "Example::" msgstr "範例: ::" -#: ../../library/datetime.rst:644 +#: ../../library/datetime.rst:690 msgid "" ">>> from datetime import date\n" ">>> d = date(2002, 12, 31)\n" @@ -1050,41 +1118,47 @@ msgstr "" ">>> d.replace(day=26)\n" "datetime.date(2002, 12, 26)" -#: ../../library/datetime.rst:652 ../../library/datetime.rst:1343 +#: ../../library/datetime.rst:695 +msgid "" +"The generic function :func:`copy.replace` also supports :class:`date` " +"objects." +msgstr "" + +#: ../../library/datetime.rst:701 ../../library/datetime.rst:1421 msgid "" "Return a :class:`time.struct_time` such as returned by :func:`time." "localtime`." msgstr "" "回傳一個 :class:`time.struct_time`,如同 :func:`time.localtime` 所回傳。" -#: ../../library/datetime.rst:654 +#: ../../library/datetime.rst:703 msgid "The hours, minutes and seconds are 0, and the DST flag is -1." msgstr "" -#: ../../library/datetime.rst:656 ../../library/datetime.rst:1345 +#: ../../library/datetime.rst:705 ../../library/datetime.rst:1423 msgid "``d.timetuple()`` is equivalent to::" msgstr "``d.timetuple()`` 等價於: ::" -#: ../../library/datetime.rst:658 +#: ../../library/datetime.rst:707 msgid "" "time.struct_time((d.year, d.month, d.day, 0, 0, 0, d.weekday(), yday, -1))" msgstr "" "time.struct_time((d.year, d.month, d.day, 0, 0, 0, d.weekday(), yday, -1))" -#: ../../library/datetime.rst:660 +#: ../../library/datetime.rst:709 msgid "" "where ``yday = d.toordinal() - date(d.year, 1, 1).toordinal() + 1`` is the " "day number within the current year starting with 1 for January 1st." msgstr "" -#: ../../library/datetime.rst:666 +#: ../../library/datetime.rst:715 msgid "" "Return the proleptic Gregorian ordinal of the date, where January 1 of year " -"1 has ordinal 1. For any :class:`date` object *d*, ``date.fromordinal(d." +"1 has ordinal 1. For any :class:`date` object ``d``, ``date.fromordinal(d." "toordinal()) == d``." msgstr "" -#: ../../library/datetime.rst:673 +#: ../../library/datetime.rst:722 msgid "" "Return the day of the week as an integer, where Monday is 0 and Sunday is 6. " "For example, ``date(2002, 12, 4).weekday() == 2``, a Wednesday. See also :" @@ -1093,25 +1167,25 @@ msgstr "" "回傳一個代表星期幾的整數,星期一為 0、星期日為 6。例如 ``date(2002, 12, 4)." "weekday() == 2`` 為星期三。也請參考 :meth:`isoweekday`。" -#: ../../library/datetime.rst:680 +#: ../../library/datetime.rst:729 msgid "" "Return the day of the week as an integer, where Monday is 1 and Sunday is 7. " "For example, ``date(2002, 12, 4).isoweekday() == 3``, a Wednesday. See also :" "meth:`weekday`, :meth:`isocalendar`." msgstr "" -#: ../../library/datetime.rst:687 +#: ../../library/datetime.rst:736 msgid "" "Return a :term:`named tuple` object with three components: ``year``, " "``week`` and ``weekday``." msgstr "" -#: ../../library/datetime.rst:690 +#: ../../library/datetime.rst:739 msgid "" "The ISO calendar is a widely used variant of the Gregorian calendar. [#]_" msgstr "" -#: ../../library/datetime.rst:692 +#: ../../library/datetime.rst:741 msgid "" "The ISO year consists of 52 or 53 full weeks, and where a week starts on a " "Monday and ends on a Sunday. The first week of an ISO year is the first " @@ -1120,13 +1194,13 @@ msgid "" "Gregorian year." msgstr "" -#: ../../library/datetime.rst:697 +#: ../../library/datetime.rst:746 msgid "" "For example, 2004 begins on a Thursday, so the first week of ISO year 2004 " "begins on Monday, 29 Dec 2003 and ends on Sunday, 4 Jan 2004::" msgstr "" -#: ../../library/datetime.rst:700 +#: ../../library/datetime.rst:749 msgid "" ">>> from datetime import date\n" ">>> date(2003, 12, 29).isocalendar()\n" @@ -1140,16 +1214,16 @@ msgstr "" ">>> date(2004, 1, 4).isocalendar()\n" "datetime.IsoCalendarDate(year=2004, week=1, weekday=7)" -#: ../../library/datetime.rst:706 +#: ../../library/datetime.rst:755 msgid "Result changed from a tuple to a :term:`named tuple`." msgstr "" -#: ../../library/datetime.rst:711 +#: ../../library/datetime.rst:760 msgid "" "Return a string representing the date in ISO 8601 format, ``YYYY-MM-DD``::" msgstr "回傳一以 ISO 8601 格式 ``YYYY-MM-DD`` 表示的日期字串: ::" -#: ../../library/datetime.rst:713 +#: ../../library/datetime.rst:762 msgid "" ">>> from datetime import date\n" ">>> date(2002, 12, 4).isoformat()\n" @@ -1159,15 +1233,15 @@ msgstr "" ">>> date(2002, 12, 4).isoformat()\n" "'2002-12-04'" -#: ../../library/datetime.rst:719 -msgid "For a date *d*, ``str(d)`` is equivalent to ``d.isoformat()``." +#: ../../library/datetime.rst:768 +msgid "For a date ``d``, ``str(d)`` is equivalent to ``d.isoformat()``." msgstr "" -#: ../../library/datetime.rst:724 +#: ../../library/datetime.rst:773 msgid "Return a string representing the date::" msgstr "" -#: ../../library/datetime.rst:726 +#: ../../library/datetime.rst:775 msgid "" ">>> from datetime import date\n" ">>> date(2002, 12, 4).ctime()\n" @@ -1177,22 +1251,22 @@ msgstr "" ">>> date(2002, 12, 4).ctime()\n" "'Wed Dec 4 00:00:00 2002'" -#: ../../library/datetime.rst:730 ../../library/datetime.rst:1529 +#: ../../library/datetime.rst:779 ../../library/datetime.rst:1607 msgid "``d.ctime()`` is equivalent to::" msgstr "``d.ctime()`` 等價於: ::" -#: ../../library/datetime.rst:732 ../../library/datetime.rst:1531 +#: ../../library/datetime.rst:781 ../../library/datetime.rst:1609 msgid "time.ctime(time.mktime(d.timetuple()))" msgstr "time.ctime(time.mktime(d.timetuple()))" -#: ../../library/datetime.rst:734 +#: ../../library/datetime.rst:783 msgid "" "on platforms where the native C :c:func:`ctime` function (which :func:`time." "ctime` invokes, but which :meth:`date.ctime` does not invoke) conforms to " "the C standard." msgstr "" -#: ../../library/datetime.rst:741 +#: ../../library/datetime.rst:790 msgid "" "Return a string representing the date, controlled by an explicit format " "string. Format codes referring to hours, minutes or seconds will see 0 " @@ -1200,7 +1274,7 @@ msgid "" "isoformat`." msgstr "" -#: ../../library/datetime.rst:748 +#: ../../library/datetime.rst:797 msgid "" "Same as :meth:`.date.strftime`. This makes it possible to specify a format " "string for a :class:`.date` object in :ref:`formatted string literals >> import time\n" ">>> from datetime import date\n" @@ -1252,11 +1326,11 @@ msgstr "" ">>> time_to_birthday.days\n" "202" -#: ../../library/datetime.rst:775 +#: ../../library/datetime.rst:824 msgid "More examples of working with :class:`date`:" msgstr "更多 :class:`date` 的用法範例:" -#: ../../library/datetime.rst:777 +#: ../../library/datetime.rst:826 msgid "" ">>> from datetime import date\n" ">>> d = date.fromordinal(730920) # 730920th day after 1. 1. 0001\n" @@ -1277,7 +1351,7 @@ msgid "" "\n" ">>> # Methods for to extracting 'components' under different calendars\n" ">>> t = d.timetuple()\n" -">>> for i in t: \n" +">>> for i in t:\n" "... print(i)\n" "2002 # year\n" "3 # month\n" @@ -1289,7 +1363,7 @@ msgid "" "70 # 70th day in the year\n" "-1\n" ">>> ic = d.isocalendar()\n" -">>> for i in ic: \n" +">>> for i in ic:\n" "... print(i)\n" "2002 # ISO year\n" "11 # ISO week number\n" @@ -1300,17 +1374,17 @@ msgid "" "datetime.date(2005, 3, 11)" msgstr "" -#: ../../library/datetime.rst:824 +#: ../../library/datetime.rst:873 msgid ":class:`.datetime` Objects" msgstr ":class:`.datetime` 物件" -#: ../../library/datetime.rst:826 +#: ../../library/datetime.rst:875 msgid "" "A :class:`.datetime` object is a single object containing all the " "information from a :class:`date` object and a :class:`.time` object." msgstr "" -#: ../../library/datetime.rst:829 +#: ../../library/datetime.rst:878 msgid "" "Like a :class:`date` object, :class:`.datetime` assumes the current " "Gregorian calendar extended in both directions; like a :class:`.time` " @@ -1318,81 +1392,81 @@ msgid "" "every day." msgstr "" -#: ../../library/datetime.rst:833 +#: ../../library/datetime.rst:882 msgid "Constructor:" -msgstr "" +msgstr "建構函式:" -#: ../../library/datetime.rst:837 +#: ../../library/datetime.rst:886 msgid "" "The *year*, *month* and *day* arguments are required. *tzinfo* may be " "``None``, or an instance of a :class:`tzinfo` subclass. The remaining " "arguments must be integers in the following ranges:" msgstr "" -#: ../../library/datetime.rst:841 +#: ../../library/datetime.rst:890 msgid "``MINYEAR <= year <= MAXYEAR``," msgstr "``MINYEAR <= year <= MAXYEAR``," -#: ../../library/datetime.rst:842 +#: ../../library/datetime.rst:891 msgid "``1 <= month <= 12``," msgstr "``1 <= month <= 12``," -#: ../../library/datetime.rst:843 +#: ../../library/datetime.rst:892 msgid "``1 <= day <= number of days in the given month and year``," msgstr "" -#: ../../library/datetime.rst:844 ../../library/datetime.rst:1693 +#: ../../library/datetime.rst:893 ../../library/datetime.rst:1771 msgid "``0 <= hour < 24``," msgstr "``0 <= hour < 24``," -#: ../../library/datetime.rst:845 ../../library/datetime.rst:1694 +#: ../../library/datetime.rst:894 ../../library/datetime.rst:1772 msgid "``0 <= minute < 60``," msgstr "``0 <= minute < 60``," -#: ../../library/datetime.rst:846 ../../library/datetime.rst:1695 +#: ../../library/datetime.rst:895 ../../library/datetime.rst:1773 msgid "``0 <= second < 60``," msgstr "``0 <= second < 60``," -#: ../../library/datetime.rst:847 ../../library/datetime.rst:1696 +#: ../../library/datetime.rst:896 ../../library/datetime.rst:1774 msgid "``0 <= microsecond < 1000000``," msgstr "``0 <= microsecond < 1000000``," -#: ../../library/datetime.rst:848 ../../library/datetime.rst:1697 +#: ../../library/datetime.rst:897 ../../library/datetime.rst:1775 msgid "``fold in [0, 1]``." -msgstr "" +msgstr "``fold in [0, 1]``。" -#: ../../library/datetime.rst:852 ../../library/datetime.rst:1264 -#: ../../library/datetime.rst:1839 +#: ../../library/datetime.rst:901 ../../library/datetime.rst:1342 +#: ../../library/datetime.rst:1920 msgid "Added the *fold* parameter." msgstr "新增 *fold* 參數。" -#: ../../library/datetime.rst:859 +#: ../../library/datetime.rst:908 msgid "Return the current local date and time, with :attr:`.tzinfo` ``None``." msgstr "回傳目前的本地日期與時間,且 :attr:`.tzinfo` 為 ``None``。" -#: ../../library/datetime.rst:861 +#: ../../library/datetime.rst:910 msgid "Equivalent to::" msgstr "等價於: ::" -#: ../../library/datetime.rst:863 +#: ../../library/datetime.rst:912 msgid "datetime.fromtimestamp(time.time())" msgstr "datetime.fromtimestamp(time.time())" -#: ../../library/datetime.rst:865 +#: ../../library/datetime.rst:914 msgid "See also :meth:`now`, :meth:`fromtimestamp`." msgstr "也請見 :meth:`now`、:meth:`fromtimestamp`。" -#: ../../library/datetime.rst:867 +#: ../../library/datetime.rst:916 msgid "" "This method is functionally equivalent to :meth:`now`, but without a ``tz`` " "parameter." msgstr "" -#: ../../library/datetime.rst:872 +#: ../../library/datetime.rst:921 msgid "Return the current local date and time." msgstr "" -#: ../../library/datetime.rst:874 +#: ../../library/datetime.rst:923 msgid "" "If optional argument *tz* is ``None`` or not specified, this is like :meth:" "`today`, but, if possible, supplies more precision than can be gotten from " @@ -1403,28 +1477,34 @@ msgstr "" "供比透過 :func:`time.time` 取得的時間戳記更多位數的資訊(例如,這在有提供 C :" "c:func:`gettimeofday` 函式的平台上可能可行)。" -#: ../../library/datetime.rst:880 +#: ../../library/datetime.rst:929 msgid "" "If *tz* is not ``None``, it must be an instance of a :class:`tzinfo` " "subclass, and the current date and time are converted to *tz*’s time zone." msgstr "" -#: ../../library/datetime.rst:883 +#: ../../library/datetime.rst:932 msgid "This function is preferred over :meth:`today` and :meth:`utcnow`." msgstr "" -#: ../../library/datetime.rst:888 +#: ../../library/datetime.rst:936 +msgid "" +"Subsequent calls to :meth:`!datetime.now` may return the same instant " +"depending on the precision of the underlying clock." +msgstr "" + +#: ../../library/datetime.rst:941 msgid "Return the current UTC date and time, with :attr:`.tzinfo` ``None``." msgstr "" -#: ../../library/datetime.rst:890 +#: ../../library/datetime.rst:943 msgid "" "This is like :meth:`now`, but returns the current UTC date and time, as a " "naive :class:`.datetime` object. An aware current UTC datetime can be " "obtained by calling ``datetime.now(timezone.utc)``. See also :meth:`now`." msgstr "" -#: ../../library/datetime.rst:896 +#: ../../library/datetime.rst:949 msgid "" "Because naive ``datetime`` objects are treated by many ``datetime`` methods " "as local times, it is preferred to use aware datetimes to represent times in " @@ -1432,11 +1512,11 @@ msgid "" "current time in UTC is by calling ``datetime.now(timezone.utc)``." msgstr "" -#: ../../library/datetime.rst:903 -msgid "Use :meth:`datetime.now` with :attr:`UTC` instead." +#: ../../library/datetime.rst:956 +msgid "Use :meth:`datetime.now` with :const:`UTC` instead." msgstr "" -#: ../../library/datetime.rst:908 +#: ../../library/datetime.rst:961 msgid "" "Return the local date and time corresponding to the POSIX timestamp, such as " "is returned by :func:`time.time`. If optional argument *tz* is ``None`` or " @@ -1444,13 +1524,13 @@ msgid "" "time, and the returned :class:`.datetime` object is naive." msgstr "" -#: ../../library/datetime.rst:913 +#: ../../library/datetime.rst:966 msgid "" "If *tz* is not ``None``, it must be an instance of a :class:`tzinfo` " "subclass, and the timestamp is converted to *tz*’s time zone." msgstr "" -#: ../../library/datetime.rst:916 +#: ../../library/datetime.rst:969 msgid "" ":meth:`fromtimestamp` may raise :exc:`OverflowError`, if the timestamp is " "out of the range of values supported by the platform C :c:func:`localtime` " @@ -1463,7 +1543,7 @@ msgid "" "preferred over :meth:`utcfromtimestamp`." msgstr "" -#: ../../library/datetime.rst:927 +#: ../../library/datetime.rst:980 msgid "" "Raise :exc:`OverflowError` instead of :exc:`ValueError` if the timestamp is " "out of the range of values supported by the platform C :c:func:`localtime` " @@ -1471,17 +1551,17 @@ msgid "" "`ValueError` on :c:func:`localtime` or :c:func:`gmtime` failure." msgstr "" -#: ../../library/datetime.rst:934 +#: ../../library/datetime.rst:987 msgid ":meth:`fromtimestamp` may return instances with :attr:`.fold` set to 1." msgstr "" -#: ../../library/datetime.rst:939 +#: ../../library/datetime.rst:992 msgid "" "Return the UTC :class:`.datetime` corresponding to the POSIX timestamp, " "with :attr:`.tzinfo` ``None``. (The resulting object is naive.)" msgstr "" -#: ../../library/datetime.rst:942 +#: ../../library/datetime.rst:995 msgid "" "This may raise :exc:`OverflowError`, if the timestamp is out of the range of " "values supported by the platform C :c:func:`gmtime` function, and :exc:" @@ -1489,33 +1569,33 @@ msgid "" "to years in 1970 through 2038." msgstr "" -#: ../../library/datetime.rst:947 +#: ../../library/datetime.rst:1000 msgid "To get an aware :class:`.datetime` object, call :meth:`fromtimestamp`::" msgstr "" -#: ../../library/datetime.rst:949 +#: ../../library/datetime.rst:1002 msgid "datetime.fromtimestamp(timestamp, timezone.utc)" msgstr "datetime.fromtimestamp(timestamp, timezone.utc)" -#: ../../library/datetime.rst:951 +#: ../../library/datetime.rst:1004 msgid "" "On the POSIX compliant platforms, it is equivalent to the following " "expression::" msgstr "" -#: ../../library/datetime.rst:954 +#: ../../library/datetime.rst:1007 msgid "" "datetime(1970, 1, 1, tzinfo=timezone.utc) + timedelta(seconds=timestamp)" msgstr "" "datetime(1970, 1, 1, tzinfo=timezone.utc) + timedelta(seconds=timestamp)" -#: ../../library/datetime.rst:956 +#: ../../library/datetime.rst:1009 msgid "" "except the latter formula always supports the full years range: between :" "const:`MINYEAR` and :const:`MAXYEAR` inclusive." msgstr "" -#: ../../library/datetime.rst:961 +#: ../../library/datetime.rst:1014 msgid "" "Because naive ``datetime`` objects are treated by many ``datetime`` methods " "as local times, it is preferred to use aware datetimes to represent times in " @@ -1524,7 +1604,7 @@ msgid "" "tz=timezone.utc)``." msgstr "" -#: ../../library/datetime.rst:967 +#: ../../library/datetime.rst:1020 msgid "" "Raise :exc:`OverflowError` instead of :exc:`ValueError` if the timestamp is " "out of the range of values supported by the platform C :c:func:`gmtime` " @@ -1532,11 +1612,11 @@ msgid "" "`gmtime` failure." msgstr "" -#: ../../library/datetime.rst:975 -msgid "Use :meth:`datetime.fromtimestamp` with :attr:`UTC` instead." +#: ../../library/datetime.rst:1028 +msgid "Use :meth:`datetime.fromtimestamp` with :const:`UTC` instead." msgstr "" -#: ../../library/datetime.rst:980 +#: ../../library/datetime.rst:1033 msgid "" "Return the :class:`.datetime` corresponding to the proleptic Gregorian " "ordinal, where January 1 of year 1 has ordinal 1. :exc:`ValueError` is " @@ -1545,7 +1625,7 @@ msgid "" "is ``None``." msgstr "" -#: ../../library/datetime.rst:988 +#: ../../library/datetime.rst:1041 msgid "" "Return a new :class:`.datetime` object whose date components are equal to " "the given :class:`date` object's, and whose time components are equal to the " @@ -1556,35 +1636,35 @@ msgid "" "attr:`.tzinfo` attributes are ignored." msgstr "" -#: ../../library/datetime.rst:996 +#: ../../library/datetime.rst:1049 msgid "" -"For any :class:`.datetime` object *d*, ``d == datetime.combine(d.date(), d." +"For any :class:`.datetime` object ``d``, ``d == datetime.combine(d.date(), d." "time(), d.tzinfo)``." msgstr "" -#: ../../library/datetime.rst:999 +#: ../../library/datetime.rst:1052 msgid "Added the *tzinfo* argument." msgstr "新增 *tzinfo* 引數。" -#: ../../library/datetime.rst:1005 +#: ../../library/datetime.rst:1058 msgid "" "Return a :class:`.datetime` corresponding to a *date_string* in any valid " "ISO 8601 format, with the following exceptions:" msgstr "" -#: ../../library/datetime.rst:1008 ../../library/datetime.rst:1793 +#: ../../library/datetime.rst:1061 ../../library/datetime.rst:1871 msgid "Time zone offsets may have fractional seconds." msgstr "" -#: ../../library/datetime.rst:1009 +#: ../../library/datetime.rst:1062 msgid "The ``T`` separator may be replaced by any single unicode character." msgstr "" -#: ../../library/datetime.rst:1010 ../../library/datetime.rst:1798 +#: ../../library/datetime.rst:1063 ../../library/datetime.rst:1876 msgid "Fractional hours and minutes are not supported." msgstr "" -#: ../../library/datetime.rst:1019 +#: ../../library/datetime.rst:1072 msgid "" ">>> from datetime import datetime\n" ">>> datetime.fromisoformat('2011-11-04')\n" @@ -1604,7 +1684,7 @@ msgid "" ">>> datetime.fromisoformat('2011-11-04 00:05:23.283+00:00')\n" "datetime.datetime(2011, 11, 4, 0, 5, 23, 283000, tzinfo=datetime.timezone." "utc)\n" -">>> datetime.fromisoformat('2011-11-04T00:05:23+04:00') \n" +">>> datetime.fromisoformat('2011-11-04T00:05:23+04:00')\n" "datetime.datetime(2011, 11, 4, 0, 5, 23,\n" " tzinfo=datetime.timezone(datetime.timedelta(seconds=14400)))" msgstr "" @@ -1626,17 +1706,17 @@ msgstr "" ">>> datetime.fromisoformat('2011-11-04 00:05:23.283+00:00')\n" "datetime.datetime(2011, 11, 4, 0, 5, 23, 283000, tzinfo=datetime.timezone." "utc)\n" -">>> datetime.fromisoformat('2011-11-04T00:05:23+04:00') \n" +">>> datetime.fromisoformat('2011-11-04T00:05:23+04:00')\n" "datetime.datetime(2011, 11, 4, 0, 5, 23,\n" " tzinfo=datetime.timezone(datetime.timedelta(seconds=14400)))" -#: ../../library/datetime.rst:1041 +#: ../../library/datetime.rst:1094 msgid "" "Previously, this method only supported formats that could be emitted by :" "meth:`date.isoformat` or :meth:`datetime.isoformat`." msgstr "" -#: ../../library/datetime.rst:1048 +#: ../../library/datetime.rst:1101 msgid "" "Return a :class:`.datetime` corresponding to the ISO calendar date specified " "by year, week and day. The non-date components of the datetime are populated " @@ -1644,23 +1724,23 @@ msgid "" "`datetime.isocalendar`." msgstr "" -#: ../../library/datetime.rst:1057 +#: ../../library/datetime.rst:1110 msgid "" "Return a :class:`.datetime` corresponding to *date_string*, parsed according " "to *format*." msgstr "" -#: ../../library/datetime.rst:1060 +#: ../../library/datetime.rst:1113 msgid "" "If *format* does not contain microseconds or time zone information, this is " "equivalent to::" msgstr "" -#: ../../library/datetime.rst:1062 ../../library/datetime.rst:2515 +#: ../../library/datetime.rst:1115 ../../library/datetime.rst:2596 msgid "datetime(*(time.strptime(date_string, format)[0:6]))" msgstr "datetime(*(time.strptime(date_string, format)[0:6]))" -#: ../../library/datetime.rst:1064 +#: ../../library/datetime.rst:1117 msgid "" ":exc:`ValueError` is raised if the date_string and format can't be parsed " "by :func:`time.strptime` or if it returns a value which isn't a time tuple. " @@ -1668,44 +1748,65 @@ msgid "" "fromisoformat`." msgstr "" -#: ../../library/datetime.rst:1075 +#: ../../library/datetime.rst:1124 +msgid "" +"If *format* specifies a day of month without a year a :exc:" +"`DeprecationWarning` 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:" +msgstr "" + +#: ../../library/datetime.rst:1133 +msgid "" +">>> from datetime import datetime\n" +">>> date_string = \"02/29\"\n" +">>> when = datetime.strptime(f\"{date_string};1984\", \"%m/%d;%Y\") # " +"Avoids leap year bug.\n" +">>> when.strftime(\"%B %d\")\n" +"'February 29'" +msgstr "" + +#: ../../library/datetime.rst:1146 msgid "" "The earliest representable :class:`.datetime`, ``datetime(MINYEAR, 1, 1, " "tzinfo=None)``." msgstr "" -#: ../../library/datetime.rst:1081 +#: ../../library/datetime.rst:1152 msgid "" "The latest representable :class:`.datetime`, ``datetime(MAXYEAR, 12, 31, 23, " "59, 59, 999999, tzinfo=None)``." msgstr "" -#: ../../library/datetime.rst:1087 +#: ../../library/datetime.rst:1158 msgid "" "The smallest possible difference between non-equal :class:`.datetime` " "objects, ``timedelta(microseconds=1)``." msgstr "" -#: ../../library/datetime.rst:1110 ../../library/datetime.rst:1726 +#: ../../library/datetime.rst:1181 ../../library/datetime.rst:1804 msgid "In ``range(24)``." msgstr "" -#: ../../library/datetime.rst:1115 ../../library/datetime.rst:1120 -#: ../../library/datetime.rst:1731 ../../library/datetime.rst:1736 +#: ../../library/datetime.rst:1186 ../../library/datetime.rst:1191 +#: ../../library/datetime.rst:1809 ../../library/datetime.rst:1814 msgid "In ``range(60)``." msgstr "" -#: ../../library/datetime.rst:1125 ../../library/datetime.rst:1741 +#: ../../library/datetime.rst:1196 ../../library/datetime.rst:1819 msgid "In ``range(1000000)``." msgstr "" -#: ../../library/datetime.rst:1130 +#: ../../library/datetime.rst:1201 msgid "" "The object passed as the *tzinfo* argument to the :class:`.datetime` " "constructor, or ``None`` if none was passed." msgstr "" -#: ../../library/datetime.rst:1136 ../../library/datetime.rst:1752 +#: ../../library/datetime.rst:1207 ../../library/datetime.rst:1830 msgid "" "In ``[0, 1]``. Used to disambiguate wall times during a repeated interval. " "(A repeated interval occurs when clocks are rolled back at the end of " @@ -1715,26 +1816,26 @@ msgid "" "time representation." msgstr "" -#: ../../library/datetime.rst:1149 +#: ../../library/datetime.rst:1220 msgid "``datetime2 = datetime1 + timedelta``" msgstr "``datetime2 = datetime1 + timedelta``" -#: ../../library/datetime.rst:1149 ../../library/datetime.rst:2362 -#: ../../library/datetime.rst:2367 ../../library/datetime.rst:2379 -#: ../../library/datetime.rst:2384 ../../library/datetime.rst:2444 -#: ../../library/datetime.rst:2449 ../../library/datetime.rst:2453 +#: ../../library/datetime.rst:1220 ../../library/datetime.rst:2443 +#: ../../library/datetime.rst:2448 ../../library/datetime.rst:2460 +#: ../../library/datetime.rst:2465 ../../library/datetime.rst:2525 +#: ../../library/datetime.rst:2530 ../../library/datetime.rst:2534 msgid "\\(1)" msgstr "\\(1)" -#: ../../library/datetime.rst:1151 +#: ../../library/datetime.rst:1222 msgid "``datetime2 = datetime1 - timedelta``" msgstr "``datetime2 = datetime1 - timedelta``" -#: ../../library/datetime.rst:1151 ../../library/datetime.rst:2395 +#: ../../library/datetime.rst:1222 ../../library/datetime.rst:2476 msgid "\\(2)" msgstr "\\(2)" -#: ../../library/datetime.rst:1153 +#: ../../library/datetime.rst:1224 msgid "``timedelta = datetime1 - datetime2``" msgstr "``timedelta = datetime1 - datetime2``" @@ -1762,7 +1863,7 @@ msgstr "``datetime1 <= datetime2``" msgid "``datetime1 >= datetime2``" msgstr "``datetime1 >= datetime2``" -#: ../../library/datetime.rst:1165 +#: ../../library/datetime.rst:1236 msgid "" "``datetime2`` is a duration of ``timedelta`` removed from ``datetime1``, " "moving forward in time if ``timedelta.days > 0``, or backward if ``timedelta." @@ -1773,7 +1874,7 @@ msgid "" "adjustments are done even if the input is an aware object." msgstr "" -#: ../../library/datetime.rst:1174 +#: ../../library/datetime.rst:1245 msgid "" "Computes the ``datetime2`` such that ``datetime2 + timedelta == datetime1``. " "As for addition, the result has the same :attr:`~.datetime.tzinfo` attribute " @@ -1781,44 +1882,41 @@ msgid "" "input is aware." msgstr "" -#: ../../library/datetime.rst:1179 +#: ../../library/datetime.rst:1250 msgid "" "Subtraction of a :class:`.datetime` from a :class:`.datetime` is defined " "only if both operands are naive, or if both are aware. If one is aware and " "the other is naive, :exc:`TypeError` is raised." msgstr "" -#: ../../library/datetime.rst:1183 +#: ../../library/datetime.rst:1254 msgid "" "If both are naive, or both are aware and have the same :attr:`~.datetime." "tzinfo` attribute, the :attr:`~.datetime.tzinfo` attributes are ignored, and " -"the result is a :class:`timedelta` object *t* such that ``datetime2 + t == " +"the result is a :class:`timedelta` object ``t`` such that ``datetime2 + t == " "datetime1``. No time zone adjustments are done in this case." msgstr "" -#: ../../library/datetime.rst:1188 +#: ../../library/datetime.rst:1259 msgid "" "If both are aware and have different :attr:`~.datetime.tzinfo` attributes, " -"``a-b`` acts as if *a* and *b* were first converted to naive UTC datetimes. " -"The result is ``(a.replace(tzinfo=None) - a.utcoffset()) - (b." +"``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." msgstr "" -#: ../../library/datetime.rst:1194 +#: ../../library/datetime.rst:1265 msgid "" ":class:`.datetime` objects are equal if they represent the same date and " "time, taking into account the time zone." msgstr "" -#: ../../library/datetime.rst:1197 -msgid "" -"Naive and aware :class:`!datetime` objects are never equal. :class:`!" -"datetime` objects are never equal to :class:`date` objects that are not " -"also :class:`!datetime` instances, even if they represent the same date." +#: ../../library/datetime.rst:1268 +msgid "Naive and aware :class:`!datetime` objects are never equal." msgstr "" -#: ../../library/datetime.rst:1202 +#: ../../library/datetime.rst:1270 msgid "" "If both comparands are aware, and have the same :attr:`!tzinfo` attribute, " "the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and " @@ -1829,20 +1927,19 @@ msgid "" "interval are never equal to :class:`!datetime` instances in other time zone." msgstr "" -#: ../../library/datetime.rst:1212 +#: ../../library/datetime.rst:1280 msgid "" "*datetime1* is considered less than *datetime2* when *datetime1* precedes " "*datetime2* in time, taking into account the time zone." msgstr "" -#: ../../library/datetime.rst:1215 +#: ../../library/datetime.rst:1283 msgid "" -"Order comparison between naive and aware :class:`.datetime` objects, as well " -"as a :class:`!datetime` object and a :class:`!date` object that is not also " -"a :class:`!datetime` instance, raises :exc:`TypeError`." +"Order comparison between naive and aware :class:`.datetime` objects raises :" +"exc:`TypeError`." msgstr "" -#: ../../library/datetime.rst:1219 +#: ../../library/datetime.rst:1286 msgid "" "If both comparands are aware, and have the same :attr:`!tzinfo` attribute, " "the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and " @@ -1852,55 +1949,61 @@ msgid "" "implementation never overflows." msgstr "" -#: ../../library/datetime.rst:1226 +#: ../../library/datetime.rst:1293 msgid "" "Equality comparisons between aware and naive :class:`.datetime` instances " "don't raise :exc:`TypeError`." msgstr "" -#: ../../library/datetime.rst:1234 +#: ../../library/datetime.rst:1309 msgid "Return :class:`date` object with same year, month and day." msgstr "" -#: ../../library/datetime.rst:1239 +#: ../../library/datetime.rst:1314 msgid "" "Return :class:`.time` object with same hour, minute, second, microsecond and " "fold. :attr:`.tzinfo` is ``None``. See also method :meth:`timetz`." msgstr "" -#: ../../library/datetime.rst:1242 ../../library/datetime.rst:1251 +#: ../../library/datetime.rst:1317 ../../library/datetime.rst:1326 msgid "The fold value is copied to the returned :class:`.time` object." msgstr "" -#: ../../library/datetime.rst:1248 +#: ../../library/datetime.rst:1323 msgid "" "Return :class:`.time` object with same hour, minute, second, microsecond, " "fold, and tzinfo attributes. See also method :meth:`time`." msgstr "" -#: ../../library/datetime.rst:1259 +#: ../../library/datetime.rst:1334 msgid "" -"Return a datetime with the same attributes, except for those attributes " -"given new values by whichever keyword arguments are specified. Note that " -"``tzinfo=None`` can be specified to create a naive datetime from an aware " -"datetime with no conversion of date and time data." +"Return a new :class:`datetime` object with the same attributes, but with " +"specified parameters updated. Note that ``tzinfo=None`` can be specified to " +"create a naive datetime from an aware datetime with no conversion of date " +"and time data." msgstr "" -#: ../../library/datetime.rst:1270 +#: ../../library/datetime.rst:1339 +msgid "" +":class:`.datetime` objects are also supported by generic function :func:" +"`copy.replace`." +msgstr "" + +#: ../../library/datetime.rst:1348 msgid "" "Return a :class:`.datetime` object with new :attr:`.tzinfo` attribute *tz*, " "adjusting the date and time data so the result is the same UTC time as " "*self*, but in *tz*'s local time." msgstr "" -#: ../../library/datetime.rst:1274 +#: ../../library/datetime.rst:1352 msgid "" "If provided, *tz* must be an instance of a :class:`tzinfo` subclass, and " "its :meth:`utcoffset` and :meth:`dst` methods must not return ``None``. If " "*self* is naive, it is presumed to represent time in the system time zone." msgstr "" -#: ../../library/datetime.rst:1278 +#: ../../library/datetime.rst:1356 msgid "" "If called without arguments (or with ``tz=None``) the system local time zone " "is assumed for the target time zone. The ``.tzinfo`` attribute of the " @@ -1908,7 +2011,7 @@ msgid "" "with the zone name and offset obtained from the OS." msgstr "" -#: ../../library/datetime.rst:1283 +#: ../../library/datetime.rst:1361 msgid "" "If ``self.tzinfo`` is *tz*, ``self.astimezone(tz)`` is equal to *self*: no " "adjustment of date or time data is performed. Else the result is local time " @@ -1917,7 +2020,7 @@ msgid "" "date and time data as ``dt - dt.utcoffset()``." msgstr "" -#: ../../library/datetime.rst:1289 +#: ../../library/datetime.rst:1367 msgid "" "If you merely want to attach a :class:`timezone` object *tz* to a datetime " "*dt* without adjustment of date and time data, use ``dt." @@ -1926,14 +2029,14 @@ msgid "" "use ``dt.replace(tzinfo=None)``." msgstr "" -#: ../../library/datetime.rst:1294 +#: ../../library/datetime.rst:1372 msgid "" "Note that the default :meth:`tzinfo.fromutc` method can be overridden in a :" "class:`tzinfo` subclass to affect the result returned by :meth:`astimezone`. " "Ignoring error cases, :meth:`astimezone` acts like::" msgstr "" -#: ../../library/datetime.rst:1298 +#: ../../library/datetime.rst:1376 msgid "" "def astimezone(self, tz):\n" " if self.tzinfo is tz:\n" @@ -1944,49 +2047,49 @@ msgid "" " return tz.fromutc(utc)" msgstr "" -#: ../../library/datetime.rst:1306 +#: ../../library/datetime.rst:1384 msgid "*tz* now can be omitted." msgstr "" -#: ../../library/datetime.rst:1309 +#: ../../library/datetime.rst:1387 msgid "" "The :meth:`astimezone` method can now be called on naive instances that are " "presumed to represent system local time." msgstr "" -#: ../../library/datetime.rst:1316 +#: ../../library/datetime.rst:1394 msgid "" "If :attr:`.tzinfo` is ``None``, returns ``None``, else returns ``self.tzinfo." "utcoffset(self)``, and raises an exception if the latter doesn't return " "``None`` or a :class:`timedelta` object with magnitude less than one day." msgstr "" -#: ../../library/datetime.rst:1320 ../../library/datetime.rst:1912 -#: ../../library/datetime.rst:2019 ../../library/datetime.rst:2264 -#: ../../library/datetime.rst:2276 ../../library/datetime.rst:2588 +#: ../../library/datetime.rst:1398 ../../library/datetime.rst:1993 +#: ../../library/datetime.rst:2100 ../../library/datetime.rst:2345 +#: ../../library/datetime.rst:2357 ../../library/datetime.rst:2669 msgid "The UTC offset is not restricted to a whole number of minutes." msgstr "" -#: ../../library/datetime.rst:1326 +#: ../../library/datetime.rst:1404 msgid "" "If :attr:`.tzinfo` is ``None``, returns ``None``, else returns ``self.tzinfo." "dst(self)``, and raises an exception if the latter doesn't return ``None`` " "or a :class:`timedelta` object with magnitude less than one day." msgstr "" -#: ../../library/datetime.rst:1330 ../../library/datetime.rst:1922 -#: ../../library/datetime.rst:2073 +#: ../../library/datetime.rst:1408 ../../library/datetime.rst:2003 +#: ../../library/datetime.rst:2154 msgid "The DST offset is not restricted to a whole number of minutes." msgstr "" -#: ../../library/datetime.rst:1336 +#: ../../library/datetime.rst:1414 msgid "" "If :attr:`.tzinfo` is ``None``, returns ``None``, else returns ``self.tzinfo." "tzname(self)``, raises an exception if the latter doesn't return ``None`` or " "a string object," msgstr "" -#: ../../library/datetime.rst:1347 +#: ../../library/datetime.rst:1425 msgid "" "time.struct_time((d.year, d.month, d.day,\n" " d.hour, d.minute, d.second,\n" @@ -1996,7 +2099,7 @@ msgstr "" " d.hour, d.minute, d.second,\n" " d.weekday(), yday, dst))" -#: ../../library/datetime.rst:1351 +#: ../../library/datetime.rst:1429 msgid "" "where ``yday = d.toordinal() - date(d.year, 1, 1).toordinal() + 1`` is the " "day number within the current year starting with 1 for January 1st. The :" @@ -2007,24 +2110,24 @@ msgid "" "to 0." msgstr "" -#: ../../library/datetime.rst:1362 +#: ../../library/datetime.rst:1440 msgid "" -"If :class:`.datetime` instance *d* is naive, this is the same as ``d." +"If :class:`.datetime` instance ``d`` is naive, this is the same as ``d." "timetuple()`` except that :attr:`~.time.struct_time.tm_isdst` is forced to 0 " "regardless of what ``d.dst()`` returns. DST is never in effect for a UTC " "time." msgstr "" -#: ../../library/datetime.rst:1366 +#: ../../library/datetime.rst:1444 msgid "" -"If *d* is aware, *d* is normalized to UTC time, by subtracting ``d." +"If ``d`` is aware, ``d`` is normalized to UTC time, by subtracting ``d." "utcoffset()``, and a :class:`time.struct_time` for the normalized time is " "returned. :attr:`!tm_isdst` is forced to 0. Note that an :exc:" "`OverflowError` may be raised if ``d.year`` was ``MINYEAR`` or ``MAXYEAR`` " "and UTC adjustment spills over a year boundary." msgstr "" -#: ../../library/datetime.rst:1375 +#: ../../library/datetime.rst:1453 msgid "" "Because naive ``datetime`` objects are treated by many ``datetime`` methods " "as local times, it is preferred to use aware datetimes to represent times in " @@ -2034,20 +2137,20 @@ msgid "" "meth:`.datetime.timetuple`." msgstr "" -#: ../../library/datetime.rst:1384 +#: ../../library/datetime.rst:1462 msgid "" "Return the proleptic Gregorian ordinal of the date. The same as ``self." "date().toordinal()``." msgstr "" -#: ../../library/datetime.rst:1389 +#: ../../library/datetime.rst:1467 msgid "" "Return POSIX timestamp corresponding to the :class:`.datetime` instance. The " "return value is a :class:`float` similar to that returned by :func:`time." "time`." msgstr "" -#: ../../library/datetime.rst:1393 +#: ../../library/datetime.rst:1471 msgid "" "Naive :class:`.datetime` instances are assumed to represent local time and " "this method relies on the platform C :c:func:`mktime` function to perform " @@ -2057,22 +2160,22 @@ msgid "" "future." msgstr "" -#: ../../library/datetime.rst:1400 +#: ../../library/datetime.rst:1478 msgid "" "For aware :class:`.datetime` instances, the return value is computed as::" msgstr "" -#: ../../library/datetime.rst:1403 +#: ../../library/datetime.rst:1481 msgid "(dt - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds()" msgstr "(dt - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds()" -#: ../../library/datetime.rst:1407 +#: ../../library/datetime.rst:1485 msgid "" "The :meth:`timestamp` method uses the :attr:`.fold` attribute to " "disambiguate the times during a repeated interval." msgstr "" -#: ../../library/datetime.rst:1413 +#: ../../library/datetime.rst:1491 msgid "" "There is no method to obtain the POSIX timestamp directly from a naive :" "class:`.datetime` instance representing UTC time. If your application uses " @@ -2080,57 +2183,57 @@ msgid "" "the POSIX timestamp by supplying ``tzinfo=timezone.utc``::" msgstr "" -#: ../../library/datetime.rst:1419 +#: ../../library/datetime.rst:1497 msgid "timestamp = dt.replace(tzinfo=timezone.utc).timestamp()" msgstr "timestamp = dt.replace(tzinfo=timezone.utc).timestamp()" -#: ../../library/datetime.rst:1421 +#: ../../library/datetime.rst:1499 msgid "or by calculating the timestamp directly::" msgstr "" -#: ../../library/datetime.rst:1423 +#: ../../library/datetime.rst:1501 msgid "timestamp = (dt - datetime(1970, 1, 1)) / timedelta(seconds=1)" msgstr "timestamp = (dt - datetime(1970, 1, 1)) / timedelta(seconds=1)" -#: ../../library/datetime.rst:1427 +#: ../../library/datetime.rst:1505 msgid "" "Return the day of the week as an integer, where Monday is 0 and Sunday is 6. " "The same as ``self.date().weekday()``. See also :meth:`isoweekday`." msgstr "" -#: ../../library/datetime.rst:1433 +#: ../../library/datetime.rst:1511 msgid "" "Return the day of the week as an integer, where Monday is 1 and Sunday is 7. " "The same as ``self.date().isoweekday()``. See also :meth:`weekday`, :meth:" "`isocalendar`." msgstr "" -#: ../../library/datetime.rst:1440 +#: ../../library/datetime.rst:1518 msgid "" "Return a :term:`named tuple` with three components: ``year``, ``week`` and " "``weekday``. The same as ``self.date().isocalendar()``." msgstr "" -#: ../../library/datetime.rst:1446 +#: ../../library/datetime.rst:1524 msgid "Return a string representing the date and time in ISO 8601 format:" msgstr "" -#: ../../library/datetime.rst:1448 +#: ../../library/datetime.rst:1526 msgid "``YYYY-MM-DDTHH:MM:SS.ffffff``, if :attr:`microsecond` is not 0" msgstr "``YYYY-MM-DDTHH:MM:SS.ffffff``,如果 :attr:`microsecond` 不是 0" -#: ../../library/datetime.rst:1449 +#: ../../library/datetime.rst:1527 msgid "``YYYY-MM-DDTHH:MM:SS``, if :attr:`microsecond` is 0" msgstr "``YYYY-MM-DDTHH:MM:SS``,如果 :attr:`microsecond` 是 0" -#: ../../library/datetime.rst:1451 +#: ../../library/datetime.rst:1529 msgid "" "If :meth:`utcoffset` does not return ``None``, a string is appended, giving " "the UTC offset:" msgstr "" "如果 :meth:`utcoffset` 没有回傳 ``None``,則會附加一个字串,給出 UTC 偏移:" -#: ../../library/datetime.rst:1454 +#: ../../library/datetime.rst:1532 msgid "" "``YYYY-MM-DDTHH:MM:SS.ffffff+HH:MM[:SS[.ffffff]]``, if :attr:`microsecond` " "is not 0" @@ -2138,13 +2241,13 @@ msgstr "" "``YYYY-MM-DDTHH:MM:SS.ffffff+HH:MM[:SS[.ffffff]]``,如果 :attr:`microsecond` " "不是 0" -#: ../../library/datetime.rst:1456 +#: ../../library/datetime.rst:1534 msgid "" "``YYYY-MM-DDTHH:MM:SS+HH:MM[:SS[.ffffff]]``, if :attr:`microsecond` is 0" msgstr "" "``YYYY-MM-DDTHH:MM:SS+HH:MM[:SS[.ffffff]]``,如果 :attr:`microsecond` 是 0" -#: ../../library/datetime.rst:1460 +#: ../../library/datetime.rst:1538 msgid "" ">>> from datetime import datetime, timezone\n" ">>> datetime(2019, 5, 18, 15, 17, 8, 132263).isoformat()\n" @@ -2158,13 +2261,13 @@ msgstr "" ">>> datetime(2019, 5, 18, 15, 17, tzinfo=timezone.utc).isoformat()\n" "'2019-05-18T15:17:00+00:00'" -#: ../../library/datetime.rst:1466 +#: ../../library/datetime.rst:1544 msgid "" "The optional argument *sep* (default ``'T'``) is a one-character separator, " "placed between the date and time portions of the result. For example::" msgstr "" -#: ../../library/datetime.rst:1469 +#: ../../library/datetime.rst:1547 msgid "" ">>> from datetime import tzinfo, timedelta, datetime\n" ">>> class TZ(tzinfo):\n" @@ -2178,83 +2281,83 @@ msgid "" "'2009-11-27T00:00:00.000100-06:39'" msgstr "" -#: ../../library/datetime.rst:1480 ../../library/datetime.rst:1852 +#: ../../library/datetime.rst:1558 ../../library/datetime.rst:1933 msgid "" "The optional argument *timespec* specifies the number of additional " "components of the time to include (the default is ``'auto'``). It can be one " "of the following:" msgstr "" -#: ../../library/datetime.rst:1484 ../../library/datetime.rst:1856 +#: ../../library/datetime.rst:1562 ../../library/datetime.rst:1937 msgid "" "``'auto'``: Same as ``'seconds'`` if :attr:`microsecond` is 0, same as " "``'microseconds'`` otherwise." msgstr "" -#: ../../library/datetime.rst:1486 ../../library/datetime.rst:1858 +#: ../../library/datetime.rst:1564 ../../library/datetime.rst:1939 msgid "``'hours'``: Include the :attr:`hour` in the two-digit ``HH`` format." msgstr "" -#: ../../library/datetime.rst:1487 ../../library/datetime.rst:1859 +#: ../../library/datetime.rst:1565 ../../library/datetime.rst:1940 msgid "" "``'minutes'``: Include :attr:`hour` and :attr:`minute` in ``HH:MM`` format." msgstr "" -#: ../../library/datetime.rst:1488 ../../library/datetime.rst:1860 +#: ../../library/datetime.rst:1566 ../../library/datetime.rst:1941 msgid "" "``'seconds'``: Include :attr:`hour`, :attr:`minute`, and :attr:`second` in " "``HH:MM:SS`` format." msgstr "" -#: ../../library/datetime.rst:1490 ../../library/datetime.rst:1862 +#: ../../library/datetime.rst:1568 ../../library/datetime.rst:1943 msgid "" "``'milliseconds'``: Include full time, but truncate fractional second part " "to milliseconds. ``HH:MM:SS.sss`` format." msgstr "" -#: ../../library/datetime.rst:1492 ../../library/datetime.rst:1864 +#: ../../library/datetime.rst:1570 ../../library/datetime.rst:1945 msgid "``'microseconds'``: Include full time in ``HH:MM:SS.ffffff`` format." msgstr "" -#: ../../library/datetime.rst:1496 ../../library/datetime.rst:1868 +#: ../../library/datetime.rst:1574 ../../library/datetime.rst:1949 msgid "Excluded time components are truncated, not rounded." msgstr "" -#: ../../library/datetime.rst:1498 +#: ../../library/datetime.rst:1576 msgid ":exc:`ValueError` will be raised on an invalid *timespec* argument::" msgstr "" -#: ../../library/datetime.rst:1501 +#: ../../library/datetime.rst:1579 msgid "" ">>> from datetime import datetime\n" -">>> datetime.now().isoformat(timespec='minutes') \n" +">>> datetime.now().isoformat(timespec='minutes')\n" "'2002-12-25T00:00'\n" ">>> dt = datetime(2015, 1, 1, 12, 30, 59, 0)\n" ">>> dt.isoformat(timespec='microseconds')\n" "'2015-01-01T12:30:59.000000'" msgstr "" ">>> from datetime import datetime\n" -">>> datetime.now().isoformat(timespec='minutes') \n" +">>> datetime.now().isoformat(timespec='minutes')\n" "'2002-12-25T00:00'\n" ">>> dt = datetime(2015, 1, 1, 12, 30, 59, 0)\n" ">>> dt.isoformat(timespec='microseconds')\n" "'2015-01-01T12:30:59.000000'" -#: ../../library/datetime.rst:1508 ../../library/datetime.rst:1883 +#: ../../library/datetime.rst:1586 ../../library/datetime.rst:1964 msgid "Added the *timespec* parameter." msgstr "新增 *timespec* 參數。" -#: ../../library/datetime.rst:1514 +#: ../../library/datetime.rst:1592 msgid "" -"For a :class:`.datetime` instance *d*, ``str(d)`` is equivalent to ``d." +"For a :class:`.datetime` instance ``d``, ``str(d)`` is equivalent to ``d." "isoformat(' ')``." msgstr "" -#: ../../library/datetime.rst:1520 +#: ../../library/datetime.rst:1598 msgid "Return a string representing the date and time::" msgstr "" -#: ../../library/datetime.rst:1522 +#: ../../library/datetime.rst:1600 msgid "" ">>> from datetime import datetime\n" ">>> datetime(2002, 12, 4, 20, 30, 40).ctime()\n" @@ -2264,27 +2367,27 @@ msgstr "" ">>> datetime(2002, 12, 4, 20, 30, 40).ctime()\n" "'Wed Dec 4 20:30:40 2002'" -#: ../../library/datetime.rst:1526 +#: ../../library/datetime.rst:1604 msgid "" "The output string will *not* include time zone information, regardless of " "whether the input is aware or naive." msgstr "" -#: ../../library/datetime.rst:1533 +#: ../../library/datetime.rst:1611 msgid "" "on platforms where the native C :c:func:`ctime` function (which :func:`time." "ctime` invokes, but which :meth:`datetime.ctime` does not invoke) conforms " "to the C standard." msgstr "" -#: ../../library/datetime.rst:1540 +#: ../../library/datetime.rst:1618 msgid "" "Return a string representing the date and time, controlled by an explicit " "format string. See also :ref:`strftime-strptime-behavior` and :meth:" "`datetime.isoformat`." msgstr "" -#: ../../library/datetime.rst:1547 +#: ../../library/datetime.rst:1625 msgid "" "Same as :meth:`.datetime.strftime`. This makes it possible to specify a " "format string for a :class:`.datetime` object in :ref:`formatted string " @@ -2292,15 +2395,15 @@ msgid "" "`strftime-strptime-behavior` and :meth:`datetime.isoformat`." msgstr "" -#: ../../library/datetime.rst:1554 +#: ../../library/datetime.rst:1632 msgid "Examples of Usage: :class:`.datetime`" msgstr "用法範例::class:`.datetime`" -#: ../../library/datetime.rst:1556 +#: ../../library/datetime.rst:1634 msgid "Examples of working with :class:`.datetime` objects:" msgstr "更多 :class:`.datetime` 的用法範例:" -#: ../../library/datetime.rst:1558 +#: ../../library/datetime.rst:1636 msgid "" ">>> from datetime import datetime, date, time, timezone\n" "\n" @@ -2311,9 +2414,9 @@ msgid "" "datetime.datetime(2005, 7, 14, 12, 30)\n" "\n" ">>> # Using datetime.now()\n" -">>> datetime.now() \n" +">>> datetime.now()\n" "datetime.datetime(2007, 12, 6, 16, 29, 43, 79043) # GMT +1\n" -">>> datetime.now(timezone.utc) \n" +">>> datetime.now(timezone.utc)\n" "datetime.datetime(2007, 12, 6, 15, 29, 43, 79060, tzinfo=datetime.timezone." "utc)\n" "\n" @@ -2324,7 +2427,7 @@ msgid "" "\n" ">>> # Using datetime.timetuple() to get tuple of all attributes\n" ">>> tt = dt.timetuple()\n" -">>> for it in tt: \n" +">>> for it in tt:\n" "... print(it)\n" "...\n" "2006 # year\n" @@ -2339,7 +2442,7 @@ msgid "" "\n" ">>> # Date in ISO format\n" ">>> ic = dt.isocalendar()\n" -">>> for it in ic: \n" +">>> for it in ic:\n" "... print(it)\n" "...\n" "2006 # ISO year\n" @@ -2354,14 +2457,14 @@ msgid "" "'The day is 21, the month is November, the time is 04:30PM.'" msgstr "" -#: ../../library/datetime.rst:1609 +#: ../../library/datetime.rst:1687 msgid "" "The example below defines a :class:`tzinfo` subclass capturing time zone " "information for Kabul, Afghanistan, which used +4 UTC until 1945 and then " "+4:30 UTC thereafter::" msgstr "" -#: ../../library/datetime.rst:1613 +#: ../../library/datetime.rst:1691 msgid "" "from datetime import timedelta, datetime, tzinfo, timezone\n" "\n" @@ -2408,11 +2511,11 @@ msgid "" " return \"+04\"" msgstr "" -#: ../../library/datetime.rst:1656 +#: ../../library/datetime.rst:1734 msgid "Usage of ``KabulTz`` from above::" msgstr "" -#: ../../library/datetime.rst:1658 +#: ../../library/datetime.rst:1736 msgid "" ">>> tz1 = KabulTz()\n" "\n" @@ -2436,63 +2539,63 @@ msgid "" "True" msgstr "" -#: ../../library/datetime.rst:1682 +#: ../../library/datetime.rst:1760 msgid ":class:`.time` Objects" msgstr ":class:`.time` 物件" -#: ../../library/datetime.rst:1684 +#: ../../library/datetime.rst:1762 msgid "" "A :class:`.time` object represents a (local) time of day, independent of any " "particular day, and subject to adjustment via a :class:`tzinfo` object." msgstr "" -#: ../../library/datetime.rst:1689 +#: ../../library/datetime.rst:1767 msgid "" "All arguments are optional. *tzinfo* may be ``None``, or an instance of a :" "class:`tzinfo` subclass. The remaining arguments must be integers in the " "following ranges:" msgstr "" -#: ../../library/datetime.rst:1699 +#: ../../library/datetime.rst:1777 msgid "" "If an argument outside those ranges is given, :exc:`ValueError` is raised. " "All default to 0 except *tzinfo*, which defaults to ``None``." msgstr "" -#: ../../library/datetime.rst:1707 +#: ../../library/datetime.rst:1785 msgid "The earliest representable :class:`.time`, ``time(0, 0, 0, 0)``." msgstr "" -#: ../../library/datetime.rst:1712 +#: ../../library/datetime.rst:1790 msgid "The latest representable :class:`.time`, ``time(23, 59, 59, 999999)``." msgstr "" -#: ../../library/datetime.rst:1717 +#: ../../library/datetime.rst:1795 msgid "" "The smallest possible difference between non-equal :class:`.time` objects, " "``timedelta(microseconds=1)``, although note that arithmetic on :class:`." "time` objects is not supported." msgstr "" -#: ../../library/datetime.rst:1746 +#: ../../library/datetime.rst:1824 msgid "" "The object passed as the tzinfo argument to the :class:`.time` constructor, " "or ``None`` if none was passed." msgstr "" -#: ../../library/datetime.rst:1760 +#: ../../library/datetime.rst:1838 msgid "" -":class:`.time` objects support equality and order comparisons, where *a* is " -"considered less than *b* when *a* precedes *b* in time." +":class:`.time` objects support equality and order comparisons, where ``a`` " +"is considered less than ``b`` when ``a`` precedes ``b`` in time." msgstr "" -#: ../../library/datetime.rst:1763 +#: ../../library/datetime.rst:1841 msgid "" "Naive and aware :class:`!time` objects are never equal. Order comparison " "between naive and aware :class:`!time` objects raises :exc:`TypeError`." msgstr "" -#: ../../library/datetime.rst:1767 +#: ../../library/datetime.rst:1845 msgid "" "If both comparands are aware, and have the same :attr:`~.time.tzinfo` " "attribute, the :attr:`!tzinfo` and :attr:`!fold` attributes are ignored and " @@ -2501,18 +2604,18 @@ msgid "" "subtracting their UTC offsets (obtained from ``self.utcoffset()``)." msgstr "" -#: ../../library/datetime.rst:1773 +#: ../../library/datetime.rst:1851 msgid "" "Equality comparisons between aware and naive :class:`.time` instances don't " "raise :exc:`TypeError`." msgstr "" -#: ../../library/datetime.rst:1777 +#: ../../library/datetime.rst:1855 msgid "" "In Boolean contexts, a :class:`.time` object is always considered to be true." msgstr "" -#: ../../library/datetime.rst:1779 +#: ../../library/datetime.rst:1857 msgid "" "Before Python 3.5, a :class:`.time` object was considered to be false if it " "represented midnight in UTC. This behavior was considered obscure and error-" @@ -2520,33 +2623,33 @@ msgid "" "details." msgstr "" -#: ../../library/datetime.rst:1786 +#: ../../library/datetime.rst:1864 msgid "Other constructor:" msgstr "" -#: ../../library/datetime.rst:1790 +#: ../../library/datetime.rst:1868 msgid "" "Return a :class:`.time` corresponding to a *time_string* in any valid ISO " "8601 format, with the following exceptions:" msgstr "" -#: ../../library/datetime.rst:1794 +#: ../../library/datetime.rst:1872 msgid "" "The leading ``T``, normally required in cases where there may be ambiguity " "between a date and a time, is not required." msgstr "" -#: ../../library/datetime.rst:1796 +#: ../../library/datetime.rst:1874 msgid "" "Fractional seconds may have any number of digits (anything beyond 6 will be " "truncated)." msgstr "" -#: ../../library/datetime.rst:1800 +#: ../../library/datetime.rst:1878 msgid "Examples:" msgstr "範例: ::" -#: ../../library/datetime.rst:1802 +#: ../../library/datetime.rst:1880 msgid "" ">>> from datetime import time\n" ">>> time.fromisoformat('04:23:01')\n" @@ -2586,49 +2689,55 @@ msgstr "" ">>> time.fromisoformat('04:23:01+00:00')\n" "datetime.time(4, 23, 1, tzinfo=datetime.timezone.utc)" -#: ../../library/datetime.rst:1824 +#: ../../library/datetime.rst:1902 msgid "" "Previously, this method only supported formats that could be emitted by :" "meth:`time.isoformat`." msgstr "" -#: ../../library/datetime.rst:1834 +#: ../../library/datetime.rst:1912 msgid "" -"Return a :class:`.time` with the same value, except for those attributes " -"given new values by whichever keyword arguments are specified. Note that " -"``tzinfo=None`` can be specified to create a naive :class:`.time` from an " -"aware :class:`.time`, without conversion of the time data." +"Return a new :class:`.time` with the same values, but with specified " +"parameters updated. Note that ``tzinfo=None`` can be specified to create a " +"naive :class:`.time` from an aware :class:`.time`, without conversion of the " +"time data." msgstr "" -#: ../../library/datetime.rst:1845 +#: ../../library/datetime.rst:1917 +msgid "" +":class:`.time` objects are also supported by generic function :func:`copy." +"replace`." +msgstr "" + +#: ../../library/datetime.rst:1926 msgid "Return a string representing the time in ISO 8601 format, one of:" msgstr "" -#: ../../library/datetime.rst:1847 +#: ../../library/datetime.rst:1928 msgid "``HH:MM:SS.ffffff``, if :attr:`microsecond` is not 0" msgstr "" -#: ../../library/datetime.rst:1848 +#: ../../library/datetime.rst:1929 msgid "``HH:MM:SS``, if :attr:`microsecond` is 0" msgstr "" -#: ../../library/datetime.rst:1849 +#: ../../library/datetime.rst:1930 msgid "" "``HH:MM:SS.ffffff+HH:MM[:SS[.ffffff]]``, if :meth:`utcoffset` does not " "return ``None``" msgstr "" -#: ../../library/datetime.rst:1850 +#: ../../library/datetime.rst:1931 msgid "" "``HH:MM:SS+HH:MM[:SS[.ffffff]]``, if :attr:`microsecond` is 0 and :meth:" "`utcoffset` does not return ``None``" msgstr "" -#: ../../library/datetime.rst:1870 +#: ../../library/datetime.rst:1951 msgid ":exc:`ValueError` will be raised on an invalid *timespec* argument." msgstr "" -#: ../../library/datetime.rst:1874 +#: ../../library/datetime.rst:1955 msgid "" ">>> from datetime import time\n" ">>> time(hour=12, minute=34, second=56, microsecond=123456)." @@ -2650,18 +2759,18 @@ msgstr "" ">>> dt.isoformat(timespec='auto')\n" "'12:34:56'" -#: ../../library/datetime.rst:1889 -msgid "For a time *t*, ``str(t)`` is equivalent to ``t.isoformat()``." +#: ../../library/datetime.rst:1970 +msgid "For a time ``t``, ``str(t)`` is equivalent to ``t.isoformat()``." msgstr "" -#: ../../library/datetime.rst:1894 +#: ../../library/datetime.rst:1975 msgid "" "Return a string representing the time, controlled by an explicit format " "string. See also :ref:`strftime-strptime-behavior` and :meth:`time." "isoformat`." msgstr "" -#: ../../library/datetime.rst:1900 +#: ../../library/datetime.rst:1981 msgid "" "Same as :meth:`.time.strftime`. This makes it possible to specify a format " "string for a :class:`.time` object in :ref:`formatted string literals >> from datetime import time, tzinfo, timedelta\n" ">>> class TZ1(tzinfo):\n" @@ -2750,18 +2859,18 @@ msgstr "" ">>> 'The {} is {:%H:%M}.'.format(\"time\", t)\n" "'The time is 12:10.'" -#: ../../library/datetime.rst:1965 +#: ../../library/datetime.rst:2046 msgid ":class:`tzinfo` Objects" msgstr ":class:`tzinfo` 物件" -#: ../../library/datetime.rst:1969 +#: ../../library/datetime.rst:2050 msgid "" "This is an abstract base class, meaning that this class should not be " "instantiated directly. Define a subclass of :class:`tzinfo` to capture " "information about a particular time zone." msgstr "" -#: ../../library/datetime.rst:1973 +#: ../../library/datetime.rst:2054 msgid "" "An instance of (a concrete subclass of) :class:`tzinfo` can be passed to the " "constructors for :class:`.datetime` and :class:`.time` objects. The latter " @@ -2771,7 +2880,7 @@ msgid "" "object passed to them." msgstr "" -#: ../../library/datetime.rst:1979 +#: ../../library/datetime.rst:2060 msgid "" "You need to derive a concrete subclass, and (at least) supply " "implementations of the standard :class:`tzinfo` methods needed by the :class:" @@ -2781,7 +2890,7 @@ msgid "" "American EST and EDT." msgstr "" -#: ../../library/datetime.rst:1986 +#: ../../library/datetime.rst:2067 msgid "" "Special requirement for pickling: A :class:`tzinfo` subclass must have an :" "meth:`~object.__init__` method that can be called with no arguments, " @@ -2789,20 +2898,20 @@ msgid "" "technical requirement that may be relaxed in the future." msgstr "" -#: ../../library/datetime.rst:1992 +#: ../../library/datetime.rst:2073 msgid "" "A concrete subclass of :class:`tzinfo` may need to implement the following " "methods. Exactly which methods are needed depends on the uses made of aware :" "mod:`!datetime` objects. If in doubt, simply implement all of them." msgstr "" -#: ../../library/datetime.rst:1999 +#: ../../library/datetime.rst:2080 msgid "" "Return offset of local time from UTC, as a :class:`timedelta` object that is " "positive east of UTC. If local time is west of UTC, this should be negative." msgstr "" -#: ../../library/datetime.rst:2002 +#: ../../library/datetime.rst:2083 msgid "" "This represents the *total* offset from UTC; for example, if a :class:" "`tzinfo` object represents both time zone and DST adjustments, :meth:" @@ -2813,31 +2922,31 @@ msgid "" "meth:`utcoffset` will probably look like one of these two::" msgstr "" -#: ../../library/datetime.rst:2010 +#: ../../library/datetime.rst:2091 msgid "" "return CONSTANT # fixed-offset class\n" "return CONSTANT + self.dst(dt) # daylight-aware class" msgstr "" -#: ../../library/datetime.rst:2013 +#: ../../library/datetime.rst:2094 msgid "" "If :meth:`utcoffset` does not return ``None``, :meth:`dst` should not return " "``None`` either." msgstr "" -#: ../../library/datetime.rst:2016 +#: ../../library/datetime.rst:2097 msgid "" "The default implementation of :meth:`utcoffset` raises :exc:" "`NotImplementedError`." msgstr "" -#: ../../library/datetime.rst:2025 +#: ../../library/datetime.rst:2106 msgid "" "Return the daylight saving time (DST) adjustment, as a :class:`timedelta` " "object or ``None`` if DST information isn't known." msgstr "" -#: ../../library/datetime.rst:2029 +#: ../../library/datetime.rst:2110 msgid "" "Return ``timedelta(0)`` if DST is not in effect. If DST is in effect, return " "the offset as a :class:`timedelta` object (see :meth:`utcoffset` for " @@ -2850,17 +2959,17 @@ msgid "" "to account for DST changes when crossing time zones." msgstr "" -#: ../../library/datetime.rst:2039 +#: ../../library/datetime.rst:2120 msgid "" "An instance *tz* of a :class:`tzinfo` subclass that models both standard and " "daylight times must be consistent in this sense:" msgstr "" -#: ../../library/datetime.rst:2042 +#: ../../library/datetime.rst:2123 msgid "``tz.utcoffset(dt) - tz.dst(dt)``" msgstr "``tz.utcoffset(dt) - tz.dst(dt)``" -#: ../../library/datetime.rst:2044 +#: ../../library/datetime.rst:2125 msgid "" "must return the same result for every :class:`.datetime` *dt* with ``dt." "tzinfo == tz``. For sane :class:`tzinfo` subclasses, this expression yields " @@ -2873,24 +2982,24 @@ msgid "" "astimezone` regardless." msgstr "" -#: ../../library/datetime.rst:2053 +#: ../../library/datetime.rst:2134 msgid "" "Most implementations of :meth:`dst` will probably look like one of these " "two::" msgstr "" -#: ../../library/datetime.rst:2055 +#: ../../library/datetime.rst:2136 msgid "" "def dst(self, dt):\n" " # a fixed-offset class: doesn't account for DST\n" " return timedelta(0)" msgstr "" -#: ../../library/datetime.rst:2059 +#: ../../library/datetime.rst:2140 msgid "or::" msgstr "或是: ::" -#: ../../library/datetime.rst:2061 +#: ../../library/datetime.rst:2142 msgid "" "def dst(self, dt):\n" " # Code to set dston and dstoff to the time zone's DST\n" @@ -2903,12 +3012,12 @@ msgid "" " return timedelta(0)" msgstr "" -#: ../../library/datetime.rst:2071 +#: ../../library/datetime.rst:2152 msgid "" "The default implementation of :meth:`dst` raises :exc:`NotImplementedError`." msgstr "" -#: ../../library/datetime.rst:2079 +#: ../../library/datetime.rst:2160 msgid "" "Return the time zone name corresponding to the :class:`.datetime` object " "*dt*, as a string. Nothing about string names is defined by the :mod:`!" @@ -2922,13 +3031,13 @@ msgid "" "accounting for daylight time." msgstr "" -#: ../../library/datetime.rst:2089 +#: ../../library/datetime.rst:2170 msgid "" "The default implementation of :meth:`tzname` raises :exc:" "`NotImplementedError`." msgstr "" -#: ../../library/datetime.rst:2092 +#: ../../library/datetime.rst:2173 msgid "" "These methods are called by a :class:`.datetime` or :class:`.time` object, " "in response to their methods of the same names. A :class:`.datetime` object " @@ -2938,7 +3047,7 @@ msgid "" "datetime`." msgstr "" -#: ../../library/datetime.rst:2098 +#: ../../library/datetime.rst:2179 msgid "" "When ``None`` is passed, it's up to the class designer to decide the best " "response. For example, returning ``None`` is appropriate if the class wishes " @@ -2947,7 +3056,7 @@ msgid "" "offset, as there is no other convention for discovering the standard offset." msgstr "" -#: ../../library/datetime.rst:2104 +#: ../../library/datetime.rst:2185 msgid "" "When a :class:`.datetime` object is passed in response to a :class:`." "datetime` method, ``dt.tzinfo`` is the same object as *self*. :class:" @@ -2957,13 +3066,13 @@ msgid "" "zones." msgstr "" -#: ../../library/datetime.rst:2110 +#: ../../library/datetime.rst:2191 msgid "" "There is one more :class:`tzinfo` method that a subclass may wish to " "override:" msgstr "" -#: ../../library/datetime.rst:2115 +#: ../../library/datetime.rst:2196 msgid "" "This is called from the default :meth:`datetime.astimezone` implementation. " "When called from that, ``dt.tzinfo`` is *self*, and *dt*'s date and time " @@ -2972,7 +3081,7 @@ msgid "" "datetime in *self*'s local time." msgstr "" -#: ../../library/datetime.rst:2121 +#: ../../library/datetime.rst:2202 msgid "" "Most :class:`tzinfo` subclasses should be able to inherit the default :meth:" "`fromutc` implementation without problems. It's strong enough to handle " @@ -2987,13 +3096,13 @@ msgid "" "offset changes." msgstr "" -#: ../../library/datetime.rst:2132 +#: ../../library/datetime.rst:2213 msgid "" "Skipping code for error cases, the default :meth:`fromutc` implementation " "acts like::" msgstr "" -#: ../../library/datetime.rst:2135 +#: ../../library/datetime.rst:2216 msgid "" "def fromutc(self, dt):\n" " # raise ValueError error if dt.tzinfo is not self\n" @@ -3011,13 +3120,13 @@ msgid "" " return dt" msgstr "" -#: ../../library/datetime.rst:2150 +#: ../../library/datetime.rst:2231 msgid "" "In the following :download:`tzinfo_examples.py <../includes/tzinfo_examples." "py>` file there are some examples of :class:`tzinfo` classes:" msgstr "" -#: ../../library/datetime.rst:2154 +#: ../../library/datetime.rst:2235 msgid "" "from datetime import tzinfo, timedelta, datetime\n" "\n" @@ -3197,7 +3306,7 @@ msgid "" "Pacific = USTimeZone(-8, \"Pacific\", \"PST\", \"PDT\")\n" msgstr "" -#: ../../library/datetime.rst:2156 +#: ../../library/datetime.rst:2237 msgid "" "Note that there are unavoidable subtleties twice per year in a :class:" "`tzinfo` subclass accounting for both standard and daylight time, at the DST " @@ -3206,7 +3315,7 @@ msgid "" "ends the minute after 1:59 (EDT) on the first Sunday in November::" msgstr "" -#: ../../library/datetime.rst:2162 +#: ../../library/datetime.rst:2243 msgid "" " UTC 3:MM 4:MM 5:MM 6:MM 7:MM 8:MM\n" " EST 22:MM 23:MM 0:MM 1:MM 2:MM 3:MM\n" @@ -3224,7 +3333,7 @@ msgstr "" "\n" " end 23:MM 0:MM 1:MM 1:MM 2:MM 3:MM" -#: ../../library/datetime.rst:2170 +#: ../../library/datetime.rst:2251 msgid "" "When DST starts (the \"start\" line), the local wall clock leaps from 1:59 " "to 3:00. A wall time of the form 2:MM doesn't really make sense on that day, " @@ -3233,7 +3342,7 @@ msgid "" "get::" msgstr "" -#: ../../library/datetime.rst:2175 +#: ../../library/datetime.rst:2256 msgid "" ">>> from datetime import datetime, timezone\n" ">>> from tzinfo_examples import HOUR, Eastern\n" @@ -3261,7 +3370,7 @@ msgstr "" "07:00:00 UTC = 03:00:00 EDT\n" "08:00:00 UTC = 04:00:00 EDT" -#: ../../library/datetime.rst:2189 +#: ../../library/datetime.rst:2270 msgid "" "When DST ends (the \"end\" line), there's a potentially worse problem: " "there's an hour that can't be spelled unambiguously in local wall time: the " @@ -3276,7 +3385,7 @@ msgid "" "Fall back transition of 2016, we get::" msgstr "" -#: ../../library/datetime.rst:2200 +#: ../../library/datetime.rst:2281 msgid "" ">>> u0 = datetime(2016, 11, 6, 4, tzinfo=timezone.utc)\n" ">>> for i in range(4):\n" @@ -3300,13 +3409,13 @@ msgstr "" "06:00:00 UTC = 01:00:00 EST 1\n" "07:00:00 UTC = 02:00:00 EST 0" -#: ../../library/datetime.rst:2211 +#: ../../library/datetime.rst:2292 msgid "" "Note that the :class:`.datetime` instances that differ only by the value of " "the :attr:`~.datetime.fold` attribute are considered equal in comparisons." msgstr "" -#: ../../library/datetime.rst:2214 +#: ../../library/datetime.rst:2295 msgid "" "Applications that can't bear wall-time ambiguities should explicitly check " "the value of the :attr:`~.datetime.fold` attribute or avoid using hybrid :" @@ -3316,28 +3425,28 @@ msgid "" "offset -4 hours))." msgstr "" -#: ../../library/datetime.rst:2222 +#: ../../library/datetime.rst:2303 msgid ":mod:`zoneinfo`" msgstr ":mod:`zoneinfo`" -#: ../../library/datetime.rst:2223 +#: ../../library/datetime.rst:2304 msgid "" "The :mod:`!datetime` module has a basic :class:`timezone` class (for " "handling arbitrary fixed offsets from UTC) and its :attr:`timezone.utc` " "attribute (a UTC :class:`!timezone` instance)." msgstr "" -#: ../../library/datetime.rst:2227 +#: ../../library/datetime.rst:2308 msgid "" "``zoneinfo`` brings the *IANA time zone database* (also known as the Olson " "database) to Python, and its usage is recommended." msgstr "" -#: ../../library/datetime.rst:2230 +#: ../../library/datetime.rst:2311 msgid "`IANA time zone database `_" msgstr "`IANA 時區資料庫 `_" -#: ../../library/datetime.rst:2231 +#: ../../library/datetime.rst:2312 msgid "" "The Time Zone Database (often called tz, tzdata or zoneinfo) contains code " "and data that represent the history of local time for many representative " @@ -3346,24 +3455,24 @@ msgid "" "saving rules." msgstr "" -#: ../../library/datetime.rst:2241 +#: ../../library/datetime.rst:2322 msgid ":class:`timezone` Objects" msgstr ":class:`timezone` 物件" -#: ../../library/datetime.rst:2243 +#: ../../library/datetime.rst:2324 msgid "" "The :class:`timezone` class is a subclass of :class:`tzinfo`, each instance " "of which represents a time zone defined by a fixed offset from UTC." msgstr "" -#: ../../library/datetime.rst:2247 +#: ../../library/datetime.rst:2328 msgid "" "Objects of this class cannot be used to represent time zone information in " "the locations where different offsets are used in different days of the year " "or where historical changes have been made to civil time." msgstr "" -#: ../../library/datetime.rst:2254 +#: ../../library/datetime.rst:2335 msgid "" "The *offset* argument must be specified as a :class:`timedelta` object " "representing the difference between the local time and UTC. It must be " @@ -3371,25 +3480,25 @@ msgid "" "otherwise :exc:`ValueError` is raised." msgstr "" -#: ../../library/datetime.rst:2259 +#: ../../library/datetime.rst:2340 msgid "" "The *name* argument is optional. If specified it must be a string that will " "be used as the value returned by the :meth:`datetime.tzname` method." msgstr "" -#: ../../library/datetime.rst:2270 ../../library/datetime.rst:2281 +#: ../../library/datetime.rst:2351 ../../library/datetime.rst:2362 msgid "" "Return the fixed value specified when the :class:`timezone` instance is " "constructed." msgstr "" -#: ../../library/datetime.rst:2273 +#: ../../library/datetime.rst:2354 msgid "" "The *dt* argument is ignored. The return value is a :class:`timedelta` " "instance equal to the difference between the local time and UTC." msgstr "" -#: ../../library/datetime.rst:2284 +#: ../../library/datetime.rst:2365 msgid "" "If *name* is not provided in the constructor, the name returned by " "``tzname(dt)`` is generated from the value of the ``offset`` as follows. If " @@ -3398,119 +3507,119 @@ msgid "" "are two digits of ``offset.hours`` and ``offset.minutes`` respectively." msgstr "" -#: ../../library/datetime.rst:2290 +#: ../../library/datetime.rst:2371 msgid "" "Name generated from ``offset=timedelta(0)`` is now plain ``'UTC'``, not " "``'UTC+00:00'``." msgstr "" -#: ../../library/datetime.rst:2297 +#: ../../library/datetime.rst:2378 msgid "Always returns ``None``." msgstr "總是回傳 ``None``。" -#: ../../library/datetime.rst:2301 +#: ../../library/datetime.rst:2382 msgid "" "Return ``dt + offset``. The *dt* argument must be an aware :class:`." "datetime` instance, with ``tzinfo`` set to ``self``." msgstr "" -#: ../../library/datetime.rst:2308 +#: ../../library/datetime.rst:2389 msgid "The UTC time zone, ``timezone(timedelta(0))``." msgstr "UTC 時區,``timezone(timedelta(0))``。" -#: ../../library/datetime.rst:2317 +#: ../../library/datetime.rst:2398 msgid ":meth:`~.datetime.strftime` and :meth:`~.datetime.strptime` Behavior" msgstr ":meth:`~.datetime.strftime` 與 :meth:`~.datetime.strptime` 的行為" -#: ../../library/datetime.rst:2319 +#: ../../library/datetime.rst:2400 msgid "" ":class:`date`, :class:`.datetime`, and :class:`.time` objects all support a " "``strftime(format)`` method, to create a string representing the time under " "the control of an explicit format string." msgstr "" -#: ../../library/datetime.rst:2323 +#: ../../library/datetime.rst:2404 msgid "" "Conversely, the :meth:`datetime.strptime` class method creates a :class:`." "datetime` object from a string representing a date and time and a " "corresponding format string." msgstr "" -#: ../../library/datetime.rst:2327 +#: ../../library/datetime.rst:2408 msgid "" "The table below provides a high-level comparison of :meth:`~.datetime." "strftime` versus :meth:`~.datetime.strptime`:" msgstr "" -#: ../../library/datetime.rst:2331 +#: ../../library/datetime.rst:2412 msgid "``strftime``" msgstr "``strftime``" -#: ../../library/datetime.rst:2331 +#: ../../library/datetime.rst:2412 msgid "``strptime``" msgstr "``strptime``" -#: ../../library/datetime.rst:2333 +#: ../../library/datetime.rst:2414 msgid "Usage" msgstr "用法" -#: ../../library/datetime.rst:2333 +#: ../../library/datetime.rst:2414 msgid "Convert object to a string according to a given format" msgstr "" -#: ../../library/datetime.rst:2333 +#: ../../library/datetime.rst:2414 msgid "" "Parse a string into a :class:`.datetime` object given a corresponding format" msgstr "" -#: ../../library/datetime.rst:2335 +#: ../../library/datetime.rst:2416 msgid "Type of method" msgstr "" -#: ../../library/datetime.rst:2335 +#: ../../library/datetime.rst:2416 msgid "Instance method" msgstr "實例方法" -#: ../../library/datetime.rst:2335 +#: ../../library/datetime.rst:2416 msgid "Class method" msgstr "類別方法" -#: ../../library/datetime.rst:2337 +#: ../../library/datetime.rst:2418 msgid "Method of" msgstr "" -#: ../../library/datetime.rst:2337 +#: ../../library/datetime.rst:2418 msgid ":class:`date`; :class:`.datetime`; :class:`.time`" msgstr ":class:`date`; :class:`.datetime`; :class:`.time`" -#: ../../library/datetime.rst:2337 +#: ../../library/datetime.rst:2418 msgid ":class:`.datetime`" msgstr ":class:`.datetime`" -#: ../../library/datetime.rst:2339 +#: ../../library/datetime.rst:2420 msgid "Signature" msgstr "" -#: ../../library/datetime.rst:2339 +#: ../../library/datetime.rst:2420 msgid "``strftime(format)``" msgstr "``strftime(format)``" -#: ../../library/datetime.rst:2339 +#: ../../library/datetime.rst:2420 msgid "``strptime(date_string, format)``" msgstr "``strptime(date_string, format)``" -#: ../../library/datetime.rst:2346 +#: ../../library/datetime.rst:2427 msgid "" ":meth:`~.datetime.strftime` and :meth:`~.datetime.strptime` Format Codes" msgstr ":meth:`~.datetime.strftime` 與 :meth:`~.datetime.strptime` 格式碼" -#: ../../library/datetime.rst:2348 +#: ../../library/datetime.rst:2429 msgid "" "These methods accept format codes that can be used to parse and format " "dates::" msgstr "" -#: ../../library/datetime.rst:2350 +#: ../../library/datetime.rst:2431 msgid "" ">>> datetime.strptime('31/01/22 23:59:59.999999',\n" "... '%d/%m/%y %H:%M:%S.%f')\n" @@ -3524,33 +3633,33 @@ msgstr "" ">>> _.strftime('%a %d %b %Y, %I:%M%p')\n" "'Mon 31 Jan 2022, 11:59PM'" -#: ../../library/datetime.rst:2356 +#: ../../library/datetime.rst:2437 msgid "" "The following is a list of all the format codes that the 1989 C standard " "requires, and these work on all platforms with a standard C implementation." msgstr "" -#: ../../library/datetime.rst:2360 ../../library/datetime.rst:2463 +#: ../../library/datetime.rst:2441 ../../library/datetime.rst:2544 msgid "Directive" msgstr "" -#: ../../library/datetime.rst:2360 ../../library/datetime.rst:2463 +#: ../../library/datetime.rst:2441 ../../library/datetime.rst:2544 msgid "Meaning" msgstr "含義" -#: ../../library/datetime.rst:2360 ../../library/datetime.rst:2463 +#: ../../library/datetime.rst:2441 ../../library/datetime.rst:2544 msgid "Example" msgstr "範例" -#: ../../library/datetime.rst:2360 ../../library/datetime.rst:2463 +#: ../../library/datetime.rst:2441 ../../library/datetime.rst:2544 msgid "Notes" msgstr "註解" -#: ../../library/datetime.rst:2362 +#: ../../library/datetime.rst:2443 msgid "``%a``" msgstr "``%a``" -#: ../../library/datetime.rst:2362 +#: ../../library/datetime.rst:2443 msgid "Weekday as locale's abbreviated name." msgstr "" @@ -3562,11 +3671,11 @@ msgstr "" msgid "So, Mo, ..., Sa (de_DE)" msgstr "" -#: ../../library/datetime.rst:2367 +#: ../../library/datetime.rst:2448 msgid "``%A``" msgstr "``%A``" -#: ../../library/datetime.rst:2367 +#: ../../library/datetime.rst:2448 msgid "Weekday as locale's full name." msgstr "" @@ -3578,42 +3687,42 @@ msgstr "" msgid "Sonntag, Montag, ..., Samstag (de_DE)" msgstr "" -#: ../../library/datetime.rst:2372 +#: ../../library/datetime.rst:2453 msgid "``%w``" msgstr "``%w``" -#: ../../library/datetime.rst:2372 +#: ../../library/datetime.rst:2453 msgid "Weekday as a decimal number, where 0 is Sunday and 6 is Saturday." msgstr "" -#: ../../library/datetime.rst:2372 +#: ../../library/datetime.rst:2453 msgid "0, 1, ..., 6" msgstr "0, 1, ..., 6" -#: ../../library/datetime.rst:2376 +#: ../../library/datetime.rst:2457 msgid "``%d``" msgstr "``%d``" -#: ../../library/datetime.rst:2376 +#: ../../library/datetime.rst:2457 msgid "Day of the month as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2376 +#: ../../library/datetime.rst:2457 msgid "01, 02, ..., 31" msgstr "01, 02, ..., 31" -#: ../../library/datetime.rst:2376 ../../library/datetime.rst:2389 -#: ../../library/datetime.rst:2392 ../../library/datetime.rst:2398 -#: ../../library/datetime.rst:2401 ../../library/datetime.rst:2407 -#: ../../library/datetime.rst:2425 +#: ../../library/datetime.rst:2457 ../../library/datetime.rst:2470 +#: ../../library/datetime.rst:2473 ../../library/datetime.rst:2479 +#: ../../library/datetime.rst:2482 ../../library/datetime.rst:2488 +#: ../../library/datetime.rst:2506 msgid "\\(9)" msgstr "\\(9)" -#: ../../library/datetime.rst:2379 +#: ../../library/datetime.rst:2460 msgid "``%b``" msgstr "``%b``" -#: ../../library/datetime.rst:2379 +#: ../../library/datetime.rst:2460 msgid "Month as locale's abbreviated name." msgstr "" @@ -3625,11 +3734,11 @@ msgstr "" msgid "Jan, Feb, ..., Dez (de_DE)" msgstr "" -#: ../../library/datetime.rst:2384 +#: ../../library/datetime.rst:2465 msgid "``%B``" msgstr "``%B``" -#: ../../library/datetime.rst:2384 +#: ../../library/datetime.rst:2465 msgid "Month as locale's full name." msgstr "" @@ -3641,67 +3750,67 @@ msgstr "" msgid "Januar, Februar, ..., Dezember (de_DE)" msgstr "" -#: ../../library/datetime.rst:2389 +#: ../../library/datetime.rst:2470 msgid "``%m``" msgstr "``%m``" -#: ../../library/datetime.rst:2389 +#: ../../library/datetime.rst:2470 msgid "Month as a zero-padded decimal number." msgstr "以零填充的並以十進位數字表示的月份。" -#: ../../library/datetime.rst:2389 ../../library/datetime.rst:2401 +#: ../../library/datetime.rst:2470 ../../library/datetime.rst:2482 msgid "01, 02, ..., 12" msgstr "01, 02, ..., 12" -#: ../../library/datetime.rst:2392 +#: ../../library/datetime.rst:2473 msgid "``%y``" msgstr "``%y``" -#: ../../library/datetime.rst:2392 +#: ../../library/datetime.rst:2473 msgid "Year without century as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2392 +#: ../../library/datetime.rst:2473 msgid "00, 01, ..., 99" msgstr "00, 01, ..., 99" -#: ../../library/datetime.rst:2395 +#: ../../library/datetime.rst:2476 msgid "``%Y``" msgstr "``%Y``" -#: ../../library/datetime.rst:2395 +#: ../../library/datetime.rst:2476 msgid "Year with century as a decimal number." msgstr "" -#: ../../library/datetime.rst:2395 ../../library/datetime.rst:2465 +#: ../../library/datetime.rst:2476 ../../library/datetime.rst:2546 msgid "0001, 0002, ..., 2013, 2014, ..., 9998, 9999" msgstr "0001, 0002, ..., 2013, 2014, ..., 9998, 9999" -#: ../../library/datetime.rst:2398 +#: ../../library/datetime.rst:2479 msgid "``%H``" msgstr "``%H``" -#: ../../library/datetime.rst:2398 +#: ../../library/datetime.rst:2479 msgid "Hour (24-hour clock) as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2398 +#: ../../library/datetime.rst:2479 msgid "00, 01, ..., 23" msgstr "00, 01, ..., 23" -#: ../../library/datetime.rst:2401 +#: ../../library/datetime.rst:2482 msgid "``%I``" msgstr "``%I``" -#: ../../library/datetime.rst:2401 +#: ../../library/datetime.rst:2482 msgid "Hour (12-hour clock) as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2404 +#: ../../library/datetime.rst:2485 msgid "``%p``" msgstr "``%p``" -#: ../../library/datetime.rst:2404 +#: ../../library/datetime.rst:2485 msgid "Locale's equivalent of either AM or PM." msgstr "" @@ -3713,128 +3822,128 @@ msgstr "AM, PM (en_US);" msgid "am, pm (de_DE)" msgstr "am, pm (de_DE)" -#: ../../library/datetime.rst:2404 +#: ../../library/datetime.rst:2485 msgid "\\(1), \\(3)" msgstr "\\(1), \\(3)" -#: ../../library/datetime.rst:2407 +#: ../../library/datetime.rst:2488 msgid "``%M``" msgstr "``%M``" -#: ../../library/datetime.rst:2407 +#: ../../library/datetime.rst:2488 msgid "Minute as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2407 ../../library/datetime.rst:2410 +#: ../../library/datetime.rst:2488 ../../library/datetime.rst:2491 msgid "00, 01, ..., 59" msgstr "00, 01, ..., 59" -#: ../../library/datetime.rst:2410 +#: ../../library/datetime.rst:2491 msgid "``%S``" msgstr "``%S``" -#: ../../library/datetime.rst:2410 +#: ../../library/datetime.rst:2491 msgid "Second as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2410 +#: ../../library/datetime.rst:2491 msgid "\\(4), \\(9)" msgstr "\\(4), \\(9)" -#: ../../library/datetime.rst:2413 +#: ../../library/datetime.rst:2494 msgid "``%f``" msgstr "``%f``" -#: ../../library/datetime.rst:2413 +#: ../../library/datetime.rst:2494 msgid "Microsecond as a decimal number, zero-padded to 6 digits." msgstr "" -#: ../../library/datetime.rst:2413 +#: ../../library/datetime.rst:2494 msgid "000000, 000001, ..., 999999" msgstr "000000, 000001, ..., 999999" -#: ../../library/datetime.rst:2413 +#: ../../library/datetime.rst:2494 msgid "\\(5)" msgstr "\\(5)" -#: ../../library/datetime.rst:2417 ../../library/datetime.rst:2576 +#: ../../library/datetime.rst:2498 ../../library/datetime.rst:2657 msgid "``%z``" msgstr "``%z``" -#: ../../library/datetime.rst:2417 +#: ../../library/datetime.rst:2498 msgid "" "UTC offset in the form ``±HHMM[SS[.ffffff]]`` (empty string if the object is " "naive)." msgstr "" -#: ../../library/datetime.rst:2417 +#: ../../library/datetime.rst:2498 msgid "(empty), +0000, -0400, +1030, +063415, -030712.345216" msgstr "" -#: ../../library/datetime.rst:2417 ../../library/datetime.rst:2422 -#: ../../library/datetime.rst:2479 +#: ../../library/datetime.rst:2498 ../../library/datetime.rst:2503 +#: ../../library/datetime.rst:2560 msgid "\\(6)" msgstr "\\(6)" -#: ../../library/datetime.rst:2422 ../../library/datetime.rst:2602 +#: ../../library/datetime.rst:2503 ../../library/datetime.rst:2683 msgid "``%Z``" msgstr "``%Z``" -#: ../../library/datetime.rst:2422 +#: ../../library/datetime.rst:2503 msgid "Time zone name (empty string if the object is naive)." msgstr "" -#: ../../library/datetime.rst:2422 +#: ../../library/datetime.rst:2503 msgid "(empty), UTC, GMT" msgstr "" -#: ../../library/datetime.rst:2425 +#: ../../library/datetime.rst:2506 msgid "``%j``" msgstr "``%j``" -#: ../../library/datetime.rst:2425 +#: ../../library/datetime.rst:2506 msgid "Day of the year as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2425 +#: ../../library/datetime.rst:2506 msgid "001, 002, ..., 366" msgstr "001, 002, ..., 366" -#: ../../library/datetime.rst:2428 +#: ../../library/datetime.rst:2509 msgid "``%U``" msgstr "``%U``" -#: ../../library/datetime.rst:2428 +#: ../../library/datetime.rst:2509 msgid "" "Week number of the year (Sunday as the first day of the week) as a zero-" "padded decimal number. All days in a new year preceding the first Sunday are " "considered to be in week 0." msgstr "" -#: ../../library/datetime.rst:2428 ../../library/datetime.rst:2436 +#: ../../library/datetime.rst:2509 ../../library/datetime.rst:2517 msgid "00, 01, ..., 53" msgstr "00, 01, ..., 53" -#: ../../library/datetime.rst:2428 ../../library/datetime.rst:2436 +#: ../../library/datetime.rst:2509 ../../library/datetime.rst:2517 msgid "\\(7), \\(9)" msgstr "\\(7), \\(9)" -#: ../../library/datetime.rst:2436 +#: ../../library/datetime.rst:2517 msgid "``%W``" msgstr "``%W``" -#: ../../library/datetime.rst:2436 +#: ../../library/datetime.rst:2517 msgid "" "Week number of the year (Monday as the first day of the week) as a zero-" "padded decimal number. All days in a new year preceding the first Monday are " "considered to be in week 0." msgstr "" -#: ../../library/datetime.rst:2444 +#: ../../library/datetime.rst:2525 msgid "``%c``" msgstr "``%c``" -#: ../../library/datetime.rst:2444 +#: ../../library/datetime.rst:2525 msgid "Locale's appropriate date and time representation." msgstr "" @@ -3846,11 +3955,11 @@ msgstr "" msgid "Di 16 Aug 21:30:00 1988 (de_DE)" msgstr "" -#: ../../library/datetime.rst:2449 +#: ../../library/datetime.rst:2530 msgid "``%x``" msgstr "``%x``" -#: ../../library/datetime.rst:2449 +#: ../../library/datetime.rst:2530 msgid "Locale's appropriate date representation." msgstr "" @@ -3866,11 +3975,11 @@ msgstr "" msgid "16.08.1988 (de_DE)" msgstr "" -#: ../../library/datetime.rst:2453 +#: ../../library/datetime.rst:2534 msgid "``%X``" msgstr "``%X``" -#: ../../library/datetime.rst:2453 +#: ../../library/datetime.rst:2534 msgid "Locale's appropriate time representation." msgstr "" @@ -3882,83 +3991,83 @@ msgstr "" msgid "21:30:00 (de_DE)" msgstr "" -#: ../../library/datetime.rst:2456 +#: ../../library/datetime.rst:2537 msgid "``%%``" msgstr "``%%``" -#: ../../library/datetime.rst:2456 +#: ../../library/datetime.rst:2537 msgid "A literal ``'%'`` character." msgstr "" -#: ../../library/datetime.rst:2456 +#: ../../library/datetime.rst:2537 msgid "%" msgstr "%" -#: ../../library/datetime.rst:2459 +#: ../../library/datetime.rst:2540 msgid "" "Several additional directives not required by the C89 standard are included " "for convenience. These parameters all correspond to ISO 8601 date values." msgstr "" -#: ../../library/datetime.rst:2465 +#: ../../library/datetime.rst:2546 msgid "``%G``" msgstr "``%G``" -#: ../../library/datetime.rst:2465 +#: ../../library/datetime.rst:2546 msgid "" "ISO 8601 year with century representing the year that contains the greater " "part of the ISO week (``%V``)." msgstr "" -#: ../../library/datetime.rst:2465 +#: ../../library/datetime.rst:2546 msgid "\\(8)" msgstr "\\(8)" -#: ../../library/datetime.rst:2470 +#: ../../library/datetime.rst:2551 msgid "``%u``" msgstr "``%u``" -#: ../../library/datetime.rst:2470 +#: ../../library/datetime.rst:2551 msgid "ISO 8601 weekday as a decimal number where 1 is Monday." msgstr "" -#: ../../library/datetime.rst:2470 +#: ../../library/datetime.rst:2551 msgid "1, 2, ..., 7" msgstr "1, 2, ..., 7" -#: ../../library/datetime.rst:2473 +#: ../../library/datetime.rst:2554 msgid "``%V``" msgstr "``%V``" -#: ../../library/datetime.rst:2473 +#: ../../library/datetime.rst:2554 msgid "" "ISO 8601 week as a decimal number with Monday as the first day of the week. " "Week 01 is the week containing Jan 4." msgstr "" -#: ../../library/datetime.rst:2473 +#: ../../library/datetime.rst:2554 msgid "01, 02, ..., 53" msgstr "01, 02, ..., 53" -#: ../../library/datetime.rst:2473 +#: ../../library/datetime.rst:2554 msgid "\\(8), \\(9)" msgstr "\\(8), \\(9)" -#: ../../library/datetime.rst:2479 ../../library/datetime.rst:2598 +#: ../../library/datetime.rst:2560 ../../library/datetime.rst:2679 msgid "``%:z``" msgstr "``%:z``" -#: ../../library/datetime.rst:2479 +#: ../../library/datetime.rst:2560 msgid "" "UTC offset in the form ``±HH:MM[:SS[.ffffff]]`` (empty string if the object " "is naive)." msgstr "" -#: ../../library/datetime.rst:2479 +#: ../../library/datetime.rst:2560 msgid "(empty), +00:00, -04:00, +10:30, +06:34:15, -03:07:12.345216" msgstr "" -#: ../../library/datetime.rst:2485 +#: ../../library/datetime.rst:2566 msgid "" "These may not be available on all platforms when used with the :meth:`~." "datetime.strftime` method. The ISO 8601 year and ISO 8601 week directives " @@ -3967,7 +4076,7 @@ msgid "" "directives will raise a :exc:`ValueError`." msgstr "" -#: ../../library/datetime.rst:2490 +#: ../../library/datetime.rst:2571 msgid "" "The full set of format codes supported varies across platforms, because " "Python calls the platform C library's :c:func:`strftime` function, and " @@ -3977,44 +4086,44 @@ msgid "" "unsupported format specifiers." msgstr "" -#: ../../library/datetime.rst:2496 +#: ../../library/datetime.rst:2577 msgid "``%G``, ``%u`` and ``%V`` were added." msgstr "新增 ``%G``、``%u`` 與 ``%V``。" -#: ../../library/datetime.rst:2499 +#: ../../library/datetime.rst:2580 msgid "``%:z`` was added." msgstr "新增 ``%:z``。" -#: ../../library/datetime.rst:2503 +#: ../../library/datetime.rst:2584 msgid "Technical Detail" msgstr "技術細節" -#: ../../library/datetime.rst:2505 +#: ../../library/datetime.rst:2586 msgid "" "Broadly speaking, ``d.strftime(fmt)`` acts like the :mod:`time` module's " "``time.strftime(fmt, d.timetuple())`` although not all objects support a :" "meth:`~date.timetuple` method." msgstr "" -#: ../../library/datetime.rst:2509 +#: ../../library/datetime.rst:2590 msgid "" "For the :meth:`.datetime.strptime` class method, the default value is " "``1900-01-01T00:00:00.000``: any components not specified in the format " "string will be pulled from the default value. [#]_" msgstr "" -#: ../../library/datetime.rst:2513 +#: ../../library/datetime.rst:2594 msgid "Using ``datetime.strptime(date_string, format)`` is equivalent to::" msgstr "" -#: ../../library/datetime.rst:2517 +#: ../../library/datetime.rst:2598 msgid "" "except when the format includes sub-second components or time zone offset " "information, which are supported in ``datetime.strptime`` but are discarded " "by ``time.strptime``." msgstr "" -#: ../../library/datetime.rst:2521 +#: ../../library/datetime.rst:2602 msgid "" "For :class:`.time` objects, the format codes for year, month, and day should " "not be used, as :class:`!time` objects have no such values. If they're used " @@ -4024,7 +4133,7 @@ msgstr "" "time` 物件並沒有這些值。如果使用這些格式碼,年份會以 1900 代替、月及日會以 1 " "代替。" -#: ../../library/datetime.rst:2525 +#: ../../library/datetime.rst:2606 msgid "" "For :class:`date` objects, the format codes for hours, minutes, seconds, and " "microseconds should not be used, as :class:`date` objects have no such " @@ -4033,7 +4142,7 @@ msgstr "" "對 :class:`.date` 物件來說,不應該使用時、分、秒、微秒的格式碼,因為 :class:" "`date` 物件並沒有這些值。如果使用這些格式碼,這些值都會以 0 代替。" -#: ../../library/datetime.rst:2529 +#: ../../library/datetime.rst:2610 msgid "" "For the same reason, handling of format strings containing Unicode code " "points that can't be represented in the charset of the current locale is " @@ -4042,7 +4151,7 @@ msgid "" "`UnicodeError` or return an empty string instead." msgstr "" -#: ../../library/datetime.rst:2538 +#: ../../library/datetime.rst:2619 msgid "" "Because the format depends on the current locale, care should be taken when " "making assumptions about the output value. Field orderings will vary (for " @@ -4050,38 +4159,38 @@ msgid "" "contain non-ASCII characters." msgstr "" -#: ../../library/datetime.rst:2544 +#: ../../library/datetime.rst:2625 msgid "" "The :meth:`~.datetime.strptime` method can parse years in the full [1, 9999] " "range, but years < 1000 must be zero-filled to 4-digit width." msgstr "" -#: ../../library/datetime.rst:2547 +#: ../../library/datetime.rst:2628 msgid "" "In previous versions, :meth:`~.datetime.strftime` method was restricted to " "years >= 1900." msgstr "" -#: ../../library/datetime.rst:2551 +#: ../../library/datetime.rst:2632 msgid "" "In version 3.2, :meth:`~.datetime.strftime` method was restricted to years " ">= 1000." msgstr "" -#: ../../library/datetime.rst:2556 +#: ../../library/datetime.rst:2637 msgid "" "When used with the :meth:`~.datetime.strptime` method, the ``%p`` directive " "only affects the output hour field if the ``%I`` directive is used to parse " "the hour." msgstr "" -#: ../../library/datetime.rst:2560 +#: ../../library/datetime.rst:2641 msgid "" "Unlike the :mod:`time` module, the :mod:`!datetime` module does not support " "leap seconds." msgstr "" -#: ../../library/datetime.rst:2564 +#: ../../library/datetime.rst:2645 msgid "" "When used with the :meth:`~.datetime.strptime` method, the ``%f`` directive " "accepts from one to six digits and zero pads on the right. ``%f`` is an " @@ -4089,17 +4198,17 @@ msgid "" "separately in datetime objects, and therefore always available)." msgstr "" -#: ../../library/datetime.rst:2571 +#: ../../library/datetime.rst:2652 msgid "" "For a naive object, the ``%z``, ``%:z`` and ``%Z`` format codes are replaced " "by empty strings." msgstr "" -#: ../../library/datetime.rst:2574 +#: ../../library/datetime.rst:2655 msgid "For an aware object:" msgstr "" -#: ../../library/datetime.rst:2577 +#: ../../library/datetime.rst:2658 msgid "" ":meth:`~.datetime.utcoffset` is transformed into a string of the form " "``±HHMM[SS[.ffffff]]``, where ``HH`` is a 2-digit string giving the number " @@ -4113,7 +4222,7 @@ msgid "" "replaced with the string ``'-0330'``." msgstr "" -#: ../../library/datetime.rst:2591 +#: ../../library/datetime.rst:2672 msgid "" "When the ``%z`` directive is provided to the :meth:`~.datetime.strptime` " "method, the UTC offsets can have a colon as a separator between hours, " @@ -4122,53 +4231,53 @@ msgid "" "``'+00:00'``." msgstr "" -#: ../../library/datetime.rst:2599 +#: ../../library/datetime.rst:2680 msgid "" "Behaves exactly as ``%z``, but has a colon separator added between hours, " "minutes and seconds." msgstr "" -#: ../../library/datetime.rst:2603 +#: ../../library/datetime.rst:2684 msgid "" "In :meth:`~.datetime.strftime`, ``%Z`` is replaced by an empty string if :" "meth:`~.datetime.tzname` returns ``None``; otherwise ``%Z`` is replaced by " "the returned value, which must be a string." msgstr "" -#: ../../library/datetime.rst:2607 +#: ../../library/datetime.rst:2688 msgid ":meth:`~.datetime.strptime` only accepts certain values for ``%Z``:" msgstr "" -#: ../../library/datetime.rst:2609 +#: ../../library/datetime.rst:2690 msgid "any value in ``time.tzname`` for your machine's locale" msgstr "" -#: ../../library/datetime.rst:2610 +#: ../../library/datetime.rst:2691 msgid "the hard-coded values ``UTC`` and ``GMT``" msgstr "" -#: ../../library/datetime.rst:2612 +#: ../../library/datetime.rst:2693 msgid "" "So someone living in Japan may have ``JST``, ``UTC``, and ``GMT`` as valid " "values, but probably not ``EST``. It will raise ``ValueError`` for invalid " "values." msgstr "" -#: ../../library/datetime.rst:2616 +#: ../../library/datetime.rst:2697 msgid "" "When the ``%z`` directive is provided to the :meth:`~.datetime.strptime` " "method, an aware :class:`.datetime` object will be produced. The ``tzinfo`` " "of the result will be set to a :class:`timezone` instance." msgstr "" -#: ../../library/datetime.rst:2622 +#: ../../library/datetime.rst:2703 msgid "" "When used with the :meth:`~.datetime.strptime` method, ``%U`` and ``%W`` are " "only used in calculations when the day of the week and the calendar year " "(``%Y``) are specified." msgstr "" -#: ../../library/datetime.rst:2627 +#: ../../library/datetime.rst:2708 msgid "" "Similar to ``%U`` and ``%W``, ``%V`` is only used in calculations when the " "day of the week and the ISO year (``%G``) are specified in a :meth:`~." @@ -4176,7 +4285,7 @@ msgid "" "interchangeable." msgstr "" -#: ../../library/datetime.rst:2633 +#: ../../library/datetime.rst:2714 msgid "" "When used with the :meth:`~.datetime.strptime` method, the leading zero is " "optional for formats ``%d``, ``%m``, ``%H``, ``%I``, ``%M``, ``%S``, " @@ -4184,15 +4293,40 @@ msgid "" "zero." msgstr "" -#: ../../library/datetime.rst:2638 +#: ../../library/datetime.rst:2719 +msgid "" +"When parsing a month and day using :meth:`~.datetime.strptime`, always " +"include a year in the format. If the value you need to parse lacks a year, " +"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..." +msgstr "" + +#: ../../library/datetime.rst:2725 +msgid "" +">>> month_day = \"02/29\"\n" +">>> datetime.strptime(f\"{month_day};1984\", \"%m/%d;%Y\") # No leap year " +"bug.\n" +"datetime.datetime(1984, 2, 29, 0, 0)" +msgstr "" + +#: ../../library/datetime.rst:2731 +msgid "" +":meth:`~.datetime.strptime` calls using a format string containing a day of " +"month without a year now emit a :exc:`DeprecationWarning`. In 3.15 or later " +"we may change this into an error or change the default year to a leap year. " +"See :gh:`70647`." +msgstr "" + +#: ../../library/datetime.rst:2738 msgid "Footnotes" msgstr "註解" -#: ../../library/datetime.rst:2639 +#: ../../library/datetime.rst:2739 msgid "If, that is, we ignore the effects of Relativity" msgstr "也就是說,我們會忽略相對論的效應" -#: ../../library/datetime.rst:2641 +#: ../../library/datetime.rst:2741 msgid "" "This matches the definition of the \"proleptic Gregorian\" calendar in " "Dershowitz and Reingold's book *Calendrical Calculations*, where it's the " @@ -4201,23 +4335,23 @@ msgid "" "systems." msgstr "" -#: ../../library/datetime.rst:2647 +#: ../../library/datetime.rst:2747 msgid "" "See R. H. van Gent's `guide to the mathematics of the ISO 8601 calendar " "`_ for a good explanation." msgstr "" -#: ../../library/datetime.rst:2651 +#: ../../library/datetime.rst:2751 msgid "" "Passing ``datetime.strptime('Feb 29', '%b %d')`` will fail since 1900 is not " "a leap year." msgstr "" -#: ../../library/datetime.rst:2311 +#: ../../library/datetime.rst:2392 msgid "% (percent)" msgstr "% (百分號)" -#: ../../library/datetime.rst:2311 +#: ../../library/datetime.rst:2392 msgid "datetime format" msgstr "datetime format(日期時間格式)" diff --git a/library/dbm.po b/library/dbm.po index 0fb484fbbd..70cf899c11 100644 --- a/library/dbm.po +++ b/library/dbm.po @@ -5,9 +5,9 @@ # jerrychen , 2016 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2025-02-12 00:13+0000\n" "PO-Revision-Date: 2018-05-23 14:42+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -27,52 +27,66 @@ msgid "**Source code:** :source:`Lib/dbm/__init__.py`" msgstr "**原始碼:**\\ :source:`Lib/dbm/__init__.py`" #: ../../library/dbm.rst:11 +msgid ":mod:`dbm` is a generic interface to variants of the DBM database:" +msgstr "" + +#: ../../library/dbm.rst:13 +msgid ":mod:`dbm.sqlite3`" +msgstr ":mod:`dbm.sqlite3`" + +#: ../../library/dbm.rst:14 +msgid ":mod:`dbm.gnu`" +msgstr ":mod:`dbm.gnu`" + +#: ../../library/dbm.rst:15 +msgid ":mod:`dbm.ndbm`" +msgstr ":mod:`dbm.ndbm`" + +#: ../../library/dbm.rst:17 msgid "" -":mod:`dbm` is a generic interface to variants of the DBM database --- :mod:" -"`dbm.gnu` or :mod:`dbm.ndbm`. If none of these modules is installed, the " -"slow-but-simple implementation in module :mod:`dbm.dumb` will be used. " -"There is a `third party interface `_ to the Oracle Berkeley DB." +"If none of these modules are installed, the slow-but-simple implementation " +"in module :mod:`dbm.dumb` will be used. There is a `third party interface " +"`_ to the Oracle Berkeley DB." msgstr "" -#: ../../library/dbm.rst:20 +#: ../../library/dbm.rst:24 msgid "" "A tuple containing the exceptions that can be raised by each of the " "supported modules, with a unique exception also named :exc:`dbm.error` as " "the first item --- the latter is used when :exc:`dbm.error` is raised." msgstr "" -#: ../../library/dbm.rst:27 +#: ../../library/dbm.rst:31 msgid "" "This function attempts to guess which of the several simple database modules " -"available --- :mod:`dbm.gnu`, :mod:`dbm.ndbm` or :mod:`dbm.dumb` --- should " -"be used to open a given file." +"available --- :mod:`dbm.sqlite3`, :mod:`dbm.gnu`, :mod:`dbm.ndbm`, or :mod:" +"`dbm.dumb` --- should be used to open a given file." msgstr "" -#: ../../library/dbm.rst:31 +#: ../../library/dbm.rst:35 msgid "Return one of the following values:" msgstr "回傳以下其中一個值:" -#: ../../library/dbm.rst:33 +#: ../../library/dbm.rst:37 msgid "" "``None`` if the file can't be opened because it's unreadable or doesn't exist" msgstr "" -#: ../../library/dbm.rst:34 +#: ../../library/dbm.rst:38 msgid "the empty string (``''``) if the file's format can't be guessed" msgstr "" -#: ../../library/dbm.rst:35 +#: ../../library/dbm.rst:39 msgid "" "a string containing the required module name, such as ``'dbm.ndbm'`` or " "``'dbm.gnu'``" msgstr "" -#: ../../library/dbm.rst:37 ../../library/dbm.rst:202 ../../library/dbm.rst:386 +#: ../../library/dbm.rst:41 ../../library/dbm.rst:250 ../../library/dbm.rst:448 msgid "*filename* accepts a :term:`path-like object`." msgstr "" -#: ../../library/dbm.rst:61 +#: ../../library/dbm.rst:65 msgid "Open a database and return the corresponding database object." msgstr "" @@ -80,7 +94,7 @@ msgstr "" msgid "Parameters" msgstr "參數" -#: ../../library/dbm.rst:63 +#: ../../library/dbm.rst:67 msgid "" "The database file to open. If the database file already exists, the :func:" "`whichdb` function is used to determine its type and the appropriate module " @@ -88,18 +102,18 @@ msgid "" "imported is used." msgstr "" -#: ../../library/dbm.rst:64 ../../library/dbm.rst:174 +#: ../../library/dbm.rst:68 ../../library/dbm.rst:222 msgid "The database file to open." msgstr "要打開的資料庫檔案" -#: ../../library/dbm.rst:66 +#: ../../library/dbm.rst:70 msgid "" "If the database file already exists, the :func:`whichdb` function is used to " "determine its type and the appropriate module is used; if it does not exist, " "the first submodule listed above that can be imported is used." msgstr "" -#: ../../library/dbm.rst:71 ../../library/dbm.rst:297 +#: ../../library/dbm.rst:75 ../../library/dbm.rst:178 ../../library/dbm.rst:353 msgid "" "* ``'r'`` (default): |flag_r| * ``'w'``: |flag_w| * ``'c'``: |flag_c| * " "``'n'``: |flag_n|" @@ -107,34 +121,36 @@ msgstr "" "* ``'r'`` (default): |flag_r| * ``'w'``: |flag_w| * ``'c'``: |flag_c| * " "``'n'``: |flag_n|" -#: ../../library/dbm.rst:72 ../../library/dbm.rst:179 ../../library/dbm.rst:298 +#: ../../library/dbm.rst:76 ../../library/dbm.rst:180 ../../library/dbm.rst:227 +#: ../../library/dbm.rst:354 msgid "``'r'`` (default): |flag_r|" msgstr "``'r'`` (default): |flag_r|" -#: ../../library/dbm.rst:73 ../../library/dbm.rst:180 ../../library/dbm.rst:299 -#: ../../library/dbm.rst:367 +#: ../../library/dbm.rst:77 ../../library/dbm.rst:181 ../../library/dbm.rst:228 +#: ../../library/dbm.rst:355 ../../library/dbm.rst:429 msgid "``'w'``: |flag_w|" msgstr "``'w'``: |flag_w|" -#: ../../library/dbm.rst:74 ../../library/dbm.rst:181 ../../library/dbm.rst:300 +#: ../../library/dbm.rst:78 ../../library/dbm.rst:182 ../../library/dbm.rst:229 +#: ../../library/dbm.rst:356 msgid "``'c'``: |flag_c|" msgstr "``'c'``: |flag_c|" -#: ../../library/dbm.rst:75 ../../library/dbm.rst:182 ../../library/dbm.rst:301 -#: ../../library/dbm.rst:369 +#: ../../library/dbm.rst:79 ../../library/dbm.rst:183 ../../library/dbm.rst:230 +#: ../../library/dbm.rst:357 ../../library/dbm.rst:431 msgid "``'n'``: |flag_n|" msgstr "``'n'``: |flag_n|" -#: ../../library/dbm.rst:77 ../../library/dbm.rst:196 ../../library/dbm.rst:303 -#: ../../library/dbm.rst:371 +#: ../../library/dbm.rst:81 ../../library/dbm.rst:244 ../../library/dbm.rst:359 +#: ../../library/dbm.rst:433 msgid "|mode_param_doc|" msgstr "|mode_param_doc|" -#: ../../library/dbm.rst:80 +#: ../../library/dbm.rst:84 msgid "*file* accepts a :term:`path-like object`." msgstr "*file* 接受一個\\ :term:`類路徑物件 `。" -#: ../../library/dbm.rst:83 +#: ../../library/dbm.rst:87 msgid "" "The object returned by :func:`~dbm.open` supports the same basic " "functionality as a :class:`dict`; keys and their corresponding values can be " @@ -143,44 +159,44 @@ msgid "" "setdefault` methods." msgstr "" -#: ../../library/dbm.rst:88 +#: ../../library/dbm.rst:92 msgid "" "Key and values are always stored as :class:`bytes`. This means that when " "strings are used they are implicitly converted to the default encoding " "before being stored." msgstr "" -#: ../../library/dbm.rst:92 +#: ../../library/dbm.rst:96 msgid "" "These objects also support being used in a :keyword:`with` statement, which " "will automatically close them when done." msgstr "" -#: ../../library/dbm.rst:95 +#: ../../library/dbm.rst:99 msgid "" ":meth:`!get` and :meth:`!setdefault` methods are now available for all :mod:" "`dbm` backends." msgstr "" -#: ../../library/dbm.rst:99 +#: ../../library/dbm.rst:103 msgid "" "Added native support for the context management protocol to the objects " "returned by :func:`~dbm.open`." msgstr "" -#: ../../library/dbm.rst:103 +#: ../../library/dbm.rst:107 msgid "" "Deleting a key from a read-only database raises a database module specific " "exception instead of :exc:`KeyError`." msgstr "" -#: ../../library/dbm.rst:107 +#: ../../library/dbm.rst:111 msgid "" "The following example records some hostnames and a corresponding title, and " "then prints out the contents of the database::" msgstr "" -#: ../../library/dbm.rst:110 +#: ../../library/dbm.rst:114 msgid "" "import dbm\n" "\n" @@ -207,51 +223,104 @@ msgid "" "# db is automatically closed when leaving the with statement." msgstr "" -#: ../../library/dbm.rst:137 +#: ../../library/dbm.rst:141 msgid "Module :mod:`shelve`" msgstr ":mod:`shelve` 模組" -#: ../../library/dbm.rst:138 +#: ../../library/dbm.rst:142 msgid "Persistence module which stores non-string data." msgstr "" -#: ../../library/dbm.rst:141 +#: ../../library/dbm.rst:145 msgid "The individual submodules are described in the following sections." msgstr "" -#: ../../library/dbm.rst:145 +#: ../../library/dbm.rst:148 +msgid ":mod:`dbm.sqlite3` --- SQLite backend for dbm" +msgstr ":mod:`dbm.sqlite3` --- dbm 的 SQLite 後端" + +#: ../../library/dbm.rst:156 +msgid "**Source code:** :source:`Lib/dbm/sqlite3.py`" +msgstr "**原始碼:**\\ :source:`Lib/dbm/sqlite3.py`" + +#: ../../library/dbm.rst:160 +msgid "" +"This module uses the standard library :mod:`sqlite3` module to provide an " +"SQLite backend for the :mod:`dbm` module. The files created by :mod:`dbm." +"sqlite3` can thus be opened by :mod:`sqlite3`, or any other SQLite browser, " +"including the SQLite CLI." +msgstr "" + +#: ../../includes/wasm-mobile-notavail.rst:3 ../../includes/wasm-notavail.rst:3 +msgid "Availability" +msgstr "可用性" + +#: ../../includes/wasm-notavail.rst:5 +msgid "" +"This module does not work or is not available on WebAssembly. See :ref:`wasm-" +"availability` for more information." +msgstr "" +"此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" +"availability`。" + +#: ../../library/dbm.rst:169 +msgid "" +"Open an SQLite database. The returned object behaves like a :term:`mapping`, " +"implements a :meth:`!close` method, and supports a \"closing\" context " +"manager via the :keyword:`with` keyword." +msgstr "" + +#: ../../library/dbm.rst:174 +msgid "The path to the database to be opened." +msgstr "要打開的資料庫路徑" + +#: ../../library/dbm.rst:185 +msgid "" +"The Unix file access mode of the file (default: octal ``0o666``), used only " +"when the database has to be created." +msgstr "" + +#: ../../library/dbm.rst:191 msgid ":mod:`dbm.gnu` --- GNU database manager" msgstr ":mod:`dbm.gnu` --- GNU 資料庫管理器" -#: ../../library/dbm.rst:151 +#: ../../library/dbm.rst:197 msgid "**Source code:** :source:`Lib/dbm/gnu.py`" msgstr "**原始碼:**\\ :source:`Lib/dbm/gnu.py`" -#: ../../library/dbm.rst:155 +#: ../../library/dbm.rst:201 msgid "" "The :mod:`dbm.gnu` module provides an interface to the :abbr:`GDBM (GNU " "dbm)` library, similar to the :mod:`dbm.ndbm` module, but with additional " "functionality like crash tolerance." msgstr "" -#: ../../library/dbm.rst:161 ../../library/dbm.rst:267 +#: ../../library/dbm.rst:207 ../../library/dbm.rst:321 msgid "" "The file formats created by :mod:`dbm.gnu` and :mod:`dbm.ndbm` are " "incompatible and can not be used interchangeably." msgstr "" -#: ../../library/dbm.rst:166 +#: ../../includes/wasm-mobile-notavail.rst:5 +msgid "" +"This module is not supported on :ref:`mobile platforms ` or :ref:`WebAssembly platforms `." +msgstr "" +"此模組在\\ :ref:`行動平台 `\\ 或\\ :ref:`WebAssembly 平" +"台 `\\ 上不支援。" + +#: ../../library/dbm.rst:214 msgid "" "Raised on :mod:`dbm.gnu`-specific errors, such as I/O errors. :exc:" "`KeyError` is raised for general mapping errors like specifying an incorrect " "key." msgstr "" -#: ../../library/dbm.rst:172 +#: ../../library/dbm.rst:220 msgid "Open a GDBM database and return a :class:`!gdbm` object." msgstr "" -#: ../../library/dbm.rst:178 +#: ../../library/dbm.rst:226 msgid "" "* ``'r'`` (default): |flag_r| * ``'w'``: |flag_w| * ``'c'``: |flag_c| * " "``'n'``: |flag_n| The following additional characters may be appended to " @@ -263,29 +332,29 @@ msgid "" "flag characters." msgstr "" -#: ../../library/dbm.rst:184 +#: ../../library/dbm.rst:232 msgid "" "The following additional characters may be appended to control how the " "database is opened:" msgstr "" -#: ../../library/dbm.rst:187 +#: ../../library/dbm.rst:235 msgid "" "``'f'``: Open the database in fast mode. Writes to the database will not be " "synchronized." msgstr "" -#: ../../library/dbm.rst:189 +#: ../../library/dbm.rst:237 msgid "" "``'s'``: Synchronized mode. Changes to the database will be written " "immediately to the file." msgstr "" -#: ../../library/dbm.rst:191 +#: ../../library/dbm.rst:239 msgid "``'u'``: Do not lock database." msgstr "``'u'``: 不要鎖住資料庫。" -#: ../../library/dbm.rst:193 +#: ../../library/dbm.rst:241 msgid "" "Not all flags are valid for all versions of GDBM. See the :data:`open_flags` " "member for a list of supported flag characters." @@ -295,24 +364,24 @@ msgstr "" msgid "Raises" msgstr "引發" -#: ../../library/dbm.rst:199 +#: ../../library/dbm.rst:247 msgid "If an invalid *flag* argument is passed." msgstr "如果一個無效的 *flag* 引數被傳入。" -#: ../../library/dbm.rst:207 +#: ../../library/dbm.rst:255 msgid "" "A string of characters the *flag* parameter of :meth:`~dbm.gnu.open` " "supports." msgstr "" -#: ../../library/dbm.rst:209 +#: ../../library/dbm.rst:257 msgid "" ":class:`!gdbm` objects behave similar to :term:`mappings `, but :" "meth:`!items` and :meth:`!values` methods are not supported. The following " "methods are also provided:" msgstr "" -#: ../../library/dbm.rst:215 +#: ../../library/dbm.rst:263 msgid "" "It's possible to loop over every key in the database using this method and " "the :meth:`nextkey` method. The traversal is ordered by GDBM's internal " @@ -320,14 +389,14 @@ msgid "" "starting key." msgstr "" -#: ../../library/dbm.rst:222 +#: ../../library/dbm.rst:270 msgid "" "Returns the key that follows *key* in the traversal. The following code " "prints every key in the database ``db``, without having to create a list in " "memory that contains them all::" msgstr "" -#: ../../library/dbm.rst:226 +#: ../../library/dbm.rst:274 msgid "" "k = db.firstkey()\n" "while k is not None:\n" @@ -339,7 +408,7 @@ msgstr "" " print(k)\n" " k = db.nextkey(k)" -#: ../../library/dbm.rst:233 +#: ../../library/dbm.rst:281 msgid "" "If you have carried out a lot of deletions and would like to shrink the " "space used by the GDBM file, this routine will reorganize the database. :" @@ -348,32 +417,36 @@ msgid "" "reused as new (key, value) pairs are added." msgstr "" -#: ../../library/dbm.rst:241 +#: ../../library/dbm.rst:289 msgid "" "When the database has been opened in fast mode, this method forces any " "unwritten data to be written to the disk." msgstr "" -#: ../../library/dbm.rst:246 +#: ../../library/dbm.rst:294 msgid "Close the GDBM database." msgstr "關閉 GDBM 資料庫。" -#: ../../library/dbm.rst:250 +#: ../../library/dbm.rst:298 +msgid "Remove all items from the GDBM database." +msgstr "移除 GDBM 資料庫中所有項目。" + +#: ../../library/dbm.rst:304 msgid ":mod:`dbm.ndbm` --- New Database Manager" msgstr ":mod:`dbm.ndbm` --- 新資料庫管理器" -#: ../../library/dbm.rst:256 +#: ../../library/dbm.rst:310 msgid "**Source code:** :source:`Lib/dbm/ndbm.py`" msgstr "**原始碼:**\\ :source:`Lib/dbm/ndbm.py`" -#: ../../library/dbm.rst:260 +#: ../../library/dbm.rst:314 msgid "" "The :mod:`dbm.ndbm` module provides an interface to the :abbr:`NDBM (New " "Database Manager)` library. This module can be used with the \"classic\" " "NDBM interface or the :abbr:`GDBM (GNU dbm)` compatibility interface." msgstr "" -#: ../../library/dbm.rst:272 +#: ../../library/dbm.rst:326 msgid "" "The NDBM library shipped as part of macOS has an undocumented limitation on " "the size of values, which can result in corrupted database files when " @@ -381,51 +454,55 @@ msgid "" "result in a hard crash (segmentation fault)." msgstr "" -#: ../../library/dbm.rst:279 +#: ../../library/dbm.rst:335 msgid "" "Raised on :mod:`dbm.ndbm`-specific errors, such as I/O errors. :exc:" "`KeyError` is raised for general mapping errors like specifying an incorrect " "key." msgstr "" -#: ../../library/dbm.rst:285 +#: ../../library/dbm.rst:341 msgid "Name of the NDBM implementation library used." msgstr "" -#: ../../library/dbm.rst:290 +#: ../../library/dbm.rst:346 msgid "Open an NDBM database and return an :class:`!ndbm` object." msgstr "" -#: ../../library/dbm.rst:292 +#: ../../library/dbm.rst:348 msgid "" "The basename of the database file (without the :file:`.dir` or :file:`.pag` " "extensions)." msgstr "" -#: ../../library/dbm.rst:306 +#: ../../library/dbm.rst:362 msgid "" ":class:`!ndbm` objects behave similar to :term:`mappings `, but :" "meth:`!items` and :meth:`!values` methods are not supported. The following " "methods are also provided:" msgstr "" -#: ../../library/dbm.rst:310 +#: ../../library/dbm.rst:366 msgid "Accepts :term:`path-like object` for filename." msgstr "" -#: ../../library/dbm.rst:315 +#: ../../library/dbm.rst:371 msgid "Close the NDBM database." msgstr "關閉 NDBM 資料庫。" -#: ../../library/dbm.rst:319 +#: ../../library/dbm.rst:375 +msgid "Remove all items from the NDBM database." +msgstr "移除 NDBM 資料庫中所有項目。" + +#: ../../library/dbm.rst:381 msgid ":mod:`dbm.dumb` --- Portable DBM implementation" msgstr ":mod:`dbm.dumb` --- 可攜式 DBM 實作" -#: ../../library/dbm.rst:324 +#: ../../library/dbm.rst:386 msgid "**Source code:** :source:`Lib/dbm/dumb.py`" msgstr "**原始碼:**\\ :source:`Lib/dbm/dumb.py`" -#: ../../library/dbm.rst:330 +#: ../../library/dbm.rst:392 msgid "" "The :mod:`dbm.dumb` module is intended as a last resort fallback for the :" "mod:`dbm` module when a more robust module is not available. The :mod:`dbm." @@ -433,53 +510,53 @@ msgid "" "the other database modules." msgstr "" -#: ../../library/dbm.rst:337 +#: ../../library/dbm.rst:399 msgid "" "The :mod:`dbm.dumb` module provides a persistent :class:`dict`-like " "interface which is written entirely in Python. Unlike other :mod:`dbm` " "backends, such as :mod:`dbm.gnu`, no external library is required." msgstr "" -#: ../../library/dbm.rst:342 +#: ../../library/dbm.rst:404 msgid "The :mod:`!dbm.dumb` module defines the following:" msgstr ":mod:`!dbm.dumb` 模組定義了以下項目:" -#: ../../library/dbm.rst:346 +#: ../../library/dbm.rst:408 msgid "" "Raised on :mod:`dbm.dumb`-specific errors, such as I/O errors. :exc:" "`KeyError` is raised for general mapping errors like specifying an incorrect " "key." msgstr "" -#: ../../library/dbm.rst:352 +#: ../../library/dbm.rst:414 msgid "" "Open a :mod:`!dbm.dumb` database. The returned database object behaves " "similar to a :term:`mapping`, in addition to providing :meth:`~dumbdbm.sync` " "and :meth:`~dumbdbm.close` methods." msgstr "" -#: ../../library/dbm.rst:357 +#: ../../library/dbm.rst:419 msgid "" "The basename of the database file (without extensions). A new database " "creates the following files: - :file:`{filename}.dat` - :file:`{filename}." "dir`" msgstr "" -#: ../../library/dbm.rst:358 +#: ../../library/dbm.rst:420 msgid "" "The basename of the database file (without extensions). A new database " "creates the following files:" msgstr "" -#: ../../library/dbm.rst:361 +#: ../../library/dbm.rst:423 msgid ":file:`{filename}.dat`" msgstr ":file:`{filename}.dat`" -#: ../../library/dbm.rst:362 +#: ../../library/dbm.rst:424 msgid ":file:`{filename}.dir`" msgstr ":file:`{filename}.dir`" -#: ../../library/dbm.rst:365 +#: ../../library/dbm.rst:427 msgid "" "* ``'r'``: |flag_r| * ``'w'``: |flag_w| * ``'c'`` (default): |flag_c| * " "``'n'``: |flag_n|" @@ -487,51 +564,48 @@ msgstr "" "* ``'r'``: |flag_r| * ``'w'``: |flag_w| * ``'c'`` (default): |flag_c| * " "``'n'``: |flag_n|" -#: ../../library/dbm.rst:366 +#: ../../library/dbm.rst:428 msgid "``'r'``: |flag_r|" msgstr "``'r'``: |flag_r|" -#: ../../library/dbm.rst:368 +#: ../../library/dbm.rst:430 msgid "``'c'`` (default): |flag_c|" msgstr "``'c'`` (default): |flag_c|" -#: ../../library/dbm.rst:375 +#: ../../library/dbm.rst:437 msgid "" "It is possible to crash the Python interpreter when loading a database with " "a sufficiently large/complex entry due to stack depth limitations in " "Python's AST compiler." msgstr "" -#: ../../library/dbm.rst:379 +#: ../../library/dbm.rst:441 msgid "" ":func:`~dbm.dumb.open` always creates a new database when *flag* is ``'n'``." msgstr "" -#: ../../library/dbm.rst:382 +#: ../../library/dbm.rst:444 msgid "" "A database opened read-only if *flag* is ``'r'``. A database is not created " "if it does not exist if *flag* is ``'r'`` or ``'w'``." msgstr "" -#: ../../library/dbm.rst:389 +#: ../../library/dbm.rst:451 msgid "" "In addition to the methods provided by the :class:`collections.abc." "MutableMapping` class, the following methods are provided:" msgstr "" -#: ../../library/dbm.rst:395 +#: ../../library/dbm.rst:457 msgid "" "Synchronize the on-disk directory and data files. This method is called by " -"the :meth:`Shelve.sync` method." +"the :meth:`shelve.Shelf.sync` method." msgstr "" -#: ../../library/dbm.rst:400 +#: ../../library/dbm.rst:462 msgid "Close the database." msgstr "關閉資料庫。" -#: ../../library/dbm.rst:326 +#: ../../library/dbm.rst:388 msgid "databases" msgstr "databases(資料庫)" - -#~ msgid "|incompat_note|" -#~ msgstr "|incompat_note|" diff --git a/library/debug.po b/library/debug.po index df784f61d1..e6d1cd5339 100644 --- a/library/debug.po +++ b/library/debug.po @@ -6,7 +6,7 @@ # Liang-Bo Wang , 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-06-20 18:08+0800\n" "PO-Revision-Date: 2021-12-08 00:47+0800\n" diff --git a/library/decimal.po b/library/decimal.po index aae7de001e..384c9f1508 100644 --- a/library/decimal.po +++ b/library/decimal.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 14:43+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -146,7 +146,7 @@ msgid "" msgstr "" #: ../../library/decimal.rst:125 -msgid "Quick-start Tutorial" +msgid "Quick-start tutorial" msgstr "" #: ../../library/decimal.rst:127 @@ -542,10 +542,12 @@ msgid "" "Other Unicode decimal digits are also permitted where ``digit`` appears " "above. These include decimal digits from various other alphabets (for " "example, Arabic-Indic and Devanāgarī digits) along with the fullwidth digits " -"``'\\uff10'`` through ``'\\uff19'``." +"``'\\uff10'`` through ``'\\uff19'``. Case is not significant, so, for " +"example, ``inf``, ``Inf``, ``INFINITY``, and ``iNfINity`` are all acceptable " +"spellings for positive infinity." msgstr "" -#: ../../library/decimal.rst:371 +#: ../../library/decimal.rst:373 msgid "" "If *value* is a :class:`tuple`, it should have three components, a sign " "(``0`` for positive or ``1`` for negative), a :class:`tuple` of digits, and " @@ -553,7 +555,7 @@ msgid "" "``Decimal('1.414')``." msgstr "" -#: ../../library/decimal.rst:376 +#: ../../library/decimal.rst:378 msgid "" "If *value* is a :class:`float`, the binary floating-point value is " "losslessly converted to its exact decimal equivalent. This conversion can " @@ -562,7 +564,7 @@ msgid "" "``Decimal('1.100000000000000088817841970012523233890533447265625')``." msgstr "" -#: ../../library/decimal.rst:382 +#: ../../library/decimal.rst:384 msgid "" "The *context* precision does not affect how many digits are stored. That is " "determined exclusively by the number of digits in *value*. For example, " @@ -570,7 +572,7 @@ msgid "" "is only three." msgstr "" -#: ../../library/decimal.rst:387 +#: ../../library/decimal.rst:389 msgid "" "The purpose of the *context* argument is determining what to do if *value* " "is a malformed string. If the context traps :const:`InvalidOperation`, an " @@ -578,29 +580,29 @@ msgid "" "the value of ``NaN``." msgstr "" -#: ../../library/decimal.rst:392 +#: ../../library/decimal.rst:394 msgid "Once constructed, :class:`Decimal` objects are immutable." msgstr "" -#: ../../library/decimal.rst:394 +#: ../../library/decimal.rst:396 msgid "" "The argument to the constructor is now permitted to be a :class:`float` " "instance." msgstr "" -#: ../../library/decimal.rst:398 +#: ../../library/decimal.rst:400 msgid "" ":class:`float` arguments raise an exception if the :exc:`FloatOperation` " "trap is set. By default the trap is off." msgstr "" -#: ../../library/decimal.rst:402 +#: ../../library/decimal.rst:404 msgid "" "Underscores are allowed for grouping, as with integral and floating-point " "literals in code." msgstr "" -#: ../../library/decimal.rst:406 +#: ../../library/decimal.rst:408 msgid "" "Decimal floating-point objects share many properties with the other built-in " "numeric types such as :class:`float` and :class:`int`. All of the usual " @@ -610,7 +612,7 @@ msgid "" "class:`int`)." msgstr "" -#: ../../library/decimal.rst:413 +#: ../../library/decimal.rst:415 msgid "" "There are some small differences between arithmetic on Decimal objects and " "arithmetic on integers and floats. When the remainder operator ``%`` is " @@ -618,7 +620,7 @@ msgid "" "*dividend* rather than the sign of the divisor::" msgstr "" -#: ../../library/decimal.rst:418 +#: ../../library/decimal.rst:420 msgid "" ">>> (-7) % 4\n" "1\n" @@ -630,14 +632,14 @@ msgstr "" ">>> Decimal(-7) % Decimal(4)\n" "Decimal('-3')" -#: ../../library/decimal.rst:423 +#: ../../library/decimal.rst:425 msgid "" "The integer division operator ``//`` behaves analogously, returning the " "integer part of the true quotient (truncating towards zero) rather than its " "floor, so as to preserve the usual identity ``x == (x // y) * y + x % y``::" msgstr "" -#: ../../library/decimal.rst:427 +#: ../../library/decimal.rst:429 msgid "" ">>> -7 // 4\n" "-2\n" @@ -649,13 +651,13 @@ msgstr "" ">>> Decimal(-7) // Decimal(4)\n" "Decimal('-1')" -#: ../../library/decimal.rst:432 +#: ../../library/decimal.rst:434 msgid "" "The ``%`` and ``//`` operators implement the ``remainder`` and ``divide-" "integer`` operations (respectively) as described in the specification." msgstr "" -#: ../../library/decimal.rst:436 +#: ../../library/decimal.rst:438 msgid "" "Decimal objects cannot generally be combined with floats or instances of :" "class:`fractions.Fraction` in arithmetic operations: an attempt to add a :" @@ -666,19 +668,19 @@ msgid "" "numbers of different types." msgstr "" -#: ../../library/decimal.rst:444 +#: ../../library/decimal.rst:446 msgid "" "Mixed-type comparisons between :class:`Decimal` instances and other numeric " "types are now fully supported." msgstr "" -#: ../../library/decimal.rst:448 +#: ../../library/decimal.rst:450 msgid "" "In addition to the standard numeric properties, decimal floating-point " "objects also have a number of specialized methods:" msgstr "" -#: ../../library/decimal.rst:454 +#: ../../library/decimal.rst:456 msgid "" "Return the adjusted exponent after shifting out the coefficient's rightmost " "digits until only the lead digit remains: ``Decimal('321e+5').adjusted()`` " @@ -686,14 +688,14 @@ msgid "" "digit with respect to the decimal point." msgstr "" -#: ../../library/decimal.rst:461 +#: ../../library/decimal.rst:463 msgid "" "Return a pair ``(n, d)`` of integers that represent the given :class:" "`Decimal` instance as a fraction, in lowest terms and with a positive " "denominator::" msgstr "" -#: ../../library/decimal.rst:465 +#: ../../library/decimal.rst:467 msgid "" ">>> Decimal('-3.14').as_integer_ratio()\n" "(-157, 50)" @@ -701,32 +703,32 @@ msgstr "" ">>> Decimal('-3.14').as_integer_ratio()\n" "(-157, 50)" -#: ../../library/decimal.rst:468 +#: ../../library/decimal.rst:470 msgid "" "The conversion is exact. Raise OverflowError on infinities and ValueError " "on NaNs." msgstr "" -#: ../../library/decimal.rst:475 +#: ../../library/decimal.rst:477 msgid "" "Return a :term:`named tuple` representation of the number: " "``DecimalTuple(sign, digits, exponent)``." msgstr "" -#: ../../library/decimal.rst:481 +#: ../../library/decimal.rst:483 msgid "" "Return the canonical encoding of the argument. Currently, the encoding of " "a :class:`Decimal` instance is always canonical, so this operation returns " "its argument unchanged." msgstr "" -#: ../../library/decimal.rst:487 +#: ../../library/decimal.rst:489 msgid "" "Compare the values of two Decimal instances. :meth:`compare` returns a " "Decimal instance, and if either operand is a NaN then the result is a NaN::" msgstr "" -#: ../../library/decimal.rst:491 +#: ../../library/decimal.rst:493 msgid "" "a or b is a NaN ==> Decimal('NaN')\n" "a < b ==> Decimal('-1')\n" @@ -738,14 +740,14 @@ msgstr "" "a == b ==> Decimal('0')\n" "a > b ==> Decimal('1')" -#: ../../library/decimal.rst:498 +#: ../../library/decimal.rst:500 msgid "" "This operation is identical to the :meth:`compare` method, except that all " "NaNs signal. That is, if neither operand is a signaling NaN then any quiet " "NaN operand is treated as though it were a signaling NaN." msgstr "" -#: ../../library/decimal.rst:504 +#: ../../library/decimal.rst:506 msgid "" "Compare two operands using their abstract representation rather than their " "numerical value. Similar to the :meth:`compare` method, but the result " @@ -754,7 +756,7 @@ msgid "" "unequal in this ordering:" msgstr "" -#: ../../library/decimal.rst:513 +#: ../../library/decimal.rst:515 msgid "" "Quiet and signaling NaNs are also included in the total ordering. The " "result of this function is ``Decimal('0')`` if both operands have the same " @@ -764,15 +766,15 @@ msgid "" "details of the total order." msgstr "" -#: ../../library/decimal.rst:520 ../../library/decimal.rst:531 -#: ../../library/decimal.rst:559 ../../library/decimal.rst:846 +#: ../../library/decimal.rst:522 ../../library/decimal.rst:533 +#: ../../library/decimal.rst:561 ../../library/decimal.rst:848 msgid "" "This operation is unaffected by context and is quiet: no flags are changed " "and no rounding is performed. As an exception, the C version may raise " "InvalidOperation if the second operand cannot be converted exactly." msgstr "" -#: ../../library/decimal.rst:526 +#: ../../library/decimal.rst:528 msgid "" "Compare two operands using their abstract representation rather than their " "value as in :meth:`compare_total`, but ignoring the sign of each operand. " @@ -780,44 +782,44 @@ msgid "" "copy_abs())``." msgstr "" -#: ../../library/decimal.rst:537 +#: ../../library/decimal.rst:539 msgid "" "Just returns self, this method is only to comply with the Decimal " "Specification." msgstr "" -#: ../../library/decimal.rst:542 +#: ../../library/decimal.rst:544 msgid "" "Return the absolute value of the argument. This operation is unaffected by " "the context and is quiet: no flags are changed and no rounding is performed." msgstr "" -#: ../../library/decimal.rst:548 +#: ../../library/decimal.rst:550 msgid "" "Return the negation of the argument. This operation is unaffected by the " "context and is quiet: no flags are changed and no rounding is performed." msgstr "" -#: ../../library/decimal.rst:553 +#: ../../library/decimal.rst:555 msgid "" "Return a copy of the first operand with the sign set to be the same as the " "sign of the second operand. For example:" msgstr "" -#: ../../library/decimal.rst:565 +#: ../../library/decimal.rst:567 msgid "" "Return the value of the (natural) exponential function ``e**x`` at the given " "number. The result is correctly rounded using the :const:`ROUND_HALF_EVEN` " "rounding mode." msgstr "" -#: ../../library/decimal.rst:576 +#: ../../library/decimal.rst:578 msgid "" "Alternative constructor that only accepts instances of :class:`float` or :" "class:`int`." msgstr "" -#: ../../library/decimal.rst:579 +#: ../../library/decimal.rst:581 msgid "" "Note ``Decimal.from_float(0.1)`` is not the same as ``Decimal('0.1')``. " "Since 0.1 is not exactly representable in binary floating point, the value " @@ -826,13 +828,13 @@ msgid "" "``0.1000000000000000055511151231257827021181583404541015625``." msgstr "" -#: ../../library/decimal.rst:585 +#: ../../library/decimal.rst:587 msgid "" "From Python 3.2 onwards, a :class:`Decimal` instance can also be constructed " "directly from a :class:`float`." msgstr "" -#: ../../library/decimal.rst:588 +#: ../../library/decimal.rst:590 msgid "" ">>> Decimal.from_float(0.1)\n" "Decimal('0.1000000000000000055511151231257827021181583404541015625')\n" @@ -852,86 +854,86 @@ msgstr "" ">>> Decimal.from_float(float('-inf'))\n" "Decimal('-Infinity')" -#: ../../library/decimal.rst:603 +#: ../../library/decimal.rst:605 msgid "" "Fused multiply-add. Return self*other+third with no rounding of the " "intermediate product self*other." msgstr "" -#: ../../library/decimal.rst:611 +#: ../../library/decimal.rst:613 msgid "" "Return :const:`True` if the argument is canonical and :const:`False` " "otherwise. Currently, a :class:`Decimal` instance is always canonical, so " "this operation always returns :const:`True`." msgstr "" -#: ../../library/decimal.rst:617 +#: ../../library/decimal.rst:619 msgid "" "Return :const:`True` if the argument is a finite number, and :const:`False` " "if the argument is an infinity or a NaN." msgstr "" -#: ../../library/decimal.rst:622 +#: ../../library/decimal.rst:624 msgid "" "Return :const:`True` if the argument is either positive or negative infinity " "and :const:`False` otherwise." msgstr "" -#: ../../library/decimal.rst:627 +#: ../../library/decimal.rst:629 msgid "" "Return :const:`True` if the argument is a (quiet or signaling) NaN and :" "const:`False` otherwise." msgstr "" -#: ../../library/decimal.rst:632 +#: ../../library/decimal.rst:634 msgid "" "Return :const:`True` if the argument is a *normal* finite number. Return :" "const:`False` if the argument is zero, subnormal, infinite or a NaN." msgstr "" -#: ../../library/decimal.rst:637 +#: ../../library/decimal.rst:639 msgid "" "Return :const:`True` if the argument is a quiet NaN, and :const:`False` " "otherwise." msgstr "" -#: ../../library/decimal.rst:642 +#: ../../library/decimal.rst:644 msgid "" "Return :const:`True` if the argument has a negative sign and :const:`False` " "otherwise. Note that zeros and NaNs can both carry signs." msgstr "" -#: ../../library/decimal.rst:647 +#: ../../library/decimal.rst:649 msgid "" "Return :const:`True` if the argument is a signaling NaN and :const:`False` " "otherwise." msgstr "" -#: ../../library/decimal.rst:652 +#: ../../library/decimal.rst:654 msgid "" "Return :const:`True` if the argument is subnormal, and :const:`False` " "otherwise." msgstr "" -#: ../../library/decimal.rst:657 +#: ../../library/decimal.rst:659 msgid "" "Return :const:`True` if the argument is a (positive or negative) zero and :" "const:`False` otherwise." msgstr "" -#: ../../library/decimal.rst:662 +#: ../../library/decimal.rst:664 msgid "" "Return the natural (base e) logarithm of the operand. The result is " "correctly rounded using the :const:`ROUND_HALF_EVEN` rounding mode." msgstr "" -#: ../../library/decimal.rst:667 +#: ../../library/decimal.rst:669 msgid "" "Return the base ten logarithm of the operand. The result is correctly " "rounded using the :const:`ROUND_HALF_EVEN` rounding mode." msgstr "" -#: ../../library/decimal.rst:672 +#: ../../library/decimal.rst:674 msgid "" "For a nonzero number, return the adjusted exponent of its operand as a :" "class:`Decimal` instance. If the operand is a zero then ``Decimal('-" @@ -939,74 +941,74 @@ msgid "" "the operand is an infinity then ``Decimal('Infinity')`` is returned." msgstr "" -#: ../../library/decimal.rst:680 +#: ../../library/decimal.rst:682 msgid "" ":meth:`logical_and` is a logical operation which takes two *logical " "operands* (see :ref:`logical_operands_label`). The result is the digit-wise " "``and`` of the two operands." msgstr "" -#: ../../library/decimal.rst:686 +#: ../../library/decimal.rst:688 msgid "" ":meth:`logical_invert` is a logical operation. The result is the digit-wise " "inversion of the operand." msgstr "" -#: ../../library/decimal.rst:691 +#: ../../library/decimal.rst:693 msgid "" ":meth:`logical_or` is a logical operation which takes two *logical operands* " "(see :ref:`logical_operands_label`). The result is the digit-wise ``or`` of " "the two operands." msgstr "" -#: ../../library/decimal.rst:697 +#: ../../library/decimal.rst:699 msgid "" ":meth:`logical_xor` is a logical operation which takes two *logical " "operands* (see :ref:`logical_operands_label`). The result is the digit-wise " "exclusive or of the two operands." msgstr "" -#: ../../library/decimal.rst:703 +#: ../../library/decimal.rst:705 msgid "" "Like ``max(self, other)`` except that the context rounding rule is applied " "before returning and that ``NaN`` values are either signaled or ignored " "(depending on the context and whether they are signaling or quiet)." msgstr "" -#: ../../library/decimal.rst:710 +#: ../../library/decimal.rst:712 msgid "" "Similar to the :meth:`.max` method, but the comparison is done using the " "absolute values of the operands." msgstr "" -#: ../../library/decimal.rst:715 +#: ../../library/decimal.rst:717 msgid "" "Like ``min(self, other)`` except that the context rounding rule is applied " "before returning and that ``NaN`` values are either signaled or ignored " "(depending on the context and whether they are signaling or quiet)." msgstr "" -#: ../../library/decimal.rst:722 +#: ../../library/decimal.rst:724 msgid "" "Similar to the :meth:`.min` method, but the comparison is done using the " "absolute values of the operands." msgstr "" -#: ../../library/decimal.rst:727 +#: ../../library/decimal.rst:729 msgid "" "Return the largest number representable in the given context (or in the " "current thread's context if no context is given) that is smaller than the " "given operand." msgstr "" -#: ../../library/decimal.rst:733 +#: ../../library/decimal.rst:735 msgid "" "Return the smallest number representable in the given context (or in the " "current thread's context if no context is given) that is larger than the " "given operand." msgstr "" -#: ../../library/decimal.rst:739 +#: ../../library/decimal.rst:741 msgid "" "If the two operands are unequal, return the number closest to the first " "operand in the direction of the second operand. If both operands are " @@ -1014,13 +1016,13 @@ msgid "" "be the same as the sign of the second operand." msgstr "" -#: ../../library/decimal.rst:746 +#: ../../library/decimal.rst:748 msgid "" "Used for producing canonical values of an equivalence class within either " "the current context or the specified context." msgstr "" -#: ../../library/decimal.rst:749 +#: ../../library/decimal.rst:751 msgid "" "This has the same semantics as the unary plus operation, except that if the " "final result is finite it is reduced to its simplest form, with all trailing " @@ -1030,79 +1032,79 @@ msgid "" "exponent is set to 0. In all cases the sign is unchanged." msgstr "" -#: ../../library/decimal.rst:756 +#: ../../library/decimal.rst:758 msgid "" "For example, ``Decimal('32.100')`` and ``Decimal('0.321000e+2')`` both " "normalize to the equivalent value ``Decimal('32.1')``." msgstr "" -#: ../../library/decimal.rst:759 +#: ../../library/decimal.rst:761 msgid "Note that rounding is applied *before* reducing to simplest form." msgstr "" -#: ../../library/decimal.rst:761 +#: ../../library/decimal.rst:763 msgid "" "In the latest versions of the specification, this operation is also known as " "``reduce``." msgstr "" -#: ../../library/decimal.rst:766 +#: ../../library/decimal.rst:768 msgid "" "Return a string describing the *class* of the operand. The returned value " "is one of the following ten strings." msgstr "" -#: ../../library/decimal.rst:769 +#: ../../library/decimal.rst:771 msgid "``\"-Infinity\"``, indicating that the operand is negative infinity." msgstr "" -#: ../../library/decimal.rst:770 +#: ../../library/decimal.rst:772 msgid "" "``\"-Normal\"``, indicating that the operand is a negative normal number." msgstr "" -#: ../../library/decimal.rst:771 +#: ../../library/decimal.rst:773 msgid "" "``\"-Subnormal\"``, indicating that the operand is negative and subnormal." msgstr "" -#: ../../library/decimal.rst:772 +#: ../../library/decimal.rst:774 msgid "``\"-Zero\"``, indicating that the operand is a negative zero." msgstr "" -#: ../../library/decimal.rst:773 +#: ../../library/decimal.rst:775 msgid "``\"+Zero\"``, indicating that the operand is a positive zero." msgstr "" -#: ../../library/decimal.rst:774 +#: ../../library/decimal.rst:776 msgid "" "``\"+Subnormal\"``, indicating that the operand is positive and subnormal." msgstr "" -#: ../../library/decimal.rst:775 +#: ../../library/decimal.rst:777 msgid "" "``\"+Normal\"``, indicating that the operand is a positive normal number." msgstr "" -#: ../../library/decimal.rst:776 +#: ../../library/decimal.rst:778 msgid "``\"+Infinity\"``, indicating that the operand is positive infinity." msgstr "" -#: ../../library/decimal.rst:777 +#: ../../library/decimal.rst:779 msgid "``\"NaN\"``, indicating that the operand is a quiet NaN (Not a Number)." msgstr "" -#: ../../library/decimal.rst:778 +#: ../../library/decimal.rst:780 msgid "``\"sNaN\"``, indicating that the operand is a signaling NaN." msgstr "" -#: ../../library/decimal.rst:782 +#: ../../library/decimal.rst:784 msgid "" "Return a value equal to the first operand after rounding and having the " "exponent of the second operand." msgstr "" -#: ../../library/decimal.rst:788 +#: ../../library/decimal.rst:790 msgid "" "Unlike other operations, if the length of the coefficient after the quantize " "operation would be greater than precision, then an :const:`InvalidOperation` " @@ -1110,13 +1112,13 @@ msgid "" "quantized exponent is always equal to that of the right-hand operand." msgstr "" -#: ../../library/decimal.rst:794 +#: ../../library/decimal.rst:796 msgid "" "Also unlike other operations, quantize never signals Underflow, even if the " "result is subnormal and inexact." msgstr "" -#: ../../library/decimal.rst:797 +#: ../../library/decimal.rst:799 msgid "" "If the exponent of the second operand is larger than that of the first then " "rounding may be necessary. In this case, the rounding mode is determined by " @@ -1125,19 +1127,19 @@ msgid "" "context is used." msgstr "" -#: ../../library/decimal.rst:803 +#: ../../library/decimal.rst:805 msgid "" "An error is returned whenever the resulting exponent is greater than :attr:" "`~Context.Emax` or less than :meth:`~Context.Etiny`." msgstr "" -#: ../../library/decimal.rst:808 +#: ../../library/decimal.rst:810 msgid "" "Return ``Decimal(10)``, the radix (base) in which the :class:`Decimal` class " "does all its arithmetic. Included for compatibility with the specification." msgstr "" -#: ../../library/decimal.rst:814 +#: ../../library/decimal.rst:816 msgid "" "Return the remainder from dividing *self* by *other*. This differs from " "``self % other`` in that the sign of the remainder is chosen so as to " @@ -1146,11 +1148,11 @@ msgid "" "other``, and if two integers are equally near then the even one is chosen." msgstr "" -#: ../../library/decimal.rst:821 +#: ../../library/decimal.rst:823 msgid "If the result is zero then its sign will be the sign of *self*." msgstr "" -#: ../../library/decimal.rst:832 +#: ../../library/decimal.rst:834 msgid "" "Return the result of rotating the digits of the first operand by an amount " "specified by the second operand. The second operand must be an integer in " @@ -1162,20 +1164,20 @@ msgid "" "are unchanged." msgstr "" -#: ../../library/decimal.rst:843 +#: ../../library/decimal.rst:845 msgid "" "Test whether self and other have the same exponent or whether both are " "``NaN``." msgstr "" -#: ../../library/decimal.rst:852 +#: ../../library/decimal.rst:854 msgid "" "Return the first operand with exponent adjusted by the second. Equivalently, " "return the first operand multiplied by ``10**other``. The second operand " "must be an integer." msgstr "" -#: ../../library/decimal.rst:858 +#: ../../library/decimal.rst:860 msgid "" "Return the result of shifting the digits of the first operand by an amount " "specified by the second operand. The second operand must be an integer in " @@ -1186,34 +1188,34 @@ msgid "" "exponent of the first operand are unchanged." msgstr "" -#: ../../library/decimal.rst:868 +#: ../../library/decimal.rst:870 msgid "Return the square root of the argument to full precision." msgstr "" -#: ../../library/decimal.rst:873 ../../library/decimal.rst:1510 +#: ../../library/decimal.rst:875 ../../library/decimal.rst:1524 msgid "" "Convert to a string, using engineering notation if an exponent is needed." msgstr "" -#: ../../library/decimal.rst:875 ../../library/decimal.rst:1512 +#: ../../library/decimal.rst:877 ../../library/decimal.rst:1526 msgid "" "Engineering notation has an exponent which is a multiple of 3. This can " "leave up to 3 digits to the left of the decimal place and may require the " "addition of either one or two trailing zeros." msgstr "" -#: ../../library/decimal.rst:879 +#: ../../library/decimal.rst:881 msgid "" "For example, this converts ``Decimal('123E+1')`` to ``Decimal('1.23E+3')``." msgstr "" -#: ../../library/decimal.rst:883 +#: ../../library/decimal.rst:885 msgid "" "Identical to the :meth:`to_integral_value` method. The ``to_integral`` name " "has been kept for compatibility with older versions." msgstr "" -#: ../../library/decimal.rst:888 +#: ../../library/decimal.rst:890 msgid "" "Round to the nearest integer, signaling :const:`Inexact` or :const:`Rounded` " "as appropriate if rounding occurs. The rounding mode is determined by the " @@ -1221,18 +1223,18 @@ msgid "" "parameter is given then the rounding mode of the current context is used." msgstr "" -#: ../../library/decimal.rst:896 +#: ../../library/decimal.rst:898 msgid "" "Round to the nearest integer without signaling :const:`Inexact` or :const:" "`Rounded`. If given, applies *rounding*; otherwise, uses the rounding " "method in either the supplied *context* or the current context." msgstr "" -#: ../../library/decimal.rst:900 +#: ../../library/decimal.rst:902 msgid "Decimal numbers can be rounded using the :func:`.round` function:" msgstr "" -#: ../../library/decimal.rst:905 +#: ../../library/decimal.rst:907 msgid "" "If *ndigits* is not given or ``None``, returns the nearest :class:`int` to " "*number*, rounding ties to even, and ignoring the rounding mode of the :" @@ -1240,7 +1242,7 @@ msgid "" "infinity or :exc:`ValueError` if it is a (quiet or signaling) NaN." msgstr "" -#: ../../library/decimal.rst:911 +#: ../../library/decimal.rst:913 msgid "" "If *ndigits* is an :class:`int`, the context's rounding mode is respected " "and a :class:`Decimal` representing *number* rounded to the nearest multiple " @@ -1252,27 +1254,27 @@ msgid "" "the current context's precision. In other words, for the non-corner cases:" msgstr "" -#: ../../library/decimal.rst:921 +#: ../../library/decimal.rst:923 msgid "" "if *ndigits* is positive, return *number* rounded to *ndigits* decimal " "places;" msgstr "" -#: ../../library/decimal.rst:923 +#: ../../library/decimal.rst:925 msgid "if *ndigits* is zero, return *number* rounded to the nearest integer;" msgstr "" -#: ../../library/decimal.rst:924 +#: ../../library/decimal.rst:926 msgid "" "if *ndigits* is negative, return *number* rounded to the nearest multiple of " "``10**abs(ndigits)``." msgstr "" -#: ../../library/decimal.rst:927 +#: ../../library/decimal.rst:929 msgid "For example::" msgstr "" -#: ../../library/decimal.rst:929 +#: ../../library/decimal.rst:931 msgid "" ">>> from decimal import Decimal, getcontext, ROUND_DOWN\n" ">>> getcontext().rounding = ROUND_DOWN\n" @@ -1288,11 +1290,11 @@ msgid "" "Decimal('0E+1')" msgstr "" -#: ../../library/decimal.rst:946 +#: ../../library/decimal.rst:948 msgid "Logical operands" msgstr "" -#: ../../library/decimal.rst:948 +#: ../../library/decimal.rst:950 msgid "" "The :meth:`~Decimal.logical_and`, :meth:`~Decimal.logical_invert`, :meth:" "`~Decimal.logical_or`, and :meth:`~Decimal.logical_xor` methods expect their " @@ -1301,38 +1303,38 @@ msgid "" "are all either ``0`` or ``1``." msgstr "" -#: ../../library/decimal.rst:960 +#: ../../library/decimal.rst:962 msgid "Context objects" msgstr "" -#: ../../library/decimal.rst:962 +#: ../../library/decimal.rst:964 msgid "" "Contexts are environments for arithmetic operations. They govern precision, " "set rules for rounding, determine which signals are treated as exceptions, " "and limit the range for exponents." msgstr "" -#: ../../library/decimal.rst:966 +#: ../../library/decimal.rst:968 msgid "" "Each thread has its own current context which is accessed or changed using " "the :func:`getcontext` and :func:`setcontext` functions:" msgstr "" -#: ../../library/decimal.rst:972 +#: ../../library/decimal.rst:974 msgid "Return the current context for the active thread." msgstr "" -#: ../../library/decimal.rst:977 +#: ../../library/decimal.rst:979 msgid "Set the current context for the active thread to *c*." msgstr "" -#: ../../library/decimal.rst:979 +#: ../../library/decimal.rst:981 msgid "" "You can also use the :keyword:`with` statement and the :func:`localcontext` " "function to temporarily change the active context." msgstr "" -#: ../../library/decimal.rst:984 +#: ../../library/decimal.rst:986 msgid "" "Return a context manager that will set the current context for the active " "thread to a copy of *ctx* on entry to the with-statement and restore the " @@ -1341,14 +1343,14 @@ msgid "" "used to set the attributes of the new context." msgstr "" -#: ../../library/decimal.rst:990 +#: ../../library/decimal.rst:992 msgid "" "For example, the following code sets the current decimal precision to 42 " "places, performs a calculation, and then automatically restores the previous " "context::" msgstr "" -#: ../../library/decimal.rst:993 +#: ../../library/decimal.rst:995 msgid "" "from decimal import localcontext\n" "\n" @@ -1358,11 +1360,11 @@ msgid "" "s = +s # Round the final result back to the default precision" msgstr "" -#: ../../library/decimal.rst:1000 +#: ../../library/decimal.rst:1002 msgid "Using keyword arguments, the code would be the following::" msgstr "" -#: ../../library/decimal.rst:1002 +#: ../../library/decimal.rst:1004 msgid "" "from decimal import localcontext\n" "\n" @@ -1376,26 +1378,26 @@ msgstr "" " s = calculate_something()\n" "s = +s" -#: ../../library/decimal.rst:1008 +#: ../../library/decimal.rst:1010 msgid "" "Raises :exc:`TypeError` if *kwargs* supplies an attribute that :class:" "`Context` doesn't support. Raises either :exc:`TypeError` or :exc:" "`ValueError` if *kwargs* supplies an invalid value for an attribute." msgstr "" -#: ../../library/decimal.rst:1012 +#: ../../library/decimal.rst:1014 msgid "" ":meth:`localcontext` now supports setting context attributes through the use " "of keyword arguments." msgstr "" -#: ../../library/decimal.rst:1015 +#: ../../library/decimal.rst:1017 msgid "" "New contexts can also be created using the :class:`Context` constructor " "described below. In addition, the module provides three pre-made contexts:" msgstr "" -#: ../../library/decimal.rst:1021 +#: ../../library/decimal.rst:1023 msgid "" "This is a standard context defined by the General Decimal Arithmetic " "Specification. Precision is set to nine. Rounding is set to :const:" @@ -1404,12 +1406,12 @@ msgid "" "`Subnormal`." msgstr "" -#: ../../library/decimal.rst:1027 +#: ../../library/decimal.rst:1029 msgid "" "Because many of the traps are enabled, this context is useful for debugging." msgstr "" -#: ../../library/decimal.rst:1032 +#: ../../library/decimal.rst:1034 msgid "" "This is a standard context defined by the General Decimal Arithmetic " "Specification. Precision is set to nine. Rounding is set to :const:" @@ -1417,7 +1419,7 @@ msgid "" "exceptions are not raised during computations)." msgstr "" -#: ../../library/decimal.rst:1037 +#: ../../library/decimal.rst:1039 msgid "" "Because the traps are disabled, this context is useful for applications that " "prefer to have result value of ``NaN`` or ``Infinity`` instead of raising " @@ -1425,7 +1427,7 @@ msgid "" "conditions that would otherwise halt the program." msgstr "" -#: ../../library/decimal.rst:1045 +#: ../../library/decimal.rst:1047 msgid "" "This context is used by the :class:`Context` constructor as a prototype for " "new contexts. Changing a field (such a precision) has the effect of " @@ -1433,7 +1435,7 @@ msgid "" "constructor." msgstr "" -#: ../../library/decimal.rst:1049 +#: ../../library/decimal.rst:1051 msgid "" "This context is most useful in multi-threaded environments. Changing one of " "the fields before threads are started has the effect of setting system-wide " @@ -1441,79 +1443,76 @@ msgid "" "as it would require thread synchronization to prevent race conditions." msgstr "" -#: ../../library/decimal.rst:1054 +#: ../../library/decimal.rst:1056 msgid "" "In single threaded environments, it is preferable to not use this context at " "all. Instead, simply create contexts explicitly as described below." msgstr "" -#: ../../library/decimal.rst:1057 +#: ../../library/decimal.rst:1059 msgid "" "The default values are :attr:`Context.prec`\\ =\\ ``28``, :attr:`Context." "rounding`\\ =\\ :const:`ROUND_HALF_EVEN`, and enabled traps for :class:" "`Overflow`, :class:`InvalidOperation`, and :class:`DivisionByZero`." msgstr "" -#: ../../library/decimal.rst:1062 +#: ../../library/decimal.rst:1064 msgid "" "In addition to the three supplied contexts, new contexts can be created with " "the :class:`Context` constructor." msgstr "" -#: ../../library/decimal.rst:1068 +#: ../../library/decimal.rst:1070 msgid "" "Creates a new context. If a field is not specified or is :const:`None`, the " "default values are copied from the :const:`DefaultContext`. If the *flags* " "field is not specified or is :const:`None`, all flags are cleared." msgstr "" -#: ../../library/decimal.rst:1072 +#: ../../library/decimal.rst:1076 msgid "" -"*prec* is an integer in the range [``1``, :const:`MAX_PREC`] that sets the " -"precision for arithmetic operations in the context." +"An integer in the range [``1``, :const:`MAX_PREC`] that sets the precision " +"for arithmetic operations in the context." msgstr "" -#: ../../library/decimal.rst:1075 -msgid "" -"The *rounding* option is one of the constants listed in the section " -"`Rounding Modes`_." +#: ../../library/decimal.rst:1081 +msgid "One of the constants listed in the section `Rounding Modes`_." msgstr "" -#: ../../library/decimal.rst:1078 +#: ../../library/decimal.rst:1086 msgid "" -"The *traps* and *flags* fields list any signals to be set. Generally, new " -"contexts should only set traps and leave the flags clear." +"Lists of any signals to be set. Generally, new contexts should only set " +"traps and leave the flags clear." msgstr "" -#: ../../library/decimal.rst:1081 +#: ../../library/decimal.rst:1092 msgid "" -"The *Emin* and *Emax* fields are integers specifying the outer limits " -"allowable for exponents. *Emin* must be in the range [:const:`MIN_EMIN`, " -"``0``], *Emax* in the range [``0``, :const:`MAX_EMAX`]." +"Integers specifying the outer limits allowable for exponents. *Emin* must be " +"in the range [:const:`MIN_EMIN`, ``0``], *Emax* in the range [``0``, :const:" +"`MAX_EMAX`]." msgstr "" -#: ../../library/decimal.rst:1085 +#: ../../library/decimal.rst:1098 msgid "" -"The *capitals* field is either ``0`` or ``1`` (the default). If set to " -"``1``, exponents are printed with a capital ``E``; otherwise, a lowercase " -"``e`` is used: ``Decimal('6.02e+23')``." +"Either ``0`` or ``1`` (the default). If set to ``1``, exponents are printed " +"with a capital ``E``; otherwise, a lowercase ``e`` is used: " +"``Decimal('6.02e+23')``." msgstr "" -#: ../../library/decimal.rst:1089 +#: ../../library/decimal.rst:1104 msgid "" -"The *clamp* field is either ``0`` (the default) or ``1``. If set to ``1``, " -"the exponent ``e`` of a :class:`Decimal` instance representable in this " -"context is strictly limited to the range ``Emin - prec + 1 <= e <= Emax - " -"prec + 1``. If *clamp* is ``0`` then a weaker condition holds: the adjusted " -"exponent of the :class:`Decimal` instance is at most :attr:`~Context.Emax`. " -"When *clamp* is ``1``, a large normal number will, where possible, have its " -"exponent reduced and a corresponding number of zeros added to its " -"coefficient, in order to fit the exponent constraints; this preserves the " -"value of the number but loses information about significant trailing zeros. " -"For example::" +"Either ``0`` (the default) or ``1``. If set to ``1``, the exponent ``e`` of " +"a :class:`Decimal` instance representable in this context is strictly " +"limited to the range ``Emin - prec + 1 <= e <= Emax - prec + 1``. If *clamp* " +"is ``0`` then a weaker condition holds: the adjusted exponent of the :class:" +"`Decimal` instance is at most :attr:`~Context.Emax`. When *clamp* is ``1``, " +"a large normal number will, where possible, have its exponent reduced and a " +"corresponding number of zeros added to its coefficient, in order to fit the " +"exponent constraints; this preserves the value of the number but loses " +"information about significant trailing zeros. For example::" msgstr "" -#: ../../library/decimal.rst:1101 +#: ../../library/decimal.rst:1115 msgid "" ">>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')\n" "Decimal('1.23000E+999')" @@ -1521,13 +1520,13 @@ msgstr "" ">>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')\n" "Decimal('1.23000E+999')" -#: ../../library/decimal.rst:1104 +#: ../../library/decimal.rst:1118 msgid "" "A *clamp* value of ``1`` allows compatibility with the fixed-width decimal " "interchange formats specified in IEEE 754." msgstr "" -#: ../../library/decimal.rst:1107 +#: ../../library/decimal.rst:1121 msgid "" "The :class:`Context` class defines several general purpose methods as well " "as a large number of methods for doing arithmetic directly in a given " @@ -1540,30 +1539,30 @@ msgid "" "instance of :class:`int`) anywhere that a Decimal instance is accepted." msgstr "" -#: ../../library/decimal.rst:1120 +#: ../../library/decimal.rst:1134 msgid "Resets all of the flags to ``0``." msgstr "" -#: ../../library/decimal.rst:1124 +#: ../../library/decimal.rst:1138 msgid "Resets all of the traps to ``0``." msgstr "" -#: ../../library/decimal.rst:1130 +#: ../../library/decimal.rst:1144 msgid "Return a duplicate of the context." msgstr "" -#: ../../library/decimal.rst:1134 +#: ../../library/decimal.rst:1148 msgid "Return a copy of the Decimal instance num." msgstr "" -#: ../../library/decimal.rst:1138 +#: ../../library/decimal.rst:1152 msgid "" "Creates a new Decimal instance from *num* but using *self* as context. " "Unlike the :class:`Decimal` constructor, the context precision, rounding " "method, flags, and traps are applied to the conversion." msgstr "" -#: ../../library/decimal.rst:1142 +#: ../../library/decimal.rst:1156 msgid "" "This is useful because constants are often given to a greater precision than " "is needed by the application. Another benefit is that rounding immediately " @@ -1572,7 +1571,7 @@ msgid "" "sum can change the result:" msgstr "" -#: ../../library/decimal.rst:1148 +#: ../../library/decimal.rst:1162 msgid "" ">>> getcontext().prec = 3\n" ">>> Decimal('3.4445') + Decimal('1.0023')\n" @@ -1586,14 +1585,14 @@ msgstr "" ">>> Decimal('3.4445') + Decimal(0) + Decimal('1.0023')\n" "Decimal('4.44')" -#: ../../library/decimal.rst:1156 +#: ../../library/decimal.rst:1170 msgid "" "This method implements the to-number operation of the IBM specification. If " "the argument is a string, no leading or trailing whitespace or underscores " "are permitted." msgstr "" -#: ../../library/decimal.rst:1162 +#: ../../library/decimal.rst:1176 msgid "" "Creates a new Decimal instance from a float *f* but rounding using *self* as " "the context. Unlike the :meth:`Decimal.from_float` class method, the " @@ -1601,7 +1600,7 @@ msgid "" "conversion." msgstr "" -#: ../../library/decimal.rst:1167 +#: ../../library/decimal.rst:1181 msgid "" ">>> context = Context(prec=5, rounding=ROUND_DOWN)\n" ">>> context.create_decimal_from_float(math.pi)\n" @@ -1621,18 +1620,18 @@ msgstr "" " ...\n" "decimal.Inexact: None" -#: ../../library/decimal.rst:1182 +#: ../../library/decimal.rst:1196 msgid "" "Returns a value equal to ``Emin - prec + 1`` which is the minimum exponent " "value for subnormal results. When underflow occurs, the exponent is set to :" "const:`Etiny`." msgstr "" -#: ../../library/decimal.rst:1188 +#: ../../library/decimal.rst:1202 msgid "Returns a value equal to ``Emax - prec + 1``." msgstr "" -#: ../../library/decimal.rst:1190 +#: ../../library/decimal.rst:1204 msgid "" "The usual approach to working with decimals is to create :class:`Decimal` " "instances and then apply arithmetic operations which take place within the " @@ -1642,189 +1641,189 @@ msgid "" "recounted here." msgstr "" -#: ../../library/decimal.rst:1200 +#: ../../library/decimal.rst:1214 msgid "Returns the absolute value of *x*." msgstr "" -#: ../../library/decimal.rst:1205 +#: ../../library/decimal.rst:1219 msgid "Return the sum of *x* and *y*." msgstr "" -#: ../../library/decimal.rst:1210 +#: ../../library/decimal.rst:1224 msgid "Returns the same Decimal object *x*." msgstr "" -#: ../../library/decimal.rst:1215 +#: ../../library/decimal.rst:1229 msgid "Compares *x* and *y* numerically." msgstr "" -#: ../../library/decimal.rst:1220 +#: ../../library/decimal.rst:1234 msgid "Compares the values of the two operands numerically." msgstr "" -#: ../../library/decimal.rst:1225 +#: ../../library/decimal.rst:1239 msgid "Compares two operands using their abstract representation." msgstr "" -#: ../../library/decimal.rst:1230 +#: ../../library/decimal.rst:1244 msgid "" "Compares two operands using their abstract representation, ignoring sign." msgstr "" -#: ../../library/decimal.rst:1235 +#: ../../library/decimal.rst:1249 msgid "Returns a copy of *x* with the sign set to 0." msgstr "" -#: ../../library/decimal.rst:1240 +#: ../../library/decimal.rst:1254 msgid "Returns a copy of *x* with the sign inverted." msgstr "" -#: ../../library/decimal.rst:1245 +#: ../../library/decimal.rst:1259 msgid "Copies the sign from *y* to *x*." msgstr "" -#: ../../library/decimal.rst:1250 +#: ../../library/decimal.rst:1264 msgid "Return *x* divided by *y*." msgstr "" -#: ../../library/decimal.rst:1255 +#: ../../library/decimal.rst:1269 msgid "Return *x* divided by *y*, truncated to an integer." msgstr "" -#: ../../library/decimal.rst:1260 +#: ../../library/decimal.rst:1274 msgid "Divides two numbers and returns the integer part of the result." msgstr "" -#: ../../library/decimal.rst:1265 +#: ../../library/decimal.rst:1279 msgid "Returns ``e ** x``." msgstr "" -#: ../../library/decimal.rst:1270 +#: ../../library/decimal.rst:1284 msgid "Returns *x* multiplied by *y*, plus *z*." msgstr "" -#: ../../library/decimal.rst:1275 +#: ../../library/decimal.rst:1289 msgid "Returns ``True`` if *x* is canonical; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1280 +#: ../../library/decimal.rst:1294 msgid "Returns ``True`` if *x* is finite; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1285 +#: ../../library/decimal.rst:1299 msgid "Returns ``True`` if *x* is infinite; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1290 +#: ../../library/decimal.rst:1304 msgid "Returns ``True`` if *x* is a qNaN or sNaN; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1295 +#: ../../library/decimal.rst:1309 msgid "" "Returns ``True`` if *x* is a normal number; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1300 +#: ../../library/decimal.rst:1314 msgid "Returns ``True`` if *x* is a quiet NaN; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1305 +#: ../../library/decimal.rst:1319 msgid "Returns ``True`` if *x* is negative; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1310 +#: ../../library/decimal.rst:1324 msgid "" "Returns ``True`` if *x* is a signaling NaN; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1315 +#: ../../library/decimal.rst:1329 msgid "Returns ``True`` if *x* is subnormal; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1320 +#: ../../library/decimal.rst:1334 msgid "Returns ``True`` if *x* is a zero; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1325 +#: ../../library/decimal.rst:1339 msgid "Returns the natural (base e) logarithm of *x*." msgstr "" -#: ../../library/decimal.rst:1330 +#: ../../library/decimal.rst:1344 msgid "Returns the base 10 logarithm of *x*." msgstr "" -#: ../../library/decimal.rst:1335 +#: ../../library/decimal.rst:1349 msgid "Returns the exponent of the magnitude of the operand's MSD." msgstr "" -#: ../../library/decimal.rst:1340 +#: ../../library/decimal.rst:1354 msgid "Applies the logical operation *and* between each operand's digits." msgstr "" -#: ../../library/decimal.rst:1345 +#: ../../library/decimal.rst:1359 msgid "Invert all the digits in *x*." msgstr "" -#: ../../library/decimal.rst:1350 +#: ../../library/decimal.rst:1364 msgid "Applies the logical operation *or* between each operand's digits." msgstr "" -#: ../../library/decimal.rst:1355 +#: ../../library/decimal.rst:1369 msgid "Applies the logical operation *xor* between each operand's digits." msgstr "" -#: ../../library/decimal.rst:1360 +#: ../../library/decimal.rst:1374 msgid "Compares two values numerically and returns the maximum." msgstr "" -#: ../../library/decimal.rst:1365 ../../library/decimal.rst:1375 +#: ../../library/decimal.rst:1379 ../../library/decimal.rst:1389 msgid "Compares the values numerically with their sign ignored." msgstr "" -#: ../../library/decimal.rst:1370 +#: ../../library/decimal.rst:1384 msgid "Compares two values numerically and returns the minimum." msgstr "" -#: ../../library/decimal.rst:1380 +#: ../../library/decimal.rst:1394 msgid "Minus corresponds to the unary prefix minus operator in Python." msgstr "" -#: ../../library/decimal.rst:1385 +#: ../../library/decimal.rst:1399 msgid "Return the product of *x* and *y*." msgstr "" -#: ../../library/decimal.rst:1390 +#: ../../library/decimal.rst:1404 msgid "Returns the largest representable number smaller than *x*." msgstr "" -#: ../../library/decimal.rst:1395 +#: ../../library/decimal.rst:1409 msgid "Returns the smallest representable number larger than *x*." msgstr "" -#: ../../library/decimal.rst:1400 +#: ../../library/decimal.rst:1414 msgid "Returns the number closest to *x*, in direction towards *y*." msgstr "" -#: ../../library/decimal.rst:1405 +#: ../../library/decimal.rst:1419 msgid "Reduces *x* to its simplest form." msgstr "" -#: ../../library/decimal.rst:1410 +#: ../../library/decimal.rst:1424 msgid "Returns an indication of the class of *x*." msgstr "" -#: ../../library/decimal.rst:1415 +#: ../../library/decimal.rst:1429 msgid "" "Plus corresponds to the unary prefix plus operator in Python. This " "operation applies the context precision and rounding, so it is *not* an " "identity operation." msgstr "" -#: ../../library/decimal.rst:1422 +#: ../../library/decimal.rst:1436 msgid "Return ``x`` to the power of ``y``, reduced modulo ``modulo`` if given." msgstr "" -#: ../../library/decimal.rst:1424 +#: ../../library/decimal.rst:1438 msgid "" "With two arguments, compute ``x**y``. If ``x`` is negative then ``y`` must " "be integral. The result will be inexact unless ``y`` is integral and the " @@ -1833,42 +1832,42 @@ msgid "" "in the Python version." msgstr "" -#: ../../library/decimal.rst:1430 +#: ../../library/decimal.rst:1444 msgid "" "``Decimal(0) ** Decimal(0)`` results in ``InvalidOperation``, and if " "``InvalidOperation`` is not trapped, then results in ``Decimal('NaN')``." msgstr "" -#: ../../library/decimal.rst:1433 +#: ../../library/decimal.rst:1447 msgid "" "The C module computes :meth:`power` in terms of the correctly rounded :meth:" "`exp` and :meth:`ln` functions. The result is well-defined but only \"almost " "always correctly rounded\"." msgstr "" -#: ../../library/decimal.rst:1438 +#: ../../library/decimal.rst:1452 msgid "" "With three arguments, compute ``(x**y) % modulo``. For the three argument " "form, the following restrictions on the arguments hold:" msgstr "" -#: ../../library/decimal.rst:1441 +#: ../../library/decimal.rst:1455 msgid "all three arguments must be integral" msgstr "" -#: ../../library/decimal.rst:1442 +#: ../../library/decimal.rst:1456 msgid "``y`` must be nonnegative" msgstr "" -#: ../../library/decimal.rst:1443 +#: ../../library/decimal.rst:1457 msgid "at least one of ``x`` or ``y`` must be nonzero" msgstr "" -#: ../../library/decimal.rst:1444 +#: ../../library/decimal.rst:1458 msgid "``modulo`` must be nonzero and have at most 'precision' digits" msgstr "" -#: ../../library/decimal.rst:1446 +#: ../../library/decimal.rst:1460 msgid "" "The value resulting from ``Context.power(x, y, modulo)`` is equal to the " "value that would be obtained by computing ``(x**y) % modulo`` with unbounded " @@ -1877,110 +1876,110 @@ msgid "" "result is always exact." msgstr "" -#: ../../library/decimal.rst:1456 +#: ../../library/decimal.rst:1470 msgid "Returns a value equal to *x* (rounded), having the exponent of *y*." msgstr "" -#: ../../library/decimal.rst:1461 +#: ../../library/decimal.rst:1475 msgid "Just returns 10, as this is Decimal, :)" msgstr "" -#: ../../library/decimal.rst:1466 +#: ../../library/decimal.rst:1480 msgid "Returns the remainder from integer division." msgstr "" -#: ../../library/decimal.rst:1468 +#: ../../library/decimal.rst:1482 msgid "" "The sign of the result, if non-zero, is the same as that of the original " "dividend." msgstr "" -#: ../../library/decimal.rst:1474 +#: ../../library/decimal.rst:1488 msgid "" "Returns ``x - y * n``, where *n* is the integer nearest the exact value of " "``x / y`` (if the result is 0 then its sign will be the sign of *x*)." msgstr "" -#: ../../library/decimal.rst:1480 +#: ../../library/decimal.rst:1494 msgid "Returns a rotated copy of *x*, *y* times." msgstr "" -#: ../../library/decimal.rst:1485 +#: ../../library/decimal.rst:1499 msgid "Returns ``True`` if the two operands have the same exponent." msgstr "" -#: ../../library/decimal.rst:1490 +#: ../../library/decimal.rst:1504 msgid "Returns the first operand after adding the second value its exp." msgstr "" -#: ../../library/decimal.rst:1495 +#: ../../library/decimal.rst:1509 msgid "Returns a shifted copy of *x*, *y* times." msgstr "" -#: ../../library/decimal.rst:1500 +#: ../../library/decimal.rst:1514 msgid "Square root of a non-negative number to context precision." msgstr "" -#: ../../library/decimal.rst:1505 +#: ../../library/decimal.rst:1519 msgid "Return the difference between *x* and *y*." msgstr "" -#: ../../library/decimal.rst:1519 +#: ../../library/decimal.rst:1533 msgid "Rounds to an integer." msgstr "" -#: ../../library/decimal.rst:1524 +#: ../../library/decimal.rst:1538 msgid "Converts a number to a string using scientific notation." msgstr "" -#: ../../library/decimal.rst:1531 +#: ../../library/decimal.rst:1545 msgid "Constants" msgstr "常數" -#: ../../library/decimal.rst:1533 +#: ../../library/decimal.rst:1547 msgid "" "The constants in this section are only relevant for the C module. They are " "also included in the pure Python version for compatibility." msgstr "" -#: ../../library/decimal.rst:1537 +#: ../../library/decimal.rst:1551 msgid "32-bit" msgstr "32 位元" -#: ../../library/decimal.rst:1537 +#: ../../library/decimal.rst:1551 msgid "64-bit" msgstr "64 位元" -#: ../../library/decimal.rst:1539 ../../library/decimal.rst:1541 +#: ../../library/decimal.rst:1553 ../../library/decimal.rst:1555 msgid "``425000000``" msgstr "``425000000``" -#: ../../library/decimal.rst:1539 ../../library/decimal.rst:1541 +#: ../../library/decimal.rst:1553 ../../library/decimal.rst:1555 msgid "``999999999999999999``" msgstr "``999999999999999999``" -#: ../../library/decimal.rst:1543 +#: ../../library/decimal.rst:1557 msgid "``-425000000``" msgstr "``-425000000``" -#: ../../library/decimal.rst:1543 +#: ../../library/decimal.rst:1557 msgid "``-999999999999999999``" msgstr "``-999999999999999999``" -#: ../../library/decimal.rst:1545 +#: ../../library/decimal.rst:1559 msgid "``-849999999``" msgstr "``-849999999``" -#: ../../library/decimal.rst:1545 +#: ../../library/decimal.rst:1559 msgid "``-1999999999999999997``" msgstr "``-1999999999999999997``" -#: ../../library/decimal.rst:1551 +#: ../../library/decimal.rst:1565 msgid "" "The value is ``True``. Deprecated, because Python now always has threads." msgstr "" -#: ../../library/decimal.rst:1557 +#: ../../library/decimal.rst:1571 msgid "" "The default value is ``True``. If Python is :option:`configured using the --" "without-decimal-contextvar option <--without-decimal-contextvar>`, the C " @@ -1989,55 +1988,55 @@ msgid "" "scenarios." msgstr "" -#: ../../library/decimal.rst:1566 +#: ../../library/decimal.rst:1580 msgid "Rounding modes" msgstr "" -#: ../../library/decimal.rst:1570 +#: ../../library/decimal.rst:1584 msgid "Round towards ``Infinity``." msgstr "" -#: ../../library/decimal.rst:1574 +#: ../../library/decimal.rst:1588 msgid "Round towards zero." msgstr "" -#: ../../library/decimal.rst:1578 +#: ../../library/decimal.rst:1592 msgid "Round towards ``-Infinity``." msgstr "" -#: ../../library/decimal.rst:1582 +#: ../../library/decimal.rst:1596 msgid "Round to nearest with ties going towards zero." msgstr "" -#: ../../library/decimal.rst:1586 +#: ../../library/decimal.rst:1600 msgid "Round to nearest with ties going to nearest even integer." msgstr "" -#: ../../library/decimal.rst:1590 +#: ../../library/decimal.rst:1604 msgid "Round to nearest with ties going away from zero." msgstr "" -#: ../../library/decimal.rst:1594 +#: ../../library/decimal.rst:1608 msgid "Round away from zero." msgstr "" -#: ../../library/decimal.rst:1598 +#: ../../library/decimal.rst:1612 msgid "" "Round away from zero if last digit after rounding towards zero would have " "been 0 or 5; otherwise round towards zero." msgstr "" -#: ../../library/decimal.rst:1605 +#: ../../library/decimal.rst:1619 msgid "Signals" msgstr "" -#: ../../library/decimal.rst:1607 +#: ../../library/decimal.rst:1621 msgid "" "Signals represent conditions that arise during computation. Each corresponds " "to one context flag and one context trap enabler." msgstr "" -#: ../../library/decimal.rst:1610 +#: ../../library/decimal.rst:1624 msgid "" "The context flag is set whenever the condition is encountered. After the " "computation, flags may be checked for informational purposes (for instance, " @@ -2045,7 +2044,7 @@ msgid "" "sure to clear all flags before starting the next computation." msgstr "" -#: ../../library/decimal.rst:1615 +#: ../../library/decimal.rst:1629 msgid "" "If the context's trap enabler is set for the signal, then the condition " "causes a Python exception to be raised. For example, if the :class:" @@ -2053,54 +2052,54 @@ msgid "" "raised upon encountering the condition." msgstr "" -#: ../../library/decimal.rst:1623 +#: ../../library/decimal.rst:1637 msgid "Altered an exponent to fit representation constraints." msgstr "" -#: ../../library/decimal.rst:1625 +#: ../../library/decimal.rst:1639 msgid "" "Typically, clamping occurs when an exponent falls outside the context's :" "attr:`~Context.Emin` and :attr:`~Context.Emax` limits. If possible, the " "exponent is reduced to fit by adding zeros to the coefficient." msgstr "" -#: ../../library/decimal.rst:1632 +#: ../../library/decimal.rst:1646 msgid "Base class for other signals and a subclass of :exc:`ArithmeticError`." msgstr "" -#: ../../library/decimal.rst:1637 +#: ../../library/decimal.rst:1651 msgid "Signals the division of a non-infinite number by zero." msgstr "" -#: ../../library/decimal.rst:1639 +#: ../../library/decimal.rst:1653 msgid "" "Can occur with division, modulo division, or when raising a number to a " "negative power. If this signal is not trapped, returns ``Infinity`` or ``-" "Infinity`` with the sign determined by the inputs to the calculation." msgstr "" -#: ../../library/decimal.rst:1646 +#: ../../library/decimal.rst:1660 msgid "Indicates that rounding occurred and the result is not exact." msgstr "" -#: ../../library/decimal.rst:1648 +#: ../../library/decimal.rst:1662 msgid "" "Signals when non-zero digits were discarded during rounding. The rounded " "result is returned. The signal flag or trap is used to detect when results " "are inexact." msgstr "" -#: ../../library/decimal.rst:1655 +#: ../../library/decimal.rst:1669 msgid "An invalid operation was performed." msgstr "" -#: ../../library/decimal.rst:1657 +#: ../../library/decimal.rst:1671 msgid "" "Indicates that an operation was requested that does not make sense. If not " "trapped, returns ``NaN``. Possible causes include::" msgstr "" -#: ../../library/decimal.rst:1660 +#: ../../library/decimal.rst:1674 msgid "" "Infinity - Infinity\n" "0 * Infinity\n" @@ -2122,11 +2121,11 @@ msgstr "" "x ** (non-integer)\n" "x ** Infinity" -#: ../../library/decimal.rst:1673 +#: ../../library/decimal.rst:1687 msgid "Numerical overflow." msgstr "" -#: ../../library/decimal.rst:1675 +#: ../../library/decimal.rst:1689 msgid "" "Indicates the exponent is larger than :attr:`Context.Emax` after rounding " "has occurred. If not trapped, the result depends on the rounding mode, " @@ -2135,42 +2134,42 @@ msgid "" "`Rounded` are also signaled." msgstr "" -#: ../../library/decimal.rst:1684 +#: ../../library/decimal.rst:1698 msgid "Rounding occurred though possibly no information was lost." msgstr "" -#: ../../library/decimal.rst:1686 +#: ../../library/decimal.rst:1700 msgid "" "Signaled whenever rounding discards digits; even if those digits are zero " "(such as rounding ``5.00`` to ``5.0``). If not trapped, returns the result " "unchanged. This signal is used to detect loss of significant digits." msgstr "" -#: ../../library/decimal.rst:1694 +#: ../../library/decimal.rst:1708 msgid "Exponent was lower than :attr:`~Context.Emin` prior to rounding." msgstr "" -#: ../../library/decimal.rst:1696 +#: ../../library/decimal.rst:1710 msgid "" "Occurs when an operation result is subnormal (the exponent is too small). If " "not trapped, returns the result unchanged." msgstr "" -#: ../../library/decimal.rst:1702 +#: ../../library/decimal.rst:1716 msgid "Numerical underflow with result rounded to zero." msgstr "" -#: ../../library/decimal.rst:1704 +#: ../../library/decimal.rst:1718 msgid "" "Occurs when a subnormal result is pushed to zero by rounding. :class:" "`Inexact` and :class:`Subnormal` are also signaled." msgstr "" -#: ../../library/decimal.rst:1710 +#: ../../library/decimal.rst:1724 msgid "Enable stricter semantics for mixing floats and Decimals." msgstr "" -#: ../../library/decimal.rst:1712 +#: ../../library/decimal.rst:1726 msgid "" "If the signal is not trapped (default), mixing floats and Decimals is " "permitted in the :class:`~decimal.Decimal` constructor, :meth:`~decimal." @@ -2181,18 +2180,18 @@ msgid "" "Context.create_decimal_from_float` do not set the flag." msgstr "" -#: ../../library/decimal.rst:1720 +#: ../../library/decimal.rst:1734 msgid "" "Otherwise (the signal is trapped), only equality comparisons and explicit " "conversions are silent. All other mixed operations raise :exc:" "`FloatOperation`." msgstr "" -#: ../../library/decimal.rst:1724 +#: ../../library/decimal.rst:1738 msgid "The following table summarizes the hierarchy of signals::" msgstr "" -#: ../../library/decimal.rst:1726 +#: ../../library/decimal.rst:1740 msgid "" "exceptions.ArithmeticError(exceptions.Exception)\n" " DecimalException\n" @@ -2218,15 +2217,15 @@ msgstr "" " Subnormal\n" " FloatOperation(DecimalException, exceptions.TypeError)" -#: ../../library/decimal.rst:1745 -msgid "Floating-Point Notes" +#: ../../library/decimal.rst:1759 +msgid "Floating-point notes" msgstr "" -#: ../../library/decimal.rst:1749 +#: ../../library/decimal.rst:1763 msgid "Mitigating round-off error with increased precision" msgstr "" -#: ../../library/decimal.rst:1751 +#: ../../library/decimal.rst:1765 msgid "" "The use of decimal floating point eliminates decimal representation error " "(making it possible to represent ``0.1`` exactly); however, some operations " @@ -2234,7 +2233,7 @@ msgid "" "precision." msgstr "" -#: ../../library/decimal.rst:1755 +#: ../../library/decimal.rst:1769 msgid "" "The effects of round-off error can be amplified by the addition or " "subtraction of nearly offsetting quantities resulting in loss of " @@ -2243,7 +2242,7 @@ msgid "" "of the associative and distributive properties of addition:" msgstr "" -#: ../../library/decimal.rst:1761 +#: ../../library/decimal.rst:1775 msgid "" "# Examples from Seminumerical Algorithms, Section 4.2.2.\n" ">>> from decimal import Decimal, getcontext\n" @@ -2262,13 +2261,13 @@ msgid "" "Decimal('0.0060000')" msgstr "" -#: ../../library/decimal.rst:1779 +#: ../../library/decimal.rst:1793 msgid "" "The :mod:`decimal` module makes it possible to restore the identities by " "expanding the precision sufficiently to avoid loss of significance:" msgstr "" -#: ../../library/decimal.rst:1782 +#: ../../library/decimal.rst:1796 msgid "" ">>> getcontext().prec = 20\n" ">>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111')\n" @@ -2284,18 +2283,18 @@ msgid "" "Decimal('0.0060000')" msgstr "" -#: ../../library/decimal.rst:1799 +#: ../../library/decimal.rst:1813 msgid "Special values" msgstr "特殊值" -#: ../../library/decimal.rst:1801 +#: ../../library/decimal.rst:1815 msgid "" "The number system for the :mod:`decimal` module provides special values " "including ``NaN``, ``sNaN``, ``-Infinity``, ``Infinity``, and two zeros, " "``+0`` and ``-0``." msgstr "" -#: ../../library/decimal.rst:1805 +#: ../../library/decimal.rst:1819 msgid "" "Infinities can be constructed directly with: ``Decimal('Infinity')``. Also, " "they can arise from dividing by zero when the :exc:`DivisionByZero` signal " @@ -2304,14 +2303,14 @@ msgid "" "representable number." msgstr "" -#: ../../library/decimal.rst:1810 +#: ../../library/decimal.rst:1824 msgid "" "The infinities are signed (affine) and can be used in arithmetic operations " "where they get treated as very large, indeterminate numbers. For instance, " "adding a constant to infinity gives another infinite result." msgstr "" -#: ../../library/decimal.rst:1814 +#: ../../library/decimal.rst:1828 msgid "" "Some operations are indeterminate and return ``NaN``, or if the :exc:" "`InvalidOperation` signal is trapped, raise an exception. For example, " @@ -2322,14 +2321,14 @@ msgid "" "the calculation to proceed while flagging specific results as invalid." msgstr "" -#: ../../library/decimal.rst:1822 +#: ../../library/decimal.rst:1836 msgid "" "A variant is ``sNaN`` which signals rather than remaining quiet after every " "operation. This is a useful return value when an invalid result needs to " "interrupt a calculation for special handling." msgstr "" -#: ../../library/decimal.rst:1826 +#: ../../library/decimal.rst:1840 msgid "" "The behavior of Python's comparison operators can be a little surprising " "where a ``NaN`` is involved. A test for equality where one of the operands " @@ -2346,7 +2345,7 @@ msgid "" "compare_signal` methods instead." msgstr "" -#: ../../library/decimal.rst:1839 +#: ../../library/decimal.rst:1853 msgid "" "The signed zeros can result from calculations that underflow. They keep the " "sign that would have resulted if the calculation had been carried out to " @@ -2354,7 +2353,7 @@ msgid "" "negative zeros are treated as equal and their sign is informational." msgstr "" -#: ../../library/decimal.rst:1844 +#: ../../library/decimal.rst:1858 msgid "" "In addition to the two signed zeros which are distinct yet equal, there are " "various representations of zero with differing precisions yet equivalent in " @@ -2363,11 +2362,11 @@ msgid "" "that the following calculation returns a value equal to zero:" msgstr "" -#: ../../library/decimal.rst:1859 +#: ../../library/decimal.rst:1873 msgid "Working with threads" msgstr "" -#: ../../library/decimal.rst:1861 +#: ../../library/decimal.rst:1875 msgid "" "The :func:`getcontext` function accesses a different :class:`Context` object " "for each thread. Having separate thread contexts means that threads may " @@ -2375,20 +2374,20 @@ msgid "" "other threads." msgstr "" -#: ../../library/decimal.rst:1865 +#: ../../library/decimal.rst:1879 msgid "" "Likewise, the :func:`setcontext` function automatically assigns its target " "to the current thread." msgstr "" -#: ../../library/decimal.rst:1868 +#: ../../library/decimal.rst:1882 msgid "" "If :func:`setcontext` has not been called before :func:`getcontext`, then :" "func:`getcontext` will automatically create a new context for use in the " "current thread." msgstr "" -#: ../../library/decimal.rst:1872 +#: ../../library/decimal.rst:1886 msgid "" "The new context is copied from a prototype context called *DefaultContext*. " "To control the defaults so that each thread will use the same values " @@ -2397,7 +2396,7 @@ msgid "" "a race condition between threads calling :func:`getcontext`. For example::" msgstr "" -#: ../../library/decimal.rst:1878 +#: ../../library/decimal.rst:1892 msgid "" "# Set applicationwide defaults for all threads about to be launched\n" "DefaultContext.prec = 12\n" @@ -2413,17 +2412,17 @@ msgid "" " . . ." msgstr "" -#: ../../library/decimal.rst:1897 +#: ../../library/decimal.rst:1911 msgid "Recipes" msgstr "" -#: ../../library/decimal.rst:1899 +#: ../../library/decimal.rst:1913 msgid "" "Here are a few recipes that serve as utility functions and that demonstrate " "ways to work with the :class:`Decimal` class::" msgstr "" -#: ../../library/decimal.rst:1902 +#: ../../library/decimal.rst:1916 msgid "" "def moneyfmt(value, places=2, curr='', sep=',', dp='.',\n" " pos='', neg='-', trailneg=''):\n" @@ -2572,41 +2571,41 @@ msgid "" " return +s" msgstr "" -#: ../../library/decimal.rst:2054 +#: ../../library/decimal.rst:2068 msgid "Decimal FAQ" msgstr "" -#: ../../library/decimal.rst:2056 +#: ../../library/decimal.rst:2070 msgid "" "Q. It is cumbersome to type ``decimal.Decimal('1234.5')``. Is there a way " "to minimize typing when using the interactive interpreter?" msgstr "" -#: ../../library/decimal.rst:2059 +#: ../../library/decimal.rst:2073 msgid "A. Some users abbreviate the constructor to just a single letter:" msgstr "" -#: ../../library/decimal.rst:2065 +#: ../../library/decimal.rst:2079 msgid "" "Q. In a fixed-point application with two decimal places, some inputs have " "many places and need to be rounded. Others are not supposed to have excess " "digits and need to be validated. What methods should be used?" msgstr "" -#: ../../library/decimal.rst:2069 +#: ../../library/decimal.rst:2083 msgid "" "A. The :meth:`~Decimal.quantize` method rounds to a fixed number of decimal " "places. If the :const:`Inexact` trap is set, it is also useful for " "validation:" msgstr "" -#: ../../library/decimal.rst:2087 +#: ../../library/decimal.rst:2101 msgid "" "Q. Once I have valid two place inputs, how do I maintain that invariant " "throughout an application?" msgstr "" -#: ../../library/decimal.rst:2090 +#: ../../library/decimal.rst:2104 msgid "" "A. Some operations like addition, subtraction, and multiplication by an " "integer will automatically preserve fixed point. Others operations, like " @@ -2614,13 +2613,13 @@ msgid "" "places and need to be followed-up with a :meth:`~Decimal.quantize` step:" msgstr "" -#: ../../library/decimal.rst:2108 +#: ../../library/decimal.rst:2122 msgid "" "In developing fixed-point applications, it is convenient to define functions " "to handle the :meth:`~Decimal.quantize` step:" msgstr "" -#: ../../library/decimal.rst:2122 +#: ../../library/decimal.rst:2136 msgid "" "Q. There are many ways to express the same value. The numbers ``200``, " "``200.000``, ``2E2``, and ``.02E+4`` all have the same value at various " @@ -2628,17 +2627,17 @@ msgid "" "canonical value?" msgstr "" -#: ../../library/decimal.rst:2127 +#: ../../library/decimal.rst:2141 msgid "" "A. The :meth:`~Decimal.normalize` method maps all equivalent values to a " "single representative:" msgstr "" -#: ../../library/decimal.rst:2134 +#: ../../library/decimal.rst:2148 msgid "Q. When does rounding occur in a computation?" msgstr "" -#: ../../library/decimal.rst:2136 +#: ../../library/decimal.rst:2150 msgid "" "A. It occurs *after* the computation. The philosophy of the decimal " "specification is that numbers are considered exact and are created " @@ -2648,7 +2647,7 @@ msgid "" "computation::" msgstr "" -#: ../../library/decimal.rst:2143 +#: ../../library/decimal.rst:2157 msgid "" ">>> getcontext().prec = 5\n" ">>> pi = Decimal('3.1415926535') # More than 5 digits\n" @@ -2662,13 +2661,13 @@ msgid "" "Decimal('3.1416')" msgstr "" -#: ../../library/decimal.rst:2154 +#: ../../library/decimal.rst:2168 msgid "" "Q. Some decimal values always print with exponential notation. Is there a " "way to get a non-exponential representation?" msgstr "" -#: ../../library/decimal.rst:2157 +#: ../../library/decimal.rst:2171 msgid "" "A. For some values, exponential notation is the only way to express the " "number of significant places in the coefficient. For example, expressing " @@ -2676,25 +2675,25 @@ msgid "" "original's two-place significance." msgstr "" -#: ../../library/decimal.rst:2162 +#: ../../library/decimal.rst:2176 msgid "" "If an application does not care about tracking significance, it is easy to " "remove the exponent and trailing zeroes, losing significance, but keeping " "the value unchanged:" msgstr "" -#: ../../library/decimal.rst:2172 +#: ../../library/decimal.rst:2186 msgid "Q. Is there a way to convert a regular float to a :class:`Decimal`?" msgstr "" -#: ../../library/decimal.rst:2174 +#: ../../library/decimal.rst:2188 msgid "" "A. Yes, any binary floating-point number can be exactly expressed as a " "Decimal though an exact conversion may take more precision than intuition " "would suggest:" msgstr "" -#: ../../library/decimal.rst:2178 +#: ../../library/decimal.rst:2192 msgid "" ">>> Decimal(math.pi)\n" "Decimal('3.141592653589793115997963468544185161590576171875')" @@ -2702,13 +2701,13 @@ msgstr "" ">>> Decimal(math.pi)\n" "Decimal('3.141592653589793115997963468544185161590576171875')" -#: ../../library/decimal.rst:2183 +#: ../../library/decimal.rst:2197 msgid "" "Q. Within a complex calculation, how can I make sure that I haven't gotten a " "spurious result because of insufficient precision or rounding anomalies." msgstr "" -#: ../../library/decimal.rst:2186 +#: ../../library/decimal.rst:2200 msgid "" "A. The decimal module makes it easy to test results. A best practice is to " "re-run calculations using greater precision and with various rounding modes. " @@ -2716,14 +2715,14 @@ msgid "" "issues, ill-conditioned inputs, or a numerically unstable algorithm." msgstr "" -#: ../../library/decimal.rst:2191 +#: ../../library/decimal.rst:2205 msgid "" "Q. I noticed that context precision is applied to the results of operations " "but not to the inputs. Is there anything to watch out for when mixing " "values of different precisions?" msgstr "" -#: ../../library/decimal.rst:2195 +#: ../../library/decimal.rst:2209 msgid "" "A. Yes. The principle is that all values are considered to be exact and so " "is the arithmetic on those values. Only the results are rounded. The " @@ -2732,7 +2731,7 @@ msgid "" "haven't been rounded:" msgstr "" -#: ../../library/decimal.rst:2200 +#: ../../library/decimal.rst:2214 msgid "" ">>> getcontext().prec = 3\n" ">>> Decimal('3.104') + Decimal('2.104')\n" @@ -2746,30 +2745,30 @@ msgstr "" ">>> Decimal('3.104') + Decimal('0.000') + Decimal('2.104')\n" "Decimal('5.20')" -#: ../../library/decimal.rst:2208 +#: ../../library/decimal.rst:2222 msgid "" "The solution is either to increase precision or to force rounding of inputs " "using the unary plus operation:" msgstr "" -#: ../../library/decimal.rst:2211 +#: ../../library/decimal.rst:2225 msgid "" ">>> getcontext().prec = 3\n" ">>> +Decimal('1.23456789') # unary plus triggers rounding\n" "Decimal('1.23')" msgstr "" -#: ../../library/decimal.rst:2217 +#: ../../library/decimal.rst:2231 msgid "" "Alternatively, inputs can be rounded upon creation using the :meth:`Context." "create_decimal` method:" msgstr "" -#: ../../library/decimal.rst:2223 +#: ../../library/decimal.rst:2237 msgid "Q. Is the CPython implementation fast for large numbers?" msgstr "" -#: ../../library/decimal.rst:2225 +#: ../../library/decimal.rst:2239 msgid "" "A. Yes. In the CPython and PyPy3 implementations, the C/CFFI versions of " "the decimal module integrate the high speed `libmpdec >> setcontext(Context(prec=MAX_PREC, Emax=MAX_EMAX, Emin=MIN_EMIN))\n" ">>> x = Decimal(2) ** 256\n" @@ -2808,13 +2807,13 @@ msgstr "" ">>> x / 128\n" "Decimal('904625697166532776746648320380374280103671755200316906558262375061821325312')" -#: ../../library/decimal.rst:2248 +#: ../../library/decimal.rst:2262 msgid "" -"For inexact results, :attr:`MAX_PREC` is far too large on 64-bit platforms " +"For inexact results, :const:`MAX_PREC` is far too large on 64-bit platforms " "and the available memory will be insufficient::" msgstr "" -#: ../../library/decimal.rst:2251 +#: ../../library/decimal.rst:2265 msgid "" ">>> Decimal(1) / 3\n" "Traceback (most recent call last):\n" @@ -2826,7 +2825,7 @@ msgstr "" " File \"\", line 1, in \n" "MemoryError" -#: ../../library/decimal.rst:2256 +#: ../../library/decimal.rst:2270 msgid "" "On systems with overallocation (e.g. Linux), a more sophisticated approach " "is to adjust :attr:`~Context.prec` to the amount of available RAM. Suppose " @@ -2834,7 +2833,7 @@ msgid "" "of 500MB each::" msgstr "" -#: ../../library/decimal.rst:2260 +#: ../../library/decimal.rst:2274 msgid "" ">>> import sys\n" ">>>\n" @@ -2858,14 +2857,14 @@ msgid "" " decimal.Inexact: []" msgstr "" -#: ../../library/decimal.rst:2280 +#: ../../library/decimal.rst:2294 msgid "" "In general (and especially on systems without overallocation), it is " "recommended to estimate even tighter bounds and set the :attr:`Inexact` trap " "if all calculations are expected to be exact." msgstr "" -#: ../../library/decimal.rst:2289 +#: ../../library/decimal.rst:2303 msgid "" "This approach now works for all exact results except for non-integer powers." msgstr "" diff --git a/library/development.po b/library/development.po index b993383ee9..0272023235 100644 --- a/library/development.po +++ b/library/development.po @@ -6,9 +6,9 @@ # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-20 18:08+0800\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2017-09-22 18:26+0000\n" "Last-Translator: Leon H.\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -29,10 +29,12 @@ msgid "" "the :mod:`pydoc` module takes a module and generates documentation based on " "the module's contents. The :mod:`doctest` and :mod:`unittest` modules " "contains frameworks for writing unit tests that automatically exercise code " -"and verify that the expected output is produced. :program:`2to3` can " -"translate Python 2.x source code into valid Python 3.x code." +"and verify that the expected output is produced." msgstr "" +"本章所描述的模組可以幫助你編寫軟體。例如 :mod:`pydoc` 模組可以根據模組的內容" +"生成文件;:mod:`doctest` 和 :mod:`unittest` 模組則包含編寫單元測試的框架,這" +"些測試程式碼會自動執行並驗證輸出結果是否正確。" -#: ../../library/development.rst:14 +#: ../../library/development.rst:13 msgid "The list of modules described in this chapter is:" -msgstr "" +msgstr "本章節所描述的模組列表為:" diff --git a/library/devmode.po b/library/devmode.po index 5449742012..d624765024 100644 --- a/library/devmode.po +++ b/library/devmode.po @@ -6,7 +6,7 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-01 22:24+0800\n" "PO-Revision-Date: 2024-05-03 02:14+0800\n" diff --git a/library/dialog.po b/library/dialog.po index dbe0255950..3460865467 100644 --- a/library/dialog.po +++ b/library/dialog.po @@ -6,7 +6,7 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-09-13 00:11+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" diff --git a/library/difflib.po b/library/difflib.po index b426822ce8..c0d1130505 100644 --- a/library/difflib.po +++ b/library/difflib.po @@ -1,10 +1,10 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2016-11-19 00:29+0000\n" @@ -471,7 +471,7 @@ msgstr "" #: ../../library/difflib.rst:399 msgid ":class:`SequenceMatcher` objects have the following methods:" -msgstr "" +msgstr ":class:`SequenceMatcher` 物件有以下方法:" #: ../../library/difflib.rst:403 msgid "Set the two sequences to be compared." @@ -590,7 +590,7 @@ msgstr "``'replace'``" #: ../../library/difflib.rst:498 msgid "``a[i1:i2]`` should be replaced by ``b[j1:j2]``." -msgstr "" +msgstr "``a[i1:i2]`` 應該被替換為 ``b[j1:j2]``。" #: ../../library/difflib.rst:501 msgid "``'delete'``" @@ -598,7 +598,7 @@ msgstr "``'delete'``" #: ../../library/difflib.rst:501 msgid "``a[i1:i2]`` should be deleted. Note that ``j1 == j2`` in this case." -msgstr "" +msgstr "``a[i1:i2]`` 應該被刪除。請注意,在這種情況下 ``j1 == j2``。" #: ../../library/difflib.rst:504 msgid "``'insert'``" @@ -781,7 +781,7 @@ msgstr "" #: ../../library/difflib.rst:649 msgid "The :class:`Differ` class has this constructor:" -msgstr "" +msgstr ":class:`Differ` 類別有這個建構函式:" #: ../../library/difflib.rst:655 msgid "" @@ -867,7 +867,7 @@ msgstr "" #: ../../library/difflib.rst:757 msgid "A command-line interface to difflib" -msgstr "" +msgstr "difflib 的命令列介面" #: ../../library/difflib.rst:759 msgid "" @@ -940,6 +940,69 @@ msgid "" "if __name__ == '__main__':\n" " main()\n" msgstr "" +"\"\"\" Command line interface to difflib.py providing diffs in four " +"formats:\n" +"\n" +"* ndiff: lists every line and highlights interline changes.\n" +"* context: highlights clusters of changes in a before/after format.\n" +"* unified: highlights clusters of changes in an inline format.\n" +"* html: generates side by side comparison with change highlights.\n" +"\n" +"\"\"\"\n" +"\n" +"import sys, os, difflib, argparse\n" +"from datetime import datetime, timezone\n" +"\n" +"def file_mtime(path):\n" +" t = datetime.fromtimestamp(os.stat(path).st_mtime,\n" +" timezone.utc)\n" +" return t.astimezone().isoformat()\n" +"\n" +"def main():\n" +"\n" +" parser = argparse.ArgumentParser()\n" +" parser.add_argument('-c', action='store_true', default=False,\n" +" help='Produce a context format diff (default)')\n" +" parser.add_argument('-u', action='store_true', default=False,\n" +" help='Produce a unified format diff')\n" +" parser.add_argument('-m', action='store_true', default=False,\n" +" help='Produce HTML side by side diff '\n" +" '(can use -c and -l in conjunction)')\n" +" parser.add_argument('-n', action='store_true', default=False,\n" +" help='Produce a ndiff format diff')\n" +" parser.add_argument('-l', '--lines', type=int, default=3,\n" +" help='Set number of context lines (default 3)')\n" +" parser.add_argument('fromfile')\n" +" parser.add_argument('tofile')\n" +" options = parser.parse_args()\n" +"\n" +" n = options.lines\n" +" fromfile = options.fromfile\n" +" tofile = options.tofile\n" +"\n" +" fromdate = file_mtime(fromfile)\n" +" todate = file_mtime(tofile)\n" +" with open(fromfile) as ff:\n" +" fromlines = ff.readlines()\n" +" with open(tofile) as tf:\n" +" tolines = tf.readlines()\n" +"\n" +" if options.u:\n" +" diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile, " +"fromdate, todate, n=n)\n" +" elif options.n:\n" +" diff = difflib.ndiff(fromlines, tolines)\n" +" elif options.m:\n" +" diff = difflib.HtmlDiff().make_file(fromlines,tolines,fromfile," +"tofile,context=options.c,numlines=n)\n" +" else:\n" +" diff = difflib.context_diff(fromlines, tolines, fromfile, tofile, " +"fromdate, todate, n=n)\n" +"\n" +" sys.stdout.writelines(diff)\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" #: ../../library/difflib.rst:764 msgid "ndiff example" diff --git a/library/dis.po b/library/dis.po index 8892ecafa3..d6ce62924e 100644 --- a/library/dis.po +++ b/library/dis.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # splasky Chang , 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-04-24 05:58+0000\n" "PO-Revision-Date: 2018-07-27 16:55+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -61,17 +61,17 @@ msgstr "" msgid "" "Some instructions are accompanied by one or more inline cache entries, which " "take the form of :opcode:`CACHE` instructions. These instructions are hidden " -"by default, but can be shown by passing ``show_caches=True`` to any :mod:" -"`dis` 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``." +"by default, but can be shown by passing ``show_caches=True`` to " +"any :mod:`dis` 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``." msgstr "" #: ../../library/dis.rst:45 msgid "" "The argument of a jump is the offset of the target instruction relative to " -"the instruction that appears immediately after the jump instruction's :" -"opcode:`CACHE` entries." +"the instruction that appears immediately after the jump " +"instruction's :opcode:`CACHE` entries." msgstr "" #: ../../library/dis.rst:50 @@ -82,10 +82,17 @@ msgid "" msgstr "" #: ../../library/dis.rst:54 +msgid "" +"The output shows logical labels rather than instruction offsets for jump " +"targets and exception handlers. The ``-O`` command line option and the " +"``show_offsets`` argument were added." +msgstr "" + +#: ../../library/dis.rst:59 msgid "Example: Given the function :func:`!myfunc`::" msgstr "" -#: ../../library/dis.rst:56 +#: ../../library/dis.rst:61 msgid "" "def myfunc(alist):\n" " return len(alist)" @@ -93,87 +100,95 @@ msgstr "" "def myfunc(alist):\n" " return len(alist)" -#: ../../library/dis.rst:59 +#: ../../library/dis.rst:64 msgid "" "the following command can be used to display the disassembly of :func:`!" "myfunc`:" msgstr "" -#: ../../library/dis.rst:62 +#: ../../library/dis.rst:67 msgid "" ">>> dis.dis(myfunc)\n" -" 2 0 RESUME 0\n" +" 2 RESUME 0\n" "\n" -" 3 2 LOAD_GLOBAL 1 (NULL + len)\n" -" 12 LOAD_FAST 0 (alist)\n" -" 14 CALL 1\n" -" 22 RETURN_VALUE" +" 3 LOAD_GLOBAL 1 (len + NULL)\n" +" LOAD_FAST 0 (alist)\n" +" CALL 1\n" +" RETURN_VALUE" msgstr "" ">>> dis.dis(myfunc)\n" -" 2 0 RESUME 0\n" +" 2 RESUME 0\n" "\n" -" 3 2 LOAD_GLOBAL 1 (NULL + len)\n" -" 12 LOAD_FAST 0 (alist)\n" -" 14 CALL 1\n" -" 22 RETURN_VALUE" +" 3 LOAD_GLOBAL 1 (len + NULL)\n" +" LOAD_FAST 0 (alist)\n" +" CALL 1\n" +" RETURN_VALUE" -#: ../../library/dis.rst:72 +#: ../../library/dis.rst:77 msgid "(The \"2\" is a line number)." msgstr "" -#: ../../library/dis.rst:77 +#: ../../library/dis.rst:82 msgid "Command-line interface" -msgstr "" +msgstr "命令列介面" -#: ../../library/dis.rst:79 +#: ../../library/dis.rst:84 msgid "The :mod:`dis` module can be invoked as a script from the command line:" msgstr "" -#: ../../library/dis.rst:81 -msgid "python -m dis [-h] [infile]" -msgstr "python -m dis [-h] [infile]" +#: ../../library/dis.rst:86 +msgid "python -m dis [-h] [-C] [-O] [infile]" +msgstr "python -m dis [-h] [-C] [-O] [infile]" -#: ../../library/dis.rst:85 +#: ../../library/dis.rst:90 msgid "The following options are accepted:" -msgstr "" +msgstr "可接受以下選項:" -#: ../../library/dis.rst:91 +#: ../../library/dis.rst:96 msgid "Display usage and exit." msgstr "" -#: ../../library/dis.rst:93 +#: ../../library/dis.rst:100 +msgid "Show inline caches." +msgstr "" + +#: ../../library/dis.rst:106 +msgid "Show offsets of instructions." +msgstr "" + +#: ../../library/dis.rst:110 msgid "" "If :file:`infile` is specified, its disassembled code will be written to " -"stdout. Otherwise, disassembly is performed on compiled source code recieved " +"stdout. Otherwise, disassembly is performed on compiled source code received " "from stdin." msgstr "" -#: ../../library/dis.rst:97 +#: ../../library/dis.rst:114 msgid "Bytecode analysis" msgstr "" -#: ../../library/dis.rst:101 +#: ../../library/dis.rst:118 msgid "" -"The bytecode analysis API allows pieces of Python code to be wrapped in a :" -"class:`Bytecode` object that provides easy access to details of the compiled " -"code." +"The bytecode analysis API allows pieces of Python code to be wrapped in " +"a :class:`Bytecode` object that provides easy access to details of the " +"compiled code." msgstr "" -#: ../../library/dis.rst:108 +#: ../../library/dis.rst:125 msgid "" "Analyse the bytecode corresponding to a function, generator, asynchronous " "generator, coroutine, method, string of source code, or a code object (as " "returned by :func:`compile`)." msgstr "" -#: ../../library/dis.rst:112 +#: ../../library/dis.rst:129 msgid "" "This is a convenience wrapper around many of the functions listed below, " "most notably :func:`get_instructions`, as iterating over a :class:`Bytecode` " "instance yields the bytecode operations as :class:`Instruction` instances." msgstr "" -#: ../../library/dis.rst:116 ../../library/dis.rst:304 +#: ../../library/dis.rst:133 ../../library/dis.rst:330 msgid "" "If *first_line* is not ``None``, it indicates the line number that should be " "reported for the first source line in the disassembled code. Otherwise, the " @@ -181,67 +196,73 @@ msgid "" "code object." msgstr "" -#: ../../library/dis.rst:121 +#: ../../library/dis.rst:138 msgid "" "If *current_offset* is not ``None``, it refers to an instruction offset in " "the disassembled code. Setting this means :meth:`.dis` will display a " "\"current instruction\" marker against the specified opcode." msgstr "" -#: ../../library/dis.rst:125 +#: ../../library/dis.rst:142 msgid "" "If *show_caches* is ``True``, :meth:`.dis` will display inline cache entries " "used by the interpreter to specialize the bytecode." msgstr "" -#: ../../library/dis.rst:128 +#: ../../library/dis.rst:145 msgid "" "If *adaptive* is ``True``, :meth:`.dis` will display specialized bytecode " "that may be different from the original bytecode." msgstr "" -#: ../../library/dis.rst:133 +#: ../../library/dis.rst:148 +msgid "" +"If *show_offsets* is ``True``, :meth:`.dis` will include instruction offsets " +"in the output." +msgstr "" + +#: ../../library/dis.rst:153 msgid "" "Construct a :class:`Bytecode` instance from the given traceback, setting " "*current_offset* to the instruction responsible for the exception." msgstr "" -#: ../../library/dis.rst:138 +#: ../../library/dis.rst:158 msgid "The compiled code object." msgstr "" -#: ../../library/dis.rst:142 +#: ../../library/dis.rst:162 msgid "The first source line of the code object (if available)" msgstr "" -#: ../../library/dis.rst:146 +#: ../../library/dis.rst:166 msgid "" -"Return a formatted view of the bytecode operations (the same as printed by :" -"func:`dis.dis`, but returned as a multi-line string)." +"Return a formatted view of the bytecode operations (the same as printed " +"by :func:`dis.dis`, but returned as a multi-line string)." msgstr "" -#: ../../library/dis.rst:151 +#: ../../library/dis.rst:171 msgid "" "Return a formatted multi-line string with detailed information about the " "code object, like :func:`code_info`." msgstr "" -#: ../../library/dis.rst:154 ../../library/dis.rst:194 -#: ../../library/dis.rst:246 +#: ../../library/dis.rst:174 ../../library/dis.rst:214 +#: ../../library/dis.rst:266 msgid "This can now handle coroutine and asynchronous generator objects." msgstr "" -#: ../../library/dis.rst:157 ../../library/dis.rst:249 -#: ../../library/dis.rst:265 ../../library/dis.rst:292 -#: ../../library/dis.rst:313 +#: ../../library/dis.rst:177 ../../library/dis.rst:269 +#: ../../library/dis.rst:286 ../../library/dis.rst:316 +#: ../../library/dis.rst:339 msgid "Added the *show_caches* and *adaptive* parameters." msgstr "新增 *show_caches* 與 *adaptive* 參數。" -#: ../../library/dis.rst:160 +#: ../../library/dis.rst:180 msgid "Example:" msgstr "範例:" -#: ../../library/dis.rst:162 +#: ../../library/dis.rst:182 msgid "" ">>> bytecode = dis.Bytecode(myfunc)\n" ">>> for instr in bytecode:\n" @@ -263,11 +284,11 @@ msgstr "" "CALL\n" "RETURN_VALUE" -#: ../../library/dis.rst:176 +#: ../../library/dis.rst:196 msgid "Analysis functions" -msgstr "" +msgstr "分析函式" -#: ../../library/dis.rst:178 +#: ../../library/dis.rst:198 msgid "" "The :mod:`dis` module also defines the following analysis functions that " "convert the input directly to the desired output. They can be useful if only " @@ -275,39 +296,39 @@ msgid "" "isn't useful:" msgstr "" -#: ../../library/dis.rst:184 +#: ../../library/dis.rst:204 msgid "" "Return a formatted multi-line string with detailed code object information " "for the supplied function, generator, asynchronous generator, coroutine, " "method, source code string or code object." msgstr "" -#: ../../library/dis.rst:188 +#: ../../library/dis.rst:208 msgid "" "Note that the exact contents of code info strings are highly implementation " "dependent and they may change arbitrarily across Python VMs or Python " "releases." msgstr "" -#: ../../library/dis.rst:200 +#: ../../library/dis.rst:220 msgid "" "Print detailed code object information for the supplied function, method, " "source code string or code object to *file* (or ``sys.stdout`` if *file* is " "not specified)." msgstr "" -#: ../../library/dis.rst:204 +#: ../../library/dis.rst:224 msgid "" "This is a convenient shorthand for ``print(code_info(x), file=file)``, " "intended for interactive exploration at the interpreter prompt." msgstr "" -#: ../../library/dis.rst:209 ../../library/dis.rst:240 -#: ../../library/dis.rst:262 ../../library/dis.rst:289 +#: ../../library/dis.rst:229 ../../library/dis.rst:260 +#: ../../library/dis.rst:283 ../../library/dis.rst:313 msgid "Added *file* parameter." msgstr "新增 *file* 參數。" -#: ../../library/dis.rst:215 +#: ../../library/dis.rst:235 msgid "" "Disassemble the *x* object. *x* can denote either a module, a class, a " "method, a function, a generator, an asynchronous generator, a coroutine, a " @@ -323,129 +344,145 @@ msgid "" "disassembles the last traceback." msgstr "" -#: ../../library/dis.rst:228 ../../library/dis.rst:259 -#: ../../library/dis.rst:286 +#: ../../library/dis.rst:248 ../../library/dis.rst:280 +#: ../../library/dis.rst:310 msgid "" "The disassembly is written as text to the supplied *file* argument if " "provided and to ``sys.stdout`` otherwise." msgstr "" -#: ../../library/dis.rst:231 +#: ../../library/dis.rst:251 msgid "" "The maximal depth of recursion is limited by *depth* unless it is ``None``. " "``depth=0`` means no recursion." msgstr "" -#: ../../library/dis.rst:234 +#: ../../library/dis.rst:254 msgid "" "If *show_caches* is ``True``, this function will display inline cache " "entries used by the interpreter to specialize the bytecode." msgstr "" -#: ../../library/dis.rst:237 +#: ../../library/dis.rst:257 msgid "" "If *adaptive* is ``True``, this function will display specialized bytecode " "that may be different from the original bytecode." msgstr "" -#: ../../library/dis.rst:243 +#: ../../library/dis.rst:263 msgid "Implemented recursive disassembling and added *depth* parameter." msgstr "" -#: ../../library/dis.rst:255 +#: ../../library/dis.rst:276 msgid "" "Disassemble the top-of-stack function of a traceback, using the last " "traceback if none was passed. The instruction causing the exception is " "indicated." msgstr "" -#: ../../library/dis.rst:272 +#: ../../library/dis.rst:289 ../../library/dis.rst:319 +msgid "Added the *show_offsets* parameter." +msgstr "新增 *show_offsets* 參數。" + +#: ../../library/dis.rst:296 msgid "" "Disassemble a code object, indicating the last instruction if *lasti* was " "provided. The output is divided in the following columns:" msgstr "" -#: ../../library/dis.rst:275 +#: ../../library/dis.rst:299 msgid "the line number, for the first instruction of each line" msgstr "" -#: ../../library/dis.rst:276 +#: ../../library/dis.rst:300 msgid "the current instruction, indicated as ``-->``," msgstr "" -#: ../../library/dis.rst:277 +#: ../../library/dis.rst:301 msgid "a labelled instruction, indicated with ``>>``," msgstr "" -#: ../../library/dis.rst:278 +#: ../../library/dis.rst:302 msgid "the address of the instruction," msgstr "" -#: ../../library/dis.rst:279 +#: ../../library/dis.rst:303 msgid "the operation code name," msgstr "" -#: ../../library/dis.rst:280 +#: ../../library/dis.rst:304 msgid "operation parameters, and" msgstr "" -#: ../../library/dis.rst:281 +#: ../../library/dis.rst:305 msgid "interpretation of the parameters in parentheses." msgstr "" -#: ../../library/dis.rst:283 +#: ../../library/dis.rst:307 msgid "" "The parameter interpretation recognizes local and global variable names, " "constant values, branch targets, and compare operators." msgstr "" -#: ../../library/dis.rst:298 +#: ../../library/dis.rst:324 msgid "" "Return an iterator over the instructions in the supplied function, method, " "source code string or code object." msgstr "" -#: ../../library/dis.rst:301 +#: ../../library/dis.rst:327 msgid "" "The iterator generates a series of :class:`Instruction` named tuples giving " "the details of each operation in the supplied code." msgstr "" -#: ../../library/dis.rst:309 +#: ../../library/dis.rst:335 +msgid "The *adaptive* parameter works as it does in :func:`dis`." +msgstr "" + +#: ../../library/dis.rst:342 msgid "" -"The *show_caches* and *adaptive* parameters work as they do in :func:`dis`." +"The *show_caches* parameter is deprecated and has no effect. The iterator " +"generates the :class:`Instruction` instances with the *cache_info* field " +"populated (regardless of the value of *show_caches*) and it no longer " +"generates separate items for the cache entries." msgstr "" -#: ../../library/dis.rst:319 +#: ../../library/dis.rst:350 msgid "" -"This generator function uses the :meth:`~codeobject.co_lines` method of the :" -"ref:`code object ` *code* to find the offsets which are starts " -"of lines in the source code. They are generated as ``(offset, lineno)`` " -"pairs." +"This generator function uses the :meth:`~codeobject.co_lines` method of " +"the :ref:`code object ` *code* to find the offsets which are " +"starts of lines in the source code. They are generated as ``(offset, " +"lineno)`` pairs." msgstr "" -#: ../../library/dis.rst:324 +#: ../../library/dis.rst:355 msgid "Line numbers can be decreasing. Before, they were always increasing." msgstr "" -#: ../../library/dis.rst:327 +#: ../../library/dis.rst:358 msgid "" -"The :pep:`626` :meth:`~codeobject.co_lines` method is used instead of the :" -"attr:`~codeobject.co_firstlineno` and :attr:`~codeobject.co_lnotab` " +"The :pep:`626` :meth:`~codeobject.co_lines` method is used instead of " +"the :attr:`~codeobject.co_firstlineno` and :attr:`~codeobject.co_lnotab` " "attributes of the :ref:`code object `." msgstr "" -#: ../../library/dis.rst:335 +#: ../../library/dis.rst:363 +msgid "" +"Line numbers can be ``None`` for bytecode that does not map to source lines." +msgstr "" + +#: ../../library/dis.rst:369 msgid "" "Detect all offsets in the raw compiled bytecode string *code* which are jump " "targets, and return a list of these offsets." msgstr "" -#: ../../library/dis.rst:341 +#: ../../library/dis.rst:375 msgid "Compute the stack effect of *opcode* with argument *oparg*." msgstr "" -#: ../../library/dis.rst:343 +#: ../../library/dis.rst:377 msgid "" "If the code has a jump target and *jump* is ``True``, :func:`~stack_effect` " "will return the stack effect of jumping. If *jump* is ``False``, it will " @@ -453,122 +490,190 @@ msgid "" "it will return the maximal stack effect of both cases." msgstr "" -#: ../../library/dis.rst:350 +#: ../../library/dis.rst:384 msgid "Added *jump* parameter." msgstr "新增 *jump* 參數。" -#: ../../library/dis.rst:357 -msgid "Python Bytecode Instructions" +#: ../../library/dis.rst:387 +msgid "" +"If ``oparg`` is omitted (or ``None``), the stack effect is now returned for " +"``oparg=0``. Previously this was an error for opcodes that use their arg. It " +"is also no longer an error to pass an integer ``oparg`` when the ``opcode`` " +"does not use it; the ``oparg`` in this case is ignored." msgstr "" -#: ../../library/dis.rst:359 +#: ../../library/dis.rst:397 +msgid "Python Bytecode Instructions" +msgstr "Python 位元組碼指令" + +#: ../../library/dis.rst:399 msgid "" "The :func:`get_instructions` function and :class:`Bytecode` class provide " "details of bytecode instructions as :class:`Instruction` instances:" msgstr "" -#: ../../library/dis.rst:364 +#: ../../library/dis.rst:404 msgid "Details for a bytecode operation" -msgstr "" +msgstr "位元組碼操作的詳細資訊" -#: ../../library/dis.rst:368 +#: ../../library/dis.rst:408 msgid "" "numeric code for operation, corresponding to the opcode values listed below " "and the bytecode values in the :ref:`opcode_collections`." msgstr "" -#: ../../library/dis.rst:374 +#: ../../library/dis.rst:414 msgid "human readable name for operation" +msgstr "操作的可讀名稱" + +#: ../../library/dis.rst:419 +msgid "" +"numeric code for the base operation if operation is specialized; otherwise " +"equal to :data:`opcode`" msgstr "" -#: ../../library/dis.rst:379 +#: ../../library/dis.rst:425 +msgid "" +"human readable name for the base operation if operation is specialized; " +"otherwise equal to :data:`opname`" +msgstr "" + +#: ../../library/dis.rst:431 msgid "numeric argument to operation (if any), otherwise ``None``" msgstr "" -#: ../../library/dis.rst:384 +#: ../../library/dis.rst:435 +msgid "alias for :data:`arg`" +msgstr ":data:`arg` 的別名。" + +#: ../../library/dis.rst:439 msgid "resolved arg value (if any), otherwise ``None``" msgstr "" -#: ../../library/dis.rst:389 +#: ../../library/dis.rst:444 msgid "" "human readable description of operation argument (if any), otherwise an " "empty string." msgstr "" -#: ../../library/dis.rst:395 +#: ../../library/dis.rst:450 msgid "start index of operation within bytecode sequence" msgstr "" -#: ../../library/dis.rst:400 -msgid "line started by this opcode (if any), otherwise ``None``" +#: ../../library/dis.rst:455 +msgid "" +"start index of operation within bytecode sequence, including prefixed " +"``EXTENDED_ARG`` operations if present; otherwise equal to :data:`offset`" +msgstr "" + +#: ../../library/dis.rst:461 +msgid "start index of the cache entries following the operation" msgstr "" -#: ../../library/dis.rst:405 +#: ../../library/dis.rst:466 +msgid "end index of the cache entries following the operation" +msgstr "" + +#: ../../library/dis.rst:471 +msgid "``True`` if this opcode starts a source line, otherwise ``False``" +msgstr "" + +#: ../../library/dis.rst:476 +msgid "" +"source line number associated with this opcode (if any), otherwise ``None``" +msgstr "" + +#: ../../library/dis.rst:481 msgid "``True`` if other code jumps to here, otherwise ``False``" msgstr "" -#: ../../library/dis.rst:410 +#: ../../library/dis.rst:486 +msgid "" +"bytecode index of the jump target if this is a jump operation, otherwise " +"``None``" +msgstr "" + +#: ../../library/dis.rst:492 msgid "" ":class:`dis.Positions` object holding the start and end locations that are " "covered by this instruction." msgstr "" -#: ../../library/dis.rst:417 +#: ../../library/dis.rst:497 +msgid "" +"Information about the cache entries of this instruction, as triplets of the " +"form ``(name, size, data)``, where the ``name`` and ``size`` describe the " +"cache format and data is the contents of the cache. ``cache_info`` is " +"``None`` if the instruction does not have caches." +msgstr "" + +#: ../../library/dis.rst:507 msgid "Field ``positions`` is added." msgstr "" -#: ../../library/dis.rst:422 +#: ../../library/dis.rst:511 +msgid "Changed field ``starts_line``." +msgstr "" + +#: ../../library/dis.rst:513 +msgid "" +"Added fields ``start_offset``, ``cache_offset``, ``end_offset``, " +"``baseopname``, ``baseopcode``, ``jump_target``, ``oparg``, ``line_number`` " +"and ``cache_info``." +msgstr "" + +#: ../../library/dis.rst:520 msgid "" "In case the information is not available, some fields might be ``None``." msgstr "" -#: ../../library/dis.rst:432 +#: ../../library/dis.rst:530 msgid "" "The Python compiler currently generates the following bytecode instructions." msgstr "" -#: ../../library/dis.rst:435 +#: ../../library/dis.rst:533 msgid "**General instructions**" -msgstr "" +msgstr "**一般指令**" -#: ../../library/dis.rst:437 +#: ../../library/dis.rst:535 msgid "" "In the following, We will refer to the interpreter stack as ``STACK`` and " "describe operations on it as if it was a Python list. The top of the stack " "corresponds to ``STACK[-1]`` in this language." msgstr "" -#: ../../library/dis.rst:443 +#: ../../library/dis.rst:541 msgid "" "Do nothing code. Used as a placeholder by the bytecode optimizer, and to " "generate line tracing events." msgstr "" -#: ../../library/dis.rst:449 +#: ../../library/dis.rst:547 msgid "Removes the top-of-stack item::" msgstr "" -#: ../../library/dis.rst:451 +#: ../../library/dis.rst:549 msgid "STACK.pop()" msgstr "STACK.pop()" -#: ../../library/dis.rst:456 +#: ../../library/dis.rst:554 msgid "" -"Removes the top two values from the stack. Equivalent to ``POP_TOP``; " -"``POP_TOP``. Used to clean up at the end of loops, hence the name." +"Removes the top-of-stack item. Equivalent to ``POP_TOP``. Used to clean up " +"at the end of loops, hence the name." msgstr "" -#: ../../library/dis.rst:465 +#: ../../library/dis.rst:563 msgid "Implements ``del STACK[-2]``. Used to clean up when a generator exits." msgstr "" -#: ../../library/dis.rst:473 +#: ../../library/dis.rst:571 msgid "" "Push the i-th item to the top of the stack without removing it from its " "original location::" msgstr "" -#: ../../library/dis.rst:476 +#: ../../library/dis.rst:574 msgid "" "assert i > 0\n" "STACK.append(STACK[-i])" @@ -576,15 +681,15 @@ msgstr "" "assert i > 0\n" "STACK.append(STACK[-i])" -#: ../../library/dis.rst:484 +#: ../../library/dis.rst:582 msgid "Swap the top of the stack with the i-th element::" msgstr "" -#: ../../library/dis.rst:486 +#: ../../library/dis.rst:584 msgid "STACK[-i], STACK[-1] = STACK[-1], STACK[-i]" msgstr "STACK[-i], STACK[-1] = STACK[-1], STACK[-i]" -#: ../../library/dis.rst:493 +#: ../../library/dis.rst:591 msgid "" "Rather than being an actual instruction, this opcode is used to mark extra " "space for the interpreter to cache useful data directly in the bytecode " @@ -592,77 +697,86 @@ msgid "" "viewed with ``show_caches=True``." msgstr "" -#: ../../library/dis.rst:498 +#: ../../library/dis.rst:596 msgid "" "Logically, this space is part of the preceding instruction. Many opcodes " "expect to be followed by an exact number of caches, and will instruct the " "interpreter to skip over them at runtime." msgstr "" -#: ../../library/dis.rst:502 +#: ../../library/dis.rst:600 msgid "" "Populated caches can look like arbitrary instructions, so great care should " "be taken when reading or modifying raw, adaptive bytecode containing " "quickened data." msgstr "" -#: ../../library/dis.rst:509 +#: ../../library/dis.rst:607 msgid "**Unary operations**" msgstr "" -#: ../../library/dis.rst:511 +#: ../../library/dis.rst:609 msgid "" "Unary operations take the top of the stack, apply the operation, and push " "the result back on the stack." msgstr "" -#: ../../library/dis.rst:517 +#: ../../library/dis.rst:615 msgid "Implements ``STACK[-1] = -STACK[-1]``." -msgstr "" +msgstr "實作 ``STACK[-1] = -STACK[-1]``。" -#: ../../library/dis.rst:522 +#: ../../library/dis.rst:620 msgid "Implements ``STACK[-1] = not STACK[-1]``." +msgstr "實作 ``STACK[-1] = not STACK[-1]``。" + +#: ../../library/dis.rst:622 ../../library/dis.rst:1318 +#: ../../library/dis.rst:1334 +msgid "This instruction now requires an exact :class:`bool` operand." msgstr "" -#: ../../library/dis.rst:527 +#: ../../library/dis.rst:628 msgid "Implements ``STACK[-1] = ~STACK[-1]``." -msgstr "" +msgstr "實作 ``STACK[-1] = ~STACK[-1]``。" -#: ../../library/dis.rst:532 +#: ../../library/dis.rst:633 msgid "Implements ``STACK[-1] = iter(STACK[-1])``." -msgstr "" +msgstr "實作 ``STACK[-1] = iter(STACK[-1])``。" -#: ../../library/dis.rst:537 +#: ../../library/dis.rst:638 msgid "" "If ``STACK[-1]`` is a :term:`generator iterator` or :term:`coroutine` object " "it is left as is. Otherwise, implements ``STACK[-1] = iter(STACK[-1])``." msgstr "" -#: ../../library/dis.rst:543 +#: ../../library/dis.rst:646 +msgid "Implements ``STACK[-1] = bool(STACK[-1])``." +msgstr "" + +#: ../../library/dis.rst:651 msgid "**Binary and in-place operations**" msgstr "" -#: ../../library/dis.rst:545 +#: ../../library/dis.rst:653 msgid "" "Binary operations remove the top two items from the stack (``STACK[-1]`` and " "``STACK[-2]``). They perform the operation, then put the result back on the " "stack." msgstr "" -#: ../../library/dis.rst:548 +#: ../../library/dis.rst:656 msgid "" "In-place operations are like binary operations, but the operation is done in-" "place when ``STACK[-2]`` supports it, and the resulting ``STACK[-1]`` may be " "(but does not have to be) the original ``STACK[-2]``." msgstr "" -#: ../../library/dis.rst:555 +#: ../../library/dis.rst:663 msgid "" "Implements the binary and in-place operators (depending on the value of " "*op*)::" msgstr "" -#: ../../library/dis.rst:558 +#: ../../library/dis.rst:666 msgid "" "rhs = STACK.pop()\n" "lhs = STACK.pop()\n" @@ -672,17 +786,17 @@ msgstr "" "lhs = STACK.pop()\n" "STACK.append(lhs op rhs)" -#: ../../library/dis.rst:567 ../../library/dis.rst:576 -#: ../../library/dis.rst:586 ../../library/dis.rst:594 -#: ../../library/dis.rst:606 ../../library/dis.rst:694 -#: ../../library/dis.rst:704 ../../library/dis.rst:714 -#: ../../library/dis.rst:934 ../../library/dis.rst:945 -#: ../../library/dis.rst:1049 ../../library/dis.rst:1061 -#: ../../library/dis.rst:1073 +#: ../../library/dis.rst:675 ../../library/dis.rst:684 +#: ../../library/dis.rst:694 ../../library/dis.rst:702 +#: ../../library/dis.rst:714 ../../library/dis.rst:802 +#: ../../library/dis.rst:812 ../../library/dis.rst:822 +#: ../../library/dis.rst:1046 ../../library/dis.rst:1057 +#: ../../library/dis.rst:1161 ../../library/dis.rst:1173 +#: ../../library/dis.rst:1185 msgid "Implements::" msgstr "" -#: ../../library/dis.rst:569 +#: ../../library/dis.rst:677 msgid "" "key = STACK.pop()\n" "container = STACK.pop()\n" @@ -692,7 +806,7 @@ msgstr "" "container = STACK.pop()\n" "STACK.append(container[key])" -#: ../../library/dis.rst:578 +#: ../../library/dis.rst:686 msgid "" "key = STACK.pop()\n" "container = STACK.pop()\n" @@ -704,7 +818,7 @@ msgstr "" "value = STACK.pop()\n" "container[key] = value" -#: ../../library/dis.rst:588 +#: ../../library/dis.rst:696 msgid "" "key = STACK.pop()\n" "container = STACK.pop()\n" @@ -714,7 +828,7 @@ msgstr "" "container = STACK.pop()\n" "del container[key]" -#: ../../library/dis.rst:596 +#: ../../library/dis.rst:704 msgid "" "end = STACK.pop()\n" "start = STACK.pop()\n" @@ -726,7 +840,7 @@ msgstr "" "container = STACK.pop()\n" "STACK.append(container[start:end])" -#: ../../library/dis.rst:608 +#: ../../library/dis.rst:716 msgid "" "end = STACK.pop()\n" "start = STACK.pop()\n" @@ -740,11 +854,11 @@ msgstr "" "values = STACK.pop()\n" "container[start:end] = value" -#: ../../library/dis.rst:617 +#: ../../library/dis.rst:725 msgid "**Coroutine opcodes**" msgstr "" -#: ../../library/dis.rst:621 +#: ../../library/dis.rst:729 msgid "" "Implements ``STACK[-1] = get_awaitable(STACK[-1])``, where " "``get_awaitable(o)`` returns ``o`` if ``o`` is a coroutine object or a " @@ -752,39 +866,39 @@ msgid "" "resolves ``o.__await__``." msgstr "" -#: ../../library/dis.rst:626 +#: ../../library/dis.rst:734 msgid "" "If the ``where`` operand is nonzero, it indicates where the instruction " "occurs:" msgstr "" -#: ../../library/dis.rst:629 +#: ../../library/dis.rst:737 msgid "``1``: After a call to ``__aenter__``" msgstr "" -#: ../../library/dis.rst:630 +#: ../../library/dis.rst:738 msgid "``2``: After a call to ``__aexit__``" msgstr "" -#: ../../library/dis.rst:634 +#: ../../library/dis.rst:742 msgid "Previously, this instruction did not have an oparg." msgstr "" -#: ../../library/dis.rst:640 +#: ../../library/dis.rst:748 msgid "Implements ``STACK[-1] = STACK[-1].__aiter__()``." msgstr "" -#: ../../library/dis.rst:643 +#: ../../library/dis.rst:751 msgid "Returning awaitable objects from ``__aiter__`` is no longer supported." msgstr "" -#: ../../library/dis.rst:650 +#: ../../library/dis.rst:758 msgid "" "Implement ``STACK.append(get_awaitable(STACK[-1].__anext__()))`` to the " "stack. See ``GET_AWAITABLE`` for details about ``get_awaitable``." msgstr "" -#: ../../library/dis.rst:658 +#: ../../library/dis.rst:766 msgid "" "Terminates an :keyword:`async for` loop. Handles an exception raised when " "awaiting a next item. The stack contains the async iterable in ``STACK[-2]`` " @@ -792,35 +906,35 @@ msgid "" "is not :exc:`StopAsyncIteration`, it is re-raised." msgstr "" -#: ../../library/dis.rst:665 ../../library/dis.rst:770 -#: ../../library/dis.rst:781 +#: ../../library/dis.rst:773 ../../library/dis.rst:881 +#: ../../library/dis.rst:892 msgid "" "Exception representation on the stack now consist of one, not three, items." msgstr "" -#: ../../library/dis.rst:671 +#: ../../library/dis.rst:779 msgid "" -"Handles an exception raised during a :meth:`~generator.throw` or :meth:" -"`~generator.close` call through the current frame. If ``STACK[-1]`` is an " -"instance of :exc:`StopIteration`, pop three values from the stack and push " -"its ``value`` member. Otherwise, re-raise ``STACK[-1]``." +"Handles an exception raised during a :meth:`~generator.throw` " +"or :meth:`~generator.close` call through the current frame. If " +"``STACK[-1]`` is an instance of :exc:`StopIteration`, pop three values from " +"the stack and push its ``value`` member. Otherwise, re-raise ``STACK[-1]``." msgstr "" -#: ../../library/dis.rst:681 +#: ../../library/dis.rst:789 msgid "" "Resolves ``__aenter__`` and ``__aexit__`` from ``STACK[-1]``. Pushes " "``__aexit__`` and result of ``__aenter__()`` to the stack::" msgstr "" -#: ../../library/dis.rst:684 +#: ../../library/dis.rst:792 msgid "STACK.extend((__aexit__, __aenter__())" msgstr "STACK.extend((__aexit__, __aenter__())" -#: ../../library/dis.rst:690 +#: ../../library/dis.rst:798 msgid "**Miscellaneous opcodes**" msgstr "" -#: ../../library/dis.rst:696 +#: ../../library/dis.rst:804 msgid "" "item = STACK.pop()\n" "set.add(STACK[-i], item)" @@ -828,11 +942,11 @@ msgstr "" "item = STACK.pop()\n" "set.add(STACK[-i], item)" -#: ../../library/dis.rst:699 +#: ../../library/dis.rst:807 msgid "Used to implement set comprehensions." msgstr "" -#: ../../library/dis.rst:706 +#: ../../library/dis.rst:814 msgid "" "item = STACK.pop()\n" "list.append(STACK[-i], item)" @@ -840,11 +954,11 @@ msgstr "" "item = STACK.pop()\n" "list.append(STACK[-i], item)" -#: ../../library/dis.rst:709 +#: ../../library/dis.rst:817 msgid "Used to implement list comprehensions." msgstr "" -#: ../../library/dis.rst:716 +#: ../../library/dis.rst:824 msgid "" "value = STACK.pop()\n" "key = STACK.pop()\n" @@ -854,47 +968,53 @@ msgstr "" "key = STACK.pop()\n" "dict.__setitem__(STACK[-i], key, value)" -#: ../../library/dis.rst:720 +#: ../../library/dis.rst:828 msgid "Used to implement dict comprehensions." msgstr "" -#: ../../library/dis.rst:723 +#: ../../library/dis.rst:831 msgid "" "Map value is ``STACK[-1]`` and map key is ``STACK[-2]``. Before, those were " "reversed." msgstr "" -#: ../../library/dis.rst:727 +#: ../../library/dis.rst:835 msgid "" -"For all of the :opcode:`SET_ADD`, :opcode:`LIST_APPEND` and :opcode:" -"`MAP_ADD` instructions, while the added value or key/value pair is popped " -"off, the container object remains on the stack so that it is available for " -"further iterations of the loop." +"For all of the :opcode:`SET_ADD`, :opcode:`LIST_APPEND` " +"and :opcode:`MAP_ADD` instructions, while the added value or key/value pair " +"is popped off, the container object remains on the stack so that it is " +"available for further iterations of the loop." msgstr "" -#: ../../library/dis.rst:735 +#: ../../library/dis.rst:843 msgid "Returns with ``STACK[-1]`` to the caller of the function." msgstr "" -#: ../../library/dis.rst:740 +#: ../../library/dis.rst:848 msgid "Returns with ``co_consts[consti]`` to the caller of the function." msgstr "" -#: ../../library/dis.rst:747 +#: ../../library/dis.rst:855 msgid "Yields ``STACK.pop()`` from a :term:`generator`." msgstr "" -#: ../../library/dis.rst:749 +#: ../../library/dis.rst:857 msgid "oparg set to be the stack depth." msgstr "" -#: ../../library/dis.rst:752 +#: ../../library/dis.rst:860 msgid "" "oparg set to be the exception block depth, for efficient closing of " "generators." msgstr "" -#: ../../library/dis.rst:758 +#: ../../library/dis.rst:863 +msgid "" +"oparg is ``1`` if this instruction is part of a yield-from or await, and " +"``0`` otherwise." +msgstr "" + +#: ../../library/dis.rst:869 msgid "" "Checks whether ``__annotations__`` is defined in ``locals()``, if not it is " "set up to an empty ``dict``. This opcode is only emitted if a class or " @@ -902,39 +1022,39 @@ msgid "" "statically." msgstr "" -#: ../../library/dis.rst:768 +#: ../../library/dis.rst:879 msgid "" "Pops a value from the stack, which is used to restore the exception state." msgstr "" -#: ../../library/dis.rst:775 +#: ../../library/dis.rst:886 msgid "" "Re-raises the exception currently on top of the stack. If oparg is non-zero, " -"pops an additional value from the stack which is used to set :attr:`~frame." -"f_lasti` of the current frame." +"pops an additional value from the stack which is used to " +"set :attr:`~frame.f_lasti` of the current frame." msgstr "" -#: ../../library/dis.rst:786 +#: ../../library/dis.rst:897 msgid "" "Pops a value from the stack. Pushes the current exception to the top of the " "stack. Pushes the value originally popped back to the stack. Used in " "exception handlers." msgstr "" -#: ../../library/dis.rst:794 +#: ../../library/dis.rst:905 msgid "" "Performs exception matching for ``except``. Tests whether the ``STACK[-2]`` " "is an exception matching ``STACK[-1]``. Pops ``STACK[-1]`` and pushes the " "boolean result of the test." msgstr "" -#: ../../library/dis.rst:802 +#: ../../library/dis.rst:913 msgid "" "Performs exception matching for ``except*``. Applies ``split(STACK[-1])`` on " "the exception group representing ``STACK[-2]``." msgstr "" -#: ../../library/dis.rst:805 +#: ../../library/dis.rst:916 msgid "" "In case of a match, pops two items from the stack and pushes the non-" "matching subgroup (``None`` in case of full match) followed by the matching " @@ -942,7 +1062,7 @@ msgid "" "``None``." msgstr "" -#: ../../library/dis.rst:814 +#: ../../library/dis.rst:925 msgid "" "Calls the function in position 4 on the stack with arguments (type, val, tb) " "representing the exception at the top of the stack. Used to implement the " @@ -950,38 +1070,40 @@ msgid "" "occurred in a :keyword:`with` statement." msgstr "" -#: ../../library/dis.rst:821 +#: ../../library/dis.rst:932 msgid "" "The ``__exit__`` function is in position 4 of the stack rather than 7. " "Exception representation on the stack now consist of one, not three, items." msgstr "" -#: ../../library/dis.rst:828 +#: ../../library/dis.rst:939 msgid "" "Pushes :exc:`AssertionError` onto the stack. Used by the :keyword:`assert` " "statement." msgstr "" -#: ../../library/dis.rst:836 +#: ../../library/dis.rst:947 msgid "" "Pushes :func:`!builtins.__build_class__` onto the stack. It is later called " "to construct a class." msgstr "" -#: ../../library/dis.rst:842 +#: ../../library/dis.rst:953 msgid "" "This opcode performs several operations before a with block starts. First, " "it loads :meth:`~object.__exit__` from the context manager and pushes it " -"onto the stack for later use by :opcode:`WITH_EXCEPT_START`. Then, :meth:" -"`~object.__enter__` is called. Finally, the result of calling the " -"``__enter__()`` method is pushed onto the stack." +"onto the stack for later use by :opcode:`WITH_EXCEPT_START`. " +"Then, :meth:`~object.__enter__` is called. Finally, the result of calling " +"the ``__enter__()`` method is pushed onto the stack." msgstr "" -#: ../../library/dis.rst:853 -msgid "Perform ``STACK.append(len(STACK[-1]))``." +#: ../../library/dis.rst:964 +msgid "" +"Perform ``STACK.append(len(STACK[-1]))``. Used in :keyword:`match` " +"statements where comparison with structure of pattern is needed." msgstr "" -#: ../../library/dis.rst:860 +#: ../../library/dis.rst:972 msgid "" "If ``STACK[-1]`` is an instance of :class:`collections.abc.Mapping` (or, " "more technically: if it has the :c:macro:`Py_TPFLAGS_MAPPING` flag set in " @@ -989,7 +1111,7 @@ msgid "" "Otherwise, push ``False``." msgstr "" -#: ../../library/dis.rst:870 +#: ../../library/dis.rst:982 msgid "" "If ``STACK[-1]`` is an instance of :class:`collections.abc.Sequence` and is " "*not* an instance of :class:`str`/:class:`bytes`/:class:`bytearray` (or, " @@ -998,40 +1120,42 @@ msgid "" "Otherwise, push ``False``." msgstr "" -#: ../../library/dis.rst:880 +#: ../../library/dis.rst:992 msgid "" "``STACK[-1]`` is a tuple of mapping keys, and ``STACK[-2]`` is the match " -"subject. If ``STACK[-2]`` contains all of the keys in ``STACK[-1]``, push a :" -"class:`tuple` containing the corresponding values. Otherwise, push ``None``." +"subject. If ``STACK[-2]`` contains all of the keys in ``STACK[-1]``, push " +"a :class:`tuple` containing the corresponding values. Otherwise, push " +"``None``." msgstr "" -#: ../../library/dis.rst:886 ../../library/dis.rst:1520 +#: ../../library/dis.rst:998 ../../library/dis.rst:1684 msgid "" "Previously, this instruction also pushed a boolean value indicating success " "(``True``) or failure (``False``)." msgstr "" -#: ../../library/dis.rst:893 +#: ../../library/dis.rst:1005 msgid "" "Implements ``name = STACK.pop()``. *namei* is the index of *name* in the " "attribute :attr:`~codeobject.co_names` of the :ref:`code object `. The compiler tries to use :opcode:`STORE_FAST` or :opcode:" -"`STORE_GLOBAL` if possible." +"objects>`. The compiler tries to use :opcode:`STORE_FAST` " +"or :opcode:`STORE_GLOBAL` if possible." msgstr "" -#: ../../library/dis.rst:900 +#: ../../library/dis.rst:1012 msgid "" -"Implements ``del name``, where *namei* is the index into :attr:`~codeobject." -"co_names` attribute of the :ref:`code object `." +"Implements ``del name``, where *namei* is the index " +"into :attr:`~codeobject.co_names` attribute of the :ref:`code object `." msgstr "" -#: ../../library/dis.rst:906 +#: ../../library/dis.rst:1018 msgid "" "Unpacks ``STACK[-1]`` into *count* individual values, which are put onto the " "stack right-to-left. Require there to be exactly *count* values.::" msgstr "" -#: ../../library/dis.rst:909 +#: ../../library/dis.rst:1021 msgid "" "assert(len(STACK[-1]) == count)\n" "STACK.extend(STACK.pop()[:-count-1:-1])" @@ -1039,7 +1163,7 @@ msgstr "" "assert(len(STACK[-1]) == count)\n" "STACK.extend(STACK.pop()[:-count-1:-1])" -#: ../../library/dis.rst:915 +#: ../../library/dis.rst:1027 msgid "" "Implements assignment with a starred target: Unpacks an iterable in " "``STACK[-1]`` into individual values, where the total number of values can " @@ -1047,11 +1171,11 @@ msgid "" "will be a list of all leftover items." msgstr "" -#: ../../library/dis.rst:920 +#: ../../library/dis.rst:1032 msgid "The number of values before and after the list value is limited to 255." msgstr "" -#: ../../library/dis.rst:922 +#: ../../library/dis.rst:1034 msgid "" "The number of values before the list value is encoded in the argument of the " "opcode. The number of values after the list if any is encoded using an " @@ -1060,13 +1184,13 @@ msgid "" "list value, the high byte of *counts* the number of values after it." msgstr "" -#: ../../library/dis.rst:928 +#: ../../library/dis.rst:1040 msgid "" "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))``." msgstr "" -#: ../../library/dis.rst:936 +#: ../../library/dis.rst:1048 msgid "" "obj = STACK.pop()\n" "value = STACK.pop()\n" @@ -1076,13 +1200,13 @@ msgstr "" "value = STACK.pop()\n" "obj.name = value" -#: ../../library/dis.rst:940 +#: ../../library/dis.rst:1052 msgid "" -"where *namei* is the index of name in :attr:`~codeobject.co_names` of the :" -"ref:`code object `." +"where *namei* is the index of name in :attr:`~codeobject.co_names` of " +"the :ref:`code object `." msgstr "" -#: ../../library/dis.rst:947 +#: ../../library/dis.rst:1059 msgid "" "obj = STACK.pop()\n" "del obj.name" @@ -1090,38 +1214,38 @@ msgstr "" "obj = STACK.pop()\n" "del obj.name" -#: ../../library/dis.rst:950 +#: ../../library/dis.rst:1062 msgid "" -"where *namei* is the index of name into :attr:`~codeobject.co_names` of the :" -"ref:`code object `." +"where *namei* is the index of name into :attr:`~codeobject.co_names` of " +"the :ref:`code object `." msgstr "" -#: ../../library/dis.rst:956 +#: ../../library/dis.rst:1068 msgid "Works as :opcode:`STORE_NAME`, but stores the name as a global." msgstr "" -#: ../../library/dis.rst:961 +#: ../../library/dis.rst:1073 msgid "Works as :opcode:`DELETE_NAME`, but deletes a global name." msgstr "" -#: ../../library/dis.rst:966 +#: ../../library/dis.rst:1078 msgid "Pushes ``co_consts[consti]`` onto the stack." msgstr "" -#: ../../library/dis.rst:971 +#: ../../library/dis.rst:1083 msgid "" "Pushes the value associated with ``co_names[namei]`` onto the stack. The " "name is looked up within the locals, then the globals, then the builtins." msgstr "" -#: ../../library/dis.rst:977 +#: ../../library/dis.rst:1089 msgid "" "Pushes a reference to the locals dictionary onto the stack. This is used to " -"prepare namespace dictionaries for :opcode:`LOAD_FROM_DICT_OR_DEREF` and :" -"opcode:`LOAD_FROM_DICT_OR_GLOBALS`." +"prepare namespace dictionaries for :opcode:`LOAD_FROM_DICT_OR_DEREF` " +"and :opcode:`LOAD_FROM_DICT_OR_GLOBALS`." msgstr "" -#: ../../library/dis.rst:986 +#: ../../library/dis.rst:1098 msgid "" "Pops a mapping off the stack and looks up the value for ``co_names[namei]``. " "If the name is not found there, looks it up in the globals and then the " @@ -1130,13 +1254,13 @@ msgid "" "bodies." msgstr "" -#: ../../library/dis.rst:997 +#: ../../library/dis.rst:1109 msgid "" "Creates a tuple consuming *count* items from the stack, and pushes the " "resulting tuple onto the stack::" msgstr "" -#: ../../library/dis.rst:1000 +#: ../../library/dis.rst:1112 msgid "" "if count == 0:\n" " value = ()\n" @@ -1154,41 +1278,41 @@ msgstr "" "\n" "STACK.append(value)" -#: ../../library/dis.rst:1011 +#: ../../library/dis.rst:1123 msgid "Works as :opcode:`BUILD_TUPLE`, but creates a list." msgstr "" -#: ../../library/dis.rst:1016 +#: ../../library/dis.rst:1128 msgid "Works as :opcode:`BUILD_TUPLE`, but creates a set." msgstr "" -#: ../../library/dis.rst:1021 +#: ../../library/dis.rst:1133 msgid "" "Pushes a new dictionary object onto the stack. Pops ``2 * count`` items so " "that the dictionary holds *count* entries: ``{..., STACK[-4]: STACK[-3], " "STACK[-2]: STACK[-1]}``." msgstr "" -#: ../../library/dis.rst:1025 +#: ../../library/dis.rst:1137 msgid "" "The dictionary is created from stack items instead of creating an empty " "dictionary pre-sized to hold *count* items." msgstr "" -#: ../../library/dis.rst:1032 +#: ../../library/dis.rst:1144 msgid "" "The version of :opcode:`BUILD_MAP` 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." msgstr "" -#: ../../library/dis.rst:1041 +#: ../../library/dis.rst:1153 msgid "" "Concatenates *count* strings from the stack and pushes the resulting string " "onto the stack." msgstr "" -#: ../../library/dis.rst:1051 +#: ../../library/dis.rst:1163 msgid "" "seq = STACK.pop()\n" "list.extend(STACK[-i], seq)" @@ -1196,11 +1320,11 @@ msgstr "" "seq = STACK.pop()\n" "list.extend(STACK[-i], seq)" -#: ../../library/dis.rst:1054 +#: ../../library/dis.rst:1166 msgid "Used to build lists." msgstr "" -#: ../../library/dis.rst:1063 +#: ../../library/dis.rst:1175 msgid "" "seq = STACK.pop()\n" "set.update(STACK[-i], seq)" @@ -1208,11 +1332,11 @@ msgstr "" "seq = STACK.pop()\n" "set.update(STACK[-i], seq)" -#: ../../library/dis.rst:1066 +#: ../../library/dis.rst:1178 msgid "Used to build sets." msgstr "" -#: ../../library/dis.rst:1075 +#: ../../library/dis.rst:1187 msgid "" "map = STACK.pop()\n" "dict.update(STACK[-i], map)" @@ -1220,161 +1344,166 @@ msgstr "" "map = STACK.pop()\n" "dict.update(STACK[-i], map)" -#: ../../library/dis.rst:1078 +#: ../../library/dis.rst:1190 msgid "Used to build dicts." msgstr "" -#: ../../library/dis.rst:1085 +#: ../../library/dis.rst:1197 msgid "Like :opcode:`DICT_UPDATE` but raises an exception for duplicate keys." msgstr "" -#: ../../library/dis.rst:1092 +#: ../../library/dis.rst:1204 msgid "" "If the low bit of ``namei`` is not set, this replaces ``STACK[-1]`` with " "``getattr(STACK[-1], co_names[namei>>1])``." msgstr "" -#: ../../library/dis.rst:1095 +#: ../../library/dis.rst:1207 msgid "" "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 :opcode:`CALL` when calling the unbound method. Otherwise, ``NULL`` and " -"the object returned by the attribute lookup are pushed." +"by :opcode:`CALL` or :opcode:`CALL_KW` when calling the unbound method. " +"Otherwise, ``NULL`` and the object returned by the attribute lookup are " +"pushed." msgstr "" -#: ../../library/dis.rst:1103 +#: ../../library/dis.rst:1216 msgid "" "If the low bit of ``namei`` is set, then a ``NULL`` or ``self`` is pushed to " "the stack before the attribute or unbound method respectively." msgstr "" -#: ../../library/dis.rst:1110 +#: ../../library/dis.rst:1223 msgid "" "This opcode implements :func:`super`, both in its zero-argument and two-" "argument forms (e.g. ``super().method()``, ``super().attr`` and ``super(cls, " "self).method()``, ``super(cls, self).attr``)." msgstr "" -#: ../../library/dis.rst:1114 -msgid "" -"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``" +#: ../../library/dis.rst:1227 +msgid "It pops three values from the stack (from top of stack down):" +msgstr "" + +#: ../../library/dis.rst:1229 +msgid "``self``: the first argument to the current method" +msgstr "" + +#: ../../library/dis.rst:1230 +msgid "``cls``: the class within which the current method was defined" +msgstr "" + +#: ../../library/dis.rst:1231 +msgid "the global ``super``" msgstr "" -#: ../../library/dis.rst:1119 +#: ../../library/dis.rst:1233 msgid "" "With respect to its argument, it works similarly to :opcode:`LOAD_ATTR`, " "except that ``namei`` is shifted left by 2 bits instead of 1." msgstr "" -#: ../../library/dis.rst:1122 +#: ../../library/dis.rst:1236 msgid "" -"The low bit of ``namei`` signals to attempt a method load, as with :opcode:" -"`LOAD_ATTR`, which results in pushing ``NULL`` and the loaded method. When " -"it is unset a single value is pushed to the stack." +"The low bit of ``namei`` signals to attempt a method load, as " +"with :opcode:`LOAD_ATTR`, which results in pushing ``NULL`` and the loaded " +"method. When it is unset a single value is pushed to the stack." msgstr "" -#: ../../library/dis.rst:1126 +#: ../../library/dis.rst:1240 msgid "" "The second-low bit of ``namei``, if set, means that this was a two-argument " "call to :func:`super` (unset means zero-argument)." msgstr "" -#: ../../library/dis.rst:1134 +#: ../../library/dis.rst:1248 msgid "" "Performs a Boolean operation. The operation name can be found in " -"``cmp_op[opname >> 4]``." +"``cmp_op[opname >> 5]``. If the fifth-lowest bit of ``opname`` is set " +"(``opname & 16``), the result should be coerced to ``bool``." msgstr "" -#: ../../library/dis.rst:1137 +#: ../../library/dis.rst:1252 msgid "" -"The cmp_op index is now stored in the four-highest bits of oparg instead of " -"the four-lowest bits of oparg." +"The fifth-lowest bit of the oparg now indicates a forced conversion " +"to :class:`bool`." msgstr "" -#: ../../library/dis.rst:1143 +#: ../../library/dis.rst:1259 msgid "Performs ``is`` comparison, or ``is not`` if ``invert`` is 1." msgstr "" -#: ../../library/dis.rst:1150 +#: ../../library/dis.rst:1266 msgid "Performs ``in`` comparison, or ``not in`` if ``invert`` is 1." msgstr "" -#: ../../library/dis.rst:1157 +#: ../../library/dis.rst:1273 msgid "" "Imports the module ``co_names[namei]``. ``STACK[-1]`` and ``STACK[-2]`` are " -"popped and provide the *fromlist* and *level* arguments of :func:" -"`__import__`. The module object is pushed onto the stack. The current " -"namespace is not affected: for a proper import statement, a subsequent :" -"opcode:`STORE_FAST` instruction modifies the namespace." +"popped and provide the *fromlist* and *level* arguments " +"of :func:`__import__`. The module object is pushed onto the stack. The " +"current namespace is not affected: for a proper import statement, a " +"subsequent :opcode:`STORE_FAST` instruction modifies the namespace." msgstr "" -#: ../../library/dis.rst:1165 +#: ../../library/dis.rst:1281 msgid "" "Loads the attribute ``co_names[namei]`` from the module found in " "``STACK[-1]``. The resulting object is pushed onto the stack, to be " "subsequently stored by a :opcode:`STORE_FAST` instruction." msgstr "" -#: ../../library/dis.rst:1172 +#: ../../library/dis.rst:1288 msgid "Increments bytecode counter by *delta*." msgstr "" -#: ../../library/dis.rst:1177 +#: ../../library/dis.rst:1293 msgid "Decrements bytecode counter by *delta*. Checks for interrupts." msgstr "" -#: ../../library/dis.rst:1184 +#: ../../library/dis.rst:1300 msgid "Decrements bytecode counter by *delta*. Does not check for interrupts." msgstr "" -#: ../../library/dis.rst:1191 +#: ../../library/dis.rst:1307 msgid "" "If ``STACK[-1]`` is true, increments the bytecode counter by *delta*. " "``STACK[-1]`` is popped." msgstr "" -#: ../../library/dis.rst:1194 ../../library/dis.rst:1207 +#: ../../library/dis.rst:1310 ../../library/dis.rst:1326 msgid "" "The oparg is now a relative delta rather than an absolute target. This " "opcode is a pseudo-instruction, replaced in final bytecode by the directed " "versions (forward/backward)." msgstr "" -#: ../../library/dis.rst:1199 ../../library/dis.rst:1212 -#: ../../library/dis.rst:1225 ../../library/dis.rst:1239 +#: ../../library/dis.rst:1315 ../../library/dis.rst:1331 +#: ../../library/dis.rst:1344 ../../library/dis.rst:1355 msgid "This is no longer a pseudo-instruction." msgstr "" -#: ../../library/dis.rst:1204 +#: ../../library/dis.rst:1323 msgid "" "If ``STACK[-1]`` is false, increments the bytecode counter by *delta*. " "``STACK[-1]`` is popped." msgstr "" -#: ../../library/dis.rst:1217 +#: ../../library/dis.rst:1339 msgid "" "If ``STACK[-1]`` is not ``None``, increments the bytecode counter by " "*delta*. ``STACK[-1]`` is popped." msgstr "" -#: ../../library/dis.rst:1220 ../../library/dis.rst:1234 -msgid "" -"This opcode is a pseudo-instruction, replaced in final bytecode by the " -"directed versions (forward/backward)." -msgstr "" - -#: ../../library/dis.rst:1231 +#: ../../library/dis.rst:1350 msgid "" "If ``STACK[-1]`` is ``None``, increments the bytecode counter by *delta*. " "``STACK[-1]`` is popped." msgstr "" -#: ../../library/dis.rst:1244 +#: ../../library/dis.rst:1360 msgid "" "``STACK[-1]`` is an :term:`iterator`. Call its :meth:`~iterator.__next__` " "method. If this yields a new value, push it on the stack (leaving the " @@ -1382,185 +1511,207 @@ msgid "" "code counter is incremented by *delta*." msgstr "" -#: ../../library/dis.rst:1249 +#: ../../library/dis.rst:1365 msgid "Up until 3.11 the iterator was popped when it was exhausted." msgstr "" -#: ../../library/dis.rst:1254 +#: ../../library/dis.rst:1370 msgid "Loads the global named ``co_names[namei>>1]`` onto the stack." msgstr "" -#: ../../library/dis.rst:1256 +#: ../../library/dis.rst:1372 msgid "" "If the low bit of ``namei`` is set, then a ``NULL`` is pushed to the stack " "before the global variable." msgstr "" -#: ../../library/dis.rst:1262 +#: ../../library/dis.rst:1378 msgid "" "Pushes a reference to the local ``co_varnames[var_num]`` onto the stack." msgstr "" -#: ../../library/dis.rst:1264 +#: ../../library/dis.rst:1380 msgid "" "This opcode is now only used in situations where the local variable is " "guaranteed to be initialized. It cannot raise :exc:`UnboundLocalError`." msgstr "" -#: ../../library/dis.rst:1270 +#: ../../library/dis.rst:1386 +msgid "" +"Pushes references to ``co_varnames[var_nums >> 4]`` and " +"``co_varnames[var_nums & 15]`` onto the stack." +msgstr "" + +#: ../../library/dis.rst:1393 msgid "" "Pushes a reference to the local ``co_varnames[var_num]`` onto the stack, " "raising an :exc:`UnboundLocalError` if the local variable has not been " "initialized." msgstr "" -#: ../../library/dis.rst:1278 +#: ../../library/dis.rst:1401 msgid "" "Pushes a reference to the local ``co_varnames[var_num]`` onto the stack (or " "pushes ``NULL`` onto the stack if the local variable has not been " "initialized) and sets ``co_varnames[var_num]`` to ``NULL``." msgstr "" -#: ../../library/dis.rst:1286 +#: ../../library/dis.rst:1409 msgid "Stores ``STACK.pop()`` into the local ``co_varnames[var_num]``." msgstr "" -#: ../../library/dis.rst:1291 -msgid "Deletes local ``co_varnames[var_num]``." -msgstr "" - -#: ../../library/dis.rst:1296 +#: ../../library/dis.rst:1413 msgid "" -"Creates a new cell in slot ``i``. If that slot is nonempty then that value " -"is stored into the new cell." +"Stores ``STACK[-1]`` into ``co_varnames[var_nums >> 4]`` and ``STACK[-2]`` " +"into ``co_varnames[var_nums & 15]``." msgstr "" -#: ../../library/dis.rst:1304 +#: ../../library/dis.rst:1420 msgid "" -"Pushes a reference to the cell contained in slot ``i`` of the \"fast " -"locals\" storage. The name of the variable is ``co_fastlocalnames[i]``." +"Stores ``STACK.pop()`` into the local ``co_varnames[var_nums >> 4]`` and " +"pushes a reference to the local ``co_varnames[var_nums & 15]`` onto the " +"stack." msgstr "" -#: ../../library/dis.rst:1307 -msgid "" -"Note that ``LOAD_CLOSURE`` is effectively an alias for ``LOAD_FAST``. It " -"exists to keep bytecode a little more readable." +#: ../../library/dis.rst:1428 +msgid "Deletes local ``co_varnames[var_num]``." msgstr "" -#: ../../library/dis.rst:1310 -msgid "``i`` is no longer offset by the length of ``co_varnames``." +#: ../../library/dis.rst:1433 +msgid "" +"Creates a new cell in slot ``i``. If that slot is nonempty then that value " +"is stored into the new cell." msgstr "" -#: ../../library/dis.rst:1316 +#: ../../library/dis.rst:1441 msgid "" "Loads the cell contained in slot ``i`` of the \"fast locals\" storage. " "Pushes a reference to the object the cell contains on the stack." msgstr "" -#: ../../library/dis.rst:1319 ../../library/dis.rst:1341 -#: ../../library/dis.rst:1352 +#: ../../library/dis.rst:1444 ../../library/dis.rst:1466 +#: ../../library/dis.rst:1477 msgid "" "``i`` is no longer offset by the length of :attr:`~codeobject.co_varnames`." msgstr "" -#: ../../library/dis.rst:1325 +#: ../../library/dis.rst:1450 msgid "" "Pops a mapping off the stack and looks up the name associated with slot " "``i`` of the \"fast locals\" storage in this mapping. If the name is not " -"found there, loads it from the cell contained in slot ``i``, similar to :" -"opcode:`LOAD_DEREF`. This is used for loading free variables in class bodies " -"(which previously used :opcode:`!LOAD_CLASSDEREF`) and in :ref:`annotation " -"scopes ` within class bodies." +"found there, loads it from the cell contained in slot ``i``, similar " +"to :opcode:`LOAD_DEREF`. This is used for loading :term:`closure variables " +"` in class bodies (which previously used :opcode:`!" +"LOAD_CLASSDEREF`) and in :ref:`annotation scopes ` within " +"class bodies." msgstr "" -#: ../../library/dis.rst:1338 +#: ../../library/dis.rst:1463 msgid "" "Stores ``STACK.pop()`` into the cell contained in slot ``i`` of the \"fast " "locals\" storage." msgstr "" -#: ../../library/dis.rst:1347 +#: ../../library/dis.rst:1472 msgid "" "Empties the cell contained in slot ``i`` of the \"fast locals\" storage. " "Used by the :keyword:`del` statement." msgstr "" -#: ../../library/dis.rst:1358 +#: ../../library/dis.rst:1483 msgid "" -"Copies the ``n`` free variables from the closure into the frame. Removes the " -"need for special code on the caller's side when calling closures." +"Copies the ``n`` :term:`free (closure) variables ` from " +"the closure into the frame. Removes the need for special code on the " +"caller's side when calling closures." msgstr "" -#: ../../library/dis.rst:1367 +#: ../../library/dis.rst:1492 msgid "" "Raises an exception using one of the 3 forms of the ``raise`` statement, " "depending on the value of *argc*:" msgstr "" -#: ../../library/dis.rst:1370 +#: ../../library/dis.rst:1495 msgid "0: ``raise`` (re-raise previous exception)" msgstr "" -#: ../../library/dis.rst:1371 +#: ../../library/dis.rst:1496 msgid "" "1: ``raise STACK[-1]`` (raise exception instance or type at ``STACK[-1]``)" msgstr "" -#: ../../library/dis.rst:1372 +#: ../../library/dis.rst:1497 msgid "" "2: ``raise STACK[-2] from STACK[-1]`` (raise exception instance or type at " "``STACK[-2]`` with ``__cause__`` set to ``STACK[-1]``)" msgstr "" -#: ../../library/dis.rst:1378 +#: ../../library/dis.rst:1503 msgid "" -"Calls a callable object with the number of arguments specified by ``argc``, " -"including the named arguments specified by the preceding :opcode:`KW_NAMES`, " -"if any. On the stack are (in ascending order), either:" +"Calls a callable object with the number of arguments specified by ``argc``. " +"On the stack are (in ascending order):" msgstr "" -#: ../../library/dis.rst:1383 -msgid "NULL" +#: ../../library/dis.rst:1506 ../../library/dis.rst:1530 +msgid "The callable" msgstr "" -#: ../../library/dis.rst:1384 ../../library/dis.rst:1390 -msgid "The callable" +#: ../../library/dis.rst:1507 ../../library/dis.rst:1531 +msgid "``self`` or ``NULL``" +msgstr "``self`` 或 ``NULL``" + +#: ../../library/dis.rst:1508 ../../library/dis.rst:1532 +msgid "The remaining positional arguments" +msgstr "剩餘的位置引數" + +#: ../../library/dis.rst:1510 +msgid "``argc`` is the total of the positional arguments, excluding ``self``." msgstr "" -#: ../../library/dis.rst:1385 -msgid "The positional arguments" +#: ../../library/dis.rst:1512 +msgid "" +"``CALL`` pops all arguments and the callable object off the stack, calls the " +"callable object with those arguments, and pushes the return value returned " +"by the callable object." msgstr "" -#: ../../library/dis.rst:1386 ../../library/dis.rst:1393 -msgid "The named arguments" +#: ../../library/dis.rst:1518 +msgid "The callable now always appears at the same position on the stack." msgstr "" -#: ../../library/dis.rst:1388 -msgid "or:" -msgstr "或:" +#: ../../library/dis.rst:1521 +msgid "Calls with keyword arguments are now handled by :opcode:`CALL_KW`." +msgstr "" -#: ../../library/dis.rst:1391 -msgid "``self``" -msgstr "``self``" +#: ../../library/dis.rst:1527 +msgid "" +"Calls a callable object with the number of arguments specified by ``argc``, " +"including one or more named arguments. On the stack are (in ascending order):" +msgstr "" -#: ../../library/dis.rst:1392 -msgid "The remaining positional arguments" +#: ../../library/dis.rst:1533 +msgid "The named arguments" msgstr "" -#: ../../library/dis.rst:1395 +#: ../../library/dis.rst:1534 +msgid "A :class:`tuple` of keyword argument names" +msgstr "" + +#: ../../library/dis.rst:1536 msgid "" "``argc`` is the total of the positional and named arguments, excluding " -"``self`` when a ``NULL`` is not present." +"``self``. The length of the tuple of keyword argument names is the number of " +"named arguments." msgstr "" -#: ../../library/dis.rst:1398 +#: ../../library/dis.rst:1539 msgid "" -"``CALL`` pops all arguments and the callable object off the stack, calls the " -"callable object with those arguments, and pushes the return value returned " -"by the callable object." +"``CALL_KW`` pops all arguments, the keyword names, and the callable object " +"off the stack, calls the callable object with those arguments, and pushes " +"the return value returned by the callable object." msgstr "" -#: ../../library/dis.rst:1407 +#: ../../library/dis.rst:1548 msgid "" "Calls a callable object with variable set of positional and keyword " "arguments. If the lowest bit of *flags* is set, the top of the stack " @@ -1572,73 +1723,76 @@ msgid "" "arguments, and pushes the return value returned by the callable object." msgstr "" -#: ../../library/dis.rst:1422 +#: ../../library/dis.rst:1563 msgid "" "Pushes a ``NULL`` to the stack. Used in the call sequence to match the " "``NULL`` pushed by :opcode:`LOAD_METHOD` for non-method calls." msgstr "" -#: ../../library/dis.rst:1431 +#: ../../library/dis.rst:1572 msgid "" -"Prefixes :opcode:`CALL`. Stores a reference to ``co_consts[consti]`` into an " -"internal variable for use by :opcode:`CALL`. ``co_consts[consti]`` must be a " -"tuple of strings." +"Pushes a new function object on the stack built from the code object at " +"``STACK[-1]``." +msgstr "" + +#: ../../library/dis.rst:1574 +msgid "Flag value ``0x04`` is a tuple of strings instead of dictionary" msgstr "" -#: ../../library/dis.rst:1440 +#: ../../library/dis.rst:1577 +msgid "Qualified name at ``STACK[-1]`` was removed." +msgstr "" + +#: ../../library/dis.rst:1580 msgid "" -"Pushes a new function object on the stack. From bottom to top, the consumed " -"stack must consist of values if the argument carries a specified flag value" +"Extra function attributes on the stack, signaled by oparg flags, were " +"removed. They now use :opcode:`SET_FUNCTION_ATTRIBUTE`." msgstr "" -#: ../../library/dis.rst:1443 +#: ../../library/dis.rst:1587 +msgid "" +"Sets an attribute on a function object. Expects the function at " +"``STACK[-1]`` and the attribute value to set at ``STACK[-2]``; consumes both " +"and leaves the function at ``STACK[-1]``. The flag determines which " +"attribute to set:" +msgstr "" + +#: ../../library/dis.rst:1591 msgid "" "``0x01`` a tuple of default values for positional-only and positional-or-" "keyword parameters in positional order" msgstr "" -#: ../../library/dis.rst:1445 +#: ../../library/dis.rst:1593 msgid "``0x02`` a dictionary of keyword-only parameters' default values" msgstr "" -#: ../../library/dis.rst:1446 +#: ../../library/dis.rst:1594 msgid "``0x04`` a tuple of strings containing parameters' annotations" msgstr "" -#: ../../library/dis.rst:1447 +#: ../../library/dis.rst:1595 msgid "``0x08`` a tuple containing cells for free variables, making a closure" msgstr "" -#: ../../library/dis.rst:1448 -msgid "the code associated with the function (at ``STACK[-1]``)" -msgstr "" - -#: ../../library/dis.rst:1450 -msgid "Flag value ``0x04`` is a tuple of strings instead of dictionary" -msgstr "" - -#: ../../library/dis.rst:1453 -msgid "Qualified name at ``STACK[-1]`` was removed." -msgstr "" - -#: ../../library/dis.rst:1461 +#: ../../library/dis.rst:1604 msgid "" "Pushes a slice object on the stack. *argc* must be 2 or 3. If it is 2, " "implements::" msgstr "" -#: ../../library/dis.rst:1463 +#: ../../library/dis.rst:1606 msgid "" "end = STACK.pop()\n" "start = STACK.pop()\n" "STACK.append(slice(start, end))" msgstr "" -#: ../../library/dis.rst:1467 +#: ../../library/dis.rst:1610 msgid "if it is 3, implements::" msgstr "" -#: ../../library/dis.rst:1469 +#: ../../library/dis.rst:1612 msgid "" "step = STACK.pop()\n" "end = STACK.pop()\n" @@ -1650,11 +1804,11 @@ msgstr "" "start = STACK.pop()\n" "STACK.append(slice(start, end, step))" -#: ../../library/dis.rst:1474 +#: ../../library/dis.rst:1617 msgid "See the :func:`slice` built-in function for more information." msgstr "" -#: ../../library/dis.rst:1479 +#: ../../library/dis.rst:1622 msgid "" "Prefixes any opcode which has an argument too big to fit into the default " "one byte. *ext* holds an additional byte which act as higher bits in the " @@ -1662,54 +1816,75 @@ msgid "" "allowed, forming an argument from two-byte to four-byte." msgstr "" -#: ../../library/dis.rst:1487 +#: ../../library/dis.rst:1630 +msgid "Convert value to a string, depending on ``oparg``::" +msgstr "" + +#: ../../library/dis.rst:1632 msgid "" -"Used for implementing formatted literal strings (f-strings). Pops an " -"optional *fmt_spec* from the stack, then a required *value*. *flags* is " -"interpreted as follows:" +"value = STACK.pop()\n" +"result = func(value)\n" +"STACK.append(result)" msgstr "" +"value = STACK.pop()\n" +"result = func(value)\n" +"STACK.append(result)" -#: ../../library/dis.rst:1491 -msgid "``(flags & 0x03) == 0x00``: *value* is formatted as-is." +#: ../../library/dis.rst:1636 +msgid "``oparg == 1``: call :func:`str` on *value*" msgstr "" -#: ../../library/dis.rst:1492 -msgid "" -"``(flags & 0x03) == 0x01``: call :func:`str` on *value* before formatting it." +#: ../../library/dis.rst:1637 +msgid "``oparg == 2``: call :func:`repr` on *value*" msgstr "" -#: ../../library/dis.rst:1494 -msgid "" -"``(flags & 0x03) == 0x02``: call :func:`repr` on *value* before formatting " -"it." +#: ../../library/dis.rst:1638 +msgid "``oparg == 3``: call :func:`ascii` on *value*" msgstr "" -#: ../../library/dis.rst:1496 -msgid "" -"``(flags & 0x03) == 0x03``: call :func:`ascii` on *value* before formatting " -"it." +#: ../../library/dis.rst:1640 ../../library/dis.rst:1653 +#: ../../library/dis.rst:1666 +msgid "Used for implementing formatted string literals (f-strings)." msgstr "" -#: ../../library/dis.rst:1498 +#: ../../library/dis.rst:1647 +msgid "Formats the value on top of stack::" +msgstr "" + +#: ../../library/dis.rst:1649 msgid "" -"``(flags & 0x04) == 0x04``: pop *fmt_spec* from the stack and use it, else " -"use an empty *fmt_spec*." +"value = STACK.pop()\n" +"result = value.__format__(\"\")\n" +"STACK.append(result)" +msgstr "" +"value = STACK.pop()\n" +"result = value.__format__(\"\")\n" +"STACK.append(result)" + +#: ../../library/dis.rst:1659 +msgid "Formats the given value with the given format spec::" msgstr "" -#: ../../library/dis.rst:1501 +#: ../../library/dis.rst:1661 msgid "" -"Formatting is performed using :c:func:`PyObject_Format`. The result is " -"pushed on the stack." +"spec = STACK.pop()\n" +"value = STACK.pop()\n" +"result = value.__format__(spec)\n" +"STACK.append(result)" msgstr "" +"spec = STACK.pop()\n" +"value = STACK.pop()\n" +"result = value.__format__(spec)\n" +"STACK.append(result)" -#: ../../library/dis.rst:1509 +#: ../../library/dis.rst:1673 msgid "" "``STACK[-1]`` is a tuple of keyword attribute names, ``STACK[-2]`` is the " "class being matched against, and ``STACK[-3]`` is the match subject. " "*count* is the number of positional sub-patterns." msgstr "" -#: ../../library/dis.rst:1513 +#: ../../library/dis.rst:1677 msgid "" "Pop ``STACK[-1]``, ``STACK[-2]``, and ``STACK[-3]``. If ``STACK[-3]`` is an " "instance of ``STACK[-2]`` and has the positional and keyword attributes " @@ -1717,269 +1892,285 @@ msgid "" "Otherwise, push ``None``." msgstr "" -#: ../../library/dis.rst:1527 +#: ../../library/dis.rst:1691 msgid "A no-op. Performs internal tracing, debugging and optimization checks." msgstr "" -#: ../../library/dis.rst:1529 -msgid "The ``where`` operand marks where the ``RESUME`` occurs:" +#: ../../library/dis.rst:1693 +msgid "" +"The ``context`` oparand consists of two parts. The lowest two bits indicate " +"where the ``RESUME`` occurs:" msgstr "" -#: ../../library/dis.rst:1531 +#: ../../library/dis.rst:1696 msgid "" "``0`` The start of a function, which is neither a generator, coroutine nor " "an async generator" msgstr "" -#: ../../library/dis.rst:1533 +#: ../../library/dis.rst:1698 msgid "``1`` After a ``yield`` expression" msgstr "" -#: ../../library/dis.rst:1534 +#: ../../library/dis.rst:1699 msgid "``2`` After a ``yield from`` expression" msgstr "" -#: ../../library/dis.rst:1535 +#: ../../library/dis.rst:1700 msgid "``3`` After an ``await`` expression" msgstr "" -#: ../../library/dis.rst:1542 +#: ../../library/dis.rst:1702 +msgid "" +"The next bit is ``1`` if the RESUME is at except-depth ``1``, and ``0`` " +"otherwise." +msgstr "" + +#: ../../library/dis.rst:1707 +msgid "The oparg value changed to include information about except-depth" +msgstr "" + +#: ../../library/dis.rst:1713 msgid "" "Create a generator, coroutine, or async generator from the current frame. " "Used as first opcode of in code object for the above mentioned callables. " "Clear the current frame and return the newly created generator." msgstr "" -#: ../../library/dis.rst:1551 +#: ../../library/dis.rst:1722 msgid "" "Equivalent to ``STACK[-1] = STACK[-2].send(STACK[-1])``. Used in ``yield " "from`` and ``await`` statements." msgstr "" -#: ../../library/dis.rst:1554 +#: ../../library/dis.rst:1725 msgid "" "If the call raises :exc:`StopIteration`, pop the top value from the stack, " "push the exception's ``value`` attribute, and increment the bytecode counter " "by *delta*." msgstr "" -#: ../../library/dis.rst:1563 +#: ../../library/dis.rst:1734 msgid "" "This is not really an opcode. It identifies the dividing line between " "opcodes in the range [0,255] which don't use their argument and those that " "do (``< HAVE_ARGUMENT`` and ``>= HAVE_ARGUMENT``, respectively)." msgstr "" -#: ../../library/dis.rst:1567 +#: ../../library/dis.rst:1738 msgid "" -"If your application uses pseudo instructions, use the :data:`hasarg` " -"collection instead." +"If your application uses pseudo instructions or specialized instructions, " +"use the :data:`hasarg` collection instead." msgstr "" -#: ../../library/dis.rst:1570 +#: ../../library/dis.rst:1741 msgid "" "Now every instruction has an argument, but opcodes ``< HAVE_ARGUMENT`` " "ignore it. Before, only opcodes ``>= HAVE_ARGUMENT`` had an argument." msgstr "" -#: ../../library/dis.rst:1574 +#: ../../library/dis.rst:1745 msgid "" "Pseudo instructions were added to the :mod:`dis` module, and for them it is " "not true that comparison with ``HAVE_ARGUMENT`` indicates whether they use " "their arg." msgstr "" -#: ../../library/dis.rst:1582 +#: ../../library/dis.rst:1750 +msgid "Use :data:`hasarg` instead." +msgstr "" + +#: ../../library/dis.rst:1755 msgid "" "Calls an intrinsic function with one argument. Passes ``STACK[-1]`` as the " "argument and sets ``STACK[-1]`` to the result. Used to implement " "functionality that is not performance critical." msgstr "" -#: ../../library/dis.rst:1586 ../../library/dis.rst:1640 +#: ../../library/dis.rst:1759 ../../library/dis.rst:1813 msgid "The operand determines which intrinsic function is called:" msgstr "" -#: ../../library/dis.rst:1589 ../../library/dis.rst:1643 +#: ../../library/dis.rst:1762 ../../library/dis.rst:1816 msgid "Operand" -msgstr "" +msgstr "運算元" -#: ../../library/dis.rst:1589 ../../library/dis.rst:1643 +#: ../../library/dis.rst:1762 ../../library/dis.rst:1816 msgid "Description" -msgstr "" +msgstr "描述" -#: ../../library/dis.rst:1591 +#: ../../library/dis.rst:1764 msgid "``INTRINSIC_1_INVALID``" msgstr "``INTRINSIC_1_INVALID``" -#: ../../library/dis.rst:1591 ../../library/dis.rst:1645 +#: ../../library/dis.rst:1764 ../../library/dis.rst:1818 msgid "Not valid" msgstr "" -#: ../../library/dis.rst:1593 +#: ../../library/dis.rst:1766 msgid "``INTRINSIC_PRINT``" msgstr "``INTRINSIC_PRINT``" -#: ../../library/dis.rst:1593 +#: ../../library/dis.rst:1766 msgid "Prints the argument to standard out. Used in the REPL." msgstr "" -#: ../../library/dis.rst:1596 +#: ../../library/dis.rst:1769 msgid "``INTRINSIC_IMPORT_STAR``" msgstr "``INTRINSIC_IMPORT_STAR``" -#: ../../library/dis.rst:1596 +#: ../../library/dis.rst:1769 msgid "Performs ``import *`` for the named module." msgstr "" -#: ../../library/dis.rst:1599 +#: ../../library/dis.rst:1772 msgid "``INTRINSIC_STOPITERATION_ERROR``" msgstr "``INTRINSIC_STOPITERATION_ERROR``" -#: ../../library/dis.rst:1599 +#: ../../library/dis.rst:1772 msgid "Extracts the return value from a ``StopIteration`` exception." msgstr "" -#: ../../library/dis.rst:1602 +#: ../../library/dis.rst:1775 msgid "``INTRINSIC_ASYNC_GEN_WRAP``" msgstr "``INTRINSIC_ASYNC_GEN_WRAP``" -#: ../../library/dis.rst:1602 +#: ../../library/dis.rst:1775 msgid "Wraps an async generator value" msgstr "" -#: ../../library/dis.rst:1604 +#: ../../library/dis.rst:1777 msgid "``INTRINSIC_UNARY_POSITIVE``" msgstr "``INTRINSIC_UNARY_POSITIVE``" -#: ../../library/dis.rst:1604 +#: ../../library/dis.rst:1777 msgid "Performs the unary ``+`` operation" msgstr "" -#: ../../library/dis.rst:1607 +#: ../../library/dis.rst:1780 msgid "``INTRINSIC_LIST_TO_TUPLE``" msgstr "``INTRINSIC_LIST_TO_TUPLE``" -#: ../../library/dis.rst:1607 +#: ../../library/dis.rst:1780 msgid "Converts a list to a tuple" msgstr "" -#: ../../library/dis.rst:1609 +#: ../../library/dis.rst:1782 msgid "``INTRINSIC_TYPEVAR``" msgstr "``INTRINSIC_TYPEVAR``" -#: ../../library/dis.rst:1609 +#: ../../library/dis.rst:1782 msgid "Creates a :class:`typing.TypeVar`" msgstr "" -#: ../../library/dis.rst:1611 +#: ../../library/dis.rst:1784 msgid "``INTRINSIC_PARAMSPEC``" msgstr "``INTRINSIC_PARAMSPEC``" -#: ../../library/dis.rst:1611 +#: ../../library/dis.rst:1784 msgid "Creates a :class:`typing.ParamSpec`" msgstr "" -#: ../../library/dis.rst:1614 +#: ../../library/dis.rst:1787 msgid "``INTRINSIC_TYPEVARTUPLE``" msgstr "``INTRINSIC_TYPEVARTUPLE``" -#: ../../library/dis.rst:1614 +#: ../../library/dis.rst:1787 msgid "Creates a :class:`typing.TypeVarTuple`" msgstr "" -#: ../../library/dis.rst:1617 +#: ../../library/dis.rst:1790 msgid "``INTRINSIC_SUBSCRIPT_GENERIC``" msgstr "``INTRINSIC_SUBSCRIPT_GENERIC``" -#: ../../library/dis.rst:1617 +#: ../../library/dis.rst:1790 msgid "Returns :class:`typing.Generic` subscripted with the argument" msgstr "" -#: ../../library/dis.rst:1620 +#: ../../library/dis.rst:1793 msgid "``INTRINSIC_TYPEALIAS``" msgstr "``INTRINSIC_TYPEALIAS``" -#: ../../library/dis.rst:1620 +#: ../../library/dis.rst:1793 msgid "" "Creates a :class:`typing.TypeAliasType`; used in the :keyword:`type` " "statement. The argument is a tuple of the type alias's name, type " "parameters, and value." msgstr "" -#: ../../library/dis.rst:1632 +#: ../../library/dis.rst:1805 msgid "" "Calls an intrinsic function with two arguments. Used to implement " "functionality that is not performance critical::" msgstr "" -#: ../../library/dis.rst:1635 +#: ../../library/dis.rst:1808 msgid "" "arg2 = STACK.pop()\n" "arg1 = STACK.pop()\n" "result = intrinsic2(arg1, arg2)\n" -"STACK.push(result)" +"STACK.append(result)" msgstr "" "arg2 = STACK.pop()\n" "arg1 = STACK.pop()\n" "result = intrinsic2(arg1, arg2)\n" -"STACK.push(result)" +"STACK.append(result)" -#: ../../library/dis.rst:1645 +#: ../../library/dis.rst:1818 msgid "``INTRINSIC_2_INVALID``" msgstr "``INTRINSIC_2_INVALID``" -#: ../../library/dis.rst:1647 +#: ../../library/dis.rst:1820 msgid "``INTRINSIC_PREP_RERAISE_STAR``" msgstr "``INTRINSIC_PREP_RERAISE_STAR``" -#: ../../library/dis.rst:1647 +#: ../../library/dis.rst:1820 msgid "Calculates the :exc:`ExceptionGroup` to raise from a ``try-except*``." msgstr "" -#: ../../library/dis.rst:1651 +#: ../../library/dis.rst:1824 msgid "``INTRINSIC_TYPEVAR_WITH_BOUND``" msgstr "``INTRINSIC_TYPEVAR_WITH_BOUND``" -#: ../../library/dis.rst:1651 +#: ../../library/dis.rst:1824 msgid "Creates a :class:`typing.TypeVar` with a bound." msgstr "" -#: ../../library/dis.rst:1654 +#: ../../library/dis.rst:1827 msgid "``INTRINSIC_TYPEVAR_WITH_CONSTRAINTS``" msgstr "``INTRINSIC_TYPEVAR_WITH_CONSTRAINTS``" -#: ../../library/dis.rst:1654 +#: ../../library/dis.rst:1827 msgid "Creates a :class:`typing.TypeVar` with constraints." msgstr "" -#: ../../library/dis.rst:1658 +#: ../../library/dis.rst:1831 msgid "``INTRINSIC_SET_FUNCTION_TYPE_PARAMS``" msgstr "``INTRINSIC_SET_FUNCTION_TYPE_PARAMS``" -#: ../../library/dis.rst:1658 +#: ../../library/dis.rst:1831 msgid "Sets the ``__type_params__`` attribute of a function." msgstr "" -#: ../../library/dis.rst:1665 +#: ../../library/dis.rst:1838 msgid "**Pseudo-instructions**" msgstr "" -#: ../../library/dis.rst:1667 +#: ../../library/dis.rst:1840 msgid "" "These opcodes do not appear in Python bytecode. They are used by the " "compiler but are replaced by real opcodes or removed before bytecode is " "generated." msgstr "" -#: ../../library/dis.rst:1672 +#: ../../library/dis.rst:1845 msgid "" "Set up an exception handler for the following code block. If an exception " "occurs, the value stack level is restored to its current state and control " "is transferred to the exception handler at ``target``." msgstr "" -#: ../../library/dis.rst:1679 +#: ../../library/dis.rst:1852 msgid "" "Like ``SETUP_FINALLY``, but in case of an exception also pushes the last " "instruction (``lasti``) to the stack so that ``RERAISE`` can restore it. If " @@ -1988,111 +2179,140 @@ msgid "" "exception handler at ``target``." msgstr "" -#: ../../library/dis.rst:1688 +#: ../../library/dis.rst:1861 msgid "" "Like ``SETUP_CLEANUP``, but in case of an exception one more item is popped " "from the stack before control is transferred to the exception handler at " "``target``." msgstr "" -#: ../../library/dis.rst:1692 +#: ../../library/dis.rst:1865 msgid "" "This variant is used in :keyword:`with` and :keyword:`async with` " -"constructs, which push the return value of the context manager's :meth:" -"`~object.__enter__` or :meth:`~object.__aenter__` to the stack." +"constructs, which push the return value of the context " +"manager's :meth:`~object.__enter__` or :meth:`~object.__aenter__` to the " +"stack." msgstr "" -#: ../../library/dis.rst:1699 +#: ../../library/dis.rst:1872 msgid "" "Marks the end of the code block associated with the last ``SETUP_FINALLY``, " "``SETUP_CLEANUP`` or ``SETUP_WITH``." msgstr "" -#: ../../library/dis.rst:1705 +#: ../../library/dis.rst:1878 msgid "" "Undirected relative jump instructions which are replaced by their directed " "(forward/backward) counterparts by the assembler." msgstr "" -#: ../../library/dis.rst:1710 +#: ../../library/dis.rst:1883 +msgid "" +"Pushes a reference to the cell contained in slot ``i`` of the \"fast " +"locals\" storage." +msgstr "" + +#: ../../library/dis.rst:1886 +msgid "" +"Note that ``LOAD_CLOSURE`` is replaced with ``LOAD_FAST`` in the assembler." +msgstr "" + +#: ../../library/dis.rst:1888 +msgid "This opcode is now a pseudo-instruction." +msgstr "" + +#: ../../library/dis.rst:1894 msgid "" "Optimized unbound method lookup. Emitted as a ``LOAD_ATTR`` opcode with a " "flag set in the arg." msgstr "" -#: ../../library/dis.rst:1717 +#: ../../library/dis.rst:1901 msgid "Opcode collections" msgstr "" -#: ../../library/dis.rst:1719 +#: ../../library/dis.rst:1903 msgid "" "These collections are provided for automatic introspection of bytecode " "instructions:" msgstr "" -#: ../../library/dis.rst:1722 +#: ../../library/dis.rst:1906 msgid "" "The collections now contain pseudo instructions and instrumented " "instructions as well. These are opcodes with values ``>= MIN_PSEUDO_OPCODE`` " "and ``>= MIN_INSTRUMENTED_OPCODE``." msgstr "" -#: ../../library/dis.rst:1729 +#: ../../library/dis.rst:1913 msgid "Sequence of operation names, indexable using the bytecode." msgstr "" -#: ../../library/dis.rst:1734 +#: ../../library/dis.rst:1918 msgid "Dictionary mapping operation names to bytecodes." msgstr "" -#: ../../library/dis.rst:1739 +#: ../../library/dis.rst:1923 msgid "Sequence of all compare operation names." msgstr "" -#: ../../library/dis.rst:1744 +#: ../../library/dis.rst:1928 msgid "Sequence of bytecodes that use their argument." msgstr "" -#: ../../library/dis.rst:1751 +#: ../../library/dis.rst:1935 msgid "Sequence of bytecodes that access a constant." msgstr "" -#: ../../library/dis.rst:1756 +#: ../../library/dis.rst:1940 msgid "" -"Sequence of bytecodes that access a free variable. '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." +"Sequence of bytecodes that access a :term:`free (closure) variable `. '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." msgstr "" -#: ../../library/dis.rst:1764 +#: ../../library/dis.rst:1948 msgid "Sequence of bytecodes that access an attribute by name." msgstr "" -#: ../../library/dis.rst:1769 -msgid "Sequence of bytecodes that have a relative jump target." -msgstr "" - -#: ../../library/dis.rst:1774 -msgid "Sequence of bytecodes that have an absolute jump target." +#: ../../library/dis.rst:1953 +msgid "Sequence of bytecodes that have a jump target. All jumps are relative." msgstr "" -#: ../../library/dis.rst:1779 +#: ../../library/dis.rst:1960 msgid "Sequence of bytecodes that access a local variable." msgstr "" -#: ../../library/dis.rst:1784 +#: ../../library/dis.rst:1965 msgid "Sequence of bytecodes of Boolean operations." msgstr "" -#: ../../library/dis.rst:1788 +#: ../../library/dis.rst:1969 msgid "Sequence of bytecodes that set an exception handler." msgstr "" -#: ../../library/dis.rst:1459 +#: ../../library/dis.rst:1976 +msgid "Sequence of bytecodes that have a relative jump target." +msgstr "" + +#: ../../library/dis.rst:1978 +msgid "All jumps are now relative. Use :data:`hasjump`." +msgstr "" + +#: ../../library/dis.rst:1984 +msgid "Sequence of bytecodes that have an absolute jump target." +msgstr "" + +#: ../../library/dis.rst:1986 +msgid "All jumps are now relative. This list is empty." +msgstr "" + +#: ../../library/dis.rst:1602 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../library/dis.rst:1459 +#: ../../library/dis.rst:1602 msgid "slice" msgstr "slice(切片)" diff --git a/library/distribution.po b/library/distribution.po index 290a362914..ef9d7dfdf8 100644 --- a/library/distribution.po +++ b/library/distribution.po @@ -6,7 +6,7 @@ # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2018-05-23 14:43+0000\n" @@ -30,3 +30,6 @@ msgid "" "Package Index `__, they can also be used with a local " "index server, or without any index server at all." msgstr "" +"這些函式庫可以幫助你發布和安裝 Python 軟體。雖然這些模組設計是為了與 `Python " +"套件索引 (Python Package Index) `__ 結合使用,但它們也可以" +"搭配本地索引伺服器,甚至可以在沒有任何索引伺服器的情況下使用。" diff --git a/library/distutils.po b/library/distutils.po new file mode 100644 index 0000000000..5705c4cc8a --- /dev/null +++ b/library/distutils.po @@ -0,0 +1,41 @@ +# Copyright (C) 2001-2024, Python Software Foundation +# This file is distributed under the same license as the Python package. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.13\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-18 00:15+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" +"tw)\n" +"Language: zh_TW\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../../library/distutils.rst:2 +msgid ":mod:`!distutils` --- Building and installing Python modules" +msgstr ":mod:`!distutils` --- 建置與安裝 Python 模組" + +#: ../../library/distutils.rst:10 +msgid "" +"This module is no longer part of the Python standard library. It was :ref:" +"`removed in Python 3.12 ` after being " +"deprecated in Python 3.10. The removal was decided in :pep:`632`, which has " +"`migration advice `_." +msgstr "" +"這個模組已不再是 Python 標準函式庫的一部分。它在 Python 3.10 中被棄用,並\\ :" +"ref:`已在 Python 3.12 中被移除 `。它的移除是" +"在 :pep:`632` 中決定的,該 PEP 附有\\ `遷移建議 `_。" + +#: ../../library/distutils.rst:16 +msgid "" +"The last version of Python that provided the :mod:`!distutils` module was " +"`Python 3.11 `_." +msgstr "" +"最後提供 :mod:`!distutils` 模組的 Python 版本是 `Python 3.11 `_。" diff --git a/library/doctest.po b/library/doctest.po index 869c6cfb34..19e05a3df7 100644 --- a/library/doctest.po +++ b/library/doctest.po @@ -4,9 +4,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-07-16 00:16+0000\n" "PO-Revision-Date: 2018-05-23 14:43+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -42,7 +42,7 @@ msgstr "" msgid "" "To perform regression testing by verifying that interactive examples from a " "test file or a test object work as expected." -msgstr "" +msgstr "透過驗證測試檔案或測試物件中的互動式範例是否按預期運作來執行迴歸測試。" #: ../../library/doctest.rst:26 msgid "" @@ -175,10 +175,10 @@ msgid "" " OverflowError: n too large\n" "ok\n" "2 items passed all tests:\n" -" 1 tests in __main__\n" -" 8 tests in __main__.factorial\n" -"9 tests in 2 items.\n" -"9 passed and 0 failed.\n" +" 1 test in __main__\n" +" 6 tests in __main__.factorial\n" +"7 tests in 2 items.\n" +"7 passed.\n" "Test passed.\n" "$" msgstr "" @@ -190,10 +190,10 @@ msgstr "" " OverflowError: n too large\n" "ok\n" "2 items passed all tests:\n" -" 1 tests in __main__\n" -" 8 tests in __main__.factorial\n" -"9 tests in 2 items.\n" -"9 passed and 0 failed.\n" +" 1 test in __main__\n" +" 6 tests in __main__.factorial\n" +"7 tests in 2 items.\n" +"7 passed.\n" "Test passed.\n" "$" @@ -265,46 +265,34 @@ msgstr "" #: ../../library/doctest.rst:171 msgid "" "You can force verbose mode by passing ``verbose=True`` to :func:`testmod`, " -"or prohibit it by passing ``verbose=False``. In either of those cases, " -"``sys.argv`` is not examined by :func:`testmod` (so passing ``-v`` or not " +"or prohibit it by passing ``verbose=False``. In either of those cases, :" +"data:`sys.argv` is not examined by :func:`testmod` (so passing ``-v`` or not " "has no effect)." msgstr "" #: ../../library/doctest.rst:176 msgid "" -"There is also a command line shortcut for running :func:`testmod`. You can " -"instruct the Python interpreter to run the doctest module directly from the " -"standard library and pass the module name(s) on the command line::" -msgstr "" - -#: ../../library/doctest.rst:180 -msgid "python -m doctest -v example.py" -msgstr "python -m doctest -v example.py" - -#: ../../library/doctest.rst:182 -msgid "" -"This will import :file:`example.py` as a standalone module and run :func:" -"`testmod` on it. Note that this may not work correctly if the file is part " -"of a package and imports other submodules from that package." +"There is also a command line shortcut for running :func:`testmod`, see " +"section :ref:`doctest-cli`." msgstr "" -#: ../../library/doctest.rst:186 +#: ../../library/doctest.rst:179 msgid "" "For more information on :func:`testmod`, see section :ref:`doctest-basic-" "api`." msgstr "" -#: ../../library/doctest.rst:192 +#: ../../library/doctest.rst:185 msgid "Simple Usage: Checking Examples in a Text File" msgstr "" -#: ../../library/doctest.rst:194 +#: ../../library/doctest.rst:187 msgid "" "Another simple application of doctest is testing interactive examples in a " "text file. This can be done with the :func:`testfile` function::" msgstr "" -#: ../../library/doctest.rst:197 +#: ../../library/doctest.rst:190 msgid "" "import doctest\n" "doctest.testfile(\"example.txt\")" @@ -312,7 +300,7 @@ msgstr "" "import doctest\n" "doctest.testfile(\"example.txt\")" -#: ../../library/doctest.rst:200 +#: ../../library/doctest.rst:193 msgid "" "That short script executes and verifies any interactive Python examples " "contained in the file :file:`example.txt`. The file content is treated as " @@ -320,7 +308,7 @@ msgid "" "Python program! For example, perhaps :file:`example.txt` contains this:" msgstr "" -#: ../../library/doctest.rst:205 +#: ../../library/doctest.rst:198 msgid "" "The ``example`` module\n" "======================\n" @@ -354,13 +342,13 @@ msgstr "" " >>> factorial(6)\n" " 120" -#: ../../library/doctest.rst:223 +#: ../../library/doctest.rst:216 msgid "" "Running ``doctest.testfile(\"example.txt\")`` then finds the error in this " "documentation::" msgstr "" -#: ../../library/doctest.rst:226 +#: ../../library/doctest.rst:219 msgid "" "File \"./example.txt\", line 14, in example.txt\n" "Failed example:\n" @@ -378,15 +366,15 @@ msgstr "" "Got:\n" " 720" -#: ../../library/doctest.rst:234 +#: ../../library/doctest.rst:227 msgid "" "As with :func:`testmod`, :func:`testfile` won't display anything unless an " "example fails. If an example does fail, then the failing example(s) and the " "cause(s) of the failure(s) are printed to stdout, using the same format as :" -"func:`testmod`." +"func:`!testmod`." msgstr "" -#: ../../library/doctest.rst:239 +#: ../../library/doctest.rst:232 msgid "" "By default, :func:`testfile` looks for files in the calling module's " "directory. See section :ref:`doctest-basic-api` for a description of the " @@ -394,40 +382,79 @@ msgid "" "locations." msgstr "" -#: ../../library/doctest.rst:243 +#: ../../library/doctest.rst:236 msgid "" "Like :func:`testmod`, :func:`testfile`'s verbosity can be set with the ``-" "v`` command-line switch or with the optional keyword argument *verbose*." msgstr "" -#: ../../library/doctest.rst:247 +#: ../../library/doctest.rst:240 msgid "" -"There is also a command line shortcut for running :func:`testfile`. You can " -"instruct the Python interpreter to run the doctest module directly from the " -"standard library and pass the file name(s) on the command line::" +"There is also a command line shortcut for running :func:`testfile`, see " +"section :ref:`doctest-cli`." +msgstr "" + +#: ../../library/doctest.rst:243 +msgid "" +"For more information on :func:`testfile`, see section :ref:`doctest-basic-" +"api`." +msgstr "" + +#: ../../library/doctest.rst:249 +msgid "Command-line Usage" msgstr "" #: ../../library/doctest.rst:251 -msgid "python -m doctest -v example.txt" -msgstr "python -m doctest -v example.txt" +msgid "" +"The :mod:`doctest` module can be invoked as a script from the command line:" +msgstr "" #: ../../library/doctest.rst:253 +msgid "python -m doctest [-v] [-o OPTION] [-f] file [file ...]" +msgstr "" + +#: ../../library/doctest.rst:261 msgid "" -"Because the file name does not end with :file:`.py`, :mod:`doctest` infers " -"that it must be run with :func:`testfile`, not :func:`testmod`." +"Detailed report of all examples tried is printed to standard output, along " +"with assorted summaries at the end::" msgstr "" -#: ../../library/doctest.rst:256 +#: ../../library/doctest.rst:264 +msgid "python -m doctest -v example.py" +msgstr "python -m doctest -v example.py" + +#: ../../library/doctest.rst:266 msgid "" -"For more information on :func:`testfile`, see section :ref:`doctest-basic-" -"api`." +"This will import :file:`example.py` as a standalone module and run :func:" +"`testmod` on it. Note that this may not work correctly if the file is part " +"of a package and imports other submodules from that package." +msgstr "" + +#: ../../library/doctest.rst:270 +msgid "" +"If the file name does not end with :file:`.py`, :mod:`!doctest` infers that " +"it must be run with :func:`testfile` instead::" msgstr "" -#: ../../library/doctest.rst:262 +#: ../../library/doctest.rst:273 +msgid "python -m doctest -v example.txt" +msgstr "python -m doctest -v example.txt" + +#: ../../library/doctest.rst:277 +msgid "" +"Option flags control various aspects of doctest's behavior, see section :ref:" +"`doctest-options`." +msgstr "" + +#: ../../library/doctest.rst:284 +msgid "This is shorthand for ``-o FAIL_FAST``." +msgstr "" + +#: ../../library/doctest.rst:292 msgid "How It Works" msgstr "" -#: ../../library/doctest.rst:264 +#: ../../library/doctest.rst:294 msgid "" "This section examines in detail how doctest works: which docstrings it looks " "at, how it finds interactive examples, what execution context it uses, how " @@ -437,17 +464,17 @@ msgid "" "see the following sections." msgstr "" -#: ../../library/doctest.rst:275 +#: ../../library/doctest.rst:305 msgid "Which Docstrings Are Examined?" msgstr "" -#: ../../library/doctest.rst:277 +#: ../../library/doctest.rst:307 msgid "" "The module docstring, and all function, class and method docstrings are " "searched. Objects imported into the module are not searched." msgstr "" -#: ../../library/doctest.rst:280 +#: ../../library/doctest.rst:317 msgid "" "In addition, there are cases when you want tests to be part of a module but " "not part of the help text, which requires that the tests not be included in " @@ -460,11 +487,11 @@ msgid "" "__test__.K``." msgstr "" -#: ../../library/doctest.rst:289 +#: ../../library/doctest.rst:326 msgid "For example, place this block of code at the top of :file:`example.py`:" msgstr "" -#: ../../library/doctest.rst:291 +#: ../../library/doctest.rst:328 msgid "" "__test__ = {\n" " 'numbers': \"\"\"\n" @@ -486,7 +513,7 @@ msgstr "" "\"\"\"\n" "}" -#: ../../library/doctest.rst:303 +#: ../../library/doctest.rst:340 msgid "" "The value of ``example.__test__[\"numbers\"]`` will be treated as a " "docstring and all the tests inside it will be run. It is important to note " @@ -495,24 +522,24 @@ msgid "" "scanned for tests." msgstr "" -#: ../../library/doctest.rst:309 +#: ../../library/doctest.rst:346 msgid "" "Any classes found are recursively searched similarly, to test docstrings in " "their contained methods and nested classes." msgstr "" -#: ../../library/doctest.rst:316 +#: ../../library/doctest.rst:353 msgid "How are Docstring Examples Recognized?" msgstr "" -#: ../../library/doctest.rst:318 +#: ../../library/doctest.rst:355 msgid "" "In most cases a copy-and-paste of an interactive console session works fine, " "but doctest isn't trying to do an exact emulation of any specific Python " "shell." msgstr "" -#: ../../library/doctest.rst:323 +#: ../../library/doctest.rst:360 msgid "" ">>> # comments are ignored\n" ">>> x = 12\n" @@ -546,18 +573,18 @@ msgstr "" "NO!!!\n" ">>>" -#: ../../library/doctest.rst:343 +#: ../../library/doctest.rst:380 msgid "" "Any expected output must immediately follow the final ``'>>> '`` or ``'... " "'`` line containing the code, and the expected output (if any) extends to " "the next ``'>>> '`` or all-whitespace line." msgstr "" -#: ../../library/doctest.rst:347 +#: ../../library/doctest.rst:384 msgid "The fine print:" msgstr "" -#: ../../library/doctest.rst:349 +#: ../../library/doctest.rst:386 msgid "" "Expected output cannot contain an all-whitespace line, since such a line is " "taken to signal the end of expected output. If expected output does contain " @@ -565,7 +592,7 @@ msgid "" "line is expected." msgstr "" -#: ../../library/doctest.rst:354 +#: ../../library/doctest.rst:391 msgid "" "All hard tab characters are expanded to spaces, using 8-column tab stops. " "Tabs in output generated by the tested code are not modified. Because any " @@ -580,20 +607,20 @@ msgid "" "`DocTestParser` class." msgstr "" -#: ../../library/doctest.rst:366 +#: ../../library/doctest.rst:403 msgid "" "Output to stdout is captured, but not output to stderr (exception tracebacks " "are captured via a different means)." msgstr "" -#: ../../library/doctest.rst:369 +#: ../../library/doctest.rst:406 msgid "" "If you continue a line via backslashing in an interactive session, or for " "any other reason use a backslash, you should use a raw docstring, which will " "preserve your backslashes exactly as you type them::" msgstr "" -#: ../../library/doctest.rst:373 +#: ../../library/doctest.rst:410 msgid "" ">>> def f(x):\n" "... r'''Backslashes in a raw docstring: m\\n'''\n" @@ -602,7 +629,7 @@ msgid "" "Backslashes in a raw docstring: m\\n" msgstr "" -#: ../../library/doctest.rst:379 +#: ../../library/doctest.rst:416 msgid "" "Otherwise, the backslash will be interpreted as part of the string. For " "example, the ``\\n`` above would be interpreted as a newline character. " @@ -610,7 +637,7 @@ msgid "" "use a raw string)::" msgstr "" -#: ../../library/doctest.rst:383 +#: ../../library/doctest.rst:420 msgid "" ">>> def f(x):\n" "... '''Backslashes in a raw docstring: m\\\\n'''\n" @@ -619,11 +646,11 @@ msgid "" "Backslashes in a raw docstring: m\\n" msgstr "" -#: ../../library/doctest.rst:389 +#: ../../library/doctest.rst:426 msgid "The starting column doesn't matter::" msgstr "" -#: ../../library/doctest.rst:391 +#: ../../library/doctest.rst:428 msgid "" ">>> assert \"Easy!\"\n" " >>> import math\n" @@ -635,17 +662,17 @@ msgstr "" " >>> math.floor(1.9)\n" " 1" -#: ../../library/doctest.rst:396 +#: ../../library/doctest.rst:433 msgid "" "and as many leading whitespace characters are stripped from the expected " "output as appeared in the initial ``'>>> '`` line that started the example." msgstr "" -#: ../../library/doctest.rst:403 +#: ../../library/doctest.rst:440 msgid "What's the Execution Context?" msgstr "" -#: ../../library/doctest.rst:405 +#: ../../library/doctest.rst:442 msgid "" "By default, each time :mod:`doctest` finds a docstring to test, it uses a " "*shallow copy* of :mod:`!M`'s globals, so that running tests doesn't change " @@ -656,17 +683,17 @@ msgid "" "defined in other docstrings." msgstr "" -#: ../../library/doctest.rst:413 +#: ../../library/doctest.rst:450 msgid "" "You can force use of your own dict as the execution context by passing " "``globs=your_dict`` to :func:`testmod` or :func:`testfile` instead." msgstr "" -#: ../../library/doctest.rst:420 +#: ../../library/doctest.rst:457 msgid "What About Exceptions?" msgstr "" -#: ../../library/doctest.rst:422 +#: ../../library/doctest.rst:459 msgid "" "No problem, provided that the traceback is the only output produced by the " "example: just paste in the traceback. [#]_ Since tracebacks contain details " @@ -675,11 +702,11 @@ msgid "" "it accepts." msgstr "" -#: ../../library/doctest.rst:428 +#: ../../library/doctest.rst:465 msgid "Simple example::" msgstr "簡單範例: ::" -#: ../../library/doctest.rst:430 +#: ../../library/doctest.rst:467 msgid "" ">>> [1, 2, 3].remove(42)\n" "Traceback (most recent call last):\n" @@ -691,20 +718,20 @@ msgstr "" " File \"\", line 1, in \n" "ValueError: list.remove(x): x not in list" -#: ../../library/doctest.rst:435 +#: ../../library/doctest.rst:472 msgid "" "That doctest succeeds if :exc:`ValueError` is raised, with the ``list." "remove(x): x not in list`` detail as shown." msgstr "" -#: ../../library/doctest.rst:438 +#: ../../library/doctest.rst:475 msgid "" "The expected output for an exception must start with a traceback header, " "which may be either of the following two lines, indented the same as the " "first line of the example::" msgstr "" -#: ../../library/doctest.rst:442 +#: ../../library/doctest.rst:479 msgid "" "Traceback (most recent call last):\n" "Traceback (innermost last):" @@ -712,14 +739,14 @@ msgstr "" "Traceback (most recent call last):\n" "Traceback (innermost last):" -#: ../../library/doctest.rst:445 +#: ../../library/doctest.rst:482 msgid "" "The traceback header is followed by an optional traceback stack, whose " "contents are ignored by doctest. The traceback stack is typically omitted, " "or copied verbatim from an interactive session." msgstr "" -#: ../../library/doctest.rst:449 +#: ../../library/doctest.rst:486 msgid "" "The traceback stack is followed by the most interesting part: the line(s) " "containing the exception type and detail. This is usually the last line of " @@ -727,7 +754,7 @@ msgid "" "multi-line detail::" msgstr "" -#: ../../library/doctest.rst:454 +#: ../../library/doctest.rst:491 msgid "" ">>> raise ValueError('multi\\n line\\ndetail')\n" "Traceback (most recent call last):\n" @@ -736,21 +763,27 @@ msgid "" " line\n" "detail" msgstr "" +">>> raise ValueError('multi\\n line\\ndetail')\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"ValueError: multi\n" +" line\n" +"detail" -#: ../../library/doctest.rst:461 +#: ../../library/doctest.rst:498 msgid "" "The last three lines (starting with :exc:`ValueError`) are compared against " "the exception's type and detail, and the rest are ignored." msgstr "" -#: ../../library/doctest.rst:464 +#: ../../library/doctest.rst:501 msgid "" "Best practice is to omit the traceback stack, unless it adds significant " "documentation value to the example. So the last example is probably better " "as::" msgstr "" -#: ../../library/doctest.rst:467 +#: ../../library/doctest.rst:504 msgid "" ">>> raise ValueError('multi\\n line\\ndetail')\n" "Traceback (most recent call last):\n" @@ -759,8 +792,14 @@ msgid "" " line\n" "detail" msgstr "" +">>> raise ValueError('multi\\n line\\ndetail')\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: multi\n" +" line\n" +"detail" -#: ../../library/doctest.rst:474 +#: ../../library/doctest.rst:511 msgid "" "Note that tracebacks are treated very specially. In particular, in the " "rewritten example, the use of ``...`` is independent of doctest's :const:" @@ -769,11 +808,11 @@ msgid "" "transcript of a Monty Python skit." msgstr "" -#: ../../library/doctest.rst:480 +#: ../../library/doctest.rst:517 msgid "Some details you should read once, but won't need to remember:" msgstr "" -#: ../../library/doctest.rst:482 +#: ../../library/doctest.rst:519 msgid "" "Doctest can't guess whether your expected output came from an exception " "traceback or from ordinary printing. So, e.g., an example that expects " @@ -783,7 +822,7 @@ msgid "" "create real problems." msgstr "" -#: ../../library/doctest.rst:489 +#: ../../library/doctest.rst:526 msgid "" "Each line of the traceback stack (if present) must be indented further than " "the first line of the example, *or* start with a non-alphanumeric character. " @@ -792,29 +831,29 @@ msgid "" "course this does the right thing for genuine tracebacks." msgstr "" -#: ../../library/doctest.rst:495 +#: ../../library/doctest.rst:532 msgid "" "When the :const:`IGNORE_EXCEPTION_DETAIL` doctest option is specified, " "everything following the leftmost colon and any module information in the " "exception name is ignored." msgstr "" -#: ../../library/doctest.rst:499 +#: ../../library/doctest.rst:536 msgid "" "The interactive shell omits the traceback header line for some :exc:" "`SyntaxError`\\ s. But doctest uses the traceback header line to " "distinguish exceptions from non-exceptions. So in the rare case where you " -"need to test a :exc:`SyntaxError` that omits the traceback header, you will " +"need to test a :exc:`!SyntaxError` that omits the traceback header, you will " "need to manually add the traceback header line to your test example." msgstr "" -#: ../../library/doctest.rst:507 +#: ../../library/doctest.rst:544 msgid "" "For some exceptions, Python displays the position of the error using ``^`` " "markers and tildes::" msgstr "" -#: ../../library/doctest.rst:510 +#: ../../library/doctest.rst:547 msgid "" ">>> 1 + None\n" " File \"\", line 1\n" @@ -828,7 +867,7 @@ msgstr "" " ~~^~~~~~\n" "TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'" -#: ../../library/doctest.rst:516 +#: ../../library/doctest.rst:553 msgid "" "Since the lines showing the position of the error come before the exception " "type and detail, they are not checked by doctest. For example, the " @@ -836,7 +875,7 @@ msgid "" "location::" msgstr "" -#: ../../library/doctest.rst:520 +#: ../../library/doctest.rst:557 msgid "" ">>> 1 + None\n" " File \"\", line 1\n" @@ -850,11 +889,11 @@ msgstr "" " ^~~~~~~~\n" "TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'" -#: ../../library/doctest.rst:531 +#: ../../library/doctest.rst:568 msgid "Option Flags" msgstr "可選旗標" -#: ../../library/doctest.rst:533 +#: ../../library/doctest.rst:570 msgid "" "A number of option flags control various aspects of doctest's behavior. " "Symbolic names for the flags are supplied as module constants, which can be :" @@ -864,17 +903,13 @@ msgid "" "option." msgstr "" -#: ../../library/doctest.rst:539 -msgid "The ``-o`` command line option." -msgstr "" - -#: ../../library/doctest.rst:542 +#: ../../library/doctest.rst:576 msgid "" "The first group of options define test semantics, controlling aspects of how " "doctest decides whether actual output matches an example's expected output:" msgstr "" -#: ../../library/doctest.rst:548 +#: ../../library/doctest.rst:582 msgid "" "By default, if an expected output block contains just ``1``, an actual " "output block containing just ``1`` or just ``True`` is considered to be a " @@ -886,7 +921,7 @@ msgid "" "not for several years." msgstr "" -#: ../../library/doctest.rst:560 +#: ../../library/doctest.rst:594 msgid "" "By default, if an expected output block contains a line containing only the " "string ````, then that line will match a blank line in the actual " @@ -895,7 +930,7 @@ msgid "" "`DONT_ACCEPT_BLANKLINE` is specified, this substitution is not allowed." msgstr "" -#: ../../library/doctest.rst:569 +#: ../../library/doctest.rst:603 msgid "" "When specified, all sequences of whitespace (blanks and newlines) are " "treated as equal. Any sequence of whitespace within the expected output " @@ -905,7 +940,7 @@ msgid "" "across multiple lines in your source." msgstr "" -#: ../../library/doctest.rst:580 +#: ../../library/doctest.rst:614 msgid "" "When specified, an ellipsis marker (``...``) in the expected output can " "match any substring in the actual output. This includes substrings that " @@ -914,14 +949,14 @@ msgid "" "matched too much!\" surprises that ``.*`` is prone to in regular expressions." msgstr "" -#: ../../library/doctest.rst:589 +#: ../../library/doctest.rst:623 msgid "" "When specified, doctests expecting exceptions pass so long as an exception " "of the expected type is raised, even if the details (message and fully " "qualified exception name) don't match." msgstr "" -#: ../../library/doctest.rst:593 +#: ../../library/doctest.rst:627 msgid "" "For example, an example expecting ``ValueError: 42`` will pass if the actual " "exception raised is ``ValueError: 3*14``, but will fail if, say, a :exc:" @@ -931,7 +966,7 @@ msgid "" "these variations will work with the flag specified:" msgstr "" -#: ../../library/doctest.rst:601 +#: ../../library/doctest.rst:635 msgid "" ">>> raise Exception('message')\n" "Traceback (most recent call last):\n" @@ -957,20 +992,20 @@ msgstr "" "Traceback (most recent call last):\n" "__main__.Exception: message" -#: ../../library/doctest.rst:615 +#: ../../library/doctest.rst:649 msgid "" "Note that :const:`ELLIPSIS` can also be used to ignore the details of the " "exception message, but such a test may still fail based on whether the " "module name is present or matches exactly." msgstr "" -#: ../../library/doctest.rst:619 +#: ../../library/doctest.rst:653 msgid "" ":const:`IGNORE_EXCEPTION_DETAIL` now also ignores any information relating " "to the module containing the exception under test." msgstr "" -#: ../../library/doctest.rst:626 +#: ../../library/doctest.rst:660 msgid "" "When specified, do not run the example at all. This can be useful in " "contexts where doctest examples serve as both documentation and test cases, " @@ -979,32 +1014,32 @@ msgid "" "might depend on resources which would be unavailable to the test driver." msgstr "" -#: ../../library/doctest.rst:632 +#: ../../library/doctest.rst:666 msgid "" "The SKIP flag can also be used for temporarily \"commenting out\" examples." msgstr "" -#: ../../library/doctest.rst:637 +#: ../../library/doctest.rst:671 msgid "A bitmask or'ing together all the comparison flags above." msgstr "" -#: ../../library/doctest.rst:639 +#: ../../library/doctest.rst:673 msgid "The second group of options controls how test failures are reported:" msgstr "" -#: ../../library/doctest.rst:644 +#: ../../library/doctest.rst:678 msgid "" "When specified, failures that involve multi-line expected and actual outputs " "are displayed using a unified diff." msgstr "" -#: ../../library/doctest.rst:650 +#: ../../library/doctest.rst:684 msgid "" "When specified, failures that involve multi-line expected and actual outputs " "will be displayed using a context diff." msgstr "" -#: ../../library/doctest.rst:656 +#: ../../library/doctest.rst:690 msgid "" "When specified, differences are computed by ``difflib.Differ``, using the " "same algorithm as the popular :file:`ndiff.py` utility. This is the only " @@ -1014,7 +1049,7 @@ msgid "" "mismatching column positions." msgstr "" -#: ../../library/doctest.rst:665 +#: ../../library/doctest.rst:699 msgid "" "When specified, display the first failing example in each doctest, but " "suppress output for all remaining examples. This will prevent doctest from " @@ -1025,7 +1060,7 @@ msgid "" "of failures reported; only the output is suppressed." msgstr "" -#: ../../library/doctest.rst:676 +#: ../../library/doctest.rst:710 msgid "" "When specified, exit after the first failing example and don't attempt to " "run the remaining examples. Thus, the number of failures reported will be at " @@ -1033,23 +1068,17 @@ msgid "" "first failure won't even produce debugging output." msgstr "" -#: ../../library/doctest.rst:681 -msgid "" -"The doctest command line accepts the option ``-f`` as a shorthand for ``-o " -"FAIL_FAST``." -msgstr "" - -#: ../../library/doctest.rst:689 +#: ../../library/doctest.rst:718 msgid "A bitmask or'ing together all the reporting flags above." msgstr "" -#: ../../library/doctest.rst:692 +#: ../../library/doctest.rst:721 msgid "" "There is also a way to register new option flag names, though this isn't " "useful unless you intend to extend :mod:`doctest` internals via subclassing:" msgstr "" -#: ../../library/doctest.rst:698 +#: ../../library/doctest.rst:727 msgid "" "Create a new option flag with a given name, and return the new flag's " "integer value. :func:`register_optionflag` can be used when subclassing :" @@ -1058,39 +1087,39 @@ msgid "" "be called using the following idiom::" msgstr "" -#: ../../library/doctest.rst:704 +#: ../../library/doctest.rst:733 msgid "MY_FLAG = register_optionflag('MY_FLAG')" msgstr "MY_FLAG = register_optionflag('MY_FLAG')" -#: ../../library/doctest.rst:714 +#: ../../library/doctest.rst:743 msgid "Directives" msgstr "" -#: ../../library/doctest.rst:716 +#: ../../library/doctest.rst:745 msgid "" "Doctest directives may be used to modify the :ref:`option flags ` for an individual example. Doctest directives are special Python " "comments following an example's source code:" msgstr "" -#: ../../library/doctest.rst:727 +#: ../../library/doctest.rst:756 msgid "" "Whitespace is not allowed between the ``+`` or ``-`` and the directive " "option name. The directive option name can be any of the option flag names " "explained above." msgstr "" -#: ../../library/doctest.rst:731 +#: ../../library/doctest.rst:760 msgid "" "An example's doctest directives modify doctest's behavior for that single " "example. Use ``+`` to enable the named behavior, or ``-`` to disable it." msgstr "" -#: ../../library/doctest.rst:734 +#: ../../library/doctest.rst:763 msgid "For example, this test passes:" msgstr "" -#: ../../library/doctest.rst:736 +#: ../../library/doctest.rst:765 msgid "" ">>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE\n" "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n" @@ -1100,7 +1129,7 @@ msgstr "" "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n" "10, 11, 12, 13, 14, 15, 16, 17, 18, 19]" -#: ../../library/doctest.rst:743 +#: ../../library/doctest.rst:772 msgid "" "Without the directive it would fail, both because the actual output doesn't " "have two blanks before the single-digit list elements, and because the " @@ -1108,7 +1137,7 @@ msgid "" "a directive to do so:" msgstr "" -#: ../../library/doctest.rst:748 +#: ../../library/doctest.rst:777 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "[0, 1, ..., 18, 19]" @@ -1116,13 +1145,13 @@ msgstr "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "[0, 1, ..., 18, 19]" -#: ../../library/doctest.rst:754 +#: ../../library/doctest.rst:783 msgid "" "Multiple directives can be used on a single physical line, separated by " "commas:" msgstr "" -#: ../../library/doctest.rst:757 +#: ../../library/doctest.rst:786 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" @@ -1130,13 +1159,13 @@ msgstr "" ">>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" -#: ../../library/doctest.rst:763 +#: ../../library/doctest.rst:792 msgid "" "If multiple directive comments are used for a single example, then they are " "combined:" msgstr "" -#: ../../library/doctest.rst:766 +#: ../../library/doctest.rst:795 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "... # doctest: +NORMALIZE_WHITESPACE\n" @@ -1146,14 +1175,14 @@ msgstr "" "... # doctest: +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" -#: ../../library/doctest.rst:773 +#: ../../library/doctest.rst:802 msgid "" "As the previous example shows, you can add ``...`` lines to your example " "containing only directives. This can be useful when an example is too long " "for a directive to comfortably fit on the same line:" msgstr "" -#: ../../library/doctest.rst:777 +#: ../../library/doctest.rst:806 msgid "" ">>> print(list(range(5)) + list(range(10, 20)) + list(range(30, 40)))\n" "... # doctest: +ELLIPSIS\n" @@ -1163,7 +1192,7 @@ msgstr "" "... # doctest: +ELLIPSIS\n" "[0, ..., 4, 10, ..., 19, 30, ..., 39]" -#: ../../library/doctest.rst:784 +#: ../../library/doctest.rst:813 msgid "" "Note that since all options are disabled by default, and directives apply " "only to the example they appear in, enabling options (via ``+`` in a " @@ -1173,11 +1202,11 @@ msgid "" "be useful." msgstr "" -#: ../../library/doctest.rst:794 +#: ../../library/doctest.rst:823 msgid "Warnings" msgstr "警告" -#: ../../library/doctest.rst:796 +#: ../../library/doctest.rst:825 msgid "" ":mod:`doctest` is serious about requiring exact matches in expected output. " "If even a single character doesn't match, the test fails. This will " @@ -1187,7 +1216,7 @@ msgid "" "test like ::" msgstr "" -#: ../../library/doctest.rst:802 +#: ../../library/doctest.rst:831 msgid "" ">>> foo()\n" "{\"spam\", \"eggs\"}" @@ -1195,11 +1224,11 @@ msgstr "" ">>> foo()\n" "{\"spam\", \"eggs\"}" -#: ../../library/doctest.rst:805 +#: ../../library/doctest.rst:834 msgid "is vulnerable! One workaround is to do ::" msgstr "" -#: ../../library/doctest.rst:807 +#: ../../library/doctest.rst:836 msgid "" ">>> foo() == {\"spam\", \"eggs\"}\n" "True" @@ -1207,11 +1236,11 @@ msgstr "" ">>> foo() == {\"spam\", \"eggs\"}\n" "True" -#: ../../library/doctest.rst:810 +#: ../../library/doctest.rst:839 msgid "instead. Another is to do ::" msgstr "" -#: ../../library/doctest.rst:812 +#: ../../library/doctest.rst:841 msgid "" ">>> d = sorted(foo())\n" ">>> d\n" @@ -1221,29 +1250,29 @@ msgstr "" ">>> d\n" "['eggs', 'spam']" -#: ../../library/doctest.rst:816 +#: ../../library/doctest.rst:845 msgid "There are others, but you get the idea." msgstr "" -#: ../../library/doctest.rst:818 +#: ../../library/doctest.rst:847 msgid "Another bad idea is to print things that embed an object address, like" msgstr "" -#: ../../library/doctest.rst:820 +#: ../../library/doctest.rst:849 msgid "" -">>> id(1.0) # certain to fail some of the time \n" +">>> id(1.0) # certain to fail some of the time\n" "7948648\n" ">>> class C: pass\n" -">>> C() # the default repr() for instances embeds an address \n" +">>> C() # the default repr() for instances embeds an address\n" "" msgstr "" -#: ../../library/doctest.rst:828 +#: ../../library/doctest.rst:857 msgid "" "The :const:`ELLIPSIS` directive gives a nice approach for the last example:" msgstr "" -#: ../../library/doctest.rst:830 +#: ../../library/doctest.rst:859 msgid "" ">>> C() # doctest: +ELLIPSIS\n" "" @@ -1251,46 +1280,46 @@ msgstr "" ">>> C() # doctest: +ELLIPSIS\n" "" -#: ../../library/doctest.rst:836 +#: ../../library/doctest.rst:865 msgid "" "Floating-point numbers are also subject to small output variations across " -"platforms, because Python defers to the platform C library for float " -"formatting, and C libraries vary widely in quality here. ::" +"platforms, because Python defers to the platform C library for some floating-" +"point calculations, and C libraries vary widely in quality here. ::" msgstr "" -#: ../../library/doctest.rst:840 +#: ../../library/doctest.rst:869 msgid "" -">>> 1./7 # risky\n" -"0.14285714285714285\n" -">>> print(1./7) # safer\n" -"0.142857142857\n" -">>> print(round(1./7, 6)) # much safer\n" -"0.142857" +">>> 1000**0.1 # risky\n" +"1.9952623149688797\n" +">>> round(1000**0.1, 9) # safer\n" +"1.995262315\n" +">>> print(f'{1000**0.1:.4f}') # much safer\n" +"1.9953" msgstr "" -#: ../../library/doctest.rst:847 +#: ../../library/doctest.rst:876 msgid "" "Numbers of the form ``I/2.**J`` are safe across all platforms, and I often " "contrive doctest examples to produce numbers of that form::" msgstr "" -#: ../../library/doctest.rst:850 +#: ../../library/doctest.rst:879 msgid "" ">>> 3./4 # utterly safe\n" "0.75" msgstr "" -#: ../../library/doctest.rst:853 +#: ../../library/doctest.rst:882 msgid "" "Simple fractions are also easier for people to understand, and that makes " "for better documentation." msgstr "" -#: ../../library/doctest.rst:860 +#: ../../library/doctest.rst:889 msgid "Basic API" msgstr "基礎 API" -#: ../../library/doctest.rst:862 +#: ../../library/doctest.rst:891 msgid "" "The functions :func:`testmod` and :func:`testfile` provide a simple " "interface to doctest that should be sufficient for most basic uses. For a " @@ -1298,25 +1327,25 @@ msgid "" "simple-testmod` and :ref:`doctest-simple-testfile`." msgstr "" -#: ../../library/doctest.rst:870 +#: ../../library/doctest.rst:899 msgid "" "All arguments except *filename* are optional, and should be specified in " "keyword form." msgstr "" -#: ../../library/doctest.rst:873 +#: ../../library/doctest.rst:902 msgid "" "Test examples in the file named *filename*. Return ``(failure_count, " "test_count)``." msgstr "" -#: ../../library/doctest.rst:876 +#: ../../library/doctest.rst:905 msgid "" "Optional argument *module_relative* specifies how the filename should be " "interpreted:" msgstr "" -#: ../../library/doctest.rst:879 +#: ../../library/doctest.rst:908 msgid "" "If *module_relative* is ``True`` (the default), then *filename* specifies an " "OS-independent module-relative path. By default, this path is relative to " @@ -1326,20 +1355,20 @@ msgid "" "absolute path (i.e., it may not begin with ``/``)." msgstr "" -#: ../../library/doctest.rst:886 +#: ../../library/doctest.rst:915 msgid "" "If *module_relative* is ``False``, then *filename* specifies an OS-specific " "path. The path may be absolute or relative; relative paths are resolved " "with respect to the current working directory." msgstr "" -#: ../../library/doctest.rst:890 +#: ../../library/doctest.rst:919 msgid "" "Optional argument *name* gives the name of the test; by default, or if " "``None``, ``os.path.basename(filename)`` is used." msgstr "" -#: ../../library/doctest.rst:893 +#: ../../library/doctest.rst:922 msgid "" "Optional argument *package* is a Python package or the name of a Python " "package whose directory should be used as the base directory for a module-" @@ -1348,7 +1377,7 @@ msgid "" "is an error to specify *package* if *module_relative* is ``False``." msgstr "" -#: ../../library/doctest.rst:899 +#: ../../library/doctest.rst:928 msgid "" "Optional argument *globs* gives a dict to be used as the globals when " "executing examples. A new shallow copy of this dict is created for the " @@ -1356,7 +1385,7 @@ msgid "" "``None``, a new empty dict is used." msgstr "" -#: ../../library/doctest.rst:904 +#: ../../library/doctest.rst:933 msgid "" "Optional argument *extraglobs* gives a dict merged into the globals used to " "execute examples. This works like :meth:`dict.update`: if *globs* and " @@ -1369,27 +1398,27 @@ msgid "" "tested." msgstr "" -#: ../../library/doctest.rst:913 +#: ../../library/doctest.rst:942 msgid "" "Optional argument *verbose* prints lots of stuff if true, and prints only " "failures if false; by default, or if ``None``, it's true if and only if ``'-" -"v'`` is in ``sys.argv``." +"v'`` is in :data:`sys.argv`." msgstr "" -#: ../../library/doctest.rst:917 +#: ../../library/doctest.rst:946 msgid "" "Optional argument *report* prints a summary at the end when true, else " "prints nothing at the end. In verbose mode, the summary is detailed, else " "the summary is very brief (in fact, empty if all tests passed)." msgstr "" -#: ../../library/doctest.rst:921 +#: ../../library/doctest.rst:950 msgid "" -"Optional argument *optionflags* (default value 0) takes the :ref:`bitwise OR " -"` of option flags. See section :ref:`doctest-options`." +"Optional argument *optionflags* (default value ``0``) takes the :ref:" +"`bitwise OR ` of option flags. See section :ref:`doctest-options`." msgstr "" -#: ../../library/doctest.rst:925 +#: ../../library/doctest.rst:954 msgid "" "Optional argument *raise_on_error* defaults to false. If true, an exception " "is raised upon the first failure or unexpected exception in an example. " @@ -1397,33 +1426,33 @@ msgid "" "continue running examples." msgstr "" -#: ../../library/doctest.rst:930 ../../library/doctest.rst:1071 +#: ../../library/doctest.rst:959 ../../library/doctest.rst:1102 msgid "" "Optional argument *parser* specifies a :class:`DocTestParser` (or subclass) " "that should be used to extract tests from the files. It defaults to a " "normal parser (i.e., ``DocTestParser()``)." msgstr "" -#: ../../library/doctest.rst:934 ../../library/doctest.rst:1075 +#: ../../library/doctest.rst:963 ../../library/doctest.rst:1106 msgid "" "Optional argument *encoding* specifies an encoding that should be used to " "convert the file to unicode." msgstr "" -#: ../../library/doctest.rst:940 +#: ../../library/doctest.rst:969 msgid "" "All arguments are optional, and all except for *m* should be specified in " "keyword form." msgstr "" -#: ../../library/doctest.rst:943 +#: ../../library/doctest.rst:972 msgid "" "Test examples in docstrings in functions and classes reachable from module " "*m* (or module :mod:`__main__` if *m* is not supplied or is ``None``), " "starting with ``m.__doc__``." msgstr "" -#: ../../library/doctest.rst:947 +#: ../../library/doctest.rst:976 msgid "" "Also test examples reachable from dict ``m.__test__``, if it exists. ``m." "__test__`` maps names (strings) to functions, classes and strings; function " @@ -1431,22 +1460,22 @@ msgid "" "directly, as if they were docstrings." msgstr "" -#: ../../library/doctest.rst:952 +#: ../../library/doctest.rst:981 msgid "" "Only docstrings attached to objects belonging to module *m* are searched." msgstr "" -#: ../../library/doctest.rst:954 +#: ../../library/doctest.rst:983 msgid "Return ``(failure_count, test_count)``." msgstr "" -#: ../../library/doctest.rst:956 +#: ../../library/doctest.rst:985 msgid "" "Optional argument *name* gives the name of the module; by default, or if " "``None``, ``m.__name__`` is used." msgstr "" -#: ../../library/doctest.rst:959 +#: ../../library/doctest.rst:988 msgid "" "Optional argument *exclude_empty* defaults to false. If true, objects for " "which no doctests are found are excluded from consideration. The default is " @@ -1457,39 +1486,39 @@ msgid "" "defaults to true." msgstr "" -#: ../../library/doctest.rst:967 +#: ../../library/doctest.rst:996 msgid "" "Optional arguments *extraglobs*, *verbose*, *report*, *optionflags*, " "*raise_on_error*, and *globs* are the same as for function :func:`testfile` " "above, except that *globs* defaults to ``m.__dict__``." msgstr "" -#: ../../library/doctest.rst:974 +#: ../../library/doctest.rst:1003 msgid "" "Test examples associated with object *f*; for example, *f* may be a string, " "a module, a function, or a class object." msgstr "" -#: ../../library/doctest.rst:977 +#: ../../library/doctest.rst:1006 msgid "" "A shallow copy of dictionary argument *globs* is used for the execution " "context." msgstr "" -#: ../../library/doctest.rst:979 +#: ../../library/doctest.rst:1008 msgid "" "Optional argument *name* is used in failure messages, and defaults to " "``\"NoName\"``." msgstr "" -#: ../../library/doctest.rst:982 +#: ../../library/doctest.rst:1011 msgid "" "If optional argument *verbose* is true, output is generated even if there " "are no failures. By default, output is generated only in case of an example " "failure." msgstr "" -#: ../../library/doctest.rst:985 +#: ../../library/doctest.rst:1014 msgid "" "Optional argument *compileflags* gives the set of flags that should be used " "by the Python compiler when running the examples. By default, or if " @@ -1497,16 +1526,16 @@ msgid "" "found in *globs*." msgstr "" -#: ../../library/doctest.rst:989 +#: ../../library/doctest.rst:1018 msgid "" "Optional argument *optionflags* works as for function :func:`testfile` above." msgstr "" -#: ../../library/doctest.rst:995 +#: ../../library/doctest.rst:1024 msgid "Unittest API" msgstr "" -#: ../../library/doctest.rst:997 +#: ../../library/doctest.rst:1026 msgid "" "As your collection of doctest'ed modules grows, you'll want a way to run all " "their doctests systematically. :mod:`doctest` provides two functions that " @@ -1516,7 +1545,7 @@ msgid "" "your test module::" msgstr "" -#: ../../library/doctest.rst:1003 +#: ../../library/doctest.rst:1032 msgid "" "import unittest\n" "import doctest\n" @@ -1534,42 +1563,44 @@ msgstr "" " tests.addTests(doctest.DocTestSuite(my_module_with_doctests))\n" " return tests" -#: ../../library/doctest.rst:1011 +#: ../../library/doctest.rst:1040 msgid "" "There are two main functions for creating :class:`unittest.TestSuite` " "instances from text files and modules with doctests:" msgstr "" -#: ../../library/doctest.rst:1017 +#: ../../library/doctest.rst:1046 msgid "" "Convert doctest tests from one or more text files to a :class:`unittest." "TestSuite`." msgstr "" -#: ../../library/doctest.rst:1020 +#: ../../library/doctest.rst:1049 msgid "" "The returned :class:`unittest.TestSuite` 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 :exc:" -"`failureException` exception is raised showing the name of the file " -"containing the test and a (sometimes approximate) line number." +"any file fails, then the synthesized unit test fails, and a :exc:`~unittest." +"TestCase.failureException` 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." msgstr "" -#: ../../library/doctest.rst:1026 +#: ../../library/doctest.rst:1056 msgid "Pass one or more paths (as strings) to text files to be examined." msgstr "" -#: ../../library/doctest.rst:1028 +#: ../../library/doctest.rst:1058 msgid "Options may be provided as keyword arguments:" msgstr "" -#: ../../library/doctest.rst:1030 +#: ../../library/doctest.rst:1060 msgid "" "Optional argument *module_relative* specifies how the filenames in *paths* " "should be interpreted:" msgstr "" -#: ../../library/doctest.rst:1033 +#: ../../library/doctest.rst:1063 msgid "" "If *module_relative* is ``True`` (the default), then each filename in " "*paths* specifies an OS-independent module-relative path. By default, this " @@ -1580,14 +1611,14 @@ msgid "" "``)." msgstr "" -#: ../../library/doctest.rst:1041 +#: ../../library/doctest.rst:1071 msgid "" "If *module_relative* is ``False``, then each filename in *paths* specifies " "an OS-specific path. The path may be absolute or relative; relative paths " "are resolved with respect to the current working directory." msgstr "" -#: ../../library/doctest.rst:1045 +#: ../../library/doctest.rst:1075 msgid "" "Optional argument *package* is a Python package or the name of a Python " "package whose directory should be used as the base directory for module-" @@ -1597,30 +1628,31 @@ msgid "" "``False``." msgstr "" -#: ../../library/doctest.rst:1052 +#: ../../library/doctest.rst:1082 msgid "" "Optional argument *setUp* specifies a set-up function for the test suite. " "This is called before running the tests in each file. The *setUp* function " -"will be passed a :class:`DocTest` object. The setUp function can access the " -"test globals as the *globs* attribute of the test passed." +"will be passed a :class:`DocTest` object. The *setUp* function can access " +"the test globals as the :attr:`~DocTest.globs` attribute of the test passed." msgstr "" -#: ../../library/doctest.rst:1057 +#: ../../library/doctest.rst:1087 msgid "" "Optional argument *tearDown* specifies a tear-down function for the test " "suite. This is called after running the tests in each file. The *tearDown* " -"function will be passed a :class:`DocTest` object. The setUp function can " -"access the test globals as the *globs* attribute of the test passed." +"function will be passed a :class:`DocTest` object. The *tearDown* function " +"can access the test globals as the :attr:`~DocTest.globs` attribute of the " +"test passed." msgstr "" -#: ../../library/doctest.rst:1062 ../../library/doctest.rst:1096 +#: ../../library/doctest.rst:1093 msgid "" "Optional argument *globs* is a dictionary containing the initial global " "variables for the tests. A new copy of this dictionary is created for each " "test. By default, *globs* is a new empty dictionary." msgstr "" -#: ../../library/doctest.rst:1066 +#: ../../library/doctest.rst:1097 msgid "" "Optional argument *optionflags* specifies the default doctest options for " "the tests, created by or-ing together individual option flags. See section :" @@ -1628,69 +1660,71 @@ msgid "" "for a better way to set reporting options." msgstr "" -#: ../../library/doctest.rst:1078 +#: ../../library/doctest.rst:1109 msgid "" "The global ``__file__`` is added to the globals provided to doctests loaded " "from a text file using :func:`DocFileSuite`." msgstr "" -#: ../../library/doctest.rst:1084 +#: ../../library/doctest.rst:1115 msgid "Convert doctest tests for a module to a :class:`unittest.TestSuite`." msgstr "" -#: ../../library/doctest.rst:1086 +#: ../../library/doctest.rst:1117 msgid "" "The returned :class:`unittest.TestSuite` 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 :exc:`failureException` " -"exception is raised showing the name of the file containing the test and a " -"(sometimes approximate) line number." +"framework and runs each doctest in the module. Each docstring is run as a " +"separate unit test. If any of the doctests fail, then the synthesized unit " +"test fails, and a :exc:`unittest.TestCase.failureException` 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" msgstr "" -#: ../../library/doctest.rst:1092 +#: ../../library/doctest.rst:1125 msgid "" "Optional argument *module* provides the module to be tested. It can be a " "module object or a (possibly dotted) module name. If not specified, the " "module calling this function is used." msgstr "" -#: ../../library/doctest.rst:1100 +#: ../../library/doctest.rst:1129 +msgid "" +"Optional argument *globs* is a dictionary containing the initial global " +"variables for the tests. A new copy of this dictionary is created for each " +"test. By default, *globs* is the module's :attr:`~module.__dict__`." +msgstr "" + +#: ../../library/doctest.rst:1133 msgid "" "Optional argument *extraglobs* specifies an extra set of global variables, " "which is merged into *globs*. By default, no extra globals are used." msgstr "" -#: ../../library/doctest.rst:1103 +#: ../../library/doctest.rst:1136 msgid "" "Optional argument *test_finder* is the :class:`DocTestFinder` object (or a " "drop-in replacement) that is used to extract doctests from the module." msgstr "" -#: ../../library/doctest.rst:1106 +#: ../../library/doctest.rst:1139 msgid "" "Optional arguments *setUp*, *tearDown*, and *optionflags* are the same as " -"for function :func:`DocFileSuite` above." +"for function :func:`DocFileSuite` above, but they are called for each " +"docstring." msgstr "" -#: ../../library/doctest.rst:1109 +#: ../../library/doctest.rst:1142 msgid "This function uses the same search technique as :func:`testmod`." msgstr "" -#: ../../library/doctest.rst:1111 +#: ../../library/doctest.rst:1144 msgid "" ":func:`DocTestSuite` returns an empty :class:`unittest.TestSuite` if " "*module* contains no docstrings instead of raising :exc:`ValueError`." msgstr "" -#: ../../library/doctest.rst:1117 -msgid "" -"When doctests which have been converted to unit tests by :func:" -"`DocFileSuite` or :func:`DocTestSuite` fail, this exception is raised " -"showing the name of the file containing the test and a (sometimes " -"approximate) line number." -msgstr "" - -#: ../../library/doctest.rst:1121 +#: ../../library/doctest.rst:1148 msgid "" "Under the covers, :func:`DocTestSuite` creates a :class:`unittest.TestSuite` " "out of :class:`!doctest.DocTestCase` instances, and :class:`!DocTestCase` is " @@ -1699,67 +1733,67 @@ msgid "" "questions about the exact details of :mod:`unittest` integration." msgstr "" -#: ../../library/doctest.rst:1127 +#: ../../library/doctest.rst:1154 msgid "" "Similarly, :func:`DocFileSuite` creates a :class:`unittest.TestSuite` out " "of :class:`!doctest.DocFileCase` instances, and :class:`!DocFileCase` is a " "subclass of :class:`!DocTestCase`." msgstr "" -#: ../../library/doctest.rst:1131 +#: ../../library/doctest.rst:1158 msgid "" "So both ways of creating a :class:`unittest.TestSuite` run instances of :" "class:`!DocTestCase`. This is important for a subtle reason: when you run :" -"mod:`doctest` functions yourself, you can control the :mod:`doctest` options " -"in use directly, by passing option flags to :mod:`doctest` functions. " -"However, if you're writing a :mod:`unittest` framework, :mod:`unittest` " -"ultimately controls when and how tests get run. The framework author " -"typically wants to control :mod:`doctest` reporting options (perhaps, e.g., " -"specified by command line options), but there's no way to pass options " -"through :mod:`unittest` to :mod:`doctest` test runners." +"mod:`doctest` functions yourself, you can control the :mod:`!doctest` " +"options in use directly, by passing option flags to :mod:`!doctest` " +"functions. However, if you're writing a :mod:`unittest` framework, :mod:`!" +"unittest` ultimately controls when and how tests get run. The framework " +"author typically wants to control :mod:`!doctest` reporting options " +"(perhaps, e.g., specified by command line options), but there's no way to " +"pass options through :mod:`!unittest` to :mod:`!doctest` test runners." msgstr "" -#: ../../library/doctest.rst:1141 +#: ../../library/doctest.rst:1168 msgid "" -"For this reason, :mod:`doctest` also supports a notion of :mod:`doctest` " +"For this reason, :mod:`doctest` also supports a notion of :mod:`!doctest` " "reporting flags specific to :mod:`unittest` support, via this function:" msgstr "" -#: ../../library/doctest.rst:1147 +#: ../../library/doctest.rst:1174 msgid "Set the :mod:`doctest` reporting flags to use." msgstr "" -#: ../../library/doctest.rst:1149 +#: ../../library/doctest.rst:1176 msgid "" "Argument *flags* takes the :ref:`bitwise OR ` of option flags. See " "section :ref:`doctest-options`. Only \"reporting flags\" can be used." msgstr "" -#: ../../library/doctest.rst:1152 +#: ../../library/doctest.rst:1179 msgid "" "This is a module-global setting, and affects all future doctests run by " "module :mod:`unittest`: the :meth:`!runTest` method of :class:`!" "DocTestCase` looks at the option flags specified for the test case when the :" "class:`!DocTestCase` instance was constructed. If no reporting flags were " -"specified (which is the typical and expected case), :mod:`!doctest`'s :mod:" -"`unittest` reporting flags are :ref:`bitwise ORed ` into the option " +"specified (which is the typical and expected case), :mod:`!doctest`'s :mod:`!" +"unittest` reporting flags are :ref:`bitwise ORed ` into the option " "flags, and the option flags so augmented are passed to the :class:" "`DocTestRunner` instance created to run the doctest. If any reporting flags " "were specified when the :class:`!DocTestCase` instance was constructed, :mod:" -"`!doctest`'s :mod:`unittest` reporting flags are ignored." +"`!doctest`'s :mod:`!unittest` reporting flags are ignored." msgstr "" -#: ../../library/doctest.rst:1163 +#: ../../library/doctest.rst:1190 msgid "" "The value of the :mod:`unittest` reporting flags in effect before the " "function was called is returned by the function." msgstr "" -#: ../../library/doctest.rst:1170 +#: ../../library/doctest.rst:1197 msgid "Advanced API" msgstr "" -#: ../../library/doctest.rst:1172 +#: ../../library/doctest.rst:1199 msgid "" "The basic API is a simple wrapper that's intended to make doctest easy to " "use. It is fairly flexible, and should meet most users' needs; however, if " @@ -1767,62 +1801,62 @@ msgid "" "doctest's capabilities, then you should use the advanced API." msgstr "" -#: ../../library/doctest.rst:1177 +#: ../../library/doctest.rst:1204 msgid "" "The advanced API revolves around two container classes, which are used to " "store the interactive examples extracted from doctest cases:" msgstr "" -#: ../../library/doctest.rst:1180 +#: ../../library/doctest.rst:1207 msgid "" ":class:`Example`: A single Python :term:`statement`, paired with its " "expected output." msgstr "" -#: ../../library/doctest.rst:1183 +#: ../../library/doctest.rst:1210 msgid "" ":class:`DocTest`: A collection of :class:`Example`\\ s, typically extracted " "from a single docstring or text file." msgstr "" -#: ../../library/doctest.rst:1186 +#: ../../library/doctest.rst:1213 msgid "" "Additional processing classes are defined to find, parse, and run, and check " "doctest examples:" msgstr "" -#: ../../library/doctest.rst:1189 +#: ../../library/doctest.rst:1216 msgid "" ":class:`DocTestFinder`: Finds all docstrings in a given module, and uses a :" "class:`DocTestParser` to create a :class:`DocTest` from every docstring that " "contains interactive examples." msgstr "" -#: ../../library/doctest.rst:1193 +#: ../../library/doctest.rst:1220 msgid "" ":class:`DocTestParser`: Creates a :class:`DocTest` object from a string " "(such as an object's docstring)." msgstr "" -#: ../../library/doctest.rst:1196 +#: ../../library/doctest.rst:1223 msgid "" ":class:`DocTestRunner`: Executes the examples in a :class:`DocTest`, and " "uses an :class:`OutputChecker` to verify their output." msgstr "" -#: ../../library/doctest.rst:1199 +#: ../../library/doctest.rst:1226 msgid "" ":class:`OutputChecker`: Compares the actual output from a doctest example " "with the expected output, and decides whether they match." msgstr "" -#: ../../library/doctest.rst:1202 +#: ../../library/doctest.rst:1229 msgid "" "The relationships among these processing classes are summarized in the " "following diagram::" msgstr "" -#: ../../library/doctest.rst:1205 +#: ../../library/doctest.rst:1232 msgid "" " list of:\n" "+------+ +---------+\n" @@ -1842,30 +1876,30 @@ msgstr "" " DocTestParser | Example | OutputChecker\n" " +---------+" -#: ../../library/doctest.rst:1218 +#: ../../library/doctest.rst:1245 msgid "DocTest Objects" msgstr "DocTest 物件" -#: ../../library/doctest.rst:1223 +#: ../../library/doctest.rst:1250 msgid "" "A collection of doctest examples that should be run in a single namespace. " "The constructor arguments are used to initialize the attributes of the same " "names." msgstr "" -#: ../../library/doctest.rst:1227 +#: ../../library/doctest.rst:1254 msgid "" ":class:`DocTest` defines the following attributes. They are initialized by " "the constructor, and should not be modified directly." msgstr "" -#: ../../library/doctest.rst:1233 +#: ../../library/doctest.rst:1260 msgid "" "A list of :class:`Example` objects encoding the individual interactive " "Python examples that should be run by this test." msgstr "" -#: ../../library/doctest.rst:1239 +#: ../../library/doctest.rst:1266 msgid "" "The namespace (aka globals) that the examples should be run in. This is a " "dictionary mapping names to values. Any changes to the namespace made by " @@ -1873,57 +1907,57 @@ msgid "" "`globs` after the test is run." msgstr "" -#: ../../library/doctest.rst:1247 +#: ../../library/doctest.rst:1274 msgid "" "A string name identifying the :class:`DocTest`. Typically, this is the name " "of the object or file that the test was extracted from." msgstr "" -#: ../../library/doctest.rst:1253 +#: ../../library/doctest.rst:1280 msgid "" "The name of the file that this :class:`DocTest` was extracted from; or " -"``None`` if the filename is unknown, or if the :class:`DocTest` was not " +"``None`` if the filename is unknown, or if the :class:`!DocTest` was not " "extracted from a file." msgstr "" -#: ../../library/doctest.rst:1260 +#: ../../library/doctest.rst:1287 msgid "" "The line number within :attr:`filename` where this :class:`DocTest` begins, " "or ``None`` if the line number is unavailable. This line number is zero-" "based with respect to the beginning of the file." msgstr "" -#: ../../library/doctest.rst:1267 +#: ../../library/doctest.rst:1294 msgid "" "The string that the test was extracted from, or ``None`` if the string is " "unavailable, or if the test was not extracted from a string." msgstr "" -#: ../../library/doctest.rst:1274 +#: ../../library/doctest.rst:1301 msgid "Example Objects" msgstr "Example 物件" -#: ../../library/doctest.rst:1279 +#: ../../library/doctest.rst:1306 msgid "" "A single interactive example, consisting of a Python statement and its " "expected output. The constructor arguments are used to initialize the " "attributes of the same names." msgstr "" -#: ../../library/doctest.rst:1284 +#: ../../library/doctest.rst:1311 msgid "" ":class:`Example` defines the following attributes. They are initialized by " "the constructor, and should not be modified directly." msgstr "" -#: ../../library/doctest.rst:1290 +#: ../../library/doctest.rst:1317 msgid "" "A string containing the example's source code. This source code consists of " "a single Python statement, and always ends with a newline; the constructor " "adds a newline when necessary." msgstr "" -#: ../../library/doctest.rst:1297 +#: ../../library/doctest.rst:1324 msgid "" "The expected output from running the example's source code (either from " "stdout, or a traceback in case of exception). :attr:`want` ends with a " @@ -1931,7 +1965,7 @@ msgid "" "The constructor adds a newline when necessary." msgstr "" -#: ../../library/doctest.rst:1305 +#: ../../library/doctest.rst:1332 msgid "" "The exception message generated by the example, if the example is expected " "to generate an exception; or ``None`` if it is not expected to generate an " @@ -1940,20 +1974,20 @@ msgid "" "unless it's ``None``. The constructor adds a newline if needed." msgstr "" -#: ../../library/doctest.rst:1314 +#: ../../library/doctest.rst:1341 msgid "" "The line number within the string containing this example where the example " "begins. This line number is zero-based with respect to the beginning of the " "containing string." msgstr "" -#: ../../library/doctest.rst:1321 +#: ../../library/doctest.rst:1348 msgid "" "The example's indentation in the containing string, i.e., the number of " "space characters that precede the example's first prompt." msgstr "" -#: ../../library/doctest.rst:1327 +#: ../../library/doctest.rst:1354 msgid "" "A dictionary mapping from option flags to ``True`` or ``False``, which is " "used to override default options for this example. Any option flags not " @@ -1962,11 +1996,11 @@ msgid "" "default, no options are set." msgstr "" -#: ../../library/doctest.rst:1337 +#: ../../library/doctest.rst:1364 msgid "DocTestFinder objects" msgstr "DocTestFinder 物件" -#: ../../library/doctest.rst:1342 +#: ../../library/doctest.rst:1369 msgid "" "A processing class used to extract the :class:`DocTest`\\ s that are " "relevant to a given object, from its docstring and the docstrings of its " @@ -1974,48 +2008,48 @@ msgid "" "classes, functions, methods, staticmethods, classmethods, and properties." msgstr "" -#: ../../library/doctest.rst:1347 +#: ../../library/doctest.rst:1374 msgid "" "The optional argument *verbose* can be used to display the objects searched " "by the finder. It defaults to ``False`` (no output)." msgstr "" -#: ../../library/doctest.rst:1350 +#: ../../library/doctest.rst:1377 msgid "" "The optional argument *parser* specifies the :class:`DocTestParser` object " "(or a drop-in replacement) that is used to extract doctests from docstrings." msgstr "" -#: ../../library/doctest.rst:1353 +#: ../../library/doctest.rst:1380 msgid "" "If the optional argument *recurse* is false, then :meth:`DocTestFinder.find` " "will only examine the given object, and not any contained objects." msgstr "" -#: ../../library/doctest.rst:1356 +#: ../../library/doctest.rst:1383 msgid "" "If the optional argument *exclude_empty* is false, then :meth:`DocTestFinder." "find` will include tests for objects with empty docstrings." msgstr "" -#: ../../library/doctest.rst:1360 +#: ../../library/doctest.rst:1387 msgid ":class:`DocTestFinder` defines the following method:" -msgstr "" +msgstr ":class:`DocTestFinder` 定義了以下方法:" -#: ../../library/doctest.rst:1365 +#: ../../library/doctest.rst:1392 msgid "" "Return a list of the :class:`DocTest`\\ s that are defined by *obj*'s " "docstring, or by any of its contained objects' docstrings." msgstr "" -#: ../../library/doctest.rst:1368 +#: ../../library/doctest.rst:1395 msgid "" "The optional argument *name* specifies the object's name; this name will be " "used to construct names for the returned :class:`DocTest`\\ s. If *name* is " "not specified, then ``obj.__name__`` is used." msgstr "" -#: ../../library/doctest.rst:1372 +#: ../../library/doctest.rst:1399 msgid "" "The optional parameter *module* is the module that contains the given " "object. If the module is not specified or is ``None``, then the test finder " @@ -2023,26 +2057,26 @@ msgid "" "module is used:" msgstr "" -#: ../../library/doctest.rst:1376 +#: ../../library/doctest.rst:1403 msgid "As a default namespace, if *globs* is not specified." msgstr "" -#: ../../library/doctest.rst:1378 +#: ../../library/doctest.rst:1405 msgid "" "To prevent the DocTestFinder from extracting DocTests from objects that are " "imported from other modules. (Contained objects with modules other than " "*module* are ignored.)" msgstr "" -#: ../../library/doctest.rst:1382 +#: ../../library/doctest.rst:1409 msgid "To find the name of the file containing the object." msgstr "" -#: ../../library/doctest.rst:1384 +#: ../../library/doctest.rst:1411 msgid "To help find the line number of the object within its file." msgstr "" -#: ../../library/doctest.rst:1386 +#: ../../library/doctest.rst:1413 msgid "" "If *module* is ``False``, no attempt to find the module will be made. This " "is obscure, of use mostly in testing doctest itself: if *module* is " @@ -2051,44 +2085,44 @@ msgid "" "contained objects will (recursively) be searched for doctests." msgstr "" -#: ../../library/doctest.rst:1392 +#: ../../library/doctest.rst:1419 msgid "" "The globals for each :class:`DocTest` is formed by combining *globs* and " "*extraglobs* (bindings in *extraglobs* override bindings in *globs*). A new " -"shallow copy of the globals dictionary is created for each :class:`DocTest`. " -"If *globs* is not specified, then it defaults to the module's *__dict__*, if " -"specified, or ``{}`` otherwise. If *extraglobs* is not specified, then it " -"defaults to ``{}``." +"shallow copy of the globals dictionary is created for each :class:`!" +"DocTest`. If *globs* is not specified, then it defaults to the module's :" +"attr:`~module.__dict__`, if specified, or ``{}`` otherwise. If *extraglobs* " +"is not specified, then it defaults to ``{}``." msgstr "" -#: ../../library/doctest.rst:1403 +#: ../../library/doctest.rst:1430 msgid "DocTestParser objects" msgstr "DocTestParser 物件" -#: ../../library/doctest.rst:1408 +#: ../../library/doctest.rst:1435 msgid "" "A processing class used to extract interactive examples from a string, and " "use them to create a :class:`DocTest` object." msgstr "" -#: ../../library/doctest.rst:1412 +#: ../../library/doctest.rst:1439 msgid ":class:`DocTestParser` defines the following methods:" -msgstr "" +msgstr ":class:`DocTestParser` 定義了以下方法:" -#: ../../library/doctest.rst:1417 +#: ../../library/doctest.rst:1444 msgid "" "Extract all doctest examples from the given string, and collect them into a :" "class:`DocTest` object." msgstr "" -#: ../../library/doctest.rst:1420 +#: ../../library/doctest.rst:1447 msgid "" "*globs*, *name*, *filename*, and *lineno* are attributes for the new :class:" -"`DocTest` object. See the documentation for :class:`DocTest` for more " +"`!DocTest` object. See the documentation for :class:`DocTest` for more " "information." msgstr "" -#: ../../library/doctest.rst:1427 +#: ../../library/doctest.rst:1454 msgid "" "Extract all doctest examples from the given string, and return them as a " "list of :class:`Example` objects. Line numbers are 0-based. The optional " @@ -2096,35 +2130,51 @@ msgid "" "error messages." msgstr "" -#: ../../library/doctest.rst:1434 +#: ../../library/doctest.rst:1461 msgid "" "Divide the given string into examples and intervening text, and return them " "as a list of alternating :class:`Example`\\ s and strings. Line numbers for " -"the :class:`Example`\\ s are 0-based. The optional argument *name* is a " +"the :class:`!Example`\\ s are 0-based. The optional argument *name* is a " "name identifying this string, and is only used for error messages." msgstr "" -#: ../../library/doctest.rst:1443 +#: ../../library/doctest.rst:1468 +msgid "TestResults objects" +msgstr "TestResults 物件" + +#: ../../library/doctest.rst:1475 +msgid "Number of failed tests." +msgstr "" + +#: ../../library/doctest.rst:1479 +msgid "Number of attempted tests." +msgstr "" + +#: ../../library/doctest.rst:1483 +msgid "Number of skipped tests." +msgstr "" + +#: ../../library/doctest.rst:1491 msgid "DocTestRunner objects" msgstr "DocTestRunner 物件" -#: ../../library/doctest.rst:1448 +#: ../../library/doctest.rst:1496 msgid "" "A processing class used to execute and verify the interactive examples in a :" "class:`DocTest`." msgstr "" -#: ../../library/doctest.rst:1451 +#: ../../library/doctest.rst:1499 msgid "" "The comparison between expected outputs and actual outputs is done by an :" "class:`OutputChecker`. This comparison may be customized with a number of " "option flags; see section :ref:`doctest-options` for more information. If " "the option flags are insufficient, then the comparison may also be " -"customized by passing a subclass of :class:`OutputChecker` to the " +"customized by passing a subclass of :class:`!OutputChecker` to the " "constructor." msgstr "" -#: ../../library/doctest.rst:1457 +#: ../../library/doctest.rst:1505 msgid "" "The test runner's display output can be controlled in two ways. First, an " "output function can be passed to :meth:`run`; this function will be called " @@ -2135,14 +2185,14 @@ msgid "" "`report_unexpected_exception`, and :meth:`report_failure`." msgstr "" -#: ../../library/doctest.rst:1465 +#: ../../library/doctest.rst:1513 msgid "" "The optional keyword argument *checker* specifies the :class:`OutputChecker` " "object (or drop-in replacement) that should be used to compare the expected " "outputs to the actual outputs of doctest examples." msgstr "" -#: ../../library/doctest.rst:1469 +#: ../../library/doctest.rst:1517 msgid "" "The optional keyword argument *verbose* controls the :class:" "`DocTestRunner`'s verbosity. If *verbose* is ``True``, then information is " @@ -2151,60 +2201,68 @@ msgid "" "verbose output is used iff the command-line switch ``-v`` is used." msgstr "" -#: ../../library/doctest.rst:1475 +#: ../../library/doctest.rst:1523 msgid "" "The optional keyword argument *optionflags* can be used to control how the " "test runner compares expected output to actual output, and how it displays " "failures. For more information, see section :ref:`doctest-options`." msgstr "" -#: ../../library/doctest.rst:1480 -msgid ":class:`DocTestRunner` defines the following methods:" +#: ../../library/doctest.rst:1527 +msgid "" +"The test runner accumulates statistics. The aggregated number of attempted, " +"failed and skipped examples is also available via the :attr:`tries`, :attr:" +"`failures` and :attr:`skips` attributes. The :meth:`run` and :meth:" +"`summarize` methods return a :class:`TestResults` instance." msgstr "" -#: ../../library/doctest.rst:1485 +#: ../../library/doctest.rst:1532 +msgid ":class:`DocTestRunner` defines the following methods:" +msgstr ":class:`DocTestRunner` 定義了以下方法:" + +#: ../../library/doctest.rst:1537 msgid "" "Report that the test runner is about to process the given example. This " "method is provided to allow subclasses of :class:`DocTestRunner` to " "customize their output; it should not be called directly." msgstr "" -#: ../../library/doctest.rst:1489 +#: ../../library/doctest.rst:1541 msgid "" "*example* is the example about to be processed. *test* is the test " -"*containing example*. *out* is the output function that was passed to :meth:" +"containing *example*. *out* is the output function that was passed to :meth:" "`DocTestRunner.run`." msgstr "" -#: ../../library/doctest.rst:1496 +#: ../../library/doctest.rst:1548 msgid "" "Report that the given example ran successfully. This method is provided to " "allow subclasses of :class:`DocTestRunner` to customize their output; it " "should not be called directly." msgstr "" -#: ../../library/doctest.rst:1500 ../../library/doctest.rst:1511 +#: ../../library/doctest.rst:1552 ../../library/doctest.rst:1563 msgid "" "*example* is the example about to be processed. *got* is the actual output " "from the example. *test* is the test containing *example*. *out* is the " "output function that was passed to :meth:`DocTestRunner.run`." msgstr "" -#: ../../library/doctest.rst:1507 +#: ../../library/doctest.rst:1559 msgid "" "Report that the given example failed. This method is provided to allow " "subclasses of :class:`DocTestRunner` to customize their output; it should " "not be called directly." msgstr "" -#: ../../library/doctest.rst:1518 +#: ../../library/doctest.rst:1570 msgid "" "Report that the given example raised an unexpected exception. This method is " "provided to allow subclasses of :class:`DocTestRunner` to customize their " "output; it should not be called directly." msgstr "" -#: ../../library/doctest.rst:1522 +#: ../../library/doctest.rst:1574 msgid "" "*example* is the example about to be processed. *exc_info* is a tuple " "containing information about the unexpected exception (as returned by :func:" @@ -2212,13 +2270,14 @@ msgid "" "output function that was passed to :meth:`DocTestRunner.run`." msgstr "" -#: ../../library/doctest.rst:1530 +#: ../../library/doctest.rst:1582 msgid "" "Run the examples in *test* (a :class:`DocTest` object), and display the " -"results using the writer function *out*." +"results using the writer function *out*. Return a :class:`TestResults` " +"instance." msgstr "" -#: ../../library/doctest.rst:1533 +#: ../../library/doctest.rst:1586 msgid "" "The examples are run in the namespace ``test.globs``. If *clear_globs* is " "true (the default), then this namespace will be cleared after the test runs, " @@ -2226,39 +2285,54 @@ msgid "" "after the test completes, then use *clear_globs=False*." msgstr "" -#: ../../library/doctest.rst:1538 +#: ../../library/doctest.rst:1591 msgid "" "*compileflags* gives the set of flags that should be used by the Python " "compiler when running the examples. If not specified, then it will default " "to the set of future-import flags that apply to *globs*." msgstr "" -#: ../../library/doctest.rst:1542 +#: ../../library/doctest.rst:1595 msgid "" "The output of each example is checked using the :class:`DocTestRunner`'s " "output checker, and the results are formatted by the :meth:`!DocTestRunner." "report_\\*` methods." msgstr "" -#: ../../library/doctest.rst:1549 +#: ../../library/doctest.rst:1602 msgid "" "Print a summary of all the test cases that have been run by this " -"DocTestRunner, and return a :term:`named tuple` ``TestResults(failed, " -"attempted)``." +"DocTestRunner, and return a :class:`TestResults` instance." msgstr "" -#: ../../library/doctest.rst:1552 +#: ../../library/doctest.rst:1605 msgid "" "The optional *verbose* argument controls how detailed the summary is. If " "the verbosity is not specified, then the :class:`DocTestRunner`'s verbosity " "is used." msgstr "" -#: ../../library/doctest.rst:1559 +#: ../../library/doctest.rst:1609 +msgid ":class:`DocTestParser` has the following attributes:" +msgstr ":class:`DocTestParser` 有以下屬性:" + +#: ../../library/doctest.rst:1613 +msgid "Number of attempted examples." +msgstr "" + +#: ../../library/doctest.rst:1617 +msgid "Number of failed examples." +msgstr "" + +#: ../../library/doctest.rst:1621 +msgid "Number of skipped examples." +msgstr "" + +#: ../../library/doctest.rst:1629 msgid "OutputChecker objects" msgstr "OutputChecker 物件" -#: ../../library/doctest.rst:1564 +#: ../../library/doctest.rst:1634 msgid "" "A class used to check the whether the actual output from a doctest example " "matches the expected output. :class:`OutputChecker` defines two methods: :" @@ -2267,11 +2341,11 @@ msgid "" "string describing the differences between two outputs." msgstr "" -#: ../../library/doctest.rst:1571 +#: ../../library/doctest.rst:1641 msgid ":class:`OutputChecker` defines the following methods:" -msgstr "" +msgstr ":class:`OutputChecker` 定義了以下方法:" -#: ../../library/doctest.rst:1575 +#: ../../library/doctest.rst:1645 msgid "" "Return ``True`` iff the actual output from an example (*got*) matches the " "expected output (*want*). These strings are always considered to match if " @@ -2280,28 +2354,28 @@ msgid "" "`doctest-options` for more information about option flags." msgstr "" -#: ../../library/doctest.rst:1584 +#: ../../library/doctest.rst:1654 msgid "" "Return a string describing the differences between the expected output for a " "given example (*example*) and the actual output (*got*). *optionflags* is " "the set of option flags used to compare *want* and *got*." msgstr "" -#: ../../library/doctest.rst:1592 +#: ../../library/doctest.rst:1662 msgid "Debugging" msgstr "" -#: ../../library/doctest.rst:1594 +#: ../../library/doctest.rst:1664 msgid "Doctest provides several mechanisms for debugging doctest examples:" msgstr "" -#: ../../library/doctest.rst:1596 +#: ../../library/doctest.rst:1666 msgid "" "Several functions convert doctests to executable Python programs, which can " "be run under the Python debugger, :mod:`pdb`." msgstr "" -#: ../../library/doctest.rst:1599 +#: ../../library/doctest.rst:1669 msgid "" "The :class:`DebugRunner` class is a subclass of :class:`DocTestRunner` that " "raises an exception for the first failing example, containing information " @@ -2309,13 +2383,13 @@ msgid "" "debugging on the example." msgstr "" -#: ../../library/doctest.rst:1604 +#: ../../library/doctest.rst:1674 msgid "" "The :mod:`unittest` cases generated by :func:`DocTestSuite` support the :" "meth:`debug` method defined by :class:`unittest.TestCase`." msgstr "" -#: ../../library/doctest.rst:1607 +#: ../../library/doctest.rst:1677 msgid "" "You can add a call to :func:`pdb.set_trace` in a doctest example, and you'll " "drop into the Python debugger when that line is executed. Then you can " @@ -2323,7 +2397,7 @@ msgid "" "`a.py` contains just this module docstring::" msgstr "" -#: ../../library/doctest.rst:1612 +#: ../../library/doctest.rst:1682 msgid "" "\"\"\"\n" ">>> def f(x):\n" @@ -2345,11 +2419,11 @@ msgstr "" "9\n" "\"\"\"" -#: ../../library/doctest.rst:1622 +#: ../../library/doctest.rst:1692 msgid "Then an interactive Python session may look like this::" msgstr "" -#: ../../library/doctest.rst:1624 +#: ../../library/doctest.rst:1694 msgid "" ">>> import a, doctest\n" ">>> doctest.testmod(a)\n" @@ -2411,17 +2485,17 @@ msgstr "" "(0, 3)\n" ">>>" -#: ../../library/doctest.rst:1655 +#: ../../library/doctest.rst:1725 msgid "" "Functions that convert doctests to Python code, and possibly run the " "synthesized code under the debugger:" msgstr "" -#: ../../library/doctest.rst:1661 +#: ../../library/doctest.rst:1731 msgid "Convert text with examples to a script." msgstr "" -#: ../../library/doctest.rst:1663 +#: ../../library/doctest.rst:1733 msgid "" "Argument *s* is a string containing doctest examples. The string is " "converted to a Python script, where doctest examples in *s* are converted to " @@ -2429,7 +2503,7 @@ msgid "" "generated script is returned as a string. For example, ::" msgstr "" -#: ../../library/doctest.rst:1668 +#: ../../library/doctest.rst:1738 msgid "" "import doctest\n" "print(doctest.script_from_examples(r\"\"\"\n" @@ -2442,11 +2516,11 @@ msgid "" "\"\"\"))" msgstr "" -#: ../../library/doctest.rst:1678 +#: ../../library/doctest.rst:1748 msgid "displays::" msgstr "" -#: ../../library/doctest.rst:1680 +#: ../../library/doctest.rst:1750 msgid "" "# Set x and y to 1 and 2.\n" "x, y = 1, 2\n" @@ -2457,18 +2531,18 @@ msgid "" "## 3" msgstr "" -#: ../../library/doctest.rst:1688 +#: ../../library/doctest.rst:1758 msgid "" "This function is used internally by other functions (see below), but can " "also be useful when you want to transform an interactive Python session into " "a Python script." msgstr "" -#: ../../library/doctest.rst:1695 +#: ../../library/doctest.rst:1765 msgid "Convert the doctest for an object to a script." msgstr "" -#: ../../library/doctest.rst:1697 +#: ../../library/doctest.rst:1767 msgid "" "Argument *module* is a module object, or dotted name of a module, containing " "the object whose doctests are of interest. Argument *name* is the name " @@ -2478,7 +2552,7 @@ msgid "" "module :file:`a.py` contains a top-level function :func:`!f`, then ::" msgstr "" -#: ../../library/doctest.rst:1704 +#: ../../library/doctest.rst:1774 msgid "" "import a, doctest\n" "print(doctest.testsource(a, \"a.f\"))" @@ -2486,17 +2560,17 @@ msgstr "" "import a, doctest\n" "print(doctest.testsource(a, \"a.f\"))" -#: ../../library/doctest.rst:1707 +#: ../../library/doctest.rst:1777 msgid "" "prints a script version of function :func:`!f`'s docstring, with doctests " "converted to code, and the rest placed in comments." msgstr "" -#: ../../library/doctest.rst:1713 +#: ../../library/doctest.rst:1783 msgid "Debug the doctests for an object." msgstr "" -#: ../../library/doctest.rst:1715 +#: ../../library/doctest.rst:1785 msgid "" "The *module* and *name* arguments are the same as for function :func:" "`testsource` above. The synthesized Python script for the named object's " @@ -2504,13 +2578,13 @@ msgid "" "the control of the Python debugger, :mod:`pdb`." msgstr "" -#: ../../library/doctest.rst:1720 +#: ../../library/doctest.rst:1790 msgid "" "A shallow copy of ``module.__dict__`` is used for both local and global " "execution context." msgstr "" -#: ../../library/doctest.rst:1723 +#: ../../library/doctest.rst:1793 msgid "" "Optional argument *pm* controls whether post-mortem debugging is used. If " "*pm* has a true value, the script file is run directly, and the debugger " @@ -2522,30 +2596,30 @@ msgid "" "to :func:`pdb.run`." msgstr "" -#: ../../library/doctest.rst:1734 +#: ../../library/doctest.rst:1804 msgid "Debug the doctests in a string." msgstr "" -#: ../../library/doctest.rst:1736 +#: ../../library/doctest.rst:1806 msgid "" "This is like function :func:`debug` above, except that a string containing " "doctest examples is specified directly, via the *src* argument." msgstr "" -#: ../../library/doctest.rst:1739 +#: ../../library/doctest.rst:1809 msgid "" "Optional argument *pm* has the same meaning as in function :func:`debug` " "above." msgstr "" -#: ../../library/doctest.rst:1741 +#: ../../library/doctest.rst:1811 msgid "" "Optional argument *globs* gives a dictionary to use as both local and global " "execution context. If not specified, or ``None``, an empty dictionary is " "used. If specified, a shallow copy of the dictionary is used." msgstr "" -#: ../../library/doctest.rst:1746 +#: ../../library/doctest.rst:1816 msgid "" "The :class:`DebugRunner` class, and the special exceptions it may raise, are " "of most interest to testing framework authors, and will only be sketched " @@ -2553,7 +2627,7 @@ msgid "" "(which is a doctest!) for more details:" msgstr "" -#: ../../library/doctest.rst:1754 +#: ../../library/doctest.rst:1824 msgid "" "A subclass of :class:`DocTestRunner` that raises an exception as soon as a " "failure is encountered. If an unexpected exception occurs, an :exc:" @@ -2563,89 +2637,89 @@ msgid "" "the actual output." msgstr "" -#: ../../library/doctest.rst:1761 +#: ../../library/doctest.rst:1831 msgid "" "For information about the constructor parameters and methods, see the " "documentation for :class:`DocTestRunner` in section :ref:`doctest-advanced-" "api`." msgstr "" -#: ../../library/doctest.rst:1764 +#: ../../library/doctest.rst:1834 msgid "" "There are two exceptions that may be raised by :class:`DebugRunner` " "instances:" msgstr "" -#: ../../library/doctest.rst:1769 +#: ../../library/doctest.rst:1839 msgid "" "An exception raised by :class:`DocTestRunner` to signal that a doctest " "example's actual output did not match its expected output. The constructor " "arguments are used to initialize the attributes of the same names." msgstr "" -#: ../../library/doctest.rst:1773 +#: ../../library/doctest.rst:1843 msgid ":exc:`DocTestFailure` defines the following attributes:" msgstr ":exc:`DocTestFailure` 定義了以下屬性:" -#: ../../library/doctest.rst:1778 ../../library/doctest.rst:1802 +#: ../../library/doctest.rst:1848 ../../library/doctest.rst:1872 msgid "The :class:`DocTest` object that was being run when the example failed." msgstr "" -#: ../../library/doctest.rst:1783 ../../library/doctest.rst:1807 +#: ../../library/doctest.rst:1853 ../../library/doctest.rst:1877 msgid "The :class:`Example` that failed." msgstr "" -#: ../../library/doctest.rst:1788 +#: ../../library/doctest.rst:1858 msgid "The example's actual output." msgstr "" -#: ../../library/doctest.rst:1793 +#: ../../library/doctest.rst:1863 msgid "" "An exception raised by :class:`DocTestRunner` to signal that a doctest " "example raised an unexpected exception. The constructor arguments are used " "to initialize the attributes of the same names." msgstr "" -#: ../../library/doctest.rst:1797 +#: ../../library/doctest.rst:1867 msgid ":exc:`UnexpectedException` defines the following attributes:" -msgstr "" +msgstr ":exc:`UnexpectedException` 定義了以下屬性:" -#: ../../library/doctest.rst:1812 +#: ../../library/doctest.rst:1882 msgid "" "A tuple containing information about the unexpected exception, as returned " "by :func:`sys.exc_info`." msgstr "" -#: ../../library/doctest.rst:1819 +#: ../../library/doctest.rst:1889 msgid "Soapbox" msgstr "" -#: ../../library/doctest.rst:1821 +#: ../../library/doctest.rst:1891 msgid "" "As mentioned in the introduction, :mod:`doctest` has grown to have three " "primary uses:" msgstr "" -#: ../../library/doctest.rst:1824 +#: ../../library/doctest.rst:1894 msgid "Checking examples in docstrings." msgstr "" -#: ../../library/doctest.rst:1826 +#: ../../library/doctest.rst:1896 msgid "Regression testing." msgstr "" -#: ../../library/doctest.rst:1828 +#: ../../library/doctest.rst:1898 msgid "Executable documentation / literate testing." msgstr "" -#: ../../library/doctest.rst:1830 +#: ../../library/doctest.rst:1900 msgid "" "These uses have different requirements, and it is important to distinguish " "them. In particular, filling your docstrings with obscure test cases makes " "for bad documentation." msgstr "" -#: ../../library/doctest.rst:1834 +#: ../../library/doctest.rst:1904 msgid "" "When writing a docstring, choose docstring examples with care. There's an " "art to this that needs to be learned---it may not be natural at first. " @@ -2657,7 +2731,7 @@ msgid "" "\"harmless\" change." msgstr "" -#: ../../library/doctest.rst:1842 +#: ../../library/doctest.rst:1912 msgid "" "Doctest also makes an excellent tool for regression testing, especially if " "you don't skimp on explanatory text. By interleaving prose and examples, it " @@ -2678,13 +2752,13 @@ msgid "" "different results, blurring the distinction between testing and explaining." msgstr "" -#: ../../library/doctest.rst:1860 +#: ../../library/doctest.rst:1930 msgid "" "Regression testing is best confined to dedicated objects or files. There " "are several options for organizing tests:" msgstr "" -#: ../../library/doctest.rst:1863 +#: ../../library/doctest.rst:1933 msgid "" "Write text files containing test cases as interactive examples, and test the " "files using :func:`testfile` or :func:`DocFileSuite`. This is recommended, " @@ -2692,7 +2766,7 @@ msgid "" "doctest." msgstr "" -#: ../../library/doctest.rst:1868 +#: ../../library/doctest.rst:1938 msgid "" "Define functions named ``_regrtest_topic`` that consist of single " "docstrings, containing test cases for the named topics. These functions can " @@ -2700,13 +2774,13 @@ msgid "" "test file." msgstr "" -#: ../../library/doctest.rst:1872 +#: ../../library/doctest.rst:1942 msgid "" -"Define a ``__test__`` dictionary mapping from regression test topics to " -"docstrings containing test cases." +"Define a :attr:`~module.__test__` dictionary mapping from regression test " +"topics to docstrings containing test cases." msgstr "" -#: ../../library/doctest.rst:1875 +#: ../../library/doctest.rst:1945 msgid "" "When you have placed your tests in a module, the module can itself be the " "test runner. When a test fails, you can arrange for your test runner to re-" @@ -2714,7 +2788,7 @@ msgid "" "example of such a test runner::" msgstr "" -#: ../../library/doctest.rst:1880 +#: ../../library/doctest.rst:1950 msgid "" "if __name__ == '__main__':\n" " import doctest\n" @@ -2729,7 +2803,7 @@ msgid "" " optionflags=flags)\n" " else:\n" " fail, total = doctest.testmod(optionflags=flags)\n" -" print(\"{} failures out of {} tests\".format(fail, total))" +" print(f\"{fail} failures out of {total} tests\")" msgstr "" "if __name__ == '__main__':\n" " import doctest\n" @@ -2744,55 +2818,58 @@ msgstr "" " optionflags=flags)\n" " else:\n" " fail, total = doctest.testmod(optionflags=flags)\n" -" print(\"{} failures out of {} tests\".format(fail, total))" +" print(f\"{fail} failures out of {total} tests\")" -#: ../../library/doctest.rst:1897 +#: ../../library/doctest.rst:1967 msgid "Footnotes" -msgstr "註解" +msgstr "註腳" -#: ../../library/doctest.rst:1898 +#: ../../library/doctest.rst:1968 msgid "" "Examples containing both expected output and an exception are not supported. " "Trying to guess where one ends and the other begins is too error-prone, and " "that also makes for a confusing test." msgstr "" -#: ../../library/doctest.rst:339 +#: ../../library/doctest.rst:376 msgid ">>>" msgstr ">>>" -#: ../../library/doctest.rst:339 +#: ../../library/doctest.rst:376 msgid "interpreter prompt" msgstr "interpreter prompt(直譯器提示)" -#: ../../library/doctest.rst:339 ../../library/doctest.rst:577 +#: ../../library/doctest.rst:376 ../../library/doctest.rst:611 msgid "..." msgstr "..." -#: ../../library/doctest.rst:505 +#: ../../library/doctest.rst:542 msgid "^ (caret)" msgstr "^ (插入符號)" -#: ../../library/doctest.rst:505 +#: ../../library/doctest.rst:542 msgid "marker" msgstr "marker(標記)" -#: ../../library/doctest.rst:557 +#: ../../library/doctest.rst:591 msgid "" msgstr "" -#: ../../library/doctest.rst:577 ../../library/doctest.rst:707 +#: ../../library/doctest.rst:611 ../../library/doctest.rst:736 msgid "in doctests" msgstr "於 doctests 中" -#: ../../library/doctest.rst:707 +#: ../../library/doctest.rst:736 msgid "# (hash)" msgstr "# (井字號)" -#: ../../library/doctest.rst:707 +#: ../../library/doctest.rst:736 msgid "+ (plus)" msgstr "+ (加號)" -#: ../../library/doctest.rst:707 +#: ../../library/doctest.rst:736 msgid "- (minus)" msgstr "- (減號)" + +#~ msgid "The ``-o`` command line option." +#~ msgstr " ``-o`` 命令列選項。" diff --git a/library/email.charset.po b/library/email.charset.po index 4800e31096..34d6286033 100644 --- a/library/email.charset.po +++ b/library/email.charset.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-05-09 00:03+0000\n" "PO-Revision-Date: 2018-05-23 14:43+0000\n" @@ -20,7 +19,7 @@ msgstr "" #: ../../library/email.charset.rst:2 msgid ":mod:`!email.charset`: Representing character sets" -msgstr ":mod:`!email.charset`:表示字元集合" +msgstr ":mod:`!email.charset`:字元集合的表示" #: ../../library/email.charset.rst:7 msgid "**Source code:** :source:`Lib/email/charset.py`" @@ -38,7 +37,7 @@ msgstr "" msgid "" "The remaining text in this section is the original documentation of the " "module." -msgstr "此章節的其餘文字是原始模組的說明文件" +msgstr "此章節的其餘內容是模組的原始說明文件" #: ../../library/email.charset.rst:16 msgid "" @@ -48,17 +47,17 @@ msgid "" "Instances of :class:`Charset` are used in several other modules within the :" "mod:`email` package." msgstr "" -"此模組提供一個 class(類別) :class:`Charset` 來表示電子郵件中的字元集合和字" -"元集合轉換,以及字元集合登錄檔 (registry) 和其他許多便捷的方法以運用此登錄" -"檔。在 :mod:`email` 套件中有許多其他模組使用 :class:`Charset` 的實例。" +"此模組提供一個類別 :class:`Charset` 來表示電子郵件訊息中的字元集合和字元集合轉" +"換,也包含字元集合登錄檔 (registry) 和其他許多運用此登錄檔的便捷方法。:class:" +"`Charset` 的實例被 :mod:`email` 套件中其他數個模組所使用。" #: ../../library/email.charset.rst:22 msgid "Import this class from the :mod:`email.charset` module." -msgstr "從 :mod:`email.charset` 模組中 import 此類別" +msgstr "從 :mod:`email.charset` 模組中引入此類別" #: ../../library/email.charset.rst:27 msgid "Map character sets to their email properties." -msgstr "" +msgstr "將字元集合對映到其電子郵件特性 (properties)。" #: ../../library/email.charset.rst:29 msgid "" @@ -68,6 +67,10 @@ msgid "" "codecs. Given a character set, it will do its best to provide information " "on how to use that character set in an email message in an RFC-compliant way." msgstr "" +"此類別提供有關於電子郵件對特定字元集合的規範資訊。考慮到適用之編解碼器 " +"(codec) 的可用性,它還提供了在字元集合之間進行轉換的便利例行操作 (routine)。" +"給定一個字元集合,它將盡量提供有關如何以符合 RFC (RFC-compliant) 的方式在電子" +"郵件訊息中使用該字元集合的資訊。" #: ../../library/email.charset.rst:35 msgid "" @@ -75,6 +78,9 @@ msgid "" "used in email headers or bodies. Certain character sets must be converted " "outright, and are not allowed in email." msgstr "" +"在電子郵件標頭 (header) 或內文 (body) 用特定字元集合時必須使用可列印字元編碼 " +"(quoted-printable) 或 base64 來編碼。特定字元集合不允許出現在電子郵件中、必須" +"被徹底轉換。" #: ../../library/email.charset.rst:39 msgid "" @@ -88,10 +94,17 @@ msgid "" "with base64, bodies will not be encoded, but output text will be converted " "from the ``euc-jp`` character set to the ``iso-2022-jp`` character set." msgstr "" +"可選的 *input_charset* 描述如下;*input_charset* 會被強制轉換 (coerced) 為小寫。經過" +"別名標準化 (alias normalize) 後,會進到字元集合登錄檔 (registry) 去查詢此字元" +"集合使用的標頭編碼、內文編碼以及輸出轉換編解碼器。舉例來說,如果 " +"*input_charset* 是 ``iso-8859-1``,標頭跟內文會以可列印字元編碼並且不需要輸出" +"轉換編解碼器。如果 *input_charset* 是 ``euc-jp``,標頭則會被編碼成 base64、內" +"文不會被編碼,但輸出文字則會從 ``euc-jp`` 字元集合被轉換成 ``iso-2022-jp`` 字" +"元集合。" #: ../../library/email.charset.rst:49 msgid ":class:`Charset` instances have the following data attributes:" -msgstr "" +msgstr ":class:`Charset` 實例有以下資料屬性:" #: ../../library/email.charset.rst:53 msgid "" @@ -99,6 +112,8 @@ msgid "" "*official* email names (e.g. ``latin_1`` is converted to ``iso-8859-1``). " "Defaults to 7-bit ``us-ascii``." msgstr "" +"指定的初始字元集合。通用別名會被轉換成它們的\\ *官方*\\ 電子郵件名稱(例如:" +"``latin_1`` 會被轉換成 ``iso-8859-1``)。預設為 7 位元 ``us-ascii``。" #: ../../library/email.charset.rst:60 msgid "" @@ -107,6 +122,10 @@ msgid "" "``charset.BASE64`` (for base64 encoding), or ``charset.SHORTEST`` for the " "shortest of QP or BASE64 encoding. Otherwise, it will be ``None``." msgstr "" +"如果字元集合在被用於電子郵件標頭前必須被編碼的話,這個屬性會被設為 ``charset." +"QP``\\ (表示可列印字元編碼)、``charset.BASE64``\\ (表示 base64 編碼格式)或" +"是 ``charset.SHORTEST`` 表示最短的 QP 或是 base64 編碼格式。不然這個屬性會是 " +"``None``。" #: ../../library/email.charset.rst:69 msgid "" @@ -114,6 +133,8 @@ msgid "" "body, which indeed may be different than the header encoding. ``charset." "SHORTEST`` is not allowed for *body_encoding*." msgstr "" +"與 *header_encoding* 相同,但表示郵件訊息內文的編碼,與上述的標頭編碼有可能不" +"同。``charset.SHORTEST`` 是不允許於 *body_encoding* 使用的。" #: ../../library/email.charset.rst:76 msgid "" @@ -122,6 +143,9 @@ msgid "" "will contain the name of the character set output will be converted to. " "Otherwise, it will be ``None``." msgstr "" +"部分的字元集合在用於電子郵件的標頭或內文前必須先被轉換。如果 *input_charset* " +"是這些字元集合的其中之一,這個屬性將會包含輸出時轉換成的字元集合名稱。不然這" +"個屬性則為 ``None``。" #: ../../library/email.charset.rst:84 msgid "" @@ -129,6 +153,8 @@ msgid "" "Unicode. If no conversion codec is necessary, this attribute will be " "``None``." msgstr "" +"用於將 *input_charset* 轉換成 Unicode 的 Python 編解碼器的名稱。如果不需要轉" +"換編解碼器,這個屬性為 ``None``。" #: ../../library/email.charset.rst:91 msgid "" @@ -136,14 +162,16 @@ msgid "" "*output_charset*. If no conversion codec is necessary, this attribute will " "have the same value as the *input_codec*." msgstr "" +"用於將 Unicode 轉換成 *output_charset* 的 Python 編解碼器名稱。如果不需要轉換" +"編解碼器,這個屬性將會與 *input_codec* 有相同的值。" #: ../../library/email.charset.rst:96 msgid ":class:`Charset` instances also have the following methods:" -msgstr "" +msgstr ":class:`Charset` 實例還有以下方法:" #: ../../library/email.charset.rst:100 msgid "Return the content transfer encoding used for body encoding." -msgstr "" +msgstr "回傳用於內文編碼的內容傳輸編碼 (content transfer encoding)。" #: ../../library/email.charset.rst:102 msgid "" @@ -153,6 +181,10 @@ msgid "" "function should then set the :mailheader:`Content-Transfer-Encoding` header " "itself to whatever is appropriate." msgstr "" +"這可以是字串 ``quoted-printable`` 或 ``base64``,具體取決於所使用的編碼,或者" +"它也可以是一個函式,在這種情況下,你應該使用單個引數呼叫該函式,即正被編碼的 " +"Message 物件。然後函式應將 :mailheader:`Content-Transfer-Encoding` 標頭本身設" +"定為任何適當的值。" #: ../../library/email.charset.rst:108 msgid "" @@ -160,30 +192,33 @@ msgid "" "returns the string ``base64`` if *body_encoding* is ``BASE64``, and returns " "the string ``7bit`` otherwise." msgstr "" +"如果 *body_encoding* 為 ``QP`` 則回傳字串 ``quoted-printable``,如果 " +"*body_encoding* 為 ``BASE64`` 則回傳字串 ``base64``,否則回傳字串 ``7bit`` 。" #: ../../library/email.charset.rst:115 msgid "Return the output character set." -msgstr "" +msgstr "回傳輸出字元集合。" #: ../../library/email.charset.rst:117 msgid "" "This is the *output_charset* attribute if that is not ``None``, otherwise it " "is *input_charset*." msgstr "" +"如果不為 ``None`` 則這會是 *output_charset* 屬性,否則它是 *input_charset*。" #: ../../library/email.charset.rst:123 msgid "Header-encode the string *string*." -msgstr "" +msgstr "對字串 *string* 進行標頭編碼 (header-encode)。" #: ../../library/email.charset.rst:125 msgid "" "The type of encoding (base64 or quoted-printable) will be based on the " "*header_encoding* attribute." -msgstr "" +msgstr "編碼類型(base64 或可列印字元編碼)將基於 *header_encoding* 屬性。" #: ../../library/email.charset.rst:131 msgid "Header-encode a *string* by converting it first to bytes." -msgstr "" +msgstr "透過先將 *string* 轉換為位元組來對它進行標頭編碼。" #: ../../library/email.charset.rst:133 msgid "" @@ -192,56 +227,64 @@ msgid "" "iterator: each element returned from this iterator will provide the next " "maximum line length." msgstr "" +"這與 :meth:`header_encode` 類似,只不過字串不會超過由引數 *maxlengths* 給定的" +"最大列長度 (maximum line length),該引數必須是個疊代器:從此疊代器回傳的每個" +"元素將提供下一個最大列長度。" #: ../../library/email.charset.rst:141 msgid "Body-encode the string *string*." -msgstr "" +msgstr "對字串 *string* 進行內文編碼 (body-encode)。" #: ../../library/email.charset.rst:143 msgid "" "The type of encoding (base64 or quoted-printable) will be based on the " "*body_encoding* attribute." -msgstr "" +msgstr "編碼類型(base64 或可列印字元編碼)將基於 *body_encoding* 屬性。" #: ../../library/email.charset.rst:146 msgid "" "The :class:`Charset` class also provides a number of methods to support " "standard operations and built-in functions." -msgstr "" +msgstr ":class:`Charset` 類別也提供了許多支援標準操作和內建函式的方法。" #: ../../library/email.charset.rst:152 msgid "" "Returns *input_charset* as a string coerced to lower case. :meth:`!__repr__` " "is an alias for :meth:`!__str__`." msgstr "" +"回傳強制轉換 *input_charset* 為小寫後的字串。:meth:`!__repr__` 是 :meth:`!" +"__str__` 的別名。" #: ../../library/email.charset.rst:158 msgid "" "This method allows you to compare two :class:`Charset` instances for " "equality." -msgstr "" +msgstr "此方法讓你比較兩個 :class:`Charset` 實例的相等性。" #: ../../library/email.charset.rst:164 msgid "" "This method allows you to compare two :class:`Charset` instances for " "inequality." -msgstr "" +msgstr "此方法讓你比較兩個 :class:`Charset` 實例的不相等性。" #: ../../library/email.charset.rst:167 msgid "" "The :mod:`email.charset` module also provides the following functions for " "adding new entries to the global character set, alias, and codec registries:" msgstr "" +":mod:`email.charset` 模組還提供以下函式,用於將項目新增至全域字元集合、別名和" +"編解碼器登錄檔中:" #: ../../library/email.charset.rst:173 msgid "Add character properties to the global registry." -msgstr "" +msgstr "將字元特性 (properties) 新增至全域登錄檔。" #: ../../library/email.charset.rst:175 msgid "" "*charset* is the input character set, and must be the canonical name of a " "character set." msgstr "" +"*charset* 是輸入的字元集合,且必須是字元集合的規範名稱 (canonical name)。" #: ../../library/email.charset.rst:178 msgid "" @@ -251,6 +294,10 @@ msgid "" "encoding. ``SHORTEST`` is only valid for *header_enc*. The default is " "``None`` for no encoding." msgstr "" +"可選的 *header_enc* 和 *body_enc* 為 ``charset.QP``\\ (表示可列印字元編" +"碼)、``charset.BASE64``\\ (表示 base64 編碼)、``charset.SHORTEST``\\ (表" +"示最短的 base64 或可列印字元編碼)或 ``None``\\ (表示無編碼)。``SHORTEST`` " +"僅在用於 *header_enc* 時有效。預設為 ``None``,表示無編碼。" #: ../../library/email.charset.rst:184 msgid "" @@ -259,6 +306,9 @@ msgid "" "charset when the method :meth:`Charset.convert` is called. The default is " "to output in the same character set as the input." msgstr "" +"可選的 *output_charset* 是輸出應採用的字元集合。當呼叫 :meth:`Charset." +"convert` 方法時,將從輸入字元集合轉換為 Unicode,再轉換為輸出字元集合。預設是" +"以與輸入相同的字元集合輸出。" #: ../../library/email.charset.rst:189 msgid "" @@ -267,30 +317,36 @@ msgid "" "codecs the module does not know about. See the :mod:`codecs` module's " "documentation for more information." msgstr "" +"*input_charset* 和 *output_charset* 都必須在模組的字元集合到編解碼器對映 " +"(character set-to-codec mapping) 中具有 Unicode 編解碼器項目;使用 :func:" +"`add_codec` 來新增模組未知的編解碼器。有關更多資訊請參閱 :mod:`codecs` 模組的" +"文件。" #: ../../library/email.charset.rst:194 msgid "" "The global character set registry is kept in the module global dictionary " "``CHARSETS``." -msgstr "" +msgstr "全域字元集合登錄檔保存在模組全域字典 ``CHARSETS`` 中。" #: ../../library/email.charset.rst:200 msgid "" "Add a character set alias. *alias* is the alias name, e.g. ``latin-1``. " "*canonical* is the character set's canonical name, e.g. ``iso-8859-1``." msgstr "" +"新增字元集合別名。*alias* 是別名,例如 ``latin-1``。*canonical* 是字元集合的" +"規範名稱,例如 ``iso-8859-1``。" #: ../../library/email.charset.rst:203 msgid "" "The global charset alias registry is kept in the module global dictionary " "``ALIASES``." -msgstr "" +msgstr "全域字元集合別名登錄檔保存在模組全域字典 ``ALIASES`` 中。" #: ../../library/email.charset.rst:209 msgid "" "Add a codec that map characters in the given character set to and from " "Unicode." -msgstr "" +msgstr "新增一個編解碼器,將給定字元集合中的字元與 Unicode 進行對映。" #: ../../library/email.charset.rst:211 msgid "" @@ -298,3 +354,5 @@ msgid "" "of a Python codec, as appropriate for the second argument to the :class:" "`str`'s :meth:`~str.encode` method." msgstr "" +"*charset* 是字元集合的規範名稱。*codecname* 是 Python 編解碼器的名稱,適用" +"於 :class:`str` 的 :meth:`~str.encode` 方法的第二個引數。" diff --git a/library/email.compat32-message.po b/library/email.compat32-message.po index adb3d3208e..1be28eae02 100644 --- a/library/email.compat32-message.po +++ b/library/email.compat32-message.po @@ -2,9 +2,9 @@ # This file is distributed under the same license as the Python package. msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-07-07 17:47+0000\n" "PO-Revision-Date: 2018-07-15 18:56+0800\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -236,8 +236,8 @@ msgstr "" #: ../../library/email.compat32-message.rst:183 msgid "" -"This is a legacy method. On the :class:`~email.emailmessage.EmailMessage` " -"class its functionality is replaced by :meth:`~email.message.EmailMessage." +"This is a legacy method. On the :class:`~email.message.EmailMessage` class " +"its functionality is replaced by :meth:`~email.message.EmailMessage." "set_content` and the related ``make`` and ``add`` methods." msgstr "" @@ -288,8 +288,8 @@ msgstr "" #: ../../library/email.compat32-message.rst:226 msgid "" -"This is a legacy method. On the :class:`~email.emailmessage.EmailMessage` " -"class its functionality is replaced by :meth:`~email.message.EmailMessage." +"This is a legacy method. On the :class:`~email.message.EmailMessage` class " +"its functionality is replaced by :meth:`~email.message.EmailMessage." "get_content` and :meth:`~email.message.EmailMessage.iter_parts`." msgstr "" @@ -302,8 +302,8 @@ msgstr "" #: ../../library/email.compat32-message.rst:238 msgid "" -"This is a legacy method. On the :class:`~email.emailmessage.EmailMessage` " -"class its functionality is replaced by :meth:`~email.message.EmailMessage." +"This is a legacy method. On the :class:`~email.message.EmailMessage` class " +"its functionality is replaced by :meth:`~email.message.EmailMessage." "set_content`." msgstr "" @@ -337,9 +337,9 @@ msgstr "" #: ../../library/email.compat32-message.rst:267 msgid "" -"This is a legacy method. On the :class:`~email.emailmessage.EmailMessage` " -"class its functionality is replaced by the *charset* parameter of the :meth:" -"`email.emailmessage.EmailMessage.set_content` method." +"This is a legacy method. On the :class:`~email.message.EmailMessage` class " +"its functionality is replaced by the *charset* parameter of the :meth:`email." +"message.EmailMessage.set_content` method." msgstr "" #: ../../library/email.compat32-message.rst:275 @@ -350,8 +350,8 @@ msgstr "" #: ../../library/email.compat32-message.rst:278 msgid "" -"This is a legacy method. On the :class:`~email.emailmessage.EmailMessage` " -"class it always returns ``None``." +"This is a legacy method. On the :class:`~email.message.EmailMessage` class " +"it always returns ``None``." msgstr "" #: ../../library/email.compat32-message.rst:283 @@ -618,9 +618,9 @@ msgstr "" #: ../../library/email.compat32-message.rst:488 #: ../../library/email.compat32-message.rst:526 msgid "" -"This is a legacy method. On the :class:`~email.emailmessage.EmailMessage` " -"class its functionality is replaced by the *params* property of the " -"individual header objects returned by the header access methods." +"This is a legacy method. On the :class:`~email.message.EmailMessage` class " +"its functionality is replaced by the *params* property of the individual " +"header objects returned by the header access methods." msgstr "" #: ../../library/email.compat32-message.rst:496 @@ -739,8 +739,8 @@ msgstr "" #: ../../library/email.compat32-message.rst:581 msgid "" -"This is a legacy method. On the :class:`~email.emailmessage.EmailMessage` " -"class its functionality is replaced by the ``make_`` and ``add_`` methods." +"This is a legacy method. On the :class:`~email.message.EmailMessage` class " +"its functionality is replaced by the ``make_`` and ``add_`` methods." msgstr "" #: ../../library/email.compat32-message.rst:588 diff --git a/library/email.contentmanager.po b/library/email.contentmanager.po index 7462046454..3ecae14486 100644 --- a/library/email.contentmanager.po +++ b/library/email.contentmanager.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-09 00:03+0000\n" +"POT-Creation-Date: 2025-01-19 00:15+0000\n" "PO-Revision-Date: 2018-05-23 14:43+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -98,46 +98,46 @@ msgid "" msgstr "" #: ../../library/email.contentmanager.rst:61 -msgid "the type's qualname (``typ.__qualname__``)" +msgid "the type's :attr:`qualname ` (``typ.__qualname__``)" msgstr "" #: ../../library/email.contentmanager.rst:62 -msgid "the type's name (``typ.__name__``)." +msgid "the type's :attr:`name ` (``typ.__name__``)." msgstr "" #: ../../library/email.contentmanager.rst:64 msgid "" "If none of the above match, repeat all of the checks above for each of the " -"types in the :term:`MRO` (``typ.__mro__``). 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 :exc:`KeyError` for the fully qualified name of the " -"type." +"types in the :term:`MRO` (:attr:`typ.__mro__ `). 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 :exc:`KeyError` for the fully " +"qualified name of the type." msgstr "" -#: ../../library/email.contentmanager.rst:70 +#: ../../library/email.contentmanager.rst:71 msgid "" "Also add a :mailheader:`MIME-Version` header if one is not present (see " "also :class:`.MIMEPart`)." msgstr "" -#: ../../library/email.contentmanager.rst:76 +#: ../../library/email.contentmanager.rst:77 msgid "" "Record the function *handler* as the handler for *key*. For the possible " "values of *key*, see :meth:`get_content`." msgstr "" -#: ../../library/email.contentmanager.rst:82 +#: ../../library/email.contentmanager.rst:83 msgid "" "Record *handler* as the function to call when an object of a type matching " "*typekey* is passed to :meth:`set_content`. For the possible values of " "*typekey*, see :meth:`set_content`." msgstr "" -#: ../../library/email.contentmanager.rst:88 +#: ../../library/email.contentmanager.rst:89 msgid "Content Manager Instances" msgstr "" -#: ../../library/email.contentmanager.rst:90 +#: ../../library/email.contentmanager.rst:91 msgid "" "Currently the email package provides only one concrete content manager, :" "data:`raw_data_manager`, although more may be added in the future. :data:" @@ -145,7 +145,7 @@ msgid "" "provided by :attr:`~email.policy.EmailPolicy` and its derivatives." msgstr "" -#: ../../library/email.contentmanager.rst:99 +#: ../../library/email.contentmanager.rst:100 msgid "" "This content manager provides only a minimum interface beyond that provided " "by :class:`~email.message.Message` itself: it deals only with text, raw " @@ -158,7 +158,7 @@ msgid "" "simplifying the creation of multipart messages." msgstr "" -#: ../../library/email.contentmanager.rst:111 +#: ../../library/email.contentmanager.rst:112 msgid "" "Return the payload of the part as either a string (for ``text`` parts), an :" "class:`~email.message.EmailMessage` object (for ``message/rfc822`` parts), " @@ -168,28 +168,28 @@ msgid "" "to unicode. The default error handler is ``replace``." msgstr "" -#: ../../library/email.contentmanager.rst:130 +#: ../../library/email.contentmanager.rst:131 msgid "Add headers and payload to *msg*:" msgstr "" -#: ../../library/email.contentmanager.rst:132 +#: ../../library/email.contentmanager.rst:133 msgid "" "Add a :mailheader:`Content-Type` header with a ``maintype/subtype`` value." msgstr "" -#: ../../library/email.contentmanager.rst:135 +#: ../../library/email.contentmanager.rst:136 msgid "" "For ``str``, set the MIME ``maintype`` to ``text``, and set the subtype to " "*subtype* if it is specified, or ``plain`` if it is not." msgstr "" -#: ../../library/email.contentmanager.rst:137 +#: ../../library/email.contentmanager.rst:138 msgid "" "For ``bytes``, use the specified *maintype* and *subtype*, or raise a :exc:" "`TypeError` if they are not specified." msgstr "" -#: ../../library/email.contentmanager.rst:139 +#: ../../library/email.contentmanager.rst:140 msgid "" "For :class:`~email.message.EmailMessage` objects, set the maintype to " "``message``, and set the subtype to *subtype* if it is specified or " @@ -197,7 +197,7 @@ msgid "" "(``bytes`` objects must be used to construct ``message/partial`` parts)." msgstr "" -#: ../../library/email.contentmanager.rst:145 +#: ../../library/email.contentmanager.rst:146 msgid "" "If *charset* is provided (which is valid only for ``str``), encode the " "string to bytes using the specified character set. The default is " @@ -205,7 +205,7 @@ msgid "" "charset name, use the standard charset instead." msgstr "" -#: ../../library/email.contentmanager.rst:150 +#: ../../library/email.contentmanager.rst:151 msgid "" "If *cte* is set, encode the payload using the specified content transfer " "encoding, and set the :mailheader:`Content-Transfer-Encoding` header to that " @@ -215,13 +215,22 @@ msgid "" "that contains non-ASCII values), raise a :exc:`ValueError`." msgstr "" -#: ../../library/email.contentmanager.rst:158 +#: ../../library/email.contentmanager.rst:159 msgid "" "For ``str`` objects, if *cte* is not set use heuristics to determine the " -"most compact encoding." +"most compact encoding. Prior to encoding, :meth:`str.splitlines` is used to " +"normalize all line boundaries, ensuring that each line of the payload is " +"terminated by the current policy's :data:`~email.policy.Policy.linesep` " +"property (even if the original string did not end with one)." msgstr "" -#: ../../library/email.contentmanager.rst:160 +#: ../../library/email.contentmanager.rst:165 +msgid "" +"For ``bytes`` objects, *cte* is taken to be base64 if not set, and the " +"aforementioned newline translation is not performed." +msgstr "" + +#: ../../library/email.contentmanager.rst:167 msgid "" "For :class:`~email.message.EmailMessage`, per :rfc:`2046`, raise an error if " "a *cte* of ``quoted-printable`` or ``base64`` is requested for *subtype* " @@ -230,14 +239,14 @@ msgid "" "For all other values of *subtype*, use ``7bit``." msgstr "" -#: ../../library/email.contentmanager.rst:167 +#: ../../library/email.contentmanager.rst:174 msgid "" "A *cte* of ``binary`` does not actually work correctly yet. The " "``EmailMessage`` object as modified by ``set_content`` is correct, but :" "class:`~email.generator.BytesGenerator` does not serialize it correctly." msgstr "" -#: ../../library/email.contentmanager.rst:172 +#: ../../library/email.contentmanager.rst:179 msgid "" "If *disposition* is set, use it as the value of the :mailheader:`Content-" "Disposition` header. If not specified, and *filename* is specified, add the " @@ -246,37 +255,37 @@ msgid "" "values for *disposition* are ``attachment`` and ``inline``." msgstr "" -#: ../../library/email.contentmanager.rst:179 +#: ../../library/email.contentmanager.rst:186 msgid "" "If *filename* is specified, use it as the value of the ``filename`` " "parameter of the :mailheader:`Content-Disposition` header." msgstr "" -#: ../../library/email.contentmanager.rst:182 +#: ../../library/email.contentmanager.rst:189 msgid "" "If *cid* is specified, add a :mailheader:`Content-ID` header with *cid* as " "its value." msgstr "" -#: ../../library/email.contentmanager.rst:185 +#: ../../library/email.contentmanager.rst:192 msgid "" "If *params* is specified, iterate its ``items`` method and use the resulting " "``(key, value)`` pairs to set additional parameters on the :mailheader:" "`Content-Type` header." msgstr "" -#: ../../library/email.contentmanager.rst:189 +#: ../../library/email.contentmanager.rst:196 msgid "" "If *headers* is specified and is a list of strings of the form ``headername: " "headervalue`` or a list of ``header`` objects (distinguished from strings by " "having a ``name`` attribute), add the headers to *msg*." msgstr "" -#: ../../library/email.contentmanager.rst:196 +#: ../../library/email.contentmanager.rst:203 msgid "Footnotes" msgstr "註解" -#: ../../library/email.contentmanager.rst:197 +#: ../../library/email.contentmanager.rst:204 msgid "" "Originally added in 3.4 as a :term:`provisional module `" msgstr "" diff --git a/library/email.encoders.po b/library/email.encoders.po index b30b4da3e9..851f162ded 100644 --- a/library/email.encoders.po +++ b/library/email.encoders.po @@ -5,7 +5,7 @@ # Matt Wang , 2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-07-29 10:36+0000\n" "PO-Revision-Date: 2024-05-03 03:44+0000\n" diff --git a/library/email.errors.po b/library/email.errors.po index b9ac58c595..2709c6bc47 100644 --- a/library/email.errors.po +++ b/library/email.errors.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-07 00:03+0000\n" +"POT-Creation-Date: 2025-03-04 00:14+0000\n" "PO-Revision-Date: 2018-05-23 14:44+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -64,40 +64,31 @@ msgstr "" #: ../../library/email.errors.rst:48 msgid "" -"Raised when a payload is added to a :class:`~email.message.Message` object " -"using :meth:`add_payload`, but the payload is already a scalar and the " -"message's :mailheader:`Content-Type` main type is not either :mimetype:" -"`multipart` or missing. :exc:`MultipartConversionError` multiply inherits " -"from :exc:`MessageError` and the built-in :exc:`TypeError`." +"Raised if the :meth:`~email.message.Message.attach` method is called on an " +"instance of a class derived from :class:`~email.mime.nonmultipart." +"MIMENonMultipart` (e.g. :class:`~email.mime.image.MIMEImage`). :exc:" +"`MultipartConversionError` multiply inherits from :exc:`MessageError` and " +"the built-in :exc:`TypeError`." msgstr "" -#: ../../library/email.errors.rst:54 -msgid "" -"Since :meth:`Message.add_payload` is deprecated, this exception is rarely " -"raised in practice. However the exception may also be raised if the :meth:" -"`~email.message.Message.attach` method is called on an instance of a class " -"derived from :class:`~email.mime.nonmultipart.MIMENonMultipart` (e.g. :class:" -"`~email.mime.image.MIMEImage`)." -msgstr "" - -#: ../../library/email.errors.rst:64 +#: ../../library/email.errors.rst:58 msgid "" "Raised when an error occurs when the :mod:`~email.generator` outputs headers." msgstr "" -#: ../../library/email.errors.rst:70 +#: ../../library/email.errors.rst:64 msgid "" "This is the base class for all defects found when parsing email messages. It " "is derived from :exc:`ValueError`." msgstr "" -#: ../../library/email.errors.rst:75 +#: ../../library/email.errors.rst:69 msgid "" "This is the base class for all defects found when parsing email headers. It " "is derived from :exc:`MessageDefect`." msgstr "" -#: ../../library/email.errors.rst:78 +#: ../../library/email.errors.rst:72 msgid "" "Here is the list of the defects that the :class:`~email.parser.FeedParser` " "can find while parsing messages. Note that the defects are added to the " @@ -107,90 +98,84 @@ msgid "" "not." msgstr "" -#: ../../library/email.errors.rst:84 +#: ../../library/email.errors.rst:78 msgid "" "All defect classes are subclassed from :class:`email.errors.MessageDefect`." msgstr "" -#: ../../library/email.errors.rst:86 +#: ../../library/email.errors.rst:82 msgid "" -":class:`NoBoundaryInMultipartDefect` -- A message claimed to be a multipart, " -"but had no :mimetype:`boundary` parameter." +"A message claimed to be a multipart, but had no :mimetype:`boundary` " +"parameter." msgstr "" -#: ../../library/email.errors.rst:89 +#: ../../library/email.errors.rst:87 msgid "" -":class:`StartBoundaryNotFoundDefect` -- The start boundary claimed in the :" -"mailheader:`Content-Type` header was never found." +"The start boundary claimed in the :mailheader:`Content-Type` header was " +"never found." msgstr "" #: ../../library/email.errors.rst:92 msgid "" -":class:`CloseBoundaryNotFoundDefect` -- A start boundary was found, but no " -"corresponding close boundary was ever found." +"A start boundary was found, but no corresponding close boundary was ever " +"found." msgstr "" -#: ../../library/email.errors.rst:97 -msgid "" -":class:`FirstHeaderLineIsContinuationDefect` -- The message had a " -"continuation line as its first header line." +#: ../../library/email.errors.rst:99 +msgid "The message had a continuation line as its first header line." msgstr "" -#: ../../library/email.errors.rst:100 -msgid "" -":class:`MisplacedEnvelopeHeaderDefect` - A \"Unix From\" header was found in " -"the middle of a header block." +#: ../../library/email.errors.rst:103 +msgid "A \"Unix From\" header was found in the middle of a header block." msgstr "" -#: ../../library/email.errors.rst:103 +#: ../../library/email.errors.rst:107 msgid "" -":class:`MissingHeaderBodySeparatorDefect` - A line was found while parsing " -"headers that had no leading white space but contained no ':'. Parsing " -"continues assuming that the line represents the first line of the body." +"A line was found while parsing headers that had no leading white space but " +"contained no ':'. Parsing continues assuming that the line represents the " +"first line of the body." msgstr "" -#: ../../library/email.errors.rst:109 +#: ../../library/email.errors.rst:115 msgid "" -":class:`MalformedHeaderDefect` -- A header was found that was missing a " -"colon, or was otherwise malformed." +"A header was found that was missing a colon, or was otherwise malformed." msgstr "" -#: ../../library/email.errors.rst:112 +#: ../../library/email.errors.rst:117 msgid "This defect has not been used for several Python versions." msgstr "" -#: ../../library/email.errors.rst:115 +#: ../../library/email.errors.rst:122 msgid "" -":class:`MultipartInvariantViolationDefect` -- A message claimed to be a :" -"mimetype:`multipart`, but no subparts were found. Note that when a message " -"has this defect, its :meth:`~email.message.Message.is_multipart` method may " -"return ``False`` even though its content type claims to be :mimetype:" -"`multipart`." +"A message claimed to be a :mimetype:`multipart`, but no subparts were found. " +"Note that when a message has this defect, its :meth:`~email.message.Message." +"is_multipart` method may return ``False`` even though its content type " +"claims to be :mimetype:`multipart`." msgstr "" -#: ../../library/email.errors.rst:120 +#: ../../library/email.errors.rst:129 msgid "" -":class:`InvalidBase64PaddingDefect` -- When decoding a block of base64 " -"encoded bytes, the padding was not correct. Enough padding is added to " -"perform the decode, but the resulting decoded bytes may be invalid." +"When decoding a block of base64 encoded bytes, the padding was not correct. " +"Enough padding is added to perform the decode, but the resulting decoded " +"bytes may be invalid." msgstr "" -#: ../../library/email.errors.rst:124 +#: ../../library/email.errors.rst:135 msgid "" -":class:`InvalidBase64CharactersDefect` -- When decoding a block of base64 " -"encoded bytes, characters outside the base64 alphabet were encountered. The " -"characters are ignored, but the resulting decoded bytes may be invalid." +"When decoding a block of base64 encoded bytes, characters outside the base64 " +"alphabet were encountered. The characters are ignored, but the resulting " +"decoded bytes may be invalid." msgstr "" -#: ../../library/email.errors.rst:128 +#: ../../library/email.errors.rst:141 msgid "" -":class:`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." +"When decoding a block of base64 encoded bytes, the number of non-padding " +"base64 characters was invalid (1 more than a multiple of 4). The encoded " +"block was kept as-is." msgstr "" -#: ../../library/email.errors.rst:132 +#: ../../library/email.errors.rst:147 msgid "" -":class:`InvalidDateDefect` -- When decoding an invalid or unparsable date " -"field. The original value is kept as-is." +"When decoding an invalid or unparsable date field. The original value is " +"kept as-is." msgstr "" diff --git a/library/email.examples.po b/library/email.examples.po index fb1ded2ecc..f027517443 100644 --- a/library/email.examples.po +++ b/library/email.examples.po @@ -3,9 +3,9 @@ # This file is distributed under the same license as the Python package. msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-04-08 00:14+0000\n" "PO-Revision-Date: 2018-07-15 18:56+0800\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -197,7 +197,7 @@ msgid "" " # Guess the content type based on the file's extension. Encoding\n" " # will be ignored, although we should check for simple things like\n" " # gzip'd or compressed files.\n" -" ctype, encoding = mimetypes.guess_type(path)\n" +" ctype, encoding = mimetypes.guess_file_type(path)\n" " if ctype is None or encoding is not None:\n" " # No guess could be made, or the file is encoded (compressed), " "so\n" @@ -306,14 +306,14 @@ msgid "" "\n" "# Create the base text message.\n" "msg = EmailMessage()\n" -"msg['Subject'] = \"Ayons asperges pour le déjeuner\"\n" +"msg['Subject'] = \"Pourquoi pas des asperges pour ce midi ?\"\n" "msg['From'] = Address(\"Pepé Le Pew\", \"pepe\", \"example.com\")\n" "msg['To'] = (Address(\"Penelope Pussycat\", \"penelope\", \"example.com\"),\n" " Address(\"Fabrette Pussycat\", \"fabrette\", \"example.com\"))\n" "msg.set_content(\"\"\"\\\n" "Salut!\n" "\n" -"Cela ressemble à un excellent recipie[1] déjeuner.\n" +"Cette recette [1] sera sûrement un très bon repas.\n" "\n" "[1] http://www.yummly.com/recipe/Roasted-Asparagus-Epicurious-203718\n" "\n" @@ -331,13 +331,13 @@ msgid "" " \n" " \n" "

Salut!

\n" -"

Cela ressemble à un excellent\n" +"

Cette\n" " \n" -" recipie\n" -" déjeuner.\n" +" recette\n" +" sera sûrement un très bon repas.\n" "

\n" -" \n" +" \n" " \n" "\n" "\"\"\".format(asparagus_cid=asparagus_cid[1:-1]), subtype='html')\n" @@ -463,11 +463,11 @@ msgid "" "To: Penelope Pussycat , Fabrette Pussycat " "\n" "From: Pepé Le Pew \n" -"Subject: Ayons asperges pour le déjeuner\n" +"Subject: Pourquoi pas des asperges pour ce midi ?\n" "\n" "Salut!\n" "\n" -"Cela ressemble à un excellent recipie[1] déjeuner." +"Cette recette [1] sera sûrement un très bon repas." msgstr "" #: ../../library/email.examples.rst:66 diff --git a/library/email.generator.po b/library/email.generator.po index b0ae12d0f7..64c675911d 100644 --- a/library/email.generator.po +++ b/library/email.generator.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-09 00:03+0000\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2018-05-23 14:44+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -31,9 +31,9 @@ msgid "" "One of the most common tasks is to generate the flat (serialized) version of " "the email message represented by a message object structure. You will need " "to do this if you want to send your message via :meth:`smtplib.SMTP." -"sendmail` or the :mod:`nntplib` module, or print the message on the " -"console. Taking a message object structure and producing a serialized " -"representation is the job of the generator classes." +"sendmail`, or print the message on the console. Taking a message object " +"structure and producing a serialized representation is the job of the " +"generator classes." msgstr "" #: ../../library/email.generator.rst:18 diff --git a/library/email.header.po b/library/email.header.po index 1e9c38a9c8..2492b8b82e 100644 --- a/library/email.header.po +++ b/library/email.header.po @@ -4,9 +4,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 14:44+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -273,43 +273,77 @@ msgid "" msgstr "" #: ../../library/email.header.rst:181 +msgid "For historical reasons, this function may return either:" +msgstr "" + +#: ../../library/email.header.rst:183 +msgid "" +"A list of pairs containing each of the decoded parts of the header, " +"``(decoded_bytes, charset)``, where *decoded_bytes* is always an instance " +"of :class:`bytes`, and *charset* is either:" +msgstr "" + +#: ../../library/email.header.rst:187 +msgid "A lower case string containing the name of the character set specified." +msgstr "" + +#: ../../library/email.header.rst:189 +msgid "``None`` for non-encoded parts of the header." +msgstr "" + +#: ../../library/email.header.rst:191 +msgid "" +"A list of length 1 containing a pair ``(string, None)``, where *string* is " +"always an instance of :class:`str`." +msgstr "" + +#: ../../library/email.header.rst:194 msgid "" -"This function returns a list of ``(decoded_string, charset)`` pairs " -"containing each of the decoded parts of the header. *charset* is ``None`` " -"for non-encoded parts of the header, otherwise a lower case string " -"containing the name of the character set specified in the encoded string." +"An :exc:`email.errors.HeaderParseError` may be raised when certain decoding " +"errors occur (e.g. a base64 decoding exception)." msgstr "" -#: ../../library/email.header.rst:186 -msgid "Here's an example::" -msgstr "以下是個範例: ::" +#: ../../library/email.header.rst:197 +msgid "Here are examples:" +msgstr "以下為範例: ::" -#: ../../library/email.header.rst:188 +#: ../../library/email.header.rst:209 msgid "" -">>> from email.header import decode_header\n" -">>> decode_header('=?iso-8859-1?q?p=F6stal?=')\n" -"[(b'p\\xf6stal', 'iso-8859-1')]" +"This function exists for backwards compatibility only. For new code, we " +"recommend using :class:`email.headerregistry.HeaderRegistry`." msgstr "" -">>> from email.header import decode_header\n" -">>> decode_header('=?iso-8859-1?q?p=F6stal?=')\n" -"[(b'p\\xf6stal', 'iso-8859-1')]" -#: ../../library/email.header.rst:195 +#: ../../library/email.header.rst:215 msgid "" "Create a :class:`Header` instance from a sequence of pairs as returned by :" "func:`decode_header`." msgstr "" -#: ../../library/email.header.rst:198 +#: ../../library/email.header.rst:218 msgid "" ":func:`decode_header` takes a header value string and returns a sequence of " "pairs of the format ``(decoded_string, charset)`` where *charset* is the " "name of the character set." msgstr "" -#: ../../library/email.header.rst:202 +#: ../../library/email.header.rst:222 msgid "" "This function takes one of those sequence of pairs and returns a :class:" "`Header` instance. Optional *maxlinelen*, *header_name*, and " "*continuation_ws* are as in the :class:`Header` constructor." msgstr "" + +#: ../../library/email.header.rst:228 +msgid "" +"This function exists for backwards compatibility only, and is not " +"recommended for use in new code." +msgstr "" + +#~ msgid "" +#~ ">>> from email.header import decode_header\n" +#~ ">>> decode_header('=?iso-8859-1?q?p=F6stal?=')\n" +#~ "[(b'p\\xf6stal', 'iso-8859-1')]" +#~ msgstr "" +#~ ">>> from email.header import decode_header\n" +#~ ">>> decode_header('=?iso-8859-1?q?p=F6stal?=')\n" +#~ "[(b'p\\xf6stal', 'iso-8859-1')]" diff --git a/library/email.headerregistry.po b/library/email.headerregistry.po index 4fedfdee9a..79898d5d74 100644 --- a/library/email.headerregistry.po +++ b/library/email.headerregistry.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-09-27 00:14+0000\n" "PO-Revision-Date: 2018-05-23 14:44+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -73,7 +73,7 @@ msgstr "" #: ../../library/email.headerregistry.rst:48 msgid "This base class defines the following read-only properties:" -msgstr "" +msgstr "這個基底類別定義了以下唯讀屬性:" #: ../../library/email.headerregistry.rst:53 msgid "" @@ -390,7 +390,7 @@ msgid "" "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 ``__bases__`` list." +"class's :class:`~type.__bases__` list." msgstr "" #: ../../library/email.headerregistry.rst:322 @@ -535,7 +535,7 @@ msgstr "MessageIDHeader" #: ../../library/email.headerregistry.rst:345 msgid "``HeaderRegistry`` has the following methods:" -msgstr "" +msgstr "``HeaderRegistry`` 有以下方法:" #: ../../library/email.headerregistry.rst:350 msgid "" diff --git a/library/email.iterators.po b/library/email.iterators.po index 4b12cddefb..71843281fb 100644 --- a/library/email.iterators.po +++ b/library/email.iterators.po @@ -5,7 +5,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2016-11-19 00:30+0000\n" diff --git a/library/email.message.po b/library/email.message.po index 8d8317321b..6be5abfbdc 100644 --- a/library/email.message.po +++ b/library/email.message.po @@ -5,7 +5,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2018-05-23 14:44+0000\n" @@ -28,7 +28,7 @@ msgstr "**原始碼:**\\ :source:`Lib/email/message.py`" #: ../../library/email.message.rst:14 msgid "[1]_" -msgstr "" +msgstr "[1]_" #: ../../library/email.message.rst:16 msgid "" diff --git a/library/email.mime.po b/library/email.mime.po index 1f45a7bcc2..2cd526c301 100644 --- a/library/email.mime.po +++ b/library/email.mime.po @@ -5,7 +5,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-05-09 00:03+0000\n" "PO-Revision-Date: 2018-05-23 16:00+0000\n" diff --git a/library/email.parser.po b/library/email.parser.po index ff3c7597c1..9bcf691477 100644 --- a/library/email.parser.po +++ b/library/email.parser.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-07-14 11:31+0000\n" "PO-Revision-Date: 2018-05-23 16:01+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -163,7 +162,7 @@ msgid "" "Works like :class:`BytesFeedParser` except that the input to the :meth:" "`~BytesFeedParser.feed` 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 :attr:`~email.policy.Policy.utf8` is " +"contain only ASCII text or, if :attr:`~email.policy.EmailPolicy.utf8` is " "``True``, no binary attachments." msgstr "" @@ -213,11 +212,11 @@ msgstr "" #: ../../library/email.parser.rst:161 msgid "" "The bytes contained in *fp* must be formatted as a block of :rfc:`5322` (or, " -"if :attr:`~email.policy.Policy.utf8` is ``True``, :rfc:`6532`) 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 :mailheader:" +"if :attr:`~email.policy.EmailPolicy.utf8` is ``True``, :rfc:`6532`) 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 :mailheader:" "`Content-Transfer-Encoding` of ``8bit``)." msgstr "" @@ -330,10 +329,10 @@ msgstr "" #: ../../library/email.parser.rst:286 msgid "" ">>> import email\n" -">>> msg = email.message_from_bytes(myBytes) " +">>> msg = email.message_from_bytes(myBytes)" msgstr "" ">>> import email\n" -">>> msg = email.message_from_bytes(myBytes) " +">>> msg = email.message_from_bytes(myBytes)" #: ../../library/email.parser.rst:291 msgid "Additional notes" diff --git a/library/email.po b/library/email.po index 1592968c73..da6d04ebe5 100644 --- a/library/email.po +++ b/library/email.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-09 00:03+0000\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2018-05-23 16:01+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -31,10 +31,10 @@ msgid "" "The :mod:`email` package is a library for managing email messages. It is " "specifically *not* designed to do any sending of email messages to SMTP (:" "rfc:`2821`), NNTP, or other servers; those are functions of modules such as :" -"mod:`smtplib` and :mod:`nntplib`. The :mod:`email` package attempts to be " -"as RFC-compliant as possible, supporting :rfc:`5322` and :rfc:`6532`, as " -"well as such MIME-related RFCs as :rfc:`2045`, :rfc:`2046`, :rfc:`2047`, :" -"rfc:`2183`, and :rfc:`2231`." +"mod:`smtplib`. The :mod:`email` package attempts to be as RFC-compliant as " +"possible, supporting :rfc:`5322` and :rfc:`6532`, as well as such MIME-" +"related RFCs as :rfc:`2045`, :rfc:`2046`, :rfc:`2047`, :rfc:`2183`, and :rfc:" +"`2231`." msgstr "" #: ../../library/email.rst:23 @@ -181,22 +181,17 @@ msgid "IMAP (Internet Message Access Protocol) client" msgstr "" #: ../../library/email.rst:144 -msgid "Module :mod:`nntplib`" -msgstr ":mod:`nntplib` 模組" - -#: ../../library/email.rst:145 -msgid "NNTP (Net News Transport Protocol) client" -msgstr "" - -#: ../../library/email.rst:147 msgid "Module :mod:`mailbox`" msgstr ":mod:`mailbox` 模組" -#: ../../library/email.rst:148 +#: ../../library/email.rst:145 msgid "" "Tools for creating, reading, and managing collections of messages on disk " "using a variety standard formats." msgstr "" +#~ msgid "Module :mod:`nntplib`" +#~ msgstr ":mod:`nntplib` 模組" + #~ msgid "Module :mod:`smtpd`" #~ msgstr ":mod:`smtpd` 模組" diff --git a/library/email.policy.po b/library/email.policy.po index fecb843622..526811754f 100644 --- a/library/email.policy.po +++ b/library/email.policy.po @@ -4,9 +4,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-01-06 00:14+0000\n" "PO-Revision-Date: 2018-05-23 16:01+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -355,7 +355,7 @@ msgstr "" #: ../../library/email.policy.rst:268 msgid "" "Handle a *defect* found on *obj*. When the email package calls this method, " -"*defect* will always be a subclass of :class:`~email.errors.Defect`." +"*defect* will always be a subclass of :class:`~email.errors.MessageDefect`." msgstr "" #: ../../library/email.policy.rst:272 @@ -368,7 +368,7 @@ msgstr "" #: ../../library/email.policy.rst:279 msgid "" "Register a *defect* on *obj*. In the email package, *defect* will always be " -"a subclass of :class:`~email.errors.Defect`." +"a subclass of :class:`~email.errors.MessageDefect`." msgstr "" #: ../../library/email.policy.rst:282 diff --git a/library/email.utils.po b/library/email.utils.po index 81afcaf3dd..eb6c4dec6b 100644 --- a/library/email.utils.po +++ b/library/email.utils.po @@ -6,7 +6,7 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-07 03:11+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" diff --git a/library/ensurepip.po b/library/ensurepip.po index 151641a7b2..9055ad0aac 100644 --- a/library/ensurepip.po +++ b/library/ensurepip.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2025-02-19 00:13+0000\n" "PO-Revision-Date: 2018-05-23 16:01+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -47,7 +47,7 @@ msgid "" "needed if installing ``pip`` was skipped when installing Python (or when " "creating a virtual environment) or after explicitly uninstalling ``pip``." msgstr "" -"大多數情況下,Python 的終端使用者不需要直接調用此模組(因為 ``pip`` 預設應為" +"大多數情況下,Python 的終端使用者不需要直接叫用此模組(因為 ``pip`` 預設應為" "初始建置),但若安裝 Python 時 ``pip`` 被省略(或建立一虛擬環境時),又或是 " "``pip`` 被明確解除安裝時,則此模組的初始建置仍有可能用上。" @@ -75,193 +75,189 @@ msgstr ":pep:`453`: 在 Python 安裝中的 pip 明確初始建置" msgid "The original rationale and specification for this module." msgstr "此模組的最初設計理念與規範。" -#: ../../includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not Emscripten, not WASI." -msgstr "" +#: ../../includes/wasm-mobile-notavail.rst:3 +msgid "Availability" +msgstr "可用性" -#: ../../includes/wasm-notavail.rst:5 +#: ../../includes/wasm-mobile-notavail.rst:5 msgid "" -"This module does not work or is not available on WebAssembly platforms " -"``wasm32-emscripten`` and ``wasm32-wasi``. See :ref:`wasm-availability` for " -"more information." +"This module is not supported on :ref:`mobile platforms ` or :ref:`WebAssembly platforms `." msgstr "" -"此模組在 WebAssembly 平台 ``wasm32-emscripten`` 和 ``wasm32-wasi`` 上無法作用" -"或無法使用。有關更多資訊,請參閱 :ref:`wasm-availability`。" +"此模組在\\ :ref:`行動平台 `\\ 或\\ :ref:`WebAssembly 平" +"台 `\\ 上不支援。" #: ../../library/ensurepip.rst:44 msgid "Command line interface" msgstr "命令列介面" -#: ../../library/ensurepip.rst:46 +#: ../../library/ensurepip.rst:48 msgid "" "The command line interface is invoked using the interpreter's ``-m`` switch." -msgstr "使用直譯器 (interpreter) 的 ``-m`` 來調用命令列介面" +msgstr "使用直譯器 (interpreter) 的 ``-m`` 來叫用命令列介面" -#: ../../library/ensurepip.rst:48 +#: ../../library/ensurepip.rst:50 msgid "The simplest possible invocation is::" -msgstr "最簡單可行的調用: ::" +msgstr "最簡單可行的呼叫: ::" -#: ../../library/ensurepip.rst:50 +#: ../../library/ensurepip.rst:52 msgid "python -m ensurepip" msgstr "python -m ensurepip" -#: ../../library/ensurepip.rst:52 +#: ../../library/ensurepip.rst:54 msgid "" "This invocation will install ``pip`` if it is not already installed, but " "otherwise does nothing. To ensure the installed version of ``pip`` is at " "least as recent as the one available in ``ensurepip``, pass the ``--" "upgrade`` option::" msgstr "" -"若 ``pip`` 未安裝,此調用會將其安裝;否則甚麼也不做。可透過傳入 ``--" -"upgrade`` 參數來確保 ``pip`` 的安裝版本至少為當前 ``ensurepip`` 中最新可用的" +"若 ``pip`` 未安裝,此呼叫會將其安裝;否則甚麼也不做。可透過傳入 ``--" +"upgrade`` 參數來確保 ``pip`` 的安裝版本至少為目前 ``ensurepip`` 中最新可用的" "版本: ::" -#: ../../library/ensurepip.rst:57 +#: ../../library/ensurepip.rst:59 msgid "python -m ensurepip --upgrade" msgstr "python -m ensurepip --upgrade" -#: ../../library/ensurepip.rst:59 +#: ../../library/ensurepip.rst:61 msgid "" "By default, ``pip`` is installed into the current virtual environment (if " "one is active) or into the system site packages (if there is no active " "virtual environment). The installation location can be controlled through " "two additional command line options:" msgstr "" -"預設上,``pip`` 會被安裝至當前虛擬環境(若已啟動虛擬環境)或系統端的套件(若" +"預設上,``pip`` 會被安裝至目前虛擬環境(若已啟動虛擬環境)或系統端的套件(若" "沒有啟動的虛擬環境)。安裝位置可透過兩個額外的命令列選項來控制:" -#: ../../library/ensurepip.rst:64 +#: ../../library/ensurepip.rst:68 msgid "" -":samp:`--root {dir}`: Installs ``pip`` relative to the given root directory " -"rather than the root of the currently active virtual environment (if any) or " -"the default root for the current Python installation." +"Installs ``pip`` relative to the given root directory rather than the root " +"of the currently active virtual environment (if any) or the default root for " +"the current Python installation." msgstr "" -"``--root ``:安裝 ``pip`` 到給定的根目錄 (root directory) 的相對路徑,而" -"不是當前虛擬環境(若存在)的根目錄,或當前 Python 安裝版所預設的根目錄。" +"安裝 ``pip`` 到給定的根目錄 (root directory) 的相對路徑,而不是目前虛擬環境" +"(若存在)的根目錄,或目前 Python 安裝版所預設的根目錄。" -#: ../../library/ensurepip.rst:67 +#: ../../library/ensurepip.rst:74 msgid "" -"``--user``: Installs ``pip`` into the user site packages directory rather " -"than globally for the current Python installation (this option is not " -"permitted inside an active virtual environment)." +"Installs ``pip`` into the user site packages directory rather than globally " +"for the current Python installation (this option is not permitted inside an " +"active virtual environment)." msgstr "" -"``--user`` :安裝 ``pip`` 到使用者端的套件目錄,而不是全域安裝到當前的 " -"Python 安裝版(此選項不允許在一啟動的虛擬環境中使用)。" +"安裝 ``pip`` 到使用者端的套件目錄,而不是全域安裝到目前的 Python 安裝版(此選" +"項不允許在一啟動的虛擬環境中使用)。" -#: ../../library/ensurepip.rst:71 +#: ../../library/ensurepip.rst:78 msgid "" "By default, the scripts ``pipX`` and ``pipX.Y`` will be installed (where X.Y " "stands for the version of Python used to invoke ``ensurepip``). The scripts " "installed can be controlled through two additional command line options:" msgstr "" -"預設會安裝 ``pipX`` 和 ``pipX.Y`` 腳本(X.Y 代表用來調用 ``ensurepip`` 的 " +"預設會安裝 ``pipX`` 和 ``pipX.Y`` 腳本(X.Y 代表用來叫用 ``ensurepip`` 的 " "Python 之版本)。安裝的腳本可透過兩個額外的命令列選項來控制:" -#: ../../library/ensurepip.rst:76 +#: ../../library/ensurepip.rst:85 msgid "" -"``--altinstall``: if an alternate installation is requested, the ``pipX`` " -"script will *not* be installed." -msgstr "" -"``--altinstall``:若要求一個替代安裝版,則\\ *不會*\\ 安裝 ``pipX`` 腳本。" +"If an alternate installation is requested, the ``pipX`` script will *not* be " +"installed." +msgstr "若要求一個替代安裝版,則\\ *不會*\\ 安裝 ``pipX`` 腳本。" -#: ../../library/ensurepip.rst:79 +#: ../../library/ensurepip.rst:90 msgid "" -"``--default-pip``: if a \"default pip\" installation is requested, the " -"``pip`` script will be installed in addition to the two regular scripts." -msgstr "" -"``--default-pip``: 若要求安裝「預設 pip」,則會安裝 ``pip`` 腳本,及 2 個常" -"規腳本。" +"If a \"default pip\" installation is requested, the ``pip`` script will be " +"installed in addition to the two regular scripts." +msgstr "若要求安裝「預設 pip」,則會安裝 ``pip`` 腳本,及 2 個常規腳本。" -#: ../../library/ensurepip.rst:82 +#: ../../library/ensurepip.rst:93 msgid "" "Providing both of the script selection options will trigger an exception." msgstr "提供兩種指令選項將會導致例外 (exception) 。" -#: ../../library/ensurepip.rst:86 +#: ../../library/ensurepip.rst:96 msgid "Module API" msgstr "模組 API" -#: ../../library/ensurepip.rst:88 +#: ../../library/ensurepip.rst:98 msgid ":mod:`ensurepip` exposes two functions for programmatic use:" msgstr ":mod:`ensurepip` 開放了兩個用於編寫程式的函式:" -#: ../../library/ensurepip.rst:92 +#: ../../library/ensurepip.rst:102 msgid "" "Returns a string specifying the available version of pip that will be " "installed when bootstrapping an environment." msgstr "回傳一個字串,用以標明初始建置時,安裝的 pip 的可行版本號。" -#: ../../library/ensurepip.rst:99 +#: ../../library/ensurepip.rst:109 msgid "Bootstraps ``pip`` into the current or designated environment." -msgstr "在當前或指定的環境之中建立 ``pip``。" +msgstr "在目前或指定的環境之中建立 ``pip``。" -#: ../../library/ensurepip.rst:101 +#: ../../library/ensurepip.rst:111 msgid "" "*root* specifies an alternative root directory to install relative to. If " "*root* is ``None``, then installation uses the default install location for " "the current environment." msgstr "" "*root* 指定一個替代的根目錄,作為安裝的相對路徑。若 *root* 為 ``None``,則安" -"裝使用當前環境的預設安裝位置。" +"裝使用目前環境的預設安裝位置。" -#: ../../library/ensurepip.rst:105 +#: ../../library/ensurepip.rst:115 msgid "" "*upgrade* indicates whether or not to upgrade an existing installation of an " "earlier version of ``pip`` to the available version." msgstr "*upgrade* 指出是否要將一個既有的較早版本的 ``pip`` 升級至可用的新版。" -#: ../../library/ensurepip.rst:108 +#: ../../library/ensurepip.rst:118 msgid "" "*user* indicates whether to use the user scheme rather than installing " "globally." msgstr "*user* 指出是否要使用使用者的安裝方案而不是全域安裝。" -#: ../../library/ensurepip.rst:111 +#: ../../library/ensurepip.rst:121 msgid "" "By default, the scripts ``pipX`` and ``pipX.Y`` will be installed (where X.Y " "stands for the current version of Python)." -msgstr "預設會安裝 ``pipX`` 和 ``pipX.Y`` 腳本(X.Y 代表 Python 的當前版本)。" +msgstr "預設會安裝 ``pipX`` 和 ``pipX.Y`` 腳本(X.Y 代表 Python 的目前版本)。" -#: ../../library/ensurepip.rst:114 +#: ../../library/ensurepip.rst:124 msgid "If *altinstall* is set, then ``pipX`` will *not* be installed." msgstr "如果啟用了 *altinstall*,則不會安裝 ``pipX``。" -#: ../../library/ensurepip.rst:116 +#: ../../library/ensurepip.rst:126 msgid "" "If *default_pip* is set, then ``pip`` will be installed in addition to the " "two regular scripts." msgstr "如果啟用了 *default_pip*,則會安裝 ``pip``,以及 2 個常規腳本。" -#: ../../library/ensurepip.rst:119 +#: ../../library/ensurepip.rst:129 msgid "" "Setting both *altinstall* and *default_pip* will trigger :exc:`ValueError`." msgstr "同時啟用 *altinstall* 跟 *default_pip*,將會觸發 :exc:`ValueError`。" -#: ../../library/ensurepip.rst:122 +#: ../../library/ensurepip.rst:132 msgid "" "*verbosity* controls the level of output to :data:`sys.stdout` from the " "bootstrapping operation." msgstr "" "*verbosity* 用來控制初始建置操作內,對於 :data:`sys.stdout` 的輸出等級。" -#: ../../library/ensurepip.rst:125 +#: ../../library/ensurepip.rst:135 msgid "" "Raises an :ref:`auditing event ` ``ensurepip.bootstrap`` with " "argument ``root``." msgstr "" -"引發一個附帶引數 ``root`` 的\\ :ref:`稽核事件 ` ``ensurepip." -"bootstrap``。" +"引發一個附帶引數 ``root`` 的\\ :ref:`稽核事件 ` " +"``ensurepip.bootstrap``。" -#: ../../library/ensurepip.rst:129 +#: ../../library/ensurepip.rst:139 msgid "" -"The bootstrapping process has side effects on both ``sys.path`` and ``os." -"environ``. Invoking the command line interface in a subprocess instead " +"The bootstrapping process has side effects on both ``sys.path`` and " +"``os.environ``. Invoking the command line interface in a subprocess instead " "allows these side effects to be avoided." msgstr "" "初始建置的過程對於 ``sys.path`` 及 ``os.environ`` 均有副作用。改為在一子行程 " -"(subprocess) 調用命令列介面可避免這些副作用。" +"(subprocess) 呼叫命令列介面可避免這些副作用。" -#: ../../library/ensurepip.rst:135 +#: ../../library/ensurepip.rst:145 msgid "" "The bootstrapping process may install additional modules required by " "``pip``, but other software should not assume those dependencies will always " diff --git a/library/enum.po b/library/enum.po index caa8b89d13..d6d9120849 100644 --- a/library/enum.po +++ b/library/enum.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" -"PO-Revision-Date: 2023-09-11 14:08+0800\n" +"POT-Creation-Date: 2025-07-23 00:17+0000\n" +"PO-Revision-Date: 2024-12-21 13:50+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -83,8 +82,18 @@ msgid "" "... BLUE = 3\n" "\n" ">>> # functional syntax\n" -">>> Color = Enum('Color', ['RED', 'GREEN', 'BLUE'])" +">>> Color = Enum('Color', [('RED', 1), ('GREEN', 2), ('BLUE', 3)])" msgstr "" +">>> from enum import Enum\n" +"\n" +">>> # class 語法\n" +">>> class Color(Enum):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 3\n" +"\n" +">>> # 函式語法\n" +">>> Color = Enum('Color', [('RED', 1), ('GREEN', 2), ('BLUE', 3)])" #: ../../library/enum.rst:49 msgid "" @@ -199,7 +208,7 @@ msgid "" "the :class:`str() ` of the mixed-in type." msgstr "" "由 :class:`IntEnum`、:class:`StrEnum` 及 :class:`IntFlag` 所使用來保留這些混" -"合類型的 :class:`str() `。" +"合型別的 :class:`str() `。" #: ../../library/enum.rst:101 msgid ":class:`EnumCheck`" @@ -228,10 +237,18 @@ msgstr "" "對如何處理非法值做更細微的控制。" #: ../../library/enum.rst:113 +msgid ":class:`EnumDict`" +msgstr ":class:`EnumDict`" + +#: ../../library/enum.rst:115 +msgid "A subclass of :class:`dict` for use when subclassing :class:`EnumType`." +msgstr ":class:`dict` 的子類別,用於當作 :class:`EnumType` 的子類別時使用。" + +#: ../../library/enum.rst:117 msgid ":class:`auto`" msgstr ":class:`auto`" -#: ../../library/enum.rst:115 +#: ../../library/enum.rst:119 msgid "" "Instances are replaced with an appropriate value for Enum members. :class:" "`StrEnum` defaults to the lower-cased version of the member name, while " @@ -240,11 +257,11 @@ msgstr "" "列舉成員的實例會被取代成合適的值。:class:`StrEnum` 預設是小寫版本的成員名稱," "其它列舉則預設是 1 且往後遞增。" -#: ../../library/enum.rst:119 +#: ../../library/enum.rst:123 msgid ":func:`~enum.property`" msgstr ":func:`~enum.property`" -#: ../../library/enum.rst:121 +#: ../../library/enum.rst:125 msgid "" "Allows :class:`Enum` members to have attributes without conflicting with " "member names. The ``value`` and ``name`` attributes are implemented this " @@ -253,46 +270,46 @@ msgstr "" "允許 :class:`Enum` 成員擁有屬性且不會與成員名稱有衝突。``value`` 及 ``name`` " "屬性是用這個方式來實作。" -#: ../../library/enum.rst:125 +#: ../../library/enum.rst:129 msgid ":func:`unique`" msgstr ":func:`unique`" -#: ../../library/enum.rst:127 +#: ../../library/enum.rst:131 msgid "" "Enum class decorator that ensures only one name is bound to any one value." msgstr "Enum 類別的裝飾器,用來確保任何值只有綁定到一個名稱上。" -#: ../../library/enum.rst:129 +#: ../../library/enum.rst:133 msgid ":func:`verify`" msgstr ":func:`verify`" -#: ../../library/enum.rst:131 +#: ../../library/enum.rst:135 msgid "" "Enum class decorator that checks user-selectable constraints on an " "enumeration." msgstr "Enum 類別的裝飾器,用來檢查列舉上使用者所選的限制。" -#: ../../library/enum.rst:134 +#: ../../library/enum.rst:138 msgid ":func:`member`" msgstr ":func:`member`" -#: ../../library/enum.rst:136 +#: ../../library/enum.rst:140 msgid "Make ``obj`` a member. Can be used as a decorator." msgstr "讓 ``obj`` 變成成員。可以當作裝飾器使用。" -#: ../../library/enum.rst:138 +#: ../../library/enum.rst:142 msgid ":func:`nonmember`" msgstr ":func:`nonmember`" -#: ../../library/enum.rst:140 +#: ../../library/enum.rst:144 msgid "Do not make ``obj`` a member. Can be used as a decorator." msgstr "不讓 ``obj`` 變成成員。可以當作裝飾器使用。" -#: ../../library/enum.rst:142 +#: ../../library/enum.rst:146 msgid ":func:`global_enum`" msgstr ":func:`global_enum`" -#: ../../library/enum.rst:144 +#: ../../library/enum.rst:148 msgid "" "Modify the :class:`str() ` and :func:`repr` of an enum to show its " "members as belonging to the module instead of its class, and export the enum " @@ -301,19 +318,19 @@ msgstr "" "修改列舉上的 :class:`str() ` 及 :func:`repr` ,讓成員顯示為屬於模組而不" "是類別,並將該列舉成員匯出到全域命名空間。" -#: ../../library/enum.rst:148 +#: ../../library/enum.rst:152 msgid ":func:`show_flag_values`" msgstr ":func:`show_flag_values`" -#: ../../library/enum.rst:150 +#: ../../library/enum.rst:154 msgid "Return a list of all power-of-two integers contained in a flag." msgstr "回傳旗標 (flag) 裡包含的所有 2 的次方的整數串列。" -#: ../../library/enum.rst:153 +#: ../../library/enum.rst:157 msgid "``Flag``, ``IntFlag``, ``auto``" msgstr "``Flag``, ``IntFlag``, ``auto``" -#: ../../library/enum.rst:154 +#: ../../library/enum.rst:158 msgid "" "``StrEnum``, ``EnumCheck``, ``ReprEnum``, ``FlagBoundary``, ``property``, " "``member``, ``nonmember``, ``global_enum``, ``show_flag_values``" @@ -322,34 +339,38 @@ msgstr "" "``member``, ``nonmember``, ``global_enum``, ``show_flag_values``" #: ../../library/enum.rst:159 +msgid "``EnumDict``" +msgstr "``EnumDict``" + +#: ../../library/enum.rst:164 msgid "Data Types" msgstr "資料型別" -#: ../../library/enum.rst:164 +#: ../../library/enum.rst:169 msgid "" "*EnumType* is the :term:`metaclass` for *enum* enumerations. It is possible " "to subclass *EnumType* -- see :ref:`Subclassing EnumType ` for details." msgstr "" -"*EnumType* 是\\ *列舉*\\ 的 :term:`metaclass`。*EnumType* 可以有子類別 -- 細" +"*EnumType* 是 *enum* 列舉的 :term:`metaclass`。*EnumType* 可以有子類別 -- 細" "節請參考 :ref:`建立 EnumType 的子類別 `。" -#: ../../library/enum.rst:168 +#: ../../library/enum.rst:173 msgid "" -"*EnumType* is responsible for setting the correct :meth:`!__repr__`, :meth:`!" -"__str__`, :meth:`!__format__`, and :meth:`!__reduce__` methods on the final " -"*enum*, as well as creating the enum members, properly handling duplicates, " -"providing iteration over the enum class, etc." +"``EnumType`` is responsible for setting the correct :meth:`!__repr__`, :meth:" +"`!__str__`, :meth:`!__format__`, and :meth:`!__reduce__` methods on the " +"final *enum*, as well as creating the enum members, properly handling " +"duplicates, providing iteration over the enum class, etc." msgstr "" -"*EnumType* 負責在最後的\\ *列舉*\\ 上面設定正確的 :meth:`!__repr__`、:meth:`!" -"__str__`、:meth:`!__format__` 及 :meth:`!__reduce__` 方法,以及建立列舉成員," -"並正確處理重複,提供列舉類別的疊代等等。" +"``EnumType`` 負責在最後的\\ *列舉*\\ 上面設定正確的 :meth:`!__repr__`、:meth:" +"`!__str__`、:meth:`!__format__` 及 :meth:`!__reduce__` 方法,以及建立列舉成" +"員、正確處理重複、提供列舉類別的疊代等等。" -#: ../../library/enum.rst:175 +#: ../../library/enum.rst:180 msgid "This method is called in two different ways:" msgstr "這個方法可以用兩種不同的方式呼叫:" -#: ../../library/enum.rst:177 +#: ../../library/enum.rst:182 msgid "to look up an existing member:" msgstr "查詢已存在的成員:" @@ -357,7 +378,7 @@ msgstr "查詢已存在的成員:" msgid "cls" msgstr "cls" -#: ../../library/enum.rst:179 ../../library/enum.rst:185 +#: ../../library/enum.rst:184 ../../library/enum.rst:190 msgid "The enum class being called." msgstr "所呼叫的列舉類別。" @@ -365,17 +386,17 @@ msgstr "所呼叫的列舉類別。" msgid "value" msgstr "value" -#: ../../library/enum.rst:180 +#: ../../library/enum.rst:185 msgid "The value to lookup." msgstr "要查詢的值。" -#: ../../library/enum.rst:182 +#: ../../library/enum.rst:187 msgid "" "to use the ``cls`` enum to create a new enum (only if the existing enum does " "not have any members):" msgstr "使用 ``cls`` 列舉來建立新列舉(只有在現有列舉沒有任何成員時)" -#: ../../library/enum.rst:186 +#: ../../library/enum.rst:191 msgid "The name of the new Enum to create." msgstr "要建立的新列舉的名稱。" @@ -383,7 +404,7 @@ msgstr "要建立的新列舉的名稱。" msgid "names" msgstr "names" -#: ../../library/enum.rst:187 +#: ../../library/enum.rst:192 msgid "The names/values of the members for the new Enum." msgstr "新列舉的成員的名稱/值。" @@ -391,7 +412,7 @@ msgstr "新列舉的成員的名稱/值。" msgid "module" msgstr "module" -#: ../../library/enum.rst:188 +#: ../../library/enum.rst:193 msgid "The name of the module the new Enum is created in." msgstr "新列舉要建立在哪個模組名稱下。" @@ -399,7 +420,7 @@ msgstr "新列舉要建立在哪個模組名稱下。" msgid "qualname" msgstr "qualname" -#: ../../library/enum.rst:189 +#: ../../library/enum.rst:194 msgid "The actual location in the module where this Enum can be found." msgstr "這個列舉在模組裡實際上的位置。" @@ -407,15 +428,15 @@ msgstr "這個列舉在模組裡實際上的位置。" msgid "type" msgstr "type" -#: ../../library/enum.rst:190 +#: ../../library/enum.rst:195 msgid "A mix-in type for the new Enum." -msgstr "新列舉的混合類型。" +msgstr "新列舉的混合型別。" #: ../../library/enum.rst:0 msgid "start" msgstr "start" -#: ../../library/enum.rst:191 +#: ../../library/enum.rst:196 msgid "The first integer value for the Enum (used by :class:`auto`)." msgstr "列舉的第一個整數值(由 :class:`auto` 所使用)" @@ -423,16 +444,16 @@ msgstr "列舉的第一個整數值(由 :class:`auto` 所使用)" msgid "boundary" msgstr "boundary" -#: ../../library/enum.rst:192 +#: ../../library/enum.rst:197 msgid "" "How to handle out-of-range values from bit operations (:class:`Flag` only)." msgstr "在位元操作時怎麼處理範圍外的值(只有 :class:`Flag` 會用到)" -#: ../../library/enum.rst:196 +#: ../../library/enum.rst:201 msgid "Returns ``True`` if member belongs to the ``cls``::" msgstr "如果 member 屬於 ``cls`` 則回傳 ``True``: ::" -#: ../../library/enum.rst:198 +#: ../../library/enum.rst:203 msgid "" ">>> some_var = Color.RED\n" ">>> some_var in Color\n" @@ -446,7 +467,7 @@ msgstr "" ">>> Color.RED.value in Color\n" "True" -#: ../../library/enum.rst:206 +#: ../../library/enum.rst:211 msgid "" "Before Python 3.12, a ``TypeError`` is raised if a non-Enum-member is used " "in a containment check." @@ -454,7 +475,7 @@ msgstr "" "在 Python 3.12 之前,如果用非列舉成員做屬於檢查 (containment check) 會引發 " "``TypeError``。" -#: ../../library/enum.rst:211 +#: ../../library/enum.rst:216 msgid "" "Returns ``['__class__', '__doc__', '__members__', '__module__']`` and the " "names of the members in *cls*::" @@ -462,7 +483,7 @@ msgstr "" "回傳 ``['__class__', '__doc__', '__members__', '__module__']`` 及 *cls* 的成" "員名稱: ::" -#: ../../library/enum.rst:214 +#: ../../library/enum.rst:219 msgid "" ">>> dir(Color)\n" "['BLUE', 'GREEN', 'RED', '__class__', '__contains__', '__doc__', " @@ -474,13 +495,13 @@ msgstr "" "'__getitem__', '__init_subclass__', '__iter__', '__len__', '__members__', " "'__module__', '__name__', '__qualname__']" -#: ../../library/enum.rst:219 +#: ../../library/enum.rst:224 msgid "" "Returns the Enum member in *cls* matching *name*, or raises a :exc:" "`KeyError`::" msgstr "回傳 *cls* 中符合 *name* 的列舉成員,或引發 :exc:`KeyError`: ::" -#: ../../library/enum.rst:221 +#: ../../library/enum.rst:226 msgid "" ">>> Color['BLUE']\n" "" @@ -488,11 +509,11 @@ msgstr "" ">>> Color['BLUE']\n" "" -#: ../../library/enum.rst:226 +#: ../../library/enum.rst:231 msgid "Returns each member in *cls* in definition order::" msgstr "以定義的順序回傳在 *cls* 中的每個成員: ::" -#: ../../library/enum.rst:228 +#: ../../library/enum.rst:233 msgid "" ">>> list(Color)\n" "[, , ]" @@ -500,11 +521,11 @@ msgstr "" ">>> list(Color)\n" "[, , ]" -#: ../../library/enum.rst:233 +#: ../../library/enum.rst:238 msgid "Returns the number of member in *cls*::" msgstr "回傳 *cls* 的成員數量: ::" -#: ../../library/enum.rst:235 +#: ../../library/enum.rst:240 msgid "" ">>> len(Color)\n" "3" @@ -512,15 +533,15 @@ msgstr "" ">>> len(Color)\n" "3" -#: ../../library/enum.rst:240 +#: ../../library/enum.rst:245 msgid "Returns a mapping of every enum name to its member, including aliases" msgstr "回傳每個列舉名稱到其成員的對映,包括別名" -#: ../../library/enum.rst:244 +#: ../../library/enum.rst:249 msgid "Returns each member in *cls* in reverse definition order::" msgstr "以跟定義相反的順序回傳 *cls* 的每個成員: ::" -#: ../../library/enum.rst:246 +#: ../../library/enum.rst:251 msgid "" ">>> list(reversed(Color))\n" "[, , ]" @@ -528,20 +549,37 @@ msgstr "" ">>> list(reversed(Color))\n" "[, , ]" -#: ../../library/enum.rst:251 -msgid "Before 3.11 ``enum`` used ``EnumMeta`` type, which is kept as an alias." +#: ../../library/enum.rst:256 +msgid "" +"Adds a new name as an alias to an existing member. Raises a :exc:" +"`NameError` if the name is already assigned to a different member." msgstr "" -"在 3.11 之前,``enum`` 使用 ``EnumMeta`` 類型,目前保留此類型當作別名。" +"新增一個名稱作為現有成員的別名。如果該名稱已被指派給不同的成員,則會引發 :" +"exc:`NameError`。" -#: ../../library/enum.rst:256 +#: ../../library/enum.rst:261 +msgid "" +"Adds a new value as an alias to an existing member. Raises a :exc:" +"`ValueError` if the value is already linked with a different member." +msgstr "" +"新增一個值作為現有成員的別名。如果該值已與不同成員連結,則會引發 :exc:" +"`ValueError`。" + +#: ../../library/enum.rst:266 +msgid "" +"Before 3.11 ``EnumType`` was called ``EnumMeta``, which is still available " +"as an alias." +msgstr "在 3.11 之前,``EnumType`` 稱作 ``EnumMeta``,其目前仍可作為別名使用。" + +#: ../../library/enum.rst:271 msgid "*Enum* is the base class for all *enum* enumerations." msgstr "*Enum* 是所有 *enum* 列舉的基礎類別。" -#: ../../library/enum.rst:260 +#: ../../library/enum.rst:275 msgid "The name used to define the ``Enum`` member::" msgstr "用來定義 ``Enum`` 成員的名稱: ::" -#: ../../library/enum.rst:262 +#: ../../library/enum.rst:277 msgid "" ">>> Color.BLUE.name\n" "'BLUE'" @@ -549,11 +587,11 @@ msgstr "" ">>> Color.BLUE.name\n" "'BLUE'" -#: ../../library/enum.rst:267 +#: ../../library/enum.rst:282 msgid "The value given to the ``Enum`` member::" msgstr "``Enum`` 成員給定的值: ::" -#: ../../library/enum.rst:269 +#: ../../library/enum.rst:284 msgid "" ">>> Color.RED.value\n" "1" @@ -561,15 +599,15 @@ msgstr "" ">>> Color.RED.value\n" "1" -#: ../../library/enum.rst:272 ../../library/enum.rst:292 +#: ../../library/enum.rst:287 ../../library/enum.rst:307 msgid "Value of the member, can be set in :meth:`~Enum.__new__`." msgstr "成員的值,可以在 :meth:`~Enum.__new__` 設定。" -#: ../../library/enum.rst:274 +#: ../../library/enum.rst:289 msgid "Enum member values" msgstr "列舉成員的值" -#: ../../library/enum.rst:276 +#: ../../library/enum.rst:291 msgid "" "Member values can be anything: :class:`int`, :class:`str`, etc. If the " "exact value is unimportant you may use :class:`auto` instances and an " @@ -579,31 +617,34 @@ msgstr "" "重要,你可以使用 :class:`auto` 實例,它會為你選擇合適的值。更多細節請參考 :" "class:`auto`。" -#: ../../library/enum.rst:281 +#: ../../library/enum.rst:296 msgid "" "While mutable/unhashable values, such as :class:`dict`, :class:`list` or a " "mutable :class:`~dataclasses.dataclass`, can be used, they will have a " "quadratic performance impact during creation relative to the total number of " "mutable/unhashable values in the enum." msgstr "" +"雖然可以使用可變的 (mutable) / 不可雜湊的 (unhashable) 值,例如 :class:" +"`dict`、:class:`list` 或可變的 :class:`~dataclasses.dataclass`,它們在建立期" +"間會對效能產生相對於列舉中可變的 / 不可雜湊的值總數量的二次方影響。" -#: ../../library/enum.rst:288 +#: ../../library/enum.rst:303 msgid "Name of the member." msgstr "成員名稱。" -#: ../../library/enum.rst:296 +#: ../../library/enum.rst:311 msgid "" "No longer used, kept for backward compatibility. (class attribute, removed " "during class creation)." msgstr "已不再使用,只為了向後相容而保留(類別屬性,在類別建立時移除)" -#: ../../library/enum.rst:301 +#: ../../library/enum.rst:316 msgid "" "``_ignore_`` is only used during creation and is removed from the " "enumeration once creation is complete." msgstr "``_ignore_`` 只有在建立的時候用到,在列舉建立完成後會被移除。" -#: ../../library/enum.rst:304 +#: ../../library/enum.rst:319 msgid "" "``_ignore_`` is a list of names that will not become members, and whose " "names will also be removed from the completed enumeration. See :ref:" @@ -612,7 +653,7 @@ msgstr "" "``_ignore_`` 是一個不會變成成員的名稱串列,在列舉建立完成後其名稱會被移除。範" "例請參考 :ref:`TimePeriod `。" -#: ../../library/enum.rst:310 +#: ../../library/enum.rst:325 msgid "" "Returns ``['__class__', '__doc__', '__module__', 'name', 'value']`` and any " "public methods defined on *self.__class__*::" @@ -620,7 +661,7 @@ msgstr "" "回傳 ``['__class__', '__doc__', '__module__', 'name', 'value']`` 及任何 " "*self.__class__* 上定義的公開方法: ::" -#: ../../library/enum.rst:313 +#: ../../library/enum.rst:328 msgid "" ">>> from datetime import date\n" ">>> class Weekday(Enum):\n" @@ -660,11 +701,11 @@ msgstr "" msgid "name" msgstr "name" -#: ../../library/enum.rst:331 +#: ../../library/enum.rst:346 msgid "The name of the member being defined (e.g. 'RED')." msgstr "定義的成員名稱(例如 'RED')。" -#: ../../library/enum.rst:332 +#: ../../library/enum.rst:347 msgid "The start value for the Enum; the default is 1." msgstr "列舉的開始值,預設為 1。" @@ -672,7 +713,7 @@ msgstr "列舉的開始值,預設為 1。" msgid "count" msgstr "count" -#: ../../library/enum.rst:333 +#: ../../library/enum.rst:348 msgid "The number of members currently defined, not including this one." msgstr "已定義的成員數量,不包含目前這一個。" @@ -680,17 +721,17 @@ msgstr "已定義的成員數量,不包含目前這一個。" msgid "last_values" msgstr "last_values" -#: ../../library/enum.rst:334 +#: ../../library/enum.rst:349 msgid "A list of the previous values." msgstr "一個之前值的串列。" -#: ../../library/enum.rst:336 +#: ../../library/enum.rst:351 msgid "" "A *staticmethod* that is used to determine the next value returned by :class:" "`auto`::" msgstr "一個 *staticmethod*,用來決定 :class:`auto` 下一個要回傳的值的: ::" -#: ../../library/enum.rst:339 +#: ../../library/enum.rst:354 msgid "" ">>> from enum import auto\n" ">>> class PowersOfThree(Enum):\n" @@ -714,7 +755,7 @@ msgstr "" ">>> PowersOfThree.SECOND.value\n" "9" -#: ../../library/enum.rst:352 +#: ../../library/enum.rst:367 msgid "" "By default, does nothing. If multiple values are given in the member " "assignment, those values become separate arguments to ``__init__``; e.g." @@ -722,19 +763,19 @@ msgstr "" "預設情況下,不執行任何操作。如果在成員賦值中給出多個值,這些值將成為與 " "``__init__`` 分別的引數;例如" -#: ../../library/enum.rst:359 +#: ../../library/enum.rst:374 msgid "" "``Weekday.__init__()`` would be called as ``Weekday.__init__(self, 1, " "'Mon')``" msgstr "``Weekday.__init__()`` 將被稱為 ``Weekday.__init__(self, 1, 'Mon')``" -#: ../../library/enum.rst:363 +#: ../../library/enum.rst:378 msgid "" "A *classmethod* that is used to further configure subsequent subclasses. By " "default, does nothing." msgstr "一個 *classmethod*,用來進一步設定後續的子類別,預設不做任何事。" -#: ../../library/enum.rst:368 +#: ../../library/enum.rst:383 msgid "" "A *classmethod* for looking up values not found in *cls*. By default it " "does nothing, but can be overridden to implement custom search behavior::" @@ -742,7 +783,7 @@ msgstr "" "一個 *classmethod*,用來查詢在 *cls* 裡找不到的值。預設不做任何事,但可以被覆" "寫以實作客製化的搜尋行為: ::" -#: ../../library/enum.rst:371 +#: ../../library/enum.rst:386 msgid "" ">>> from enum import StrEnum\n" ">>> class Build(StrEnum):\n" @@ -778,7 +819,7 @@ msgstr "" ">>> Build('deBUG')\n" "" -#: ../../library/enum.rst:390 +#: ../../library/enum.rst:405 msgid "" "By default, doesn't exist. If specified, either in the enum class " "definition or in a mixin class (such as ``int``), all values given in the " @@ -787,12 +828,12 @@ msgstr "" "預設情況下不存在。如果有指定,無論是在列舉類別定義中還是在 mixin 類別中(例" "如 ``int``\\ ),都將傳遞成員賦值中給出的所有值;例如" -#: ../../library/enum.rst:398 +#: ../../library/enum.rst:413 msgid "" "results in the call ``int('1a', 16)`` and a value of ``26`` for the member." -msgstr "" +msgstr "會產生呼叫 ``int('1a', 16)`` 而該成員的值為 ``26``。" -#: ../../library/enum.rst:402 +#: ../../library/enum.rst:417 msgid "" "When writing a custom ``__new__``, do not use ``super().__new__`` -- call " "the appropriate ``__new__`` instead." @@ -800,7 +841,7 @@ msgstr "" "當寫自訂的 ``__new__`` 時,不要使用 ``super().__new__``,而是要呼叫適當的 " "``__new__``。" -#: ../../library/enum.rst:407 +#: ../../library/enum.rst:422 msgid "" "Returns the string used for *repr()* calls. By default, returns the *Enum* " "name, member name, and value, but can be overridden::" @@ -808,7 +849,7 @@ msgstr "" "回傳呼叫 *repr()* 時使用的字串。預設回傳 *Enum* 名稱、成員名稱及值,但可以被" "覆寫: ::" -#: ../../library/enum.rst:410 +#: ../../library/enum.rst:425 msgid "" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" @@ -834,7 +875,7 @@ msgstr "" "ALTERNATE}\"\n" "(OtherStyle.ALTERNATE, 'OtherStyle.ALTERNATE', 'OtherStyle.ALTERNATE')" -#: ../../library/enum.rst:423 +#: ../../library/enum.rst:438 msgid "" "Returns the string used for *str()* calls. By default, returns the *Enum* " "name and member name, but can be overridden::" @@ -842,7 +883,7 @@ msgstr "" "回傳呼叫 *str()* 時使用的字串。預設回傳 *Enum* 名稱及成員名稱,但可以被覆" "寫: ::" -#: ../../library/enum.rst:426 +#: ../../library/enum.rst:441 msgid "" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" @@ -866,7 +907,7 @@ msgstr "" "ALTERNATE}\"\n" "(, 'ALTERNATE', 'ALTERNATE')" -#: ../../library/enum.rst:438 +#: ../../library/enum.rst:453 msgid "" "Returns the string used for *format()* and *f-string* calls. By default, " "returns :meth:`__str__` return value, but can be overridden::" @@ -874,7 +915,7 @@ msgstr "" "回傳呼叫 *format()* 及 *f-string* 時使用的字串。預設回傳 :meth:`__str__` 的回" "傳值,但可以被覆寫: ::" -#: ../../library/enum.rst:441 +#: ../../library/enum.rst:456 msgid "" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" @@ -898,33 +939,33 @@ msgstr "" "ALTERNATE}\"\n" "(, 'OtherStyle.ALTERNATE', 'ALTERNATE')" -#: ../../library/enum.rst:453 +#: ../../library/enum.rst:468 msgid "" "Using :class:`auto` with :class:`Enum` results in integers of increasing " "value, starting with ``1``." msgstr ":class:`Enum` 使用 :class:`auto` 會產生從 ``1`` 開始遞增的整數。" -#: ../../library/enum.rst:456 +#: ../../library/enum.rst:471 msgid "Added :ref:`enum-dataclass-support`" msgstr "新增 :ref:`enum-dataclass-support`" -#: ../../library/enum.rst:461 +#: ../../library/enum.rst:476 msgid "" -"*IntEnum* is the same as *Enum*, but its members are also integers and can " -"be used anywhere that an integer can be used. If any integer operation is " -"performed with an *IntEnum* member, the resulting value loses its " -"enumeration status." +"*IntEnum* is the same as :class:`Enum`, but its members are also integers " +"and can be used anywhere that an integer can be used. If any integer " +"operation is performed with an *IntEnum* member, the resulting value loses " +"its enumeration status." msgstr "" -"*IntEnum* 和 *Enum* 一樣,但其成員同時也是整數而可以被用在任何使用整數的地" -"方。如果 *IntEnum* 成員經過任何整數運算,其結果會失去列舉狀態。" +"*IntEnum* 和 :class:`Enum` 一樣,但其成員同時也是整數而可以被用在任何使用整數" +"的地方。如果 *IntEnum* 成員經過任何整數運算,結果值會失去其列舉狀態。" -#: ../../library/enum.rst:482 +#: ../../library/enum.rst:497 msgid "" "Using :class:`auto` with :class:`IntEnum` results in integers of increasing " "value, starting with ``1``." msgstr ":class:`IntEnum` 使用 :class:`auto` 會產生從 ``1`` 開始遞增的整數。" -#: ../../library/enum.rst:485 +#: ../../library/enum.rst:500 msgid "" ":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` was " @@ -934,34 +975,34 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!int.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 已經是 :meth:`!int.__format__`。" -#: ../../library/enum.rst:492 +#: ../../library/enum.rst:507 msgid "" -"*StrEnum* is the same as *Enum*, but its members are also strings and can be " -"used in most of the same places that a string can be used. The result of " -"any string operation performed on or with a *StrEnum* member is not part of " -"the enumeration." +"*StrEnum* is the same as :class:`Enum`, but its members are also strings and " +"can be used in most of the same places that a string can be used. The result " +"of any string operation performed on or with a *StrEnum* member is not part " +"of the enumeration." msgstr "" -"*StrEnum* 和 *Enum* 一樣,但其成員同時也是字串而可以被用在幾乎所有使用字串的" -"地方。*StrEnum* 成員經過任何字串操作的結果會不再是列舉的一部份。" +"*StrEnum* 和 :class:`Enum` 一樣,但其成員同時也是字串而可以被用在幾乎所有使" +"用字串的地方。*StrEnum* 成員經過任何字串操作的結果會不再是列舉的一部份。" -#: ../../library/enum.rst:498 +#: ../../library/enum.rst:528 msgid "" "There are places in the stdlib that check for an exact :class:`str` instead " "of a :class:`str` subclass (i.e. ``type(unknown) == str`` instead of " "``isinstance(unknown, str)``), and in those locations you will need to use " -"``str(StrEnum.member)``." +"``str(MyStrEnum.MY_MEMBER)``." msgstr "" "stdlib 裡有些地方會檢查只能是 :class:`str` 而不是 :class:`str` 的子類別(也就" "是 ``type(unknown) == str`` 而不是 ``isinstance(unknown, str)``),在這些地方" -"你需要使用 ``str(StrEnum.member)``。" +"你需要使用 ``str(MyStrEnum.MY_MEMBER)``。" -#: ../../library/enum.rst:505 +#: ../../library/enum.rst:535 msgid "" "Using :class:`auto` with :class:`StrEnum` results in the lower-cased member " "name as the value." msgstr ":class:`StrEnum` 使用 :class:`auto` 會產生小寫的成員名稱當作值。" -#: ../../library/enum.rst:510 +#: ../../library/enum.rst:540 msgid "" ":meth:`~object.__str__` is :meth:`!str.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` is " @@ -971,7 +1012,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!str.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 也會是 :meth:`!str.__format__`。" -#: ../../library/enum.rst:518 +#: ../../library/enum.rst:548 msgid "" "``Flag`` is the same as :class:`Enum`, but its members support the bitwise " "operators ``&`` (*AND*), ``|`` (*OR*), ``^`` (*XOR*), and ``~`` (*INVERT*); " @@ -981,11 +1022,11 @@ msgstr "" "(*OR*)、``^`` (*XOR*) 和 ``~`` (*INVERT*);這些操作的結果是列舉的成員(的別" "名)。" -#: ../../library/enum.rst:524 +#: ../../library/enum.rst:554 msgid "Returns *True* if value is in self::" msgstr "如果 value 在 self 裡則回傳 *True*: ::" -#: ../../library/enum.rst:526 +#: ../../library/enum.rst:556 msgid "" ">>> from enum import Flag, auto\n" ">>> class Color(Flag):\n" @@ -1021,11 +1062,11 @@ msgstr "" ">>> white in purple\n" "False" -#: ../../library/enum.rst:545 +#: ../../library/enum.rst:575 msgid "Returns all contained non-alias members::" msgstr "回傳所有包含的非別名成員: ::" -#: ../../library/enum.rst:547 +#: ../../library/enum.rst:577 msgid "" ">>> list(Color.RED)\n" "[]\n" @@ -1037,11 +1078,11 @@ msgstr "" ">>> list(purple)\n" "[, ]" -#: ../../library/enum.rst:556 +#: ../../library/enum.rst:586 msgid "Returns number of members in flag::" msgstr "回傳旗標裡的成員數量: ::" -#: ../../library/enum.rst:558 +#: ../../library/enum.rst:588 msgid "" ">>> len(Color.GREEN)\n" "1\n" @@ -1053,11 +1094,11 @@ msgstr "" ">>> len(white)\n" "3" -#: ../../library/enum.rst:567 +#: ../../library/enum.rst:597 msgid "Returns *True* if any members in flag, *False* otherwise::" msgstr "如果成員在旗標裡則回傳 *True*,否則回傳 *False*: ::" -#: ../../library/enum.rst:569 +#: ../../library/enum.rst:599 msgid "" ">>> bool(Color.GREEN)\n" "True\n" @@ -1075,11 +1116,11 @@ msgstr "" ">>> bool(black)\n" "False" -#: ../../library/enum.rst:579 +#: ../../library/enum.rst:609 msgid "Returns current flag binary or'ed with other::" msgstr "回傳和 other 做 OR 過後的二進位旗標: ::" -#: ../../library/enum.rst:581 +#: ../../library/enum.rst:611 msgid "" ">>> Color.RED | Color.GREEN\n" "" @@ -1087,11 +1128,11 @@ msgstr "" ">>> Color.RED | Color.GREEN\n" "" -#: ../../library/enum.rst:586 +#: ../../library/enum.rst:616 msgid "Returns current flag binary and'ed with other::" msgstr "回傳和 other 做 AND 過後的二進位旗標: ::" -#: ../../library/enum.rst:588 +#: ../../library/enum.rst:618 msgid "" ">>> purple & white\n" "\n" @@ -1103,11 +1144,11 @@ msgstr "" ">>> purple & Color.GREEN\n" "" -#: ../../library/enum.rst:595 +#: ../../library/enum.rst:625 msgid "Returns current flag binary xor'ed with other::" msgstr "回傳和 other 做 XOR 過後的二進位旗標: ::" -#: ../../library/enum.rst:597 +#: ../../library/enum.rst:627 msgid "" ">>> purple ^ white\n" "\n" @@ -1119,11 +1160,11 @@ msgstr "" ">>> purple ^ Color.GREEN\n" "" -#: ../../library/enum.rst:604 -msgid "Returns all the flags in *type(self)* that are not in self::" -msgstr "回傳所有在 *type(self)* 但不在 self 裡的旗標: ::" +#: ../../library/enum.rst:634 +msgid "Returns all the flags in *type(self)* that are not in *self*::" +msgstr "回傳所有在 *type(self)* 但不在 *self* 裡的旗標: ::" -#: ../../library/enum.rst:606 +#: ../../library/enum.rst:636 msgid "" ">>> ~white\n" "\n" @@ -1139,7 +1180,7 @@ msgstr "" ">>> ~Color.RED\n" "" -#: ../../library/enum.rst:615 +#: ../../library/enum.rst:645 msgid "" "Function used to format any remaining unnamed numeric values. Default is " "the value's repr; common choices are :func:`hex` and :func:`oct`." @@ -1147,31 +1188,31 @@ msgstr "" "用來格式化任何剩下未命名數值的函式。預設是值的 repr,常見選擇是 :func:`hex` " "和 :func:`oct`。" -#: ../../library/enum.rst:620 +#: ../../library/enum.rst:650 msgid "" "Using :class:`auto` with :class:`Flag` results in integers that are powers " "of two, starting with ``1``." msgstr ":class:`Flag` 使用 :class:`auto` 會產生從 ``1`` 開始 2 的次方的整數。" -#: ../../library/enum.rst:623 +#: ../../library/enum.rst:653 msgid "The *repr()* of zero-valued flags has changed. It is now::" msgstr "值為 0 的旗標的 *repr()* 已改變。現在是: ::" -#: ../../library/enum.rst:631 +#: ../../library/enum.rst:661 msgid "" -"*IntFlag* is the same as *Flag*, but its members are also integers and can " -"be used anywhere that an integer can be used." +"``IntFlag`` is the same as :class:`Flag`, but its members are also integers " +"and can be used anywhere that an integer can be used." msgstr "" -"*IntFlag* 和 *Flag* 一樣,但其成員同時也是整數而可以被用在任何使用整數的地" -"方。" +"``IntFlag`` 和 :class:`Flag` 一樣,但其成員同時也是整數而可以被用在任何使用整" +"數的地方。" -#: ../../library/enum.rst:645 +#: ../../library/enum.rst:675 msgid "" "If any integer operation is performed with an *IntFlag* member, the result " "is not an *IntFlag*::" msgstr "如果 *IntFlag* 成員經過任何整數運算,其結果不是 *IntFlag*: ::" -#: ../../library/enum.rst:648 +#: ../../library/enum.rst:678 msgid "" ">>> Color.RED + 2\n" "3" @@ -1179,32 +1220,32 @@ msgstr "" ">>> Color.RED + 2\n" "3" -#: ../../library/enum.rst:651 -msgid "If a *Flag* operation is performed with an *IntFlag* member and:" -msgstr "如果 *IntFlag* 成員經過 *Flag* 操作且:" +#: ../../library/enum.rst:681 +msgid "If a :class:`Flag` operation is performed with an *IntFlag* member and:" +msgstr "如果 *IntFlag* 成員經過 :class:`Flag` 操作且:" -#: ../../library/enum.rst:653 +#: ../../library/enum.rst:683 msgid "the result is a valid *IntFlag*: an *IntFlag* is returned" msgstr "結果是合法的 *IntFlag*:回傳 *IntFlag*" -#: ../../library/enum.rst:654 +#: ../../library/enum.rst:684 msgid "" -"the result is not a valid *IntFlag*: the result depends on the " -"*FlagBoundary* setting" -msgstr "結果不是合法的 *IntFlag*:結果會根據 *FlagBoundary* 的設定" +"the result is not a valid *IntFlag*: the result depends on the :class:" +"`FlagBoundary` setting" +msgstr "結果不是合法的 *IntFlag*:結果會根據 :class:`FlagBoundary` 的設定" -#: ../../library/enum.rst:656 -msgid "The *repr()* of unnamed zero-valued flags has changed. It is now:" -msgstr "未命名且值為 0 的旗標的 *repr()* 已改變。現在是: ::" +#: ../../library/enum.rst:686 +msgid "The :func:`repr` of unnamed zero-valued flags has changed. It is now:" +msgstr "未命名且值為 0 的旗標的 :func:`repr` 已改變。現在是:" -#: ../../library/enum.rst:663 +#: ../../library/enum.rst:693 msgid "" "Using :class:`auto` with :class:`IntFlag` results in integers that are " "powers of two, starting with ``1``." msgstr "" ":class:`IntFlag` 使用 :class:`auto` 會產生從 ``1`` 開始 2 的次方的整數。" -#: ../../library/enum.rst:668 +#: ../../library/enum.rst:698 msgid "" ":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` " @@ -1214,7 +1255,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!int.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 已經是 :meth:`!int.__format__`。" -#: ../../library/enum.rst:672 +#: ../../library/enum.rst:702 msgid "" "Inversion of an :class:`!IntFlag` now returns a positive value that is the " "union of all flags not in the given flag, rather than a negative value. This " @@ -1223,32 +1264,32 @@ msgstr "" ":class:`!IntFlag` 的反轉 (inversion) 現在會回傳正值,該值是不在給定旗標的所有" "旗標聯集,而不是一個負值。這符合現有 :class:`Flag` 的行為。" -#: ../../library/enum.rst:678 +#: ../../library/enum.rst:708 msgid "" ":class:`!ReprEnum` uses the :meth:`repr() ` of :class:`Enum`, " "but the :class:`str() ` of the mixed-in data type:" msgstr "" ":class:`!ReprEnum` 使用 :class:`Enum` 的 :meth:`repr() `,但使" -"用混合資料類型的 :class:`str() `:" +"用混合資料型別的 :class:`str() `:" -#: ../../library/enum.rst:681 +#: ../../library/enum.rst:711 msgid ":meth:`!int.__str__` for :class:`IntEnum` and :class:`IntFlag`" msgstr "對 :class:`IntEnum` 和 :class:`IntFlag` 是 :meth:`!int.__str__`" -#: ../../library/enum.rst:682 +#: ../../library/enum.rst:712 msgid ":meth:`!str.__str__` for :class:`StrEnum`" msgstr "對 :class:`StrEnum` 是 :meth:`!str.__str__`" -#: ../../library/enum.rst:684 +#: ../../library/enum.rst:714 msgid "" "Inherit from :class:`!ReprEnum` to keep the :class:`str() ` / :func:" "`format` of the mixed-in data type instead of using the :class:`Enum`-" "default :meth:`str() `." msgstr "" -"繼承 :class:`!ReprEnum` 來保留混合資料類型的 :class:`str() ` / :func:" +"繼承 :class:`!ReprEnum` 來保留混合資料型別的 :class:`str() ` / :func:" "`format`,而不是使用 :class:`Enum` 預設的 :meth:`str() `。" -#: ../../library/enum.rst:693 +#: ../../library/enum.rst:723 msgid "" "*EnumCheck* contains the options used by the :func:`verify` decorator to " "ensure various constraints; failed constraints result in a :exc:`ValueError`." @@ -1256,11 +1297,11 @@ msgstr "" "*EnumCheck* 包含 :func:`verify` 裝飾器使用的選項,以確保多樣的限制,不符合限" "制會產生 :exc:`ValueError`。" -#: ../../library/enum.rst:698 +#: ../../library/enum.rst:728 msgid "Ensure that each value has only one name::" msgstr "確保每個值只有一個名稱: ::" -#: ../../library/enum.rst:700 +#: ../../library/enum.rst:730 msgid "" ">>> from enum import Enum, verify, UNIQUE\n" ">>> @verify(UNIQUE)\n" @@ -1284,13 +1325,13 @@ msgstr "" "...\n" "ValueError: aliases found in : CRIMSON -> RED" -#: ../../library/enum.rst:714 +#: ../../library/enum.rst:744 msgid "" "Ensure that there are no missing values between the lowest-valued member and " "the highest-valued member::" msgstr "確保在最小值成員跟最大值成員間沒有缺少值: ::" -#: ../../library/enum.rst:717 +#: ../../library/enum.rst:747 msgid "" ">>> from enum import Enum, verify, CONTINUOUS\n" ">>> @verify(CONTINUOUS)\n" @@ -1312,7 +1353,7 @@ msgstr "" "...\n" "ValueError: invalid enum 'Color': missing values 3, 4" -#: ../../library/enum.rst:729 +#: ../../library/enum.rst:759 msgid "" "Ensure that any flag groups/masks contain only named flags -- useful when " "values are specified instead of being generated by :func:`auto`::" @@ -1320,7 +1361,7 @@ msgstr "" "確保任何旗標群組 / 遮罩只包含命名旗標 -- 當值是用指定而不是透過 :func:`auto` " "產生時是很實用的: ::" -#: ../../library/enum.rst:732 +#: ../../library/enum.rst:762 msgid "" ">>> from enum import Flag, verify, NAMED_FLAGS\n" ">>> @verify(NAMED_FLAGS)\n" @@ -1348,24 +1389,24 @@ msgstr "" "ValueError: invalid Flag 'Color': aliases WHITE and NEON are missing " "combined values of 0x18 [use enum.show_flag_values(value) for details]" -#: ../../library/enum.rst:746 +#: ../../library/enum.rst:776 msgid "" "CONTINUOUS and NAMED_FLAGS are designed to work with integer-valued members." msgstr "CONTINUOUS 和 NAMED_FLAGS 是設計用來運作在整數值的成員上。" -#: ../../library/enum.rst:752 +#: ../../library/enum.rst:782 msgid "" -"*FlagBoundary* controls how out-of-range values are handled in *Flag* and " -"its subclasses." -msgstr "*FlagBoundary* 控制在 *Flag* 及其子類別中如何處理範圍外的值。" +"``FlagBoundary`` controls how out-of-range values are handled in :class:" +"`Flag` and its subclasses." +msgstr "``FlagBoundary`` 控制在 :class:`Flag` 及其子類別中如何處理範圍外的值。" -#: ../../library/enum.rst:757 +#: ../../library/enum.rst:787 msgid "" "Out-of-range values cause a :exc:`ValueError` to be raised. This is the " "default for :class:`Flag`::" msgstr "範圍外的值會引發 :exc:`ValueError`。這是 :class:`Flag` 的預設行為: ::" -#: ../../library/enum.rst:760 +#: ../../library/enum.rst:790 msgid "" ">>> from enum import Flag, STRICT, auto\n" ">>> class StrictFlag(Flag, boundary=STRICT):\n" @@ -1393,13 +1434,13 @@ msgstr "" " given 0b0 10100\n" " allowed 0b0 00111" -#: ../../library/enum.rst:775 +#: ../../library/enum.rst:805 msgid "" -"Out-of-range values have invalid values removed, leaving a valid *Flag* " -"value::" -msgstr "範圍外的值會移除非法值,留下合法的 *Flag* 值: ::" +"Out-of-range values have invalid values removed, leaving a valid :class:" +"`Flag` value::" +msgstr "會移除範圍外的值中的非法值,留下合法的 :class:`Flag` 值: ::" -#: ../../library/enum.rst:778 +#: ../../library/enum.rst:808 msgid "" ">>> from enum import Flag, CONFORM, auto\n" ">>> class ConformFlag(Flag, boundary=CONFORM):\n" @@ -1419,20 +1460,21 @@ msgstr "" ">>> ConformFlag(2**2 + 2**4)\n" "" -#: ../../library/enum.rst:789 +#: ../../library/enum.rst:819 msgid "" -"Out-of-range values lose their *Flag* membership and revert to :class:`int`." -msgstr "範圍外的值會失去它們的 *Flag* 成員資格且恢復成 :class:`int`。" +"Out-of-range values lose their :class:`Flag` membership and revert to :class:" +"`int`." +msgstr "範圍外的值會失去它們的 :class:`Flag` 成員資格且恢復成 :class:`int`。" -#: ../../library/enum.rst:802 +#: ../../library/enum.rst:832 msgid "" -"Out-of-range values are kept, and the *Flag* membership is kept. This is the " -"default for :class:`IntFlag`::" +"Out-of-range values are kept, and the :class:`Flag` membership is kept. This " +"is the default for :class:`IntFlag`::" msgstr "" -"範圍外的值會被保留,*Flag* 成員資格也會被保留。這是 :class:`IntFlag` 的預設行" -"為: ::" +"範圍外的值會被保留,:class:`Flag` 成員資格也會被保留。這是 :class:`IntFlag` " +"的預設行為: ::" -#: ../../library/enum.rst:805 +#: ../../library/enum.rst:835 msgid "" ">>> from enum import Flag, KEEP, auto\n" ">>> class KeepFlag(Flag, boundary=KEEP):\n" @@ -1452,11 +1494,40 @@ msgstr "" ">>> KeepFlag(2**2 + 2**4)\n" "" -#: ../../library/enum.rst:819 +#: ../../library/enum.rst:848 +msgid "" +"*EnumDict* is a subclass of :class:`dict` that is used as the namespace for " +"defining enum classes (see :ref:`prepare`). It is exposed to allow " +"subclasses of :class:`EnumType` with advanced behavior like having multiple " +"values per member. It should be called with the name of the enum class being " +"created, otherwise private names and internal classes will not be handled " +"correctly." +msgstr "" +"*EnumDict* 是 :class:`dict` 的子類別,用來作為定義列舉類別的命名空間(參見 :" +"ref:`prepare`)。它被公開來使得 :class:`EnumType` 的子類別能具有進階行為,例" +"如讓每個成員有多個值。它應該在被呼叫時帶上正在建立的列舉類別名稱,否則私有名" +"稱和內部類別將無法被正確處理。" + +#: ../../library/enum.rst:855 +msgid "" +"Note that only the :class:`~collections.abc.MutableMapping` interface (:meth:" +"`~object.__setitem__` and :meth:`~dict.update`) is overridden. It may be " +"possible to bypass the checks using other :class:`!dict` operations like :" +"meth:`|= `." +msgstr "" +"注意只有 :class:`~collections.abc.MutableMapping` 介面(:meth:`~object." +"__setitem__` 和 :meth:`~dict.update`)被覆寫。可能可以使用其他 :class:`!" +"dict` 操作來繞過檢查,例如 :meth:`|= `。" + +#: ../../library/enum.rst:862 +msgid "A list of member names." +msgstr "一個成員名稱的串列。" + +#: ../../library/enum.rst:869 msgid "Supported ``__dunder__`` names" -msgstr "支援 ``__dunder__`` 名稱" +msgstr "支援的 ``__dunder__`` 名稱" -#: ../../library/enum.rst:821 +#: ../../library/enum.rst:871 msgid "" ":attr:`~EnumType.__members__` is a read-only ordered mapping of " "``member_name``:``member`` items. It is only available on the class." @@ -1464,36 +1535,48 @@ msgstr "" ":attr:`~EnumType.__members__` 是一個唯讀有序的\\ ``成員名稱``:``成員``\\ 項" "目的對映。只有在類別上可用。" -#: ../../library/enum.rst:824 +#: ../../library/enum.rst:874 msgid "" ":meth:`~Enum.__new__`, if specified, must create and return the enum " "members; it is also a very good idea to set the member's :attr:`!_value_` " -"appropriately. Once all the members are created it is no longer used." +"appropriately. Once all the members are created it is no longer used." msgstr "" -"如果指定了 :meth:`~Enum.__new__`,它必須建立並回傳列舉成員;適當地設定成員" +":meth:`~Enum.__new__`,如果有指定,它必須建立並回傳列舉成員;適當地設定成員" "的 :attr:`!_value_` 也是一個很好的主意。一旦所有成員都建立之後就不會再被用" "到。" -#: ../../library/enum.rst:830 +#: ../../library/enum.rst:880 msgid "Supported ``_sunder_`` names" -msgstr "支援 ``_sunder_`` 名稱" +msgstr "支援的 ``_sunder_`` 名稱" -#: ../../library/enum.rst:832 +#: ../../library/enum.rst:882 +msgid "" +":meth:`~EnumType._add_alias_` -- adds a new name as an alias to an existing " +"member." +msgstr ":meth:`~EnumType._add_alias_` -- 新增一個名稱作為現有成員的別名。" + +#: ../../library/enum.rst:884 +msgid "" +":meth:`~EnumType._add_value_alias_` -- adds a new value as an alias to an " +"existing member." +msgstr ":meth:`~EnumType._add_value_alias_` -- 新增一個值作為現有成員的別名。" + +#: ../../library/enum.rst:886 msgid ":attr:`~Enum._name_` -- name of the member" msgstr ":attr:`~Enum._name_` -- 成員名稱" -#: ../../library/enum.rst:833 +#: ../../library/enum.rst:887 msgid ":attr:`~Enum._value_` -- value of the member; can be set in ``__new__``" msgstr ":attr:`~Enum._value_` -- 成員的值;可以在 ``__new__`` 設定" -#: ../../library/enum.rst:834 +#: ../../library/enum.rst:888 msgid "" ":meth:`~Enum._missing_` -- a lookup function used when a value is not found; " "may be overridden" msgstr "" ":meth:`~Enum._missing_` -- 當值沒有被找到時會使用的查詢函式;可以被覆寫" -#: ../../library/enum.rst:836 +#: ../../library/enum.rst:890 msgid "" ":attr:`~Enum._ignore_` -- a list of names, either as a :class:`list` or a :" "class:`str`, that will not be transformed into members, and will be removed " @@ -1502,7 +1585,7 @@ msgstr "" ":attr:`~Enum._ignore_` -- 一個名稱的串列,可以是 :class:`list` 或 :class:" "`str`,它不會被轉換成成員,且在最後的類別上會被移除" -#: ../../library/enum.rst:839 +#: ../../library/enum.rst:893 msgid "" ":attr:`~Enum._order_` -- no longer used, kept for backward compatibility " "(class attribute, removed during class creation)" @@ -1510,66 +1593,84 @@ msgstr "" ":attr:`~Enum._order_` -- 不再被使用,僅為了向後相容而保留(類別屬性,在類別建" "立時移除)" -#: ../../library/enum.rst:841 +#: ../../library/enum.rst:895 msgid "" ":meth:`~Enum._generate_next_value_` -- used to get an appropriate value for " "an enum member; may be overridden" msgstr "" ":meth:`~Enum._generate_next_value_` -- 用來為列舉成員取得合適的值;可以被覆寫" -#: ../../library/enum.rst:846 +#: ../../library/enum.rst:900 msgid "" -"For standard :class:`Enum` classes the next value chosen is the last value " -"seen incremented by one." +"For standard :class:`Enum` classes the next value chosen is the highest " +"value seen incremented by one." msgstr "" -"對標準的 :class:`Enum` 類別來說,下一個被選擇的值是最後一個看見的值加一。" +"對標準的 :class:`Enum` 類別來說,下一個被選擇的值是所看過的最大值加一。" -#: ../../library/enum.rst:849 +#: ../../library/enum.rst:903 msgid "" "For :class:`Flag` classes the next value chosen will be the next highest " -"power-of-two, regardless of the last value seen." +"power-of-two." msgstr "" -"對 :class:`Flag` 類別來說,下一個被選擇的值是下一個最大的 2 的次方,不管最後" -"一個看見的值是什麼。" +"對 :class:`Flag` 類別來說,下一個被選擇的值是下一個最大的 2 的次方的數字。" -#: ../../library/enum.rst:852 +#: ../../library/enum.rst:906 +msgid "" +"While ``_sunder_`` names are generally reserved for the further development " +"of the :class:`Enum` class and can not be used, some are explicitly allowed:" +msgstr "" +"雖然 ``_sunder_`` 名稱通常保留用於 :class:`Enum` 類別的進一步開發而不能被使" +"用,但有些是明確允許的:" + +#: ../../library/enum.rst:909 +msgid "" +"``_repr_*`` (e.g. ``_repr_html_``), as used in `IPython's rich display`_" +msgstr "" +"``_repr_*``\\ (例如 ``_repr_html_``),例如用於 `IPython 的豐富顯示 " +"`_" + +#: ../../library/enum.rst:911 msgid "``_missing_``, ``_order_``, ``_generate_next_value_``" msgstr "``_missing_``、``_order_``、``_generate_next_value_``" -#: ../../library/enum.rst:853 +#: ../../library/enum.rst:912 msgid "``_ignore_``" msgstr "``_ignore_``" -#: ../../library/enum.rst:858 +#: ../../library/enum.rst:913 +msgid "``_add_alias_``, ``_add_value_alias_``, ``_repr_*``" +msgstr "``_add_alias_``、``_add_value_alias_``、``_repr_*``" + +#: ../../library/enum.rst:919 msgid "Utilities and Decorators" msgstr "通用項目與裝飾器" -#: ../../library/enum.rst:862 +#: ../../library/enum.rst:923 msgid "" "*auto* can be used in place of a value. If used, the *Enum* machinery will " -"call an *Enum*'s :meth:`~Enum._generate_next_value_` to get an appropriate " -"value. For *Enum* and *IntEnum* that appropriate value will be the last " -"value plus one; for *Flag* and *IntFlag* it will be the first power-of-two " -"greater than the highest value; for *StrEnum* it will be the lower-cased " -"version of the member's name. Care must be taken if mixing *auto()* with " -"manually specified values." -msgstr "" -"*auto* 可以用來取代給值。如果使用的話,*Enum* 系統會呼叫 *Enum* 的 :meth:" -"`~Enum._generate_next_value_` 來取得合適的值。對 *Enum* 和 *IntEnum* 來說,合" -"適的值是最後一個值加一;對 *Flag* 和 *IntFlag* 來說,是第一個比最大值還大的 " -"2 的次方的數字;對 *StrEnum* 來說,是成員名稱的小寫版本。如果混用 *auto()* 和" -"手動指定值的話要特別注意。" +"call an :class:`Enum`'s :meth:`~Enum._generate_next_value_` to get an " +"appropriate value. For :class:`Enum` and :class:`IntEnum` that appropriate " +"value will be the last value plus one; for :class:`Flag` and :class:" +"`IntFlag` it will be the first power-of-two greater than the highest value; " +"for :class:`StrEnum` it will be the lower-cased version of the member's " +"name. Care must be taken if mixing *auto()* with manually specified values." +msgstr "" +"*auto* 可以用來取代給值。如果使用的話,*Enum* 系統會呼叫 :class:`Enum` 的 :" +"meth:`~Enum._generate_next_value_` 來取得合適的值。對 :class:`Enum` 和 :" +"class:`IntEnum` 來說,合適的值是最後一個值加一;對 :class:`Flag` 和 :class:" +"`IntFlag` 來說,是第一個比最大值還大的 2 的次方的數字;對 :class:`StrEnum` 來" +"說,是成員名稱的小寫版本。如果混用 *auto()* 和手動指定值的話要特別注意。" -#: ../../library/enum.rst:870 +#: ../../library/enum.rst:931 msgid "" "*auto* instances are only resolved when at the top level of an assignment:" msgstr "*auto* 實例只有在最上層的賦值時才會被解析:" -#: ../../library/enum.rst:872 +#: ../../library/enum.rst:933 msgid "``FIRST = auto()`` will work (auto() is replaced with ``1``);" msgstr "``FIRST = auto()`` 可以運作(auto() 會被取代成 ``1``)" -#: ../../library/enum.rst:873 +#: ../../library/enum.rst:934 msgid "" "``SECOND = auto(), -2`` will work (auto is replaced with ``2``, so ``2, -2`` " "is used to create the ``SECOND`` enum member;" @@ -1577,7 +1678,7 @@ msgstr "" "``SECOND = auto(), -2`` 可以運作(auto 會被取代成 ``2``, 因此 ``2, -2`` 會被" "用來建立列舉成員 ``SECOND``;" -#: ../../library/enum.rst:875 +#: ../../library/enum.rst:936 msgid "" "``THREE = [auto(), -3]`` will *not* work (``, -3`` is used to " "create the ``THREE`` enum member)" @@ -1585,28 +1686,28 @@ msgstr "" "``THREE = [auto(), -3]`` *無法*\\ 運作(\\ ``, -3`` 會被用來建立列" "舉成員 ``THREE``)" -#: ../../library/enum.rst:880 +#: ../../library/enum.rst:941 msgid "" "In prior versions, ``auto()`` had to be the only thing on the assignment " "line to work properly." msgstr "在之前的版本中,``auto()`` 必須是賦值行裡的唯一內容才能運作正確。" -#: ../../library/enum.rst:883 +#: ../../library/enum.rst:944 msgid "" "``_generate_next_value_`` can be overridden to customize the values used by " "*auto*." msgstr "可以覆寫 ``_generate_next_value_`` 來客製 *auto* 使用的值。" -#: ../../library/enum.rst:886 +#: ../../library/enum.rst:947 msgid "" "in 3.13 the default ``_generate_next_value_`` will always return the highest " "member value incremented by 1, and will fail if any member is an " "incompatible type." msgstr "" "在 3.13 預設 ``_generate_next_value_`` 總是回傳最大的成員值加一,如果任何成員" -"是不相容的類型就會失敗。" +"是不相容的型別就會失敗。" -#: ../../library/enum.rst:892 +#: ../../library/enum.rst:953 msgid "" "A decorator similar to the built-in *property*, but specifically for " "enumerations. It allows member attributes to have the same names as members " @@ -1615,7 +1716,7 @@ msgstr "" "和內建的 *property* 相似的裝飾器,但只專門針對列舉。它允許成員屬性和成員本身" "有相同名稱。" -#: ../../library/enum.rst:896 +#: ../../library/enum.rst:957 msgid "" "the *property* and the member must be defined in separate classes; for " "example, the *value* and *name* attributes are defined in the *Enum* class, " @@ -1625,7 +1726,7 @@ msgstr "" "*屬性*\\ 和成員必須定義在分開的類別裡;例如 *value* 和 *name* 屬性定義在 " "*Enum* 類別而 *Enum* 子類別可以定義成員名稱為 ``value`` 和 ``name``。" -#: ../../library/enum.rst:905 +#: ../../library/enum.rst:966 msgid "" "A :keyword:`class` decorator specifically for enumerations. It searches an " "enumeration's :attr:`~EnumType.__members__`, gathering any aliases it finds; " @@ -1635,7 +1736,7 @@ msgstr "" "__members__`,蒐集任何它找到的別名;如果有找到任何別名則引發 :exc:" "`ValueError` 並附上細節: ::" -#: ../../library/enum.rst:909 +#: ../../library/enum.rst:970 msgid "" ">>> from enum import Enum, unique\n" ">>> @unique\n" @@ -1661,7 +1762,7 @@ msgstr "" "...\n" "ValueError: duplicate values found in : FOUR -> THREE" -#: ../../library/enum.rst:923 +#: ../../library/enum.rst:984 msgid "" "A :keyword:`class` decorator specifically for enumerations. Members from :" "class:`EnumCheck` are used to specify which constraints should be checked on " @@ -1670,15 +1771,15 @@ msgstr "" "專門針對列舉的 :keyword:`class` 裝飾器。使用 :class:`EnumCheck` 裡的成員來指" "定在裝飾的列舉上應該檢查什麼限制。" -#: ../../library/enum.rst:931 +#: ../../library/enum.rst:992 msgid "A decorator for use in enums: its target will become a member." msgstr "列舉所使用的裝飾器:其目標會變成成員。" -#: ../../library/enum.rst:937 +#: ../../library/enum.rst:998 msgid "A decorator for use in enums: its target will not become a member." msgstr "列舉所使用的裝飾器:其目標不會變成成員。" -#: ../../library/enum.rst:943 +#: ../../library/enum.rst:1004 msgid "" "A decorator to change the :class:`str() ` and :func:`repr` of an enum " "to show its members as belonging to the module instead of its class. Should " @@ -1689,45 +1790,45 @@ msgstr "" "組而不是其類別。應該只有當列舉成員被匯出到模組的全域命名空間才使用(範例請參" "考 :class:`re.RegexFlag`)。" -#: ../../library/enum.rst:953 +#: ../../library/enum.rst:1013 msgid "Return a list of all power-of-two integers contained in a flag *value*." msgstr "回傳在旗標\\ *值*\\ 中包含的所有 2 的次方的整數串列。" -#: ../../library/enum.rst:960 +#: ../../library/enum.rst:1021 msgid "Notes" msgstr "備註" -#: ../../library/enum.rst:962 +#: ../../library/enum.rst:1023 msgid ":class:`IntEnum`, :class:`StrEnum`, and :class:`IntFlag`" msgstr ":class:`IntEnum`、:class:`StrEnum` 及 :class:`IntFlag`" -#: ../../library/enum.rst:964 +#: ../../library/enum.rst:1025 msgid "" "These three enum types are designed to be drop-in replacements for existing " "integer- and string-based values; as such, they have extra limitations:" msgstr "" -"這三種列舉類型是設計來直接取代現有以整數及字串為基底的值;因此它們有額外的限" +"這三種列舉型別是設計來直接取代現有以整數及字串為基底的值;因此它們有額外的限" "制:" -#: ../../library/enum.rst:967 +#: ../../library/enum.rst:1028 msgid "``__str__`` uses the value and not the name of the enum member" msgstr "``__str__`` 使用值而不是列舉成員的名稱" -#: ../../library/enum.rst:969 +#: ../../library/enum.rst:1030 msgid "" "``__format__``, because it uses ``__str__``, will also use the value of the " "enum member instead of its name" msgstr "``__format__`` 因為使用 ``__str__``,也會使用值而不是列舉成員的名稱" -#: ../../library/enum.rst:972 +#: ../../library/enum.rst:1033 msgid "" "If you do not need/want those limitations, you can either create your own " "base class by mixing in the ``int`` or ``str`` type yourself::" msgstr "" -"如果你不需要或不想要這些限制,你可以透過混合 ``int`` 或 ``str`` 類型來建立自" +"如果你不需要或不想要這些限制,你可以透過混合 ``int`` 或 ``str`` 型別來建立自" "己的基礎類別: ::" -#: ../../library/enum.rst:975 +#: ../../library/enum.rst:1036 msgid "" ">>> from enum import Enum\n" ">>> class MyIntEnum(int, Enum):\n" @@ -1737,11 +1838,11 @@ msgstr "" ">>> class MyIntEnum(int, Enum):\n" "... pass" -#: ../../library/enum.rst:979 +#: ../../library/enum.rst:1040 msgid "or you can reassign the appropriate :meth:`str`, etc., in your enum::" msgstr "或者你也可以在你的列舉重新給定合適的 :meth:`str`: ::" -#: ../../library/enum.rst:981 +#: ../../library/enum.rst:1042 msgid "" ">>> from enum import Enum, IntEnum\n" ">>> class MyIntEnum(IntEnum):\n" diff --git a/library/errno.po b/library/errno.po index 6316d82767..53fcac01e5 100644 --- a/library/errno.po +++ b/library/errno.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-09 00:03+0000\n" +"POT-Creation-Date: 2025-01-29 00:13+0000\n" "PO-Revision-Date: 2015-12-09 17:51+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -581,24 +581,128 @@ msgstr "" msgid "Interface output queue is full" msgstr "" -#: ../../library/errno.rst:670 +#: ../../library/errno.rst:671 +msgid "No medium found" +msgstr "" + +#: ../../library/errno.rst:676 +msgid "Wrong medium type" +msgstr "" + +#: ../../library/errno.rst:681 +msgid "Required key not available" +msgstr "" + +#: ../../library/errno.rst:686 +msgid "Key has expired" +msgstr "" + +#: ../../library/errno.rst:691 +msgid "Key has been revoked" +msgstr "" + +#: ../../library/errno.rst:696 +msgid "Key was rejected by service" +msgstr "" + +#: ../../library/errno.rst:701 +msgid "Operation not possible due to RF-kill" +msgstr "" + +#: ../../library/errno.rst:706 +msgid "Locked lock was unmapped" +msgstr "" + +#: ../../library/errno.rst:711 +msgid "Facility is not active" +msgstr "" + +#: ../../library/errno.rst:716 +msgid "Authentication error" +msgstr "" + +#: ../../library/errno.rst:723 +msgid "Bad CPU type in executable" +msgstr "" + +#: ../../library/errno.rst:730 +msgid "Bad executable (or shared library)" +msgstr "" + +#: ../../library/errno.rst:737 +msgid "Malformed Mach-o file" +msgstr "" + +#: ../../library/errno.rst:744 +msgid "Device error" +msgstr "" + +#: ../../library/errno.rst:751 +msgid "Inappropriate file type or format" +msgstr "" + +#: ../../library/errno.rst:758 +msgid "Need authenticator" +msgstr "" + +#: ../../library/errno.rst:765 +msgid "Attribute not found" +msgstr "" + +#: ../../library/errno.rst:772 +msgid "Policy not found" +msgstr "" + +#: ../../library/errno.rst:779 +msgid "Too many processes" +msgstr "" + +#: ../../library/errno.rst:786 +msgid "Bad procedure for program" +msgstr "" + +#: ../../library/errno.rst:793 +msgid "Program version wrong" +msgstr "" + +#: ../../library/errno.rst:800 +msgid "RPC prog. not avail" +msgstr "" + +#: ../../library/errno.rst:807 +msgid "Device power is off" +msgstr "" + +#: ../../library/errno.rst:814 +msgid "RPC struct is bad" +msgstr "" + +#: ../../library/errno.rst:821 +msgid "RPC version wrong" +msgstr "" + +#: ../../library/errno.rst:828 +msgid "Shared library version mismatch" +msgstr "" + +#: ../../library/errno.rst:835 msgid "" "Capabilities insufficient. This error is mapped to the exception :exc:" "`PermissionError`." msgstr "" -#: ../../library/errno.rst:673 -msgid ":ref:`Availability `: WASI, FreeBSD" -msgstr ":ref:`適用 `:WASI, FreeBSD" +#: ../../library/errno.rst:838 +msgid "Availability" +msgstr "可用性" -#: ../../library/errno.rst:680 +#: ../../library/errno.rst:845 msgid "Operation canceled" msgstr "" -#: ../../library/errno.rst:687 +#: ../../library/errno.rst:852 msgid "Owner died" msgstr "" -#: ../../library/errno.rst:694 +#: ../../library/errno.rst:859 msgid "State not recoverable" msgstr "" diff --git a/library/exceptions.po b/library/exceptions.po index 9ef5f376f1..2208e56a09 100644 --- a/library/exceptions.po +++ b/library/exceptions.po @@ -1,15 +1,14 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-07-20 00:03+0000\n" -"PO-Revision-Date: 2024-09-17 09:18+0800\n" +"POT-Creation-Date: 2025-07-09 00:17+0000\n" +"PO-Revision-Date: 2024-12-20 16:57+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -18,7 +17,6 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Poedit 3.4.2\n" #: ../../library/exceptions.rst:4 msgid "Built-in Exceptions" @@ -163,7 +161,7 @@ msgid "" "possible conflicts between how the bases handle the ``args`` attribute, as " "well as due to possible memory layout incompatibilities." msgstr "" -"使用者的程式碼可以建立繼承自例外類型的子類別。建議一次只繼承一種例外類型以避" +"使用者的程式碼可以建立繼承自例外型別的子類別。建議一次只繼承一種例外型別以避" "免在基底類別之間如何處理 ``args`` 屬性的任何可能衝突,以及可能的記憶體佈局 " "(memory layout) 不相容。" @@ -177,9 +175,9 @@ msgid "" "it's recommended to avoid subclassing multiple exception types altogether." msgstr "" "為了效率,大部分的內建例外使用 C 來實作,參考 :source:`Objects/exceptions." -"c`。一些例外有客製化的記憶體佈局,使其不可能建立一個繼承多種例外類型的子類" -"別。類型的記憶體佈局是實作細節且可能會在不同 Python 版本間改變,造成未來新的" -"衝突。因此,總之建議避免繼承多種例外類型。" +"c`。一些例外有客製化的記憶體佈局,使其不可能建立一個繼承多種例外型別的子類" +"別。型別的記憶體佈局是實作細節且可能會在不同 Python 版本間改變,造成未來新的" +"衝突。因此,總之建議避免繼承多種例外型別。" #: ../../library/exceptions.rst:105 msgid "Base classes" @@ -327,34 +325,37 @@ msgstr "" #: ../../library/exceptions.rst:207 msgid "" -"The :attr:`name` and :attr:`obj` attributes can be set using keyword-only " -"arguments to the constructor. When set they represent the name of the " -"attribute that was attempted to be accessed and the object that was accessed " -"for said attribute, respectively." -msgstr "" -":attr:`name` 和 :attr:`obj` 屬性可以使用建構函式的僅限關鍵字 (keyword-only) " -"引數來設定。當被設定的時候,它們分別代表被嘗試存取的屬性名稱以及被以該屬性存" -"取的物件。" +"The optional *name* and *obj* keyword-only arguments set the corresponding " +"attributes:" +msgstr "可選的僅限關鍵字引數 *name* 和 *obj* 會設定對應的屬性:" #: ../../library/exceptions.rst:212 +msgid "The name of the attribute that was attempted to be accessed." +msgstr "嘗試被存取的屬性名稱。" + +#: ../../library/exceptions.rst:216 +msgid "The object that was accessed for the named attribute." +msgstr "存取指定屬性的物件。" + +#: ../../library/exceptions.rst:218 msgid "Added the :attr:`name` and :attr:`obj` attributes." msgstr "新增 :attr:`name` 與 :attr:`obj` 屬性。" -#: ../../library/exceptions.rst:217 +#: ../../library/exceptions.rst:223 msgid "" "Raised when the :func:`input` function hits an end-of-file condition (EOF) " -"without reading any data. (N.B.: the :meth:`io.IOBase.read` and :meth:`io." +"without reading any data. (Note: the :meth:`!io.IOBase.read` and :meth:`io." "IOBase.readline` methods return an empty string when they hit EOF.)" msgstr "" "當 :func:`input` 函式在沒有讀到任何資料而到達檔案結尾 (end-of-file, EOF) 條件" -"的時候被引發。(注意::meth:`io.IOBase.read` 和 :meth:`io.IOBase.readline` 方" +"的時候被引發。(注意::meth:`!io.IOBase.read` 和 :meth:`io.IOBase.readline` 方" "法當達到 EOF 時會回傳空字串。)" -#: ../../library/exceptions.rst:224 +#: ../../library/exceptions.rst:230 msgid "Not currently used." msgstr "目前沒有被使用。" -#: ../../library/exceptions.rst:229 +#: ../../library/exceptions.rst:235 msgid "" "Raised when a :term:`generator` or :term:`coroutine` is closed; see :meth:" "`generator.close` and :meth:`coroutine.close`. It directly inherits from :" @@ -365,7 +366,7 @@ msgstr "" "`generator.close` 和 :meth:`coroutine.close`。此例外直接繼承自 :exc:" "`BaseException` 而不是 :exc:`Exception`,因為技術上來說這不是一個錯誤。" -#: ../../library/exceptions.rst:237 +#: ../../library/exceptions.rst:243 msgid "" "Raised when the :keyword:`import` statement has troubles trying to load a " "module. Also raised when the \"from list\" in ``from ... import`` has a " @@ -374,25 +375,25 @@ msgstr "" "當 :keyword:`import` 陳述式嘗試載入模組遇到問題的時候會被引發。當 ``from ... " "import`` 裡的 \"from list\" 包含找不到的名稱時也會被引發。" -#: ../../library/exceptions.rst:241 +#: ../../library/exceptions.rst:247 msgid "" "The optional *name* and *path* keyword-only arguments set the corresponding " "attributes:" msgstr "可選的僅限關鍵字引數 *name* 和 *path* 設定對應的屬性:" -#: ../../library/exceptions.rst:246 +#: ../../library/exceptions.rst:252 msgid "The name of the module that was attempted to be imported." msgstr "嘗試引入 (import) 的模組名稱。" -#: ../../library/exceptions.rst:250 +#: ../../library/exceptions.rst:256 msgid "The path to any file which triggered the exception." msgstr "觸發此例外的任何檔案的路徑。" -#: ../../library/exceptions.rst:252 +#: ../../library/exceptions.rst:258 msgid "Added the :attr:`name` and :attr:`path` attributes." msgstr "新增 :attr:`name` 與 :attr:`path` 屬性。" -#: ../../library/exceptions.rst:257 +#: ../../library/exceptions.rst:263 msgid "" "A subclass of :exc:`ImportError` which is raised by :keyword:`import` when a " "module could not be located. It is also raised when ``None`` is found in :" @@ -401,7 +402,7 @@ msgstr "" ":exc:`ImportError` 的子類別,當模組不能被定位的時候會被 :keyword:`import` 所" "引發。當在 :data:`sys.modules` 裡找到 ``None`` 時也會被引發。" -#: ../../library/exceptions.rst:266 +#: ../../library/exceptions.rst:272 msgid "" "Raised when a sequence subscript is out of range. (Slice indices are " "silently truncated to fall in the allowed range; if an index is not an " @@ -410,13 +411,13 @@ msgstr "" "當序列的索引超出範圍的時候會被引發。(切片索引 (slice indices) 會默默地被截短" "使其能落在允許的範圍內;如果索引不是整數,:exc:`TypeError` 會被引發。)" -#: ../../library/exceptions.rst:275 +#: ../../library/exceptions.rst:281 msgid "" "Raised when a mapping (dictionary) key is not found in the set of existing " "keys." msgstr "當對映(字典)的鍵無法在已存在的鍵的集合中被找到時會被引發。" -#: ../../library/exceptions.rst:282 +#: ../../library/exceptions.rst:288 msgid "" "Raised when the user hits the interrupt key (normally :kbd:`Control-C` or :" "kbd:`Delete`). During execution, a check for interrupts is made regularly. " @@ -429,7 +430,7 @@ msgstr "" "exc:`BaseException` 以防止意外地被捕捉 :exc:`Exception` 的程式碼所捕捉,而因" "此讓直譯器無法結束。" -#: ../../library/exceptions.rst:290 +#: ../../library/exceptions.rst:296 msgid "" "Catching a :exc:`KeyboardInterrupt` requires special consideration. Because " "it can be raised at unpredictable points, it may, in some circumstances, " @@ -442,7 +443,7 @@ msgstr "" "exc:`KeyboardInterrupt` 越快結束程式越好,或者完全避免引發它。(參考 :ref:" "`handlers-and-exceptions`。)" -#: ../../library/exceptions.rst:300 +#: ../../library/exceptions.rst:306 msgid "" "Raised when an operation runs out of memory but the situation may still be " "rescued (by deleting some objects). The associated value is a string " @@ -458,7 +459,7 @@ msgstr "" "整地從該情況中修復;僅管如此,它還是引發例外以讓堆疊回溯可以被印出,以防原因" "出在失控的程式。" -#: ../../library/exceptions.rst:311 +#: ../../library/exceptions.rst:317 msgid "" "Raised when a local or global name is not found. This applies only to " "unqualified names. The associated value is an error message that includes " @@ -467,20 +468,19 @@ msgstr "" "當找不到本地或全域的名稱時會被引發。這只應用在不合格的名稱 (unqualified " "name) 上。關聯值是一個錯誤訊息,包含那個無法被找到的名稱。" -#: ../../library/exceptions.rst:315 -msgid "" -"The :attr:`name` attribute can be set using a keyword-only argument to the " -"constructor. When set it represent the name of the variable that was " -"attempted to be accessed." -msgstr "" -":attr:`name` 屬性可以使用僅限關鍵字引數來設定到建構函式。當被設定的時候它代表" -"被嘗試存取的變數名稱。" +#: ../../library/exceptions.rst:321 +msgid "The optional *name* keyword-only argument sets the attribute:" +msgstr "可選的僅限關鍵字引數 *name* 設定對應的屬性:" + +#: ../../library/exceptions.rst:325 +msgid "The name of the variable that was attempted to be accessed." +msgstr "嘗試被存取的變數名稱。" -#: ../../library/exceptions.rst:319 +#: ../../library/exceptions.rst:327 msgid "Added the :attr:`name` attribute." msgstr "新增 :attr:`name` 屬性。" -#: ../../library/exceptions.rst:325 +#: ../../library/exceptions.rst:333 msgid "" "This exception is derived from :exc:`RuntimeError`. In user defined base " "classes, abstract methods should raise this exception when they require " @@ -491,7 +491,7 @@ msgstr "" "生類別覆寫該方法時應該要引發此例外,或者當類別正在開發中,可用此例外表示還需" "要加入真正的實作。" -#: ../../library/exceptions.rst:332 +#: ../../library/exceptions.rst:340 msgid "" "It should not be used to indicate that an operator or method is not meant to " "be supported at all -- in that case either leave the operator / method " @@ -500,25 +500,26 @@ msgstr "" "此例外不應該用來表示根本沒有要支援的運算子或方法 ── 在這個情況下可以讓該運算" "子或方法保持未定義,或者如果是子類別的話將其設成 :data:`None`。" -#: ../../library/exceptions.rst:338 +#: ../../library/exceptions.rst:346 msgid "" -"``NotImplementedError`` and :data:`NotImplemented` are not interchangeable, " -"even though they have similar names and purposes. See :data:`!" -"NotImplemented` for details on when to use it." +":exc:`!NotImplementedError` and :data:`!NotImplemented` are not " +"interchangeable. This exception should only be used as described above; see :" +"data:`NotImplemented` for details on correct usage of the built-in constant." msgstr "" -"``NotImplementedError`` 和 :data:`NotImplemented` 雖然有相似的名稱和目的但並" -"不是可互換的。參考 :data:`!NotImplemented` 裡關於何時使用的細節。" +":exc:`!NotImplementedError` 和 :data:`!NotImplemented` 並不是可互換的。這個例" +"外只能用在上面描述的情況;參考 :data:`NotImplemented` 裡關於內建常數正確使用" +"方法的細節。" -#: ../../library/exceptions.rst:347 +#: ../../library/exceptions.rst:357 msgid "" "This exception is raised when a system function returns a system-related " -"error, including I/O failures such as \"file not found\" or \"disk full\" " -"(not for illegal argument types or other incidental errors)." +"error, including I/O failures such as \"file not found\" or \"disk " +"full\" (not for illegal argument types or other incidental errors)." msgstr "" "當系統函式回傳系統相關錯誤,包含像\"找不到檔案\"或\"硬碟已滿\"的 I/O 失敗會引" "發此例外(而非不合法的引數或其他次要的錯誤)。" -#: ../../library/exceptions.rst:351 +#: ../../library/exceptions.rst:361 msgid "" "The second form of the constructor sets the corresponding attributes, " "described below. The attributes default to :const:`None` if not specified. " @@ -530,7 +531,7 @@ msgstr "" "const:`None`。為了向後相容,如果傳入三個引數,:attr:`~BaseException.args` 屬" "性只會是包含建構函式前兩個引數的雙元素元組。" -#: ../../library/exceptions.rst:357 +#: ../../library/exceptions.rst:367 msgid "" "The constructor often actually returns a subclass of :exc:`OSError`, as " "described in `OS exceptions`_ below. The particular subclass depends on the " @@ -543,11 +544,11 @@ msgstr "" "個行為只發生在直接建構 :exc:`OSError` 或透過別名,且產生子類別的時候不會被繼" "承。" -#: ../../library/exceptions.rst:365 +#: ../../library/exceptions.rst:375 msgid "A numeric error code from the C variable :c:data:`errno`." msgstr "從 C 變數 :c:data:`errno` 而來的數值錯誤代碼。" -#: ../../library/exceptions.rst:369 +#: ../../library/exceptions.rst:379 msgid "" "Under Windows, this gives you the native Windows error code. The :attr:`." "errno` attribute is then an approximate translation, in POSIX terms, of that " @@ -556,7 +557,7 @@ msgstr "" "在 Windows 下,這會提供你原生的 Windows 錯誤代碼。而 :attr:`.errno` 屬性是一" "個該原生錯誤代碼對於 POSIX 來說的近似翻譯。" -#: ../../library/exceptions.rst:373 +#: ../../library/exceptions.rst:383 msgid "" "Under Windows, if the *winerror* constructor argument is an integer, the :" "attr:`.errno` attribute is determined from the Windows error code, and the " @@ -567,16 +568,16 @@ msgstr "" "據該 Windows 錯誤代碼來決定,且 *errno* 引數會被忽略。在其他平台上," "*winerror* 引數會被忽略,而 :attr:`winerror` 屬性會不存在。" -#: ../../library/exceptions.rst:381 +#: ../../library/exceptions.rst:391 msgid "" "The corresponding error message, as provided by the operating system. It is " -"formatted by the C functions :c:func:`perror` under POSIX, and :c:func:" -"`FormatMessage` under Windows." +"formatted by the C functions :c:func:`!perror` under POSIX, and :c:func:`!" +"FormatMessage` under Windows." msgstr "" -"作業系統提供的對應錯誤訊息。在 POSIX 下會使用 C 函式 :c:func:`perror` 做格式" -"化,而在 Windows 下會使用 :c:func:`FormatMessage`。" +"作業系統提供的對應錯誤訊息。在 POSIX 下會使用 C 函式 :c:func:`!perror` 做格式" +"化,而在 Windows 下會使用 :c:func:`!FormatMessage`。" -#: ../../library/exceptions.rst:389 +#: ../../library/exceptions.rst:399 msgid "" "For exceptions that involve a file system path (such as :func:`open` or :" "func:`os.unlink`), :attr:`filename` is the file name passed to the function. " @@ -588,17 +589,17 @@ msgstr "" "`filename` 是傳入函式的檔案名稱。對於包含兩個檔案系統路徑的函式(像是 :func:" "`os.rename`),:attr:`filename2` 對應到傳入函式的第二個檔案名稱。" -#: ../../library/exceptions.rst:396 +#: ../../library/exceptions.rst:406 msgid "" ":exc:`EnvironmentError`, :exc:`IOError`, :exc:`WindowsError`, :exc:`socket." -"error`, :exc:`select.error` and :exc:`mmap.error` have been merged into :exc:" -"`OSError`, and the constructor may return a subclass." +"error`, :exc:`select.error` and :exc:`!mmap.error` have been merged into :" +"exc:`OSError`, and the constructor may return a subclass." msgstr "" ":exc:`EnvironmentError`、:exc:`IOError`、:exc:`WindowsError`、:exc:`socket." -"error`、:exc:`select.error` 及 :exc:`mmap.error` 已合併進 :exc:`OSError`,而" +"error`、:exc:`select.error` 及 :exc:`!mmap.error` 已合併進 :exc:`OSError`,而" "建構函式可能會回傳子類別。" -#: ../../library/exceptions.rst:402 +#: ../../library/exceptions.rst:412 msgid "" "The :attr:`filename` attribute is now the original file name passed to the " "function, instead of the name encoded to or decoded from the :term:" @@ -609,7 +610,7 @@ msgstr "" "和錯誤處理函式 `\\ 編碼或解碼過的名" "稱。並且新增 *filename2* 建構函式引數與屬性。" -#: ../../library/exceptions.rst:411 +#: ../../library/exceptions.rst:421 msgid "" "Raised when the result of an arithmetic operation is too large to be " "represented. This cannot occur for integers (which would rather raise :exc:" @@ -623,7 +624,41 @@ msgstr "" "有時候會因為整數在要求範圍之外而引發。因為在 C 裡面缺乏浮點數例外處理的標準" "化,大部分的浮點數運算都沒有被檢查。" -#: ../../library/exceptions.rst:421 +#: ../../library/exceptions.rst:431 +msgid "" +"This exception is derived from :exc:`RuntimeError`. It is raised when an " +"operation is blocked during interpreter shutdown also known as :term:`Python " +"finalization `." +msgstr "" +"此例外衍生自 :exc:`RuntimeError`。當一個操作在直譯器關閉(也稱作 :term:" +"`Python 最終化 (Python finalization) `)期間被阻塞會引" +"發此例外。" + +#: ../../library/exceptions.rst:435 +msgid "" +"Examples of operations which can be blocked with a :exc:" +"`PythonFinalizationError` during the Python finalization:" +msgstr "" +"在 Python 最終化期間,能夠以 :exc:`PythonFinalizationError` 被阻塞的操作範" +"例:" + +#: ../../library/exceptions.rst:438 +msgid "Creating a new Python thread." +msgstr "建立新的 Python 執行緒。" + +#: ../../library/exceptions.rst:439 +msgid ":func:`os.fork`." +msgstr ":func:`os.fork`。" + +#: ../../library/exceptions.rst:441 +msgid "See also the :func:`sys.is_finalizing` function." +msgstr "也可以參閱 :func:`sys.is_finalizing` 函式。" + +#: ../../library/exceptions.rst:443 ../../library/exceptions.rst:453 +msgid "Previously, a plain :exc:`RuntimeError` was raised." +msgstr "在之前,會引發一般的 :exc:`RuntimeError`。" + +#: ../../library/exceptions.rst:449 msgid "" "This exception is derived from :exc:`RuntimeError`. It is raised when the " "interpreter detects that the maximum recursion depth (see :func:`sys." @@ -632,11 +667,7 @@ msgstr "" "此例外衍生自 :exc:`RuntimeError`。當直譯器偵測到超過最大的遞迴深度(參考 :" "func:`sys.getrecursionlimit`)時會引發此例外。" -#: ../../library/exceptions.rst:425 -msgid "Previously, a plain :exc:`RuntimeError` was raised." -msgstr "在之前,會引發一般的 :exc:`RuntimeError`。" - -#: ../../library/exceptions.rst:431 +#: ../../library/exceptions.rst:459 msgid "" "This exception is raised when a weak reference proxy, created by the :func:" "`weakref.proxy` function, is used to access an attribute of the referent " @@ -647,7 +678,7 @@ msgstr "" "用來存取已經被垃圾回收 (garbage collected) 的參照物屬性時會引發此例外。更多關" "於弱參照的資訊參考 :mod:`weakref` 模組。" -#: ../../library/exceptions.rst:439 +#: ../../library/exceptions.rst:467 msgid "" "Raised when an error is detected that doesn't fall in any of the other " "categories. The associated value is a string indicating what precisely went " @@ -656,7 +687,7 @@ msgstr "" "當偵測到一個不屬於任何其他種類的錯誤時會引發此例外。關聯值是一個表示確切什麼" "地方出錯的字串。" -#: ../../library/exceptions.rst:446 +#: ../../library/exceptions.rst:474 msgid "" "Raised by built-in function :func:`next` and an :term:`iterator`\\'s :meth:" "`~iterator.__next__` method to signal that there are no further items " @@ -665,7 +696,7 @@ msgstr "" "會被內建函式 :func:`next` 及 :term:`iterator` 的 :meth:`~iterator.__next__` " "方法引發,用來表示疊代器沒有更多項目可以產生。" -#: ../../library/exceptions.rst:452 +#: ../../library/exceptions.rst:480 msgid "" "The exception object has a single attribute :attr:`!value`, which is given " "as an argument when constructing the exception, and defaults to :const:" @@ -674,7 +705,7 @@ msgstr "" "此例外物件有單一屬性 :attr:`!value`,當建構此例外時會以引數給定,預設為 :" "const:`None`。" -#: ../../library/exceptions.rst:456 +#: ../../library/exceptions.rst:484 msgid "" "When a :term:`generator` or :term:`coroutine` function returns, a new :exc:" "`StopIteration` instance is raised, and the value returned by the function " @@ -684,7 +715,7 @@ msgstr "" "`StopIteration` 實例會被引發,而該函式的回傳值會被用來當作此例外建構函式的 :" "attr:`value` 參數。" -#: ../../library/exceptions.rst:461 +#: ../../library/exceptions.rst:489 msgid "" "If a generator code directly or indirectly raises :exc:`StopIteration`, it " "is converted into a :exc:`RuntimeError` (retaining the :exc:`StopIteration` " @@ -693,13 +724,13 @@ msgstr "" "如果產生器程式直接或間接引發 :exc:`StopIteration`,則其會被轉換成 :exc:" "`RuntimeError`\\ (保留 :exc:`StopIteration` 作為新例外的成因)。" -#: ../../library/exceptions.rst:465 +#: ../../library/exceptions.rst:493 msgid "" "Added ``value`` attribute and the ability for generator functions to use it " "to return a value." msgstr "新增 ``value`` 屬性且產生器函式可以用它來回傳值。" -#: ../../library/exceptions.rst:469 +#: ../../library/exceptions.rst:497 msgid "" "Introduced the RuntimeError transformation via ``from __future__ import " "generator_stop``, see :pep:`479`." @@ -707,7 +738,7 @@ msgstr "" "透過 ``from __future__ import generator_stop`` 引入 RuntimeError 的轉換,參" "考 :pep:`479`。" -#: ../../library/exceptions.rst:473 +#: ../../library/exceptions.rst:501 msgid "" "Enable :pep:`479` for all code by default: a :exc:`StopIteration` error " "raised in a generator is transformed into a :exc:`RuntimeError`." @@ -715,7 +746,7 @@ msgstr "" "預設對所有程式啟用 :pep:`479`:在產生器引發的 :exc:`StopIteration` 錯誤會轉換" "成 :exc:`RuntimeError`。" -#: ../../library/exceptions.rst:479 +#: ../../library/exceptions.rst:507 msgid "" "Must be raised by :meth:`~object.__anext__` method of an :term:`asynchronous " "iterator` object to stop the iteration." @@ -723,7 +754,7 @@ msgstr "" "此例外必須被 :term:`asynchronous iterator` 物件的 :meth:`~object.__anext__` " "方法引發來停止疊代。" -#: ../../library/exceptions.rst:486 +#: ../../library/exceptions.rst:514 msgid "" "Raised when the parser encounters a syntax error. This may occur in an :" "keyword:`import` statement, in a call to the built-in functions :func:" @@ -734,7 +765,7 @@ msgstr "" "呼叫內建函式 :func:`compile`、:func:`exec` 或 :func:`eval` 的時候,或者在讀取" "初始腳本或標準輸入(也包含互動式)的時候。" -#: ../../library/exceptions.rst:492 +#: ../../library/exceptions.rst:520 msgid "" "The :func:`str` of the exception instance returns only the error message. " "Details is a tuple whose members are also available as separate attributes." @@ -742,18 +773,18 @@ msgstr "" "例外實例的 :func:`str` 只回傳錯誤訊息。Details 是個元組,其成員也能夠以分開的" "屬性取得。" -#: ../../library/exceptions.rst:497 +#: ../../library/exceptions.rst:525 msgid "The name of the file the syntax error occurred in." msgstr "發生語法錯誤所在的檔案名稱。" -#: ../../library/exceptions.rst:501 +#: ../../library/exceptions.rst:529 msgid "" "Which line number in the file the error occurred in. This is 1-indexed: the " "first line in the file has a ``lineno`` of 1." msgstr "" "發生錯誤所在檔案的列號。這是以 1 開始的索引:檔案第一列的 ``lineno`` 是 1。" -#: ../../library/exceptions.rst:506 +#: ../../library/exceptions.rst:534 msgid "" "The column in the line where the error occurred. This is 1-indexed: the " "first character in the line has an ``offset`` of 1." @@ -761,11 +792,11 @@ msgstr "" "發生錯誤所在該列的欄號 (column)。這是以 1 開始的索引:該列第一個字元的 " "``offset`` 是 1。" -#: ../../library/exceptions.rst:511 +#: ../../library/exceptions.rst:539 msgid "The source code text involved in the error." msgstr "涉及該錯誤的原始程式碼文字。" -#: ../../library/exceptions.rst:515 +#: ../../library/exceptions.rst:543 msgid "" "Which line number in the file the error occurred ends in. This is 1-indexed: " "the first line in the file has a ``lineno`` of 1." @@ -773,7 +804,7 @@ msgstr "" "發生錯誤所在檔案的結束列號。這是以 1 開始的索引:檔案第一列的 ``lineno`` 是 " "1。" -#: ../../library/exceptions.rst:520 +#: ../../library/exceptions.rst:548 msgid "" "The column in the end line where the error occurred finishes. This is 1-" "indexed: the first character in the line has an ``offset`` of 1." @@ -781,7 +812,7 @@ msgstr "" "發生錯誤所在該結束列的欄號。這是以 1 開始的索引:該列第一個字元的 ``offset`` " "是 1。" -#: ../../library/exceptions.rst:523 +#: ../../library/exceptions.rst:551 msgid "" "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 " @@ -792,18 +823,18 @@ msgstr "" "(offset) 是從替代表達式建構的文字的偏移量。例如編譯 f'Bad {a b} field' 會得到" "這個 args 屬性:('f-string: ...', ('', 1, 2, '(a b)\\n', 1, 5))。" -#: ../../library/exceptions.rst:528 +#: ../../library/exceptions.rst:556 msgid "Added the :attr:`end_lineno` and :attr:`end_offset` attributes." msgstr "新增 :attr:`end_lineno` 與 :attr:`end_offset` 屬性。" -#: ../../library/exceptions.rst:533 +#: ../../library/exceptions.rst:561 msgid "" "Base class for syntax errors related to incorrect indentation. This is a " "subclass of :exc:`SyntaxError`." msgstr "" "與不正確的縮排有關的語法錯誤的基礎類別。這是 :exc:`SyntaxError` 的子類別。" -#: ../../library/exceptions.rst:539 +#: ../../library/exceptions.rst:567 msgid "" "Raised when indentation contains an inconsistent use of tabs and spaces. " "This is a subclass of :exc:`IndentationError`." @@ -811,28 +842,35 @@ msgstr "" "當縮排包含製表符號 (tab) 和空白的不一致用法時會引發此例外。這是 :exc:" "`IndentationError` 的子類別。" -#: ../../library/exceptions.rst:545 +#: ../../library/exceptions.rst:573 msgid "" "Raised when the interpreter finds an internal error, but the situation does " "not look so serious to cause it to abandon all hope. The associated value is " -"a string indicating what went wrong (in low-level terms)." +"a string indicating what went wrong (in low-level terms). In :term:" +"`CPython`, this could be raised by incorrectly using Python's C API, such as " +"returning a ``NULL`` value without an exception set." msgstr "" "當直譯器找到一個內部錯誤,但該情況看起來沒有嚴重到要讓它放棄所有的希望時會引" -"發此例外。關聯值是一個表示什麼地方出錯的字串(以低階的方式表達)。" +"發此例外。關聯值是一個表示什麼地方出錯的字串(以低階的方式表達)。在 :term:" +"`CPython` 中,這可能是因為錯誤地使用 Python 的 C API,例如回傳一個 ``NULL`` " +"值而沒有設定例外。" -#: ../../library/exceptions.rst:549 +#: ../../library/exceptions.rst:579 msgid "" -"You should report this to the author or maintainer of your Python " -"interpreter. Be sure to report the version of the Python interpreter (``sys." -"version``; it is also printed at the start of an interactive Python " -"session), the exact error message (the exception's associated value) and if " -"possible the source of the program that triggered the error." +"If you're confident that this exception wasn't your fault, or the fault of a " +"package you're using, you should report this to the author or maintainer of " +"your Python interpreter. Be sure to report the version of the Python " +"interpreter (``sys.version``; it is also printed at the start of an " +"interactive Python session), the exact error message (the exception's " +"associated value) and if possible the source of the program that triggered " +"the error." msgstr "" -"你應該向你的 Python 直譯器作者或維護者回報此錯誤。務必要回報該 Python 直譯器" -"的版本(``sys.version``;這也會在互動式 Python 會話的開頭被印出)、確切的錯誤" -"訊息(該例外的關聯值)及如果可能的話,觸發此錯誤的程式來源。" +"如果你確定這個例外不是你的或者所用套件的錯,你應該向你的 Python 直譯器作者或" +"維護者回報此錯誤。務必要回報該 Python 直譯器的版本(``sys.version``;這也會在" +"互動式 Python 會話的開頭被印出)、確切的錯誤訊息(該例外的關聯值)及如果可能" +"的話,觸發此錯誤的程式來源。" -#: ../../library/exceptions.rst:558 +#: ../../library/exceptions.rst:590 msgid "" "This exception is raised by the :func:`sys.exit` function. It inherits " "from :exc:`BaseException` instead of :exc:`Exception` so that it is not " @@ -841,7 +879,7 @@ msgid "" "it is not handled, the Python interpreter exits; no stack traceback is " "printed. The constructor accepts the same optional argument passed to :func:" "`sys.exit`. If the value is an integer, it specifies the system exit status " -"(passed to C's :c:func:`exit` function); if it is ``None``, the exit status " +"(passed to C's :c:func:`!exit` function); if it is ``None``, the exit status " "is zero; if it has another type (such as a string), the object's value is " "printed and the exit status is one." msgstr "" @@ -849,11 +887,11 @@ msgstr "" "exc:`Exception` 因此不會被捕捉 :exc:`Exception` 的程式意外地捕捉。這允許例外" "可以正確地向上傳遞並導致直譯器結束。當它未被處理時,Python 直譯器會結束;不會" "印出堆疊回溯。建構函式接受跟傳入 :func:`sys.exit` 一樣的可選引數。如果該值是" -"整數,它會指定系統的結束狀態(傳入 C 的 :c:func:`exit` 函式 );如果它是 " -"``None``,結束狀態會是 0;如果它是其他類型(例如字串),則物件的值會被印出而" +"整數,它會指定系統的結束狀態(傳入 C 的 :c:func:`!exit` 函式);如果它是 " +"``None``,結束狀態會是 0;如果它是其他型別(例如字串),則物件的值會被印出而" "結束狀態是 1。" -#: ../../library/exceptions.rst:569 +#: ../../library/exceptions.rst:601 msgid "" "A call to :func:`sys.exit` is translated into an exception so that clean-up " "handlers (:keyword:`finally` clauses of :keyword:`try` statements) can be " @@ -867,22 +905,22 @@ msgstr "" "風險下執行腳本。如果在絕對有必要立即結束的情況(例如在子行程呼叫完 :func:`os." "fork` 之後 )可以使用 :func:`os._exit` 函式。" -#: ../../library/exceptions.rst:578 +#: ../../library/exceptions.rst:610 msgid "" "The exit status or error message that is passed to the constructor. " "(Defaults to ``None``.)" msgstr "傳入建構函式的結束狀態或錯誤訊息。(預設是 ``None``。 )" -#: ../../library/exceptions.rst:584 +#: ../../library/exceptions.rst:616 msgid "" "Raised when an operation or function is applied to an object of " "inappropriate type. The associated value is a string giving details about " "the type mismatch." msgstr "" -"當一個操作或函式被用在不適合的類型的物件時會引發此例外。關聯值是一個字串,提" -"供關於不相符類型的細節。" +"當一個操作或函式被用在不適合的型別的物件時會引發此例外。關聯值是一個字串,提" +"供關於不相符型別的細節。" -#: ../../library/exceptions.rst:587 +#: ../../library/exceptions.rst:619 msgid "" "This exception may be raised by user code to indicate that an attempted " "operation on an object is not supported, and is not meant to be. If an " @@ -893,18 +931,18 @@ msgstr "" "這樣做。如果一個物件有意要支援某個給定的操作但尚未提供實作,該引發的正確例外" "是 :exc:`NotImplementedError`。" -#: ../../library/exceptions.rst:592 +#: ../../library/exceptions.rst:624 msgid "" "Passing arguments of the wrong type (e.g. passing a :class:`list` when an :" "class:`int` is expected) should result in a :exc:`TypeError`, but passing " "arguments with the wrong value (e.g. a number outside expected boundaries) " "should result in a :exc:`ValueError`." msgstr "" -"傳入錯誤類型的引數(例如當預期傳入 :class:`int` 卻傳入 :class:`list`)應該要" +"傳入錯誤型別的引數(例如當預期傳入 :class:`int` 卻傳入 :class:`list`)應該要" "導致 :exc:`TypeError`,但傳入帶有錯誤值的引數(例如超出預期範圍的數值)應該要" "導致 :exc:`ValueError`。" -#: ../../library/exceptions.rst:599 +#: ../../library/exceptions.rst:631 msgid "" "Raised when a reference is made to a local variable in a function or method, " "but no value has been bound to that variable. This is a subclass of :exc:" @@ -913,7 +951,7 @@ msgstr "" "當在函式或方法裡引用某個區域變數,但該變數尚未被繫結到任何值的時候會引發此例" "外。這是 :exc:`NameError` 的子類別。" -#: ../../library/exceptions.rst:606 +#: ../../library/exceptions.rst:638 msgid "" "Raised when a Unicode-related encoding or decoding error occurs. It is a " "subclass of :exc:`ValueError`." @@ -921,7 +959,7 @@ msgstr "" "當 Unicode 相關的編碼或解碼錯誤發生時會引發此例外。這是 :exc:`ValueError` 的" "子類別。" -#: ../../library/exceptions.rst:609 +#: ../../library/exceptions.rst:641 msgid "" ":exc:`UnicodeError` has attributes that describe the encoding or decoding " "error. For example, ``err.object[err.start:err.end]`` gives the particular " @@ -930,27 +968,27 @@ msgstr "" ":exc:`UnicodeError` 有屬性描述編碼或解碼錯誤。例如 ``err.object[err.start:" "err.end]`` 會提供讓編解碼器失敗的具體無效輸入。" -#: ../../library/exceptions.rst:615 +#: ../../library/exceptions.rst:647 msgid "The name of the encoding that raised the error." msgstr "引發錯誤的編碼名稱。" -#: ../../library/exceptions.rst:619 +#: ../../library/exceptions.rst:651 msgid "A string describing the specific codec error." msgstr "描述特定編解碼器錯誤的字串。" -#: ../../library/exceptions.rst:623 +#: ../../library/exceptions.rst:655 msgid "The object the codec was attempting to encode or decode." msgstr "編解碼器嘗試編碼或解碼的物件。" -#: ../../library/exceptions.rst:627 +#: ../../library/exceptions.rst:659 msgid "The first index of invalid data in :attr:`object`." msgstr "在 :attr:`object` 中無效資料的開始索引。" -#: ../../library/exceptions.rst:631 +#: ../../library/exceptions.rst:663 msgid "The index after the last invalid data in :attr:`object`." msgstr "在 :attr:`object` 中最後的無效資料後的索引。" -#: ../../library/exceptions.rst:636 +#: ../../library/exceptions.rst:668 msgid "" "Raised when a Unicode-related error occurs during encoding. It is a " "subclass of :exc:`UnicodeError`." @@ -958,7 +996,7 @@ msgstr "" "在編碼當中發生 Unicode 相關錯誤時會引發此例外。這是 :exc:`UnicodeError` 的子" "類別。" -#: ../../library/exceptions.rst:642 +#: ../../library/exceptions.rst:674 msgid "" "Raised when a Unicode-related error occurs during decoding. It is a " "subclass of :exc:`UnicodeError`." @@ -966,7 +1004,7 @@ msgstr "" "在解碼當中發生 Unicode 相關錯誤時會引發此例外。這是 :exc:`UnicodeError` 的子" "類別。" -#: ../../library/exceptions.rst:648 +#: ../../library/exceptions.rst:680 msgid "" "Raised when a Unicode-related error occurs during translating. It is a " "subclass of :exc:`UnicodeError`." @@ -974,16 +1012,16 @@ msgstr "" "在轉譯當中發生 Unicode 相關錯誤時會引發此例外。這是 :exc:`UnicodeError` 的子" "類別。" -#: ../../library/exceptions.rst:654 +#: ../../library/exceptions.rst:686 msgid "" "Raised when an operation or function receives an argument that has the right " "type but an inappropriate value, and the situation is not described by a " "more precise exception such as :exc:`IndexError`." msgstr "" -"當一個操作或函式收到引數是正確類型但是不適合的值,且該情況無法被更精確的例外" +"當一個操作或函式收到引數是正確型別但是不適合的值,且該情況無法被更精確的例外" "例如 :exc:`IndexError` 所描述時會引發此例外。" -#: ../../library/exceptions.rst:661 +#: ../../library/exceptions.rst:693 msgid "" "Raised when the second argument of a division or modulo operation is zero. " "The associated value is a string indicating the type of the operands and the " @@ -992,7 +1030,7 @@ msgstr "" "當除法或模數運算 (modulo operation) 的第二個引數是 0 的時候會引發此例外。關聯" "值是一個字串,表示運算元及運算的類型。" -#: ../../library/exceptions.rst:666 +#: ../../library/exceptions.rst:698 msgid "" "The following exceptions are kept for compatibility with previous versions; " "starting from Python 3.3, they are aliases of :exc:`OSError`." @@ -1000,21 +1038,21 @@ msgstr "" "以下例外是為了相容於之前版本而保留;從 Python 3.3 開始,它們是 :exc:" "`OSError` 的別名。" -#: ../../library/exceptions.rst:675 +#: ../../library/exceptions.rst:707 msgid "Only available on Windows." msgstr "僅限於在 Windows 中使用。" -#: ../../library/exceptions.rst:679 +#: ../../library/exceptions.rst:711 msgid "OS exceptions" msgstr "作業系統例外" -#: ../../library/exceptions.rst:681 +#: ../../library/exceptions.rst:713 msgid "" "The following exceptions are subclasses of :exc:`OSError`, they get raised " "depending on the system error code." msgstr "以下的例外是 :exc:`OSError` 的子類別,它們根據系統錯誤代碼來引發。" -#: ../../library/exceptions.rst:686 +#: ../../library/exceptions.rst:718 msgid "" "Raised when an operation would block on an object (e.g. socket) set for non-" "blocking operation. Corresponds to :c:data:`errno` :py:const:`~errno." @@ -1025,14 +1063,14 @@ msgstr "" "到 :c:data:`errno` :py:const:`~errno.EAGAIN`、:py:const:`~errno.EALREADY`、:" "py:const:`~errno.EWOULDBLOCK` 及 :py:const:`~errno.EINPROGRESS`。" -#: ../../library/exceptions.rst:691 +#: ../../library/exceptions.rst:723 msgid "" "In addition to those of :exc:`OSError`, :exc:`BlockingIOError` can have one " "more attribute:" msgstr "" "除了 :exc:`OSError` 的那些屬性之外,:exc:`BlockingIOError` 有多一個屬性:" -#: ../../library/exceptions.rst:696 +#: ../../library/exceptions.rst:728 msgid "" "An integer containing the number of characters written to the stream before " "it blocked. This attribute is available when using the buffered I/O classes " @@ -1041,7 +1079,7 @@ msgstr "" "一個整數,內容為在其阻塞之前,已寫進串流的字元數。當使用 :mod:`io` 模組裡的緩" "衝 I/O 類別時這個屬性是可用的。" -#: ../../library/exceptions.rst:702 +#: ../../library/exceptions.rst:734 msgid "" "Raised when an operation on a child process failed. Corresponds to :c:data:" "`errno` :py:const:`~errno.ECHILD`." @@ -1049,11 +1087,11 @@ msgstr "" "當子行程上的操作失敗時會引發此例外。對應到 :c:data:`errno` :py:const:`~errno." "ECHILD`。" -#: ../../library/exceptions.rst:707 +#: ../../library/exceptions.rst:739 msgid "A base class for connection-related issues." msgstr "連線相關問題的基礎類別。" -#: ../../library/exceptions.rst:709 +#: ../../library/exceptions.rst:741 msgid "" "Subclasses are :exc:`BrokenPipeError`, :exc:`ConnectionAbortedError`, :exc:" "`ConnectionRefusedError` and :exc:`ConnectionResetError`." @@ -1061,7 +1099,7 @@ msgstr "" "子類別有 :exc:`BrokenPipeError`、:exc:`ConnectionAbortedError`、:exc:" "`ConnectionRefusedError` 及 :exc:`ConnectionResetError`。" -#: ../../library/exceptions.rst:714 +#: ../../library/exceptions.rst:746 msgid "" "A subclass of :exc:`ConnectionError`, raised when trying to write on a pipe " "while the other end has been closed, or trying to write on a socket which " @@ -1072,7 +1110,7 @@ msgstr "" "會引發此例外,或者當嘗試寫入已關閉寫入的 socket 時也會引發。對應到 :c:data:" "`errno` :py:const:`~errno.EPIPE` 及 :py:const:`~errno.ESHUTDOWN`。" -#: ../../library/exceptions.rst:721 +#: ../../library/exceptions.rst:753 msgid "" "A subclass of :exc:`ConnectionError`, raised when a connection attempt is " "aborted by the peer. Corresponds to :c:data:`errno` :py:const:`~errno." @@ -1081,7 +1119,7 @@ msgstr "" ":exc:`ConnectionError` 的子類別。當一個連線的嘗試被對等端點 (peer) 中斷時會引" "發此例外。對應到 :c:data:`errno` :py:const:`~errno.ECONNABORTED`。" -#: ../../library/exceptions.rst:727 +#: ../../library/exceptions.rst:759 msgid "" "A subclass of :exc:`ConnectionError`, raised when a connection attempt is " "refused by the peer. Corresponds to :c:data:`errno` :py:const:`~errno." @@ -1090,7 +1128,7 @@ msgstr "" ":exc:`ConnectionError` 的子類別。當一個連線的嘗試被對等端點拒絕時會引發此例" "外。對應到 :c:data:`errno` :py:const:`~errno.ECONNREFUSED`。" -#: ../../library/exceptions.rst:733 +#: ../../library/exceptions.rst:765 msgid "" "A subclass of :exc:`ConnectionError`, raised when a connection is reset by " "the peer. Corresponds to :c:data:`errno` :py:const:`~errno.ECONNRESET`." @@ -1098,7 +1136,7 @@ msgstr "" ":exc:`ConnectionError` 的子類別。當一個連線被對等端點重置時會引發此例外。對應" "到 :c:data:`errno` :py:const:`~errno.ECONNRESET`。" -#: ../../library/exceptions.rst:739 +#: ../../library/exceptions.rst:771 msgid "" "Raised when trying to create a file or directory which already exists. " "Corresponds to :c:data:`errno` :py:const:`~errno.EEXIST`." @@ -1106,7 +1144,7 @@ msgstr "" "當嘗試建立已存在的檔案或目錄時會引發此例外。對應到 :c:data:`errno` :py:const:" "`~errno.EEXIST`。" -#: ../../library/exceptions.rst:744 +#: ../../library/exceptions.rst:776 msgid "" "Raised when a file or directory is requested but doesn't exist. Corresponds " "to :c:data:`errno` :py:const:`~errno.ENOENT`." @@ -1114,7 +1152,7 @@ msgstr "" "當請求不存在的檔案或目錄時會引發此例外。對應到 :c:data:`errno` :py:const:" "`~errno.ENOENT`。" -#: ../../library/exceptions.rst:749 +#: ../../library/exceptions.rst:781 msgid "" "Raised when a system call is interrupted by an incoming signal. Corresponds " "to :c:data:`errno` :py:const:`~errno.EINTR`." @@ -1122,7 +1160,7 @@ msgstr "" "當系統呼叫被傳入的信號中斷時會引發此例外。對應到 :c:data:`errno` :py:const:" "`~errno.EINTR`。" -#: ../../library/exceptions.rst:752 +#: ../../library/exceptions.rst:784 msgid "" "Python now retries system calls when a syscall is interrupted by a signal, " "except if the signal handler raises an exception (see :pep:`475` for the " @@ -1131,7 +1169,7 @@ msgstr "" "現在當 syscall 被信號中斷時 Python 會重試系統呼叫而不會引發 :exc:" "`InterruptedError`,除非信號處理器引發例外(理由可參考 :pep:`475`)。" -#: ../../library/exceptions.rst:759 +#: ../../library/exceptions.rst:791 msgid "" "Raised when a file operation (such as :func:`os.remove`) is requested on a " "directory. Corresponds to :c:data:`errno` :py:const:`~errno.EISDIR`." @@ -1139,7 +1177,7 @@ msgstr "" "當在目錄上請求檔案操作(例如 :func:`os.remove`)時會引發此例外。對應到 :c:" "data:`errno` :py:const:`~errno.EISDIR`。" -#: ../../library/exceptions.rst:765 +#: ../../library/exceptions.rst:797 msgid "" "Raised when a directory operation (such as :func:`os.listdir`) is requested " "on something which is not a directory. On most POSIX platforms, it may also " @@ -1151,7 +1189,7 @@ msgstr "" "外。在大多數的 POSIX 平台上,如果嘗試操作開啟或遍歷一個當作目錄的非目錄檔案也" "會引發此例外。對應到 :c:data:`errno` :py:const:`~errno.ENOTDIR`。" -#: ../../library/exceptions.rst:773 +#: ../../library/exceptions.rst:805 msgid "" "Raised when trying to run an operation without the adequate access rights - " "for example filesystem permissions. Corresponds to :c:data:`errno` :py:const:" @@ -1162,14 +1200,14 @@ msgstr "" "到 :c:data:`errno` :py:const:`~errno.EACCES`、:py:const:`~errno.EPERM` 及 :" "py:const:`~errno.ENOTCAPABLE`。" -#: ../../library/exceptions.rst:778 +#: ../../library/exceptions.rst:810 msgid "" "WASI's :py:const:`~errno.ENOTCAPABLE` is now mapped to :exc:" "`PermissionError`." msgstr "" "WASI 的 :py:const:`~errno.ENOTCAPABLE` 現在對應到 :exc:`PermissionError`。" -#: ../../library/exceptions.rst:784 +#: ../../library/exceptions.rst:816 msgid "" "Raised when a given process doesn't exist. Corresponds to :c:data:`errno` :" "py:const:`~errno.ESRCH`." @@ -1177,7 +1215,7 @@ msgstr "" "當給定的行程不存在時會引發此例外。對應到 :c:data:`errno` :py:const:`~errno." "ESRCH`。" -#: ../../library/exceptions.rst:789 +#: ../../library/exceptions.rst:821 msgid "" "Raised when a system function timed out at the system level. Corresponds to :" "c:data:`errno` :py:const:`~errno.ETIMEDOUT`." @@ -1185,40 +1223,40 @@ msgstr "" "當系統函式在系統層級超時會引發此例外。對應到 :c:data:`errno` :py:const:" "`~errno.ETIMEDOUT`。" -#: ../../library/exceptions.rst:792 +#: ../../library/exceptions.rst:824 msgid "All the above :exc:`OSError` subclasses were added." msgstr "加入以上所有的 :exc:`OSError` 子類別。" -#: ../../library/exceptions.rst:798 +#: ../../library/exceptions.rst:830 msgid ":pep:`3151` - Reworking the OS and IO exception hierarchy" msgstr ":pep:`3151` — 改寫作業系統與 IO 例外階層" -#: ../../library/exceptions.rst:804 +#: ../../library/exceptions.rst:836 msgid "Warnings" msgstr "警告" -#: ../../library/exceptions.rst:806 +#: ../../library/exceptions.rst:838 msgid "" "The following exceptions are used as warning categories; see the :ref:" "`warning-categories` documentation for more details." msgstr "" "以下的例外是當作警告的種類使用;更多細節參考 :ref:`warning-categories` 文件。" -#: ../../library/exceptions.rst:811 +#: ../../library/exceptions.rst:843 msgid "Base class for warning categories." msgstr "警告種類的基礎類別。" -#: ../../library/exceptions.rst:816 +#: ../../library/exceptions.rst:848 msgid "Base class for warnings generated by user code." msgstr "使用者程式碼產生的警告的基礎類別。" -#: ../../library/exceptions.rst:821 +#: ../../library/exceptions.rst:853 msgid "" "Base class for warnings about deprecated features when those warnings are " "intended for other Python developers." msgstr "關於已棄用功能的警告的基礎類別,且當那些警告是針對其他 Python 開發者。" -#: ../../library/exceptions.rst:824 +#: ../../library/exceptions.rst:856 msgid "" "Ignored by the default warning filters, except in the ``__main__`` module (:" "pep:`565`). Enabling the :ref:`Python Development Mode ` shows this " @@ -1227,17 +1265,17 @@ msgstr "" "會被預設的警告過濾器忽略,在 ``__main__`` 模組裡除外 (:pep:`565`)。啟用 :ref:" "`Python 開發模式 `\\ 會顯示此警告。" -#: ../../library/exceptions.rst:828 ../../library/exceptions.rst:844 +#: ../../library/exceptions.rst:860 ../../library/exceptions.rst:876 msgid "The deprecation policy is described in :pep:`387`." msgstr "棄用原則描述在 :pep:`387` 裡。" -#: ../../library/exceptions.rst:833 +#: ../../library/exceptions.rst:865 msgid "" "Base class for warnings about features which are obsolete and expected to be " "deprecated in the future, but are not deprecated at the moment." msgstr "關於過時且預期未來要被棄用,但目前尚未被棄用的功能的警告的基礎類別。" -#: ../../library/exceptions.rst:837 +#: ../../library/exceptions.rst:869 msgid "" "This class is rarely used as emitting a warning about a possible upcoming " "deprecation is unusual, and :exc:`DeprecationWarning` is preferred for " @@ -1246,8 +1284,8 @@ msgstr "" "因為發出關於可能即將被棄用的警告是不尋常的,此類別很少被使用,而對已經被棄用" "的情況會優先使用 :exc:`DeprecationWarning`。" -#: ../../library/exceptions.rst:841 ../../library/exceptions.rst:867 -#: ../../library/exceptions.rst:894 +#: ../../library/exceptions.rst:873 ../../library/exceptions.rst:899 +#: ../../library/exceptions.rst:926 msgid "" "Ignored by the default warning filters. Enabling the :ref:`Python " "Development Mode ` shows this warning." @@ -1255,15 +1293,15 @@ msgstr "" "會被預設的警告過濾器忽略。啟用 :ref:`Python 開發模式 `\\ 會顯示此警" "告。" -#: ../../library/exceptions.rst:849 +#: ../../library/exceptions.rst:881 msgid "Base class for warnings about dubious syntax." msgstr "關於可疑語法的警告的基礎類別。" -#: ../../library/exceptions.rst:854 +#: ../../library/exceptions.rst:886 msgid "Base class for warnings about dubious runtime behavior." msgstr "關於可疑執行環境行為的警告的基礎類別。" -#: ../../library/exceptions.rst:859 +#: ../../library/exceptions.rst:891 msgid "" "Base class for warnings about deprecated features when those warnings are " "intended for end users of applications that are written in Python." @@ -1271,36 +1309,36 @@ msgstr "" "關於已棄用功能的警告的基礎類別,且當那些警告是針對以 Python 寫的應用程式的終" "端使用者。" -#: ../../library/exceptions.rst:865 +#: ../../library/exceptions.rst:897 msgid "Base class for warnings about probable mistakes in module imports." msgstr "關於在模組引入的可能錯誤的警告的基礎類別。" -#: ../../library/exceptions.rst:873 +#: ../../library/exceptions.rst:905 msgid "Base class for warnings related to Unicode." msgstr "Unicode 相關警告的基礎類別。" -#: ../../library/exceptions.rst:878 +#: ../../library/exceptions.rst:910 msgid "Base class for warnings related to encodings." msgstr "編碼相關警告的基礎類別。" -#: ../../library/exceptions.rst:880 +#: ../../library/exceptions.rst:912 msgid "See :ref:`io-encoding-warning` for details." msgstr "細節參考\\ :ref:`io-encoding-warning`。" -#: ../../library/exceptions.rst:887 +#: ../../library/exceptions.rst:919 msgid "" "Base class for warnings related to :class:`bytes` and :class:`bytearray`." msgstr ":class:`bytes` 及 :class:`bytearray` 相關警告的基礎類別。" -#: ../../library/exceptions.rst:892 +#: ../../library/exceptions.rst:924 msgid "Base class for warnings related to resource usage." msgstr "資源用法相關警告的基礎類別。" -#: ../../library/exceptions.rst:903 +#: ../../library/exceptions.rst:935 msgid "Exception groups" msgstr "例外群組" -#: ../../library/exceptions.rst:905 +#: ../../library/exceptions.rst:937 msgid "" "The following are used when it is necessary to raise multiple unrelated " "exceptions. They are part of the exception hierarchy so they can be handled " @@ -1309,10 +1347,10 @@ msgid "" "based on the types of the contained exceptions." msgstr "" "當需要引發多個不相關例外時會使用下列的類別。它們是例外階層的一部分所以可以像" -"所有其他例外一樣使用 :keyword:`except` 來處理。此外,它們會以包含的例外類型為" +"所有其他例外一樣使用 :keyword:`except` 來處理。此外,它們會以包含的例外型別為" "基礎來比對其子群組而被 :keyword:`except*` 辨認出來。" -#: ../../library/exceptions.rst:914 +#: ../../library/exceptions.rst:946 msgid "" "Both of these exception types wrap the exceptions in the sequence ``excs``. " "The ``msg`` parameter must be a string. The difference between the two " @@ -1322,13 +1360,13 @@ msgid "" "is so that ``except Exception`` catches an :exc:`ExceptionGroup` but not :" "exc:`BaseExceptionGroup`." msgstr "" -"這兩個例外類型都將例外包裝在序列 ``excs`` 中。``msg`` 參數必須是字串。這兩個" +"這兩個例外型別都將例外包裝在序列 ``excs`` 中。``msg`` 參數必須是字串。這兩個" "類別的差異是 :exc:`BaseExceptionGroup` 擴充了 :exc:`BaseException` 且可以包裝" "任何例外,而 :exc:`ExceptionGroup` 擴充了 :exc:`Exception` 且只能包裝 :exc:" "`Exception` 的子類別。這個設計使得 ``except Exception`` 可以捕捉 :exc:" "`ExceptionGroup` 但不能捕捉 :exc:`BaseExceptionGroup`。" -#: ../../library/exceptions.rst:922 +#: ../../library/exceptions.rst:954 msgid "" "The :exc:`BaseExceptionGroup` constructor returns an :exc:`ExceptionGroup` " "rather than a :exc:`BaseExceptionGroup` if all contained exceptions are :exc:" @@ -1341,17 +1379,17 @@ msgstr "" "使用來讓這樣的選擇自動化。另一方面來說,如果任何包含的例外不是 :exc:" "`Exception` 的子類別,:exc:`ExceptionGroup` 建構函式會引發 :exc:`TypeError`。" -#: ../../library/exceptions.rst:931 +#: ../../library/exceptions.rst:963 msgid "The ``msg`` argument to the constructor. This is a read-only attribute." msgstr "建構函式的 ``msg`` 引數。這是一個唯讀的屬性。" -#: ../../library/exceptions.rst:935 +#: ../../library/exceptions.rst:967 msgid "" "A tuple of the exceptions in the ``excs`` sequence given to the constructor. " "This is a read-only attribute." msgstr "指定給建構函式 ``excs`` 序列中的例外組成的元組。這是一個唯讀的屬性。" -#: ../../library/exceptions.rst:940 +#: ../../library/exceptions.rst:972 msgid "" "Returns an exception group that contains only the exceptions from the " "current group that match *condition*, or ``None`` if the result is empty." @@ -1359,18 +1397,20 @@ msgstr "" "回傳只包含從現有群組比對到 *condition* 的例外的例外群組,或者當結果為空時回" "傳 ``None``。" -#: ../../library/exceptions.rst:943 +#: ../../library/exceptions.rst:975 msgid "" -"The condition can be either a function that accepts an exception and returns " -"true for those that should be in the subgroup, or it can be an exception " -"type or a tuple of exception types, which is used to check for a match using " -"the same check that is used in an ``except`` clause." +"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." msgstr "" -"條件可以是一個函式,接受一個例外並對那些應該要在子群組裡的例外回傳 true,或者" -"可以是一個例外類型或例外類型的元組,並使用與 ``except`` 子句所使用的相同檢查" -"來檢查是否有比對到。" +"條件式可以是一個例外型別或是例外型別的元組,在此情況下,每個例外都會使用與 " +"``except`` 子句中使用的相同檢查方法來檢查是否有匹配。條件式也可以是一個可呼叫" +"物件(除了型別物件之外),其接受一個例外作為單一引數,而如果該例外應該在子群" +"組中就回傳 true。" -#: ../../library/exceptions.rst:948 +#: ../../library/exceptions.rst:981 msgid "" "The nesting structure of the current exception is preserved in the result, " "as are the values of its :attr:`message`, :attr:`~BaseException." @@ -1383,7 +1423,7 @@ msgstr "" "__context__` 及 :attr:`~BaseException.__notes__` 欄位的值也一樣。空的巢狀群組" "會從結果裡排除。" -#: ../../library/exceptions.rst:955 +#: ../../library/exceptions.rst:988 msgid "" "The condition is checked for all exceptions in the nested exception group, " "including the top-level and any nested exception groups. If the condition is " @@ -1392,7 +1432,11 @@ msgstr "" "條件會對巢狀例外群組裡的所有例外做檢查,包括頂層及任何巢狀的例外群組。如果條" "件對這樣的例外群組為 true,它會被完整包含在結果裡。" -#: ../../library/exceptions.rst:961 +#: ../../library/exceptions.rst:992 +msgid "``condition`` can be any callable which is not a type object." +msgstr "``condition`` 可以是任何不是型別物件的可呼叫物件。" + +#: ../../library/exceptions.rst:997 msgid "" "Like :meth:`subgroup`, but returns the pair ``(match, rest)`` where " "``match`` is ``subgroup(condition)`` and ``rest`` is the remaining non-" @@ -1401,13 +1445,13 @@ msgstr "" "像 :meth:`subgroup` 一樣,但回傳一對 ``(match, rest)``,其中 ``match`` 是 " "``subgroup(condition)`` 而 ``rest`` 是剩下沒有比對到的部分。" -#: ../../library/exceptions.rst:967 +#: ../../library/exceptions.rst:1003 msgid "" "Returns an exception group with the same :attr:`message`, but which wraps " "the exceptions in ``excs``." msgstr "回傳有相同 :attr:`message` 但將例外包裝在 ``excs`` 的例外群組。" -#: ../../library/exceptions.rst:970 +#: ../../library/exceptions.rst:1006 msgid "" "This method is used by :meth:`subgroup` and :meth:`split`, which are used in " "various contexts to break up an exception group. A subclass needs to " @@ -1418,7 +1462,7 @@ msgstr "" "組。子類別需要覆寫它來讓 :meth:`subgroup` 及 :meth:`split` 回傳子類別而不是 :" "exc:`ExceptionGroup` 的實例。" -#: ../../library/exceptions.rst:976 +#: ../../library/exceptions.rst:1012 msgid "" ":meth:`subgroup` and :meth:`split` copy the :attr:`~BaseException." "__traceback__`, :attr:`~BaseException.__cause__`, :attr:`~BaseException." @@ -1431,7 +1475,7 @@ msgstr "" "`~BaseException.__context__` 和 :attr:`~BaseException.__notes__` 欄位到 :" "meth:`derive` 所回傳的例外群組上,因此這些欄位不需要被 :meth:`derive` 更新。" -#: ../../library/exceptions.rst:983 +#: ../../library/exceptions.rst:1019 msgid "" ">>> class MyGroup(ExceptionGroup):\n" "... def derive(self, excs):\n" @@ -1485,19 +1529,19 @@ msgstr "" ">>> exc.__traceback__ is match.__traceback__ is rest.__traceback__\n" "True" -#: ../../library/exceptions.rst:1009 +#: ../../library/exceptions.rst:1045 msgid "" "Note that :exc:`BaseExceptionGroup` defines :meth:`~object.__new__`, so " "subclasses that need a different constructor signature need to override that " "rather than :meth:`~object.__init__`. For example, the following defines an " -"exception group subclass which accepts an exit_code and and constructs the " +"exception group subclass which accepts an exit_code and constructs the " "group's message from it. ::" msgstr "" "需注意 :exc:`BaseExceptionGroup` 定義了 :meth:`~object.__new__`,因此需要不同" "建構函式簽名的子類別需要覆寫它而不是 :meth:`~object.__init__`。例如下面定義了" "一個例外群組子類別接受 exit_code 並從中建構群組的訊息。: ::" -#: ../../library/exceptions.rst:1015 +#: ../../library/exceptions.rst:1051 msgid "" "class Errors(ExceptionGroup):\n" " def __new__(cls, errors, exit_code):\n" @@ -1517,7 +1561,7 @@ msgstr "" " def derive(self, excs):\n" " return Errors(excs, self.exit_code)" -#: ../../library/exceptions.rst:1024 +#: ../../library/exceptions.rst:1060 msgid "" "Like :exc:`ExceptionGroup`, any subclass of :exc:`BaseExceptionGroup` which " "is also a subclass of :exc:`Exception` can only wrap instances of :exc:" @@ -1526,15 +1570,15 @@ msgstr "" "像 :exc:`ExceptionGroup` 一樣,任何 :exc:`BaseExceptionGroup` 的子類別且也" "是 :exc:`Exception` 的子類別只能包裝 :exc:`Exception` 的實例。" -#: ../../library/exceptions.rst:1032 +#: ../../library/exceptions.rst:1068 msgid "Exception hierarchy" msgstr "例外階層" -#: ../../library/exceptions.rst:1034 +#: ../../library/exceptions.rst:1070 msgid "The class hierarchy for built-in exceptions is:" msgstr "內建例外的類別階層如下:" -#: ../../library/exceptions.rst:1036 +#: ../../library/exceptions.rst:1072 msgid "" "BaseException\n" " ├── BaseExceptionGroup\n" @@ -1578,6 +1622,7 @@ msgid "" " ├── ReferenceError\n" " ├── RuntimeError\n" " │ ├── NotImplementedError\n" +" │ ├── PythonFinalizationError\n" " │ └── RecursionError\n" " ├── StopAsyncIteration\n" " ├── StopIteration\n" @@ -1646,6 +1691,7 @@ msgstr "" " ├── ReferenceError\n" " ├── RuntimeError\n" " │ ├── NotImplementedError\n" +" │ ├── PythonFinalizationError\n" " │ └── RecursionError\n" " ├── StopAsyncIteration\n" " ├── StopIteration\n" @@ -1713,10 +1759,28 @@ msgstr "__suppress_context__(例外屬性)" msgid "assert" msgstr "assert" -#: ../../library/exceptions.rst:345 +#: ../../library/exceptions.rst:355 msgid "module" msgstr "module(模組)" -#: ../../library/exceptions.rst:345 +#: ../../library/exceptions.rst:355 msgid "errno" msgstr "errno" + +#~ msgid "" +#~ "The :attr:`name` and :attr:`obj` attributes can be set using keyword-only " +#~ "arguments to the constructor. When set they represent the name of the " +#~ "attribute that was attempted to be accessed and the object that was " +#~ "accessed for said attribute, respectively." +#~ msgstr "" +#~ ":attr:`name` 和 :attr:`obj` 屬性可以使用建構函式的僅限關鍵字 (keyword-" +#~ "only) 引數來設定。當被設定的時候,它們分別代表被嘗試存取的屬性名稱以及被以" +#~ "該屬性存取的物件。" + +#~ msgid "" +#~ "The :attr:`name` attribute can be set using a keyword-only argument to " +#~ "the constructor. When set it represent the name of the variable that was " +#~ "attempted to be accessed." +#~ msgstr "" +#~ ":attr:`name` 屬性可以使用僅限關鍵字引數來設定到建構函式。當被設定的時候它" +#~ "代表被嘗試存取的變數名稱。" diff --git a/library/faulthandler.po b/library/faulthandler.po index 290364ae87..202d723b3c 100644 --- a/library/faulthandler.po +++ b/library/faulthandler.po @@ -4,7 +4,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2018-05-23 16:01+0000\n" diff --git a/library/fcntl.po b/library/fcntl.po index 38455cb763..bf6a8ef814 100644 --- a/library/fcntl.po +++ b/library/fcntl.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-04-24 05:58+0000\n" "PO-Revision-Date: 2017-09-22 18:26+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -31,8 +31,8 @@ msgid "" msgstr "" #: ../../library/fcntl.rst:21 -msgid ":ref:`Availability `: Unix, not Emscripten, not WASI." -msgstr ":ref:`適用 `:Unix、非 Emscripten、非 WASI。" +msgid "Availability" +msgstr "可用性" #: ../../library/fcntl.rst:23 msgid "" @@ -51,29 +51,30 @@ msgstr "" #: ../../library/fcntl.rst:33 msgid "" -"The fcntl module now contains ``F_ADD_SEALS``, ``F_GET_SEALS``, and " +"The :mod:`!fcntl` module now contains ``F_ADD_SEALS``, ``F_GET_SEALS``, and " "``F_SEAL_*`` constants for sealing of :func:`os.memfd_create` file " "descriptors." msgstr "" #: ../../library/fcntl.rst:38 msgid "" -"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." +"On macOS, the :mod:`!fcntl` module exposes the ``F_GETPATH`` constant, which " +"obtains the path of a file from a file descriptor. On Linux(>=3.15), the :" +"mod:`!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." msgstr "" #: ../../library/fcntl.rst:45 msgid "" -"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." +"On Linux >= 2.6.11, the :mod:`!fcntl` module exposes the ``F_GETPIPE_SZ`` " +"and ``F_SETPIPE_SZ`` constants, which allow to check and modify a pipe's " +"size respectively." msgstr "" #: ../../library/fcntl.rst:50 msgid "" -"On FreeBSD, the fcntl module exposes the ``F_DUP2FD`` and " +"On FreeBSD, the :mod:`!fcntl` module exposes the ``F_DUP2FD`` and " "``F_DUP2FD_CLOEXEC`` constants, which allow to duplicate a file descriptor, " "the latter setting ``FD_CLOEXEC`` flag in addition." msgstr "" @@ -87,33 +88,73 @@ msgid "" msgstr "" #: ../../library/fcntl.rst:61 +msgid "" +"On Linux >= 2.6.32, the :mod:`!fcntl` module exposes the ``F_GETOWN_EX``, " +"``F_SETOWN_EX``, ``F_OWNER_TID``, ``F_OWNER_PID``, ``F_OWNER_PGRP`` " +"constants, which allow to direct I/O availability signals to a specific " +"thread, process, or process group. On Linux >= 4.13, the :mod:`!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 :mod:`!fcntl` module exposes " +"the ``F_SEAL_FUTURE_WRITE`` constant for use with ``F_ADD_SEALS`` and " +"``F_GET_SEALS`` operations. On FreeBSD, the :mod:`!fcntl` module exposes the " +"``F_READAHEAD``, ``F_ISUNIONSTACK``, and ``F_KINFO`` constants. On macOS and " +"FreeBSD, the :mod:`!fcntl` module exposes the ``F_RDAHEAD`` constant. On " +"NetBSD and AIX, the :mod:`!fcntl` module exposes the ``F_CLOSEM`` constant. " +"On NetBSD, the :mod:`!fcntl` module exposes the ``F_MAXFD`` constant. On " +"macOS and NetBSD, the :mod:`!fcntl` module exposes the ``F_GETNOSIGPIPE`` " +"and ``F_SETNOSIGPIPE`` constant." +msgstr "" + +#: ../../library/fcntl.rst:82 msgid "The module defines the following functions:" -msgstr "" +msgstr "這個模組定義了以下函式:" -#: ../../library/fcntl.rst:66 +#: ../../library/fcntl.rst:87 msgid "" "Perform the operation *cmd* on file descriptor *fd* (file objects providing " "a :meth:`~io.IOBase.fileno` method are accepted as well). The values used " "for *cmd* are operating system dependent, and are available as constants in " "the :mod:`fcntl` module, using the same names as used in the relevant C " -"header files. The argument *arg* can either be an integer value, or a :class:" -"`bytes` object. With an integer value, the return value of this function is " -"the integer return value of the C :c:func:`fcntl` call. When the argument " -"is bytes it represents a binary structure, e.g. created by :func:`struct." -"pack`. The binary data is copied to a buffer whose address is passed to the " -"C :c:func:`fcntl` call. The return value after a successful call is the " -"contents of the buffer, converted to a :class:`bytes` object. The length of " -"the returned object will be the same as the length of the *arg* argument. " -"This is limited to 1024 bytes. If the information returned in the buffer by " -"the operating system is larger than 1024 bytes, this is most likely to " -"result in a segmentation violation or a more subtle data corruption." -msgstr "" - -#: ../../library/fcntl.rst:83 +"header files. The argument *arg* can either be an integer value, a :class:" +"`bytes` object, or a string. The type and size of *arg* must match the type " +"and size of the argument of the operation as specified in the relevant C " +"documentation." +msgstr "" + +#: ../../library/fcntl.rst:96 +msgid "" +"When *arg* is an integer, the function returns the integer return value of " +"the C :c:func:`fcntl` call." +msgstr "" + +#: ../../library/fcntl.rst:99 +msgid "" +"When the argument is bytes, it represents a binary structure, for example, " +"created by :func:`struct.pack`. A string value is encoded to binary using " +"the UTF-8 encoding. The binary data is copied to a buffer whose address is " +"passed to the C :c:func:`fcntl` call. The return value after a successful " +"call is the contents of the buffer, converted to a :class:`bytes` object. " +"The length of the returned object will be the same as the length of the " +"*arg* argument. This is limited to 1024 bytes." +msgstr "" + +#: ../../library/fcntl.rst:108 msgid "If the :c:func:`fcntl` call fails, an :exc:`OSError` is raised." msgstr "" -#: ../../library/fcntl.rst:85 +#: ../../library/fcntl.rst:111 +msgid "" +"If the type or the size of *arg* does not match the type or size of the " +"argument of the operation (for example, if an integer is passed when a " +"pointer is expected, or the information returned in the buffer by the " +"operating system is larger than 1024 bytes), this is most likely to result " +"in a segmentation violation or a more subtle data corruption." +msgstr "" + +#: ../../library/fcntl.rst:118 msgid "" "Raises an :ref:`auditing event ` ``fcntl.fcntl`` with arguments " "``fd``, ``cmd``, ``arg``." @@ -121,68 +162,65 @@ msgstr "" "引發一個附帶引數 ``fd``、``cmd``、``arg`` 的\\ :ref:`稽核事件 ` " "``fcntl.fcntl``。" -#: ../../library/fcntl.rst:90 +#: ../../library/fcntl.rst:123 msgid "" "This function is identical to the :func:`~fcntl.fcntl` function, except that " "the argument handling is even more complicated." msgstr "" -#: ../../library/fcntl.rst:93 +#: ../../library/fcntl.rst:126 msgid "" -"The *request* parameter is limited to values that can fit in 32-bits. " -"Additional constants of interest for use as the *request* argument can be " -"found in the :mod:`termios` module, under the same names as used in the " -"relevant C header files." +"The *request* parameter is limited to values that can fit in 32-bits or 64-" +"bits, depending on the platform. Additional constants of interest for use as " +"the *request* argument can be found in the :mod:`termios` module, under the " +"same names as used in the relevant C header files." msgstr "" -#: ../../library/fcntl.rst:98 +#: ../../library/fcntl.rst:132 msgid "" -"The parameter *arg* can be one of an integer, an object supporting the read-" -"only buffer interface (like :class:`bytes`) or an object supporting the read-" -"write buffer interface (like :class:`bytearray`)." +"The parameter *arg* can be an integer, a :term:`bytes-like object`, or a " +"string. The type and size of *arg* must match the type and size of the " +"argument of the operation as specified in the relevant C documentation." msgstr "" -#: ../../library/fcntl.rst:102 +#: ../../library/fcntl.rst:137 msgid "" -"In all but the last case, behaviour is as for the :func:`~fcntl.fcntl` " -"function." +"If *arg* does not support the read-write buffer interface or the " +"*mutate_flag* is false, behavior is as for the :func:`~fcntl.fcntl` function." msgstr "" -#: ../../library/fcntl.rst:105 -msgid "" -"If a mutable buffer is passed, then the behaviour is determined by the value " -"of the *mutate_flag* parameter." -msgstr "" - -#: ../../library/fcntl.rst:108 +#: ../../library/fcntl.rst:141 msgid "" -"If it is false, the buffer's mutability is ignored and behaviour is as for a " -"read-only buffer, except that the 1024 byte limit mentioned above is avoided " -"-- so long as the buffer you pass is at least as long as what the operating " -"system wants to put there, things should work." +"If *arg* supports the read-write buffer interface (like :class:`bytearray`) " +"and *mutate_flag* is true (the default), then the buffer is (in effect) " +"passed to the underlying :c:func:`!ioctl` system call, the latter's return " +"code is passed back to the calling Python, and the buffer's new contents " +"reflect the action of the :c:func:`ioctl`. This is a slight simplification, " +"because if the supplied buffer is less than 1024 bytes long it is first " +"copied into a static buffer 1024 bytes long which is then passed to :func:" +"`ioctl` and copied back into the supplied buffer." msgstr "" -#: ../../library/fcntl.rst:113 +#: ../../library/fcntl.rst:150 msgid "" -"If *mutate_flag* is true (the default), then the buffer is (in effect) " -"passed to the underlying :func:`ioctl` system call, the latter's return code " -"is passed back to the calling Python, and the buffer's new contents reflect " -"the action of the :func:`ioctl`. This is a slight simplification, because " -"if the supplied buffer is less than 1024 bytes long it is first copied into " -"a static buffer 1024 bytes long which is then passed to :func:`ioctl` and " -"copied back into the supplied buffer." +"If the :c:func:`ioctl` call fails, an :exc:`OSError` exception is raised." msgstr "" -#: ../../library/fcntl.rst:121 +#: ../../library/fcntl.rst:153 msgid "" -"If the :c:func:`ioctl` call fails, an :exc:`OSError` exception is raised." +"If the type or size of *arg* does not match the type or size of the " +"operation's argument (for example, if an integer is passed when a pointer is " +"expected, or the information returned in the buffer by the operating system " +"is larger than 1024 bytes, or the size of the mutable bytes-like object is " +"too small), this is most likely to result in a segmentation violation or a " +"more subtle data corruption." msgstr "" -#: ../../library/fcntl.rst:123 +#: ../../library/fcntl.rst:161 msgid "An example::" msgstr "範例: ::" -#: ../../library/fcntl.rst:125 +#: ../../library/fcntl.rst:163 msgid "" ">>> import array, fcntl, struct, termios, os\n" ">>> os.getpgrp()\n" @@ -206,7 +244,7 @@ msgstr "" ">>> buf\n" "array('h', [13341])" -#: ../../library/fcntl.rst:136 +#: ../../library/fcntl.rst:174 msgid "" "Raises an :ref:`auditing event ` ``fcntl.ioctl`` with arguments " "``fd``, ``request``, ``arg``." @@ -214,7 +252,7 @@ msgstr "" "引發一個附帶引數 ``fd``、``request``、``arg`` 的\\ :ref:`稽核事件 " "` ``fcntl.ioctl``。" -#: ../../library/fcntl.rst:141 +#: ../../library/fcntl.rst:179 msgid "" "Perform the lock operation *operation* on file descriptor *fd* (file objects " "providing a :meth:`~io.IOBase.fileno` method are accepted as well). See the " @@ -222,12 +260,12 @@ msgid "" "function is emulated using :c:func:`fcntl`.)" msgstr "" -#: ../../library/fcntl.rst:146 +#: ../../library/fcntl.rst:184 msgid "" "If the :c:func:`flock` call fails, an :exc:`OSError` exception is raised." msgstr "" -#: ../../library/fcntl.rst:148 +#: ../../library/fcntl.rst:186 msgid "" "Raises an :ref:`auditing event ` ``fcntl.flock`` with arguments " "``fd``, ``operation``." @@ -235,7 +273,7 @@ msgstr "" "引發一個附帶引數 ``fd``、``operation`` 的\\ :ref:`稽核事件 ` " "``fcntl.flock``。" -#: ../../library/fcntl.rst:153 +#: ../../library/fcntl.rst:191 msgid "" "This is essentially a wrapper around the :func:`~fcntl.fcntl` locking calls. " "*fd* is the file descriptor (file objects providing a :meth:`~io.IOBase." @@ -243,25 +281,25 @@ msgid "" "*cmd* is one of the following values:" msgstr "" -#: ../../library/fcntl.rst:160 +#: ../../library/fcntl.rst:198 msgid "Release an existing lock." msgstr "" -#: ../../library/fcntl.rst:164 +#: ../../library/fcntl.rst:202 msgid "Acquire a shared lock." msgstr "" -#: ../../library/fcntl.rst:168 +#: ../../library/fcntl.rst:206 msgid "Acquire an exclusive lock." msgstr "" -#: ../../library/fcntl.rst:172 +#: ../../library/fcntl.rst:210 msgid "" "Bitwise OR with any of the other three ``LOCK_*`` constants to make the " "request non-blocking." msgstr "" -#: ../../library/fcntl.rst:175 +#: ../../library/fcntl.rst:213 msgid "" "If :const:`!LOCK_NB` is used and the lock cannot be acquired, an :exc:" "`OSError` will be raised and the exception will have an *errno* attribute " @@ -271,33 +309,33 @@ msgid "" "a file opened for writing." msgstr "" -#: ../../library/fcntl.rst:182 +#: ../../library/fcntl.rst:220 msgid "" "*len* is the number of bytes to lock, *start* is the byte offset at which " "the lock starts, relative to *whence*, and *whence* is as with :func:`io." "IOBase.seek`, specifically:" msgstr "" -#: ../../library/fcntl.rst:186 +#: ../../library/fcntl.rst:224 msgid "``0`` -- relative to the start of the file (:const:`os.SEEK_SET`)" msgstr "" -#: ../../library/fcntl.rst:187 +#: ../../library/fcntl.rst:225 msgid "``1`` -- relative to the current buffer position (:const:`os.SEEK_CUR`)" msgstr "" -#: ../../library/fcntl.rst:188 +#: ../../library/fcntl.rst:226 msgid "``2`` -- relative to the end of the file (:const:`os.SEEK_END`)" msgstr "" -#: ../../library/fcntl.rst:190 +#: ../../library/fcntl.rst:228 msgid "" "The default for *start* is 0, which means to start at the beginning of the " "file. The default for *len* is 0 which means to lock to the end of the " "file. The default for *whence* is also 0." msgstr "" -#: ../../library/fcntl.rst:194 +#: ../../library/fcntl.rst:232 msgid "" "Raises an :ref:`auditing event ` ``fcntl.lockf`` with arguments " "``fd``, ``cmd``, ``len``, ``start``, ``whence``." @@ -305,11 +343,11 @@ msgstr "" "引發一個附帶引數 ``fd``、``cmd``、``len``、``start``、``whence`` 的\\ :ref:`" "稽核事件 ` ``fcntl.lockf``。" -#: ../../library/fcntl.rst:196 +#: ../../library/fcntl.rst:234 msgid "Examples (all on a SVR4 compliant system)::" msgstr "" -#: ../../library/fcntl.rst:198 +#: ../../library/fcntl.rst:236 msgid "" "import struct, fcntl, os\n" "\n" @@ -327,7 +365,7 @@ msgstr "" "lockdata = struct.pack('hhllhh', fcntl.F_WRLCK, 0, 0, 0, 0, 0)\n" "rv = fcntl.fcntl(f, fcntl.F_SETLKW, lockdata)" -#: ../../library/fcntl.rst:206 +#: ../../library/fcntl.rst:244 msgid "" "Note that in the first example the return value variable *rv* will hold an " "integer value; in the second example it will hold a :class:`bytes` object. " @@ -335,11 +373,11 @@ msgid "" "therefore using the :func:`flock` call may be better." msgstr "" -#: ../../library/fcntl.rst:214 +#: ../../library/fcntl.rst:252 msgid "Module :mod:`os`" msgstr ":mod:`os` 模組" -#: ../../library/fcntl.rst:215 +#: ../../library/fcntl.rst:253 msgid "" "If the locking flags :const:`~os.O_SHLOCK` and :const:`~os.O_EXLOCK` are " "present in the :mod:`os` module (on BSD only), the :func:`os.open` function " @@ -357,11 +395,3 @@ msgstr "file control(檔案控制)" #: ../../library/fcntl.rst:10 msgid "I/O control" msgstr "I/O control(I/O 控制)" - -#~ msgid "" -#~ "This module does not work or is not available on WebAssembly platforms " -#~ "``wasm32-emscripten`` and ``wasm32-wasi``. See :ref:`wasm-availability` " -#~ "for more information." -#~ msgstr "" -#~ "此模組在 WebAssembly 平台 ``wasm32-emscripten`` 和 ``wasm32-wasi`` 上無法" -#~ "作用或無法使用。有關更多資訊,請參閱 :ref:`wasm-availability`。" diff --git a/library/filecmp.po b/library/filecmp.po index 4d635d6e80..03990f1fdc 100644 --- a/library/filecmp.po +++ b/library/filecmp.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-02-19 00:13+0000\n" "PO-Revision-Date: 2015-12-09 17:51+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -35,7 +35,7 @@ msgstr "" #: ../../library/filecmp.rst:17 msgid "The :mod:`filecmp` module defines the following functions:" -msgstr "" +msgstr ":mod:`filecmp` 模組定義了以下函式:" #: ../../library/filecmp.rst:22 msgid "" @@ -87,8 +87,8 @@ msgstr "" #: ../../library/filecmp.rst:51 msgid "" -"The *shallow* parameter has the same meaning and default value as for :func:" -"`filecmp.cmp`." +"The *shallow* parameter has the same meaning and default value as " +"for :func:`filecmp.cmp`." msgstr "" #: ../../library/filecmp.rst:54 @@ -112,132 +112,136 @@ msgstr "" #: ../../library/filecmp.rst:75 msgid "" "Construct a new directory comparison object, to compare the directories *a* " -"and *b*. *ignore* is a list of names to ignore, and defaults to :const:" -"`filecmp.DEFAULT_IGNORES`. *hide* is a list of names to hide, and defaults " -"to ``[os.curdir, os.pardir]``." +"and *b*. *ignore* is a list of names to ignore, and defaults " +"to :const:`filecmp.DEFAULT_IGNORES`. *hide* is a list of names to hide, and " +"defaults to ``[os.curdir, os.pardir]``." msgstr "" #: ../../library/filecmp.rst:80 msgid "" "The :class:`dircmp` class compares files by doing *shallow* comparisons as " -"described for :func:`filecmp.cmp`." +"described for :func:`filecmp.cmp` by default using the *shallow* parameter." +msgstr "" + +#: ../../library/filecmp.rst:86 +msgid "Added the *shallow* parameter." msgstr "" -#: ../../library/filecmp.rst:83 +#: ../../library/filecmp.rst:88 msgid "The :class:`dircmp` class provides the following methods:" msgstr "" -#: ../../library/filecmp.rst:87 +#: ../../library/filecmp.rst:92 msgid "Print (to :data:`sys.stdout`) a comparison between *a* and *b*." msgstr "" -#: ../../library/filecmp.rst:91 +#: ../../library/filecmp.rst:96 msgid "" "Print a comparison between *a* and *b* and common immediate subdirectories." msgstr "" -#: ../../library/filecmp.rst:96 +#: ../../library/filecmp.rst:101 msgid "" "Print a comparison between *a* and *b* and common subdirectories " "(recursively)." msgstr "" -#: ../../library/filecmp.rst:99 +#: ../../library/filecmp.rst:104 msgid "" "The :class:`dircmp` class offers a number of interesting attributes that may " "be used to get various bits of information about the directory trees being " "compared." msgstr "" -#: ../../library/filecmp.rst:103 +#: ../../library/filecmp.rst:108 msgid "" "Note that via :meth:`~object.__getattr__` hooks, all attributes are computed " "lazily, so there is no speed penalty if only those attributes which are " "lightweight to compute are used." msgstr "" -#: ../../library/filecmp.rst:110 +#: ../../library/filecmp.rst:115 msgid "The directory *a*." msgstr "" -#: ../../library/filecmp.rst:115 +#: ../../library/filecmp.rst:120 msgid "The directory *b*." msgstr "" -#: ../../library/filecmp.rst:120 +#: ../../library/filecmp.rst:125 msgid "Files and subdirectories in *a*, filtered by *hide* and *ignore*." msgstr "" -#: ../../library/filecmp.rst:125 +#: ../../library/filecmp.rst:130 msgid "Files and subdirectories in *b*, filtered by *hide* and *ignore*." msgstr "" -#: ../../library/filecmp.rst:130 +#: ../../library/filecmp.rst:135 msgid "Files and subdirectories in both *a* and *b*." msgstr "" -#: ../../library/filecmp.rst:135 +#: ../../library/filecmp.rst:140 msgid "Files and subdirectories only in *a*." msgstr "" -#: ../../library/filecmp.rst:140 +#: ../../library/filecmp.rst:145 msgid "Files and subdirectories only in *b*." msgstr "" -#: ../../library/filecmp.rst:145 +#: ../../library/filecmp.rst:150 msgid "Subdirectories in both *a* and *b*." msgstr "" -#: ../../library/filecmp.rst:150 +#: ../../library/filecmp.rst:155 msgid "Files in both *a* and *b*." msgstr "" -#: ../../library/filecmp.rst:155 +#: ../../library/filecmp.rst:160 msgid "" "Names in both *a* and *b*, such that the type differs between the " "directories, or names for which :func:`os.stat` reports an error." msgstr "" -#: ../../library/filecmp.rst:161 +#: ../../library/filecmp.rst:166 msgid "" "Files which are identical in both *a* and *b*, using the class's file " "comparison operator." msgstr "" -#: ../../library/filecmp.rst:167 +#: ../../library/filecmp.rst:172 msgid "" "Files which are in both *a* and *b*, whose contents differ according to the " "class's file comparison operator." msgstr "" -#: ../../library/filecmp.rst:173 +#: ../../library/filecmp.rst:178 msgid "Files which are in both *a* and *b*, but could not be compared." msgstr "" -#: ../../library/filecmp.rst:178 +#: ../../library/filecmp.rst:183 msgid "" "A dictionary mapping names in :attr:`common_dirs` to :class:`dircmp` " "instances (or MyDirCmp instances if this instance is of type MyDirCmp, a " "subclass of :class:`dircmp`)." msgstr "" -#: ../../library/filecmp.rst:182 +#: ../../library/filecmp.rst:187 msgid "" "Previously entries were always :class:`dircmp` instances. Now entries are " "the same type as *self*, if *self* is a subclass of :class:`dircmp`." msgstr "" -#: ../../library/filecmp.rst:191 +#: ../../library/filecmp.rst:196 msgid "List of directories ignored by :class:`dircmp` by default." msgstr "" -#: ../../library/filecmp.rst:194 +#: ../../library/filecmp.rst:199 msgid "" "Here is a simplified example of using the ``subdirs`` attribute to search " "recursively through two directories to show common different files::" msgstr "" -#: ../../library/filecmp.rst:197 +#: ../../library/filecmp.rst:202 msgid "" ">>> from filecmp import dircmp\n" ">>> def print_diff_files(dcmp):\n" @@ -247,8 +251,8 @@ msgid "" "... for sub_dcmp in dcmp.subdirs.values():\n" "... print_diff_files(sub_dcmp)\n" "...\n" -">>> dcmp = dircmp('dir1', 'dir2') \n" -">>> print_diff_files(dcmp) " +">>> dcmp = dircmp('dir1', 'dir2')\n" +">>> print_diff_files(dcmp)" msgstr "" ">>> from filecmp import dircmp\n" ">>> def print_diff_files(dcmp):\n" @@ -258,5 +262,5 @@ msgstr "" "... for sub_dcmp in dcmp.subdirs.values():\n" "... print_diff_files(sub_dcmp)\n" "...\n" -">>> dcmp = dircmp('dir1', 'dir2') \n" -">>> print_diff_files(dcmp) " +">>> dcmp = dircmp('dir1', 'dir2')\n" +">>> print_diff_files(dcmp)" diff --git a/library/fileformats.po b/library/fileformats.po index 567de48562..9da5169774 100644 --- a/library/fileformats.po +++ b/library/fileformats.po @@ -4,13 +4,14 @@ # # Translators: # Leon H., 2017 +# Weilin Du, 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" -"PO-Revision-Date: 2017-09-22 18:26+0000\n" -"Last-Translator: Leon H.\n" +"PO-Revision-Date: 2025-06-28 00:51+0800\n" +"Last-Translator: Weilin Du\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -28,3 +29,4 @@ msgid "" "The modules described in this chapter parse various miscellaneous file " "formats that aren't markup languages and are not related to e-mail." msgstr "" +"本章所描述的模組會剖析各種非標記類型語言且與電子郵件無關的雜項檔案格式。" diff --git a/library/fileinput.po b/library/fileinput.po index c54fab2cc5..6c58733102 100644 --- a/library/fileinput.po +++ b/library/fileinput.po @@ -5,7 +5,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-01 22:24+0800\n" "PO-Revision-Date: 2018-05-23 16:01+0000\n" @@ -67,7 +67,7 @@ msgstr "" #: ../../library/fileinput.rst:35 msgid ":exc:`IOError` used to be raised; it is now an alias of :exc:`OSError`." -msgstr "" +msgstr ":exc:`IOError` 曾經被引發;現在它是一個 :exc:`OSError` 的別名。" #: ../../library/fileinput.rst:38 msgid "" diff --git a/library/filesys.po b/library/filesys.po index e682fe6090..9c42ea3858 100644 --- a/library/filesys.po +++ b/library/filesys.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,9 +6,9 @@ # Allen Wu , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-04-18 00:04+0000\n" +"POT-Creation-Date: 2024-12-29 11:18+0000\n" "PO-Revision-Date: 2021-11-22 20:13+0800\n" "Last-Translator: Allen Wu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -36,11 +35,11 @@ msgstr "" "取檔案的屬性、以可攜 (portable) 方式操作路徑以及建立暫存檔。本章中的完整 " "module 清單是:" -#: ../../library/filesys.rst:29 +#: ../../library/filesys.rst:28 msgid "Module :mod:`os`" msgstr "Module :mod:`os`" -#: ../../library/filesys.rst:30 +#: ../../library/filesys.rst:29 msgid "" "Operating system interfaces, including functions to work with files at a " "lower level than Python :term:`file objects `." @@ -48,11 +47,11 @@ msgstr "" "作業系統介面,包括處理比 Python :term:`檔案物件 `\\ 更低階檔案的" "函式。" -#: ../../library/filesys.rst:33 +#: ../../library/filesys.rst:32 msgid "Module :mod:`io`" msgstr "Module :mod:`io`" -#: ../../library/filesys.rst:34 +#: ../../library/filesys.rst:33 msgid "" "Python's built-in I/O library, including both abstract classes and some " "concrete classes such as file I/O." @@ -60,10 +59,10 @@ msgstr "" "Python 的內建 I/O 函式庫,包含抽象類別和一些具體類別 (concrete class),如檔" "案 I/O。" -#: ../../library/filesys.rst:37 +#: ../../library/filesys.rst:36 msgid "Built-in function :func:`open`" msgstr "內建函式 :func:`open`" -#: ../../library/filesys.rst:38 +#: ../../library/filesys.rst:37 msgid "The standard way to open files for reading and writing with Python." msgstr "使用 Python 打開檔案以進行讀寫檔案的標準方法。" diff --git a/library/fnmatch.po b/library/fnmatch.po index 3f51f72882..75dd730a60 100644 --- a/library/fnmatch.po +++ b/library/fnmatch.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-01-15 00:13+0000\n" "PO-Revision-Date: 2018-05-23 16:02+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -90,12 +90,20 @@ msgstr "" #: ../../library/fnmatch.rst:49 msgid "" -"Also note that :func:`functools.lru_cache` with the *maxsize* of 32768 is " -"used to cache the compiled regex patterns in the following functions: :func:" -"`fnmatch`, :func:`fnmatchcase`, :func:`.filter`." +"Unless stated otherwise, \"filename string\" and \"pattern string\" either " +"refer to :class:`str` or ``ISO-8859-1`` encoded :class:`bytes` objects. Note " +"that the functions documented below do not allow to mix a :class:`!bytes` " +"pattern with a :class:`!str` filename, and vice-versa." msgstr "" -#: ../../library/fnmatch.rst:55 +#: ../../library/fnmatch.rst:54 +msgid "" +"Finally, note that :func:`functools.lru_cache` with a *maxsize* of 32768 is " +"used to cache the (typed) compiled regex patterns in the following " +"functions: :func:`fnmatch`, :func:`fnmatchcase`, :func:`.filter`." +msgstr "" + +#: ../../library/fnmatch.rst:61 msgid "" "Test whether the filename string *name* matches the pattern string *pat*, " "returning ``True`` or ``False``. Both parameters are case-normalized using :" @@ -104,13 +112,13 @@ msgid "" "operating system." msgstr "" -#: ../../library/fnmatch.rst:61 +#: ../../library/fnmatch.rst:67 msgid "" "This example will print all file names in the current directory with the " "extension ``.txt``::" msgstr "" -#: ../../library/fnmatch.rst:64 +#: ../../library/fnmatch.rst:70 msgid "" "import fnmatch\n" "import os\n" @@ -126,35 +134,35 @@ msgstr "" " if fnmatch.fnmatch(file, '*.txt'):\n" " print(file)" -#: ../../library/fnmatch.rst:74 +#: ../../library/fnmatch.rst:80 msgid "" "Test whether the filename string *name* matches the pattern string *pat*, " "returning ``True`` or ``False``; the comparison is case-sensitive and does " "not apply :func:`os.path.normcase`." msgstr "" -#: ../../library/fnmatch.rst:81 +#: ../../library/fnmatch.rst:87 msgid "" -"Construct a list from those elements of the :term:`iterable` *names* that " -"match pattern *pat*. It is the same as ``[n for n in names if fnmatch(n, " -"pat)]``, but implemented more efficiently." +"Construct a list from those elements of the :term:`iterable` of filename " +"strings *names* that match the pattern string *pat*. It is the same as ``[n " +"for n in names if fnmatch(n, pat)]``, but implemented more efficiently." msgstr "" -#: ../../library/fnmatch.rst:89 +#: ../../library/fnmatch.rst:95 msgid "" "Return the shell-style pattern *pat* converted to a regular expression for " -"using with :func:`re.match`." +"using with :func:`re.match`. The pattern is expected to be a :class:`str`." msgstr "" -#: ../../library/fnmatch.rst:92 +#: ../../library/fnmatch.rst:98 msgid "Example:" msgstr "範例:" -#: ../../library/fnmatch.rst:106 +#: ../../library/fnmatch.rst:112 msgid "Module :mod:`glob`" msgstr ":mod:`glob` 模組" -#: ../../library/fnmatch.rst:107 +#: ../../library/fnmatch.rst:113 msgid "Unix shell-style path expansion." msgstr "" diff --git a/library/fractions.po b/library/fractions.po index 82a4c8225e..92a898b867 100644 --- a/library/fractions.po +++ b/library/fractions.po @@ -5,9 +5,9 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2016-01-31 07:18+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -43,13 +43,13 @@ msgid "" "of :class:`numbers.Rational` and returns a new :class:`Fraction` instance " "with value ``numerator/denominator``. If *denominator* is ``0``, it raises " "a :exc:`ZeroDivisionError`. The second version requires that " -"*other_fraction* is an instance of :class:`numbers.Rational` and returns a :" -"class:`Fraction` instance with the same value. The next two versions accept " -"either a :class:`float` or a :class:`decimal.Decimal` instance, and return " -"a :class:`Fraction` instance with exactly the same value. Note that due to " -"the usual issues with binary floating point (see :ref:`tut-fp-issues`), 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 " +"*other_fraction* is an instance of :class:`numbers.Rational` and returns " +"a :class:`Fraction` instance with the same value. The next two versions " +"accept either a :class:`float` or a :class:`decimal.Decimal` instance, and " +"return a :class:`Fraction` instance with exactly the same value. Note that " +"due to the usual issues with binary floating point (see :ref:`tut-fp-" +"issues`), 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 :meth:`limit_denominator` method " "below.) The last version of the constructor expects a string or unicode " "instance. The usual form for this instance is::" @@ -64,10 +64,10 @@ msgid "" "where the optional ``sign`` may be either '+' or '-' and ``numerator`` and " "``denominator`` (if present) are strings of decimal digits (underscores may " "be used to delimit digits as with integral literals in code). In addition, " -"any string that represents a finite value and is accepted by the :class:" -"`float` constructor is also accepted by the :class:`Fraction` constructor. " -"In either form the input string may also have leading and/or trailing " -"whitespace. Here are some examples::" +"any string that represents a finite value and is accepted by " +"the :class:`float` constructor is also accepted by the :class:`Fraction` " +"constructor. In either form the input string may also have leading and/or " +"trailing whitespace. Here are some examples::" msgstr "" #: ../../library/fractions.rst:52 @@ -124,18 +124,18 @@ msgstr "" #: ../../library/fractions.rst:78 msgid "" -"The :class:`Fraction` class inherits from the abstract base class :class:" -"`numbers.Rational`, and implements all of the methods and operations from " -"that class. :class:`Fraction` instances are :term:`hashable`, and should be " -"treated as immutable. In addition, :class:`Fraction` has the following " -"properties and methods:" +"The :class:`Fraction` class inherits from the abstract base " +"class :class:`numbers.Rational`, and implements all of the methods and " +"operations from that class. :class:`Fraction` instances " +"are :term:`hashable`, and should be treated as immutable. In " +"addition, :class:`Fraction` has the following properties and methods:" msgstr "" #: ../../library/fractions.rst:84 msgid "" -"The :class:`Fraction` constructor now accepts :class:`float` and :class:" -"`decimal.Decimal` instances." -msgstr "" +"The :class:`Fraction` constructor now accepts :class:`float` " +"and :class:`decimal.Decimal` instances." +msgstr ":class:`Fraction` 建構函式現在可接受 :class:`float` 和 :class:`decimal.Decimal` 實例。" #: ../../library/fractions.rst:88 msgid "" @@ -152,8 +152,8 @@ msgstr "" #: ../../library/fractions.rst:97 msgid "" -":class:`Fraction` implements ``__int__`` now to satisfy ``typing." -"SupportsInt`` instance checks." +":class:`Fraction` implements ``__int__`` now to satisfy " +"``typing.SupportsInt`` instance checks." msgstr "" #: ../../library/fractions.rst:101 @@ -168,99 +168,129 @@ msgid "" "``\"G\"`` and ``\"%\"\"``." msgstr "" -#: ../../library/fractions.rst:111 -msgid "Numerator of the Fraction in lowest term." +#: ../../library/fractions.rst:109 +msgid "" +"Formatting of :class:`Fraction` instances without a presentation type now " +"supports fill, alignment, sign handling, minimum width and grouping." msgstr "" #: ../../library/fractions.rst:115 +msgid "Numerator of the Fraction in lowest term." +msgstr "" + +#: ../../library/fractions.rst:119 msgid "Denominator of the Fraction in lowest term." msgstr "" -#: ../../library/fractions.rst:120 +#: ../../library/fractions.rst:124 msgid "" "Return a tuple of two integers, whose ratio is equal to the original " "Fraction. The ratio is in lowest terms and has a positive denominator." msgstr "" -#: ../../library/fractions.rst:128 +#: ../../library/fractions.rst:132 msgid "Return ``True`` if the Fraction is an integer." msgstr "" -#: ../../library/fractions.rst:134 +#: ../../library/fractions.rst:138 msgid "" -"Alternative constructor which only accepts instances of :class:`float` or :" -"class:`numbers.Integral`. Beware that ``Fraction.from_float(0.3)`` is not " -"the same value as ``Fraction(3, 10)``." +"Alternative constructor which only accepts instances of :class:`float` " +"or :class:`numbers.Integral`. Beware that ``Fraction.from_float(0.3)`` is " +"not the same value as ``Fraction(3, 10)``." msgstr "" -#: ../../library/fractions.rst:140 +#: ../../library/fractions.rst:144 msgid "" "From Python 3.2 onwards, you can also construct a :class:`Fraction` instance " "directly from a :class:`float`." msgstr "" -#: ../../library/fractions.rst:146 +#: ../../library/fractions.rst:150 msgid "" -"Alternative constructor which only accepts instances of :class:`decimal." -"Decimal` or :class:`numbers.Integral`." +"Alternative constructor which only accepts instances " +"of :class:`decimal.Decimal` or :class:`numbers.Integral`." msgstr "" -#: ../../library/fractions.rst:151 +#: ../../library/fractions.rst:155 msgid "" "From Python 3.2 onwards, you can also construct a :class:`Fraction` instance " "directly from a :class:`decimal.Decimal` instance." msgstr "" -#: ../../library/fractions.rst:158 +#: ../../library/fractions.rst:162 msgid "" "Finds and returns the closest :class:`Fraction` to ``self`` that has " "denominator at most max_denominator. This method is useful for finding " "rational approximations to a given floating-point number:" msgstr "" -#: ../../library/fractions.rst:166 +#: ../../library/fractions.rst:170 msgid "or for recovering a rational number that's represented as a float:" msgstr "" -#: ../../library/fractions.rst:179 +#: ../../library/fractions.rst:183 msgid "" "Returns the greatest :class:`int` ``<= self``. This method can also be " "accessed through the :func:`math.floor` function:" msgstr "" -#: ../../library/fractions.rst:189 +#: ../../library/fractions.rst:193 msgid "" "Returns the least :class:`int` ``>= self``. This method can also be " "accessed through the :func:`math.ceil` function." msgstr "" -#: ../../library/fractions.rst:196 +#: ../../library/fractions.rst:200 msgid "" "The first version returns the nearest :class:`int` to ``self``, rounding " "half to even. The second version rounds ``self`` to the nearest multiple of " "``Fraction(1, 10**ndigits)`` (logically, if ``ndigits`` is negative), again " -"rounding half toward even. This method can also be accessed through the :" -"func:`round` function." +"rounding half toward even. This method can also be accessed through " +"the :func:`round` function." msgstr "" -#: ../../library/fractions.rst:204 +#: ../../library/fractions.rst:208 msgid "" -"Provides support for float-style formatting of :class:`Fraction` instances " -"via the :meth:`str.format` method, the :func:`format` built-in function, or :" -"ref:`Formatted string literals `. The presentation types " -"``\"e\"``, ``\"E\"``, ``\"f\"``, ``\"F\"``, ``\"g\"``, ``\"G\"`` and ``\"%" -"\"`` are supported. For these presentation types, formatting for a :class:" -"`Fraction` object ``x`` follows the rules outlined for the :class:`float` " -"type in the :ref:`formatspec` section." +"Provides support for formatting of :class:`Fraction` instances via " +"the :meth:`str.format` method, the :func:`format` built-in function, " +"or :ref:`Formatted string literals `." msgstr "" #: ../../library/fractions.rst:212 +msgid "" +"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 :ref:`format " +"specification mini-language `. 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." +msgstr "" + +#: ../../library/fractions.rst:222 +msgid "" +"If the ``format_spec`` format specification string ends with one of the " +"presentation types ``'e'``, ``'E'``, ``'f'``, ``'F'``, ``'g'``, ``'G'`` or " +"``'%'`` then formatting follows the rules outlined for the :class:`float` " +"type in the :ref:`formatspec` section." +msgstr "" + +#: ../../library/fractions.rst:227 msgid "Here are some examples::" msgstr "" -#: ../../library/fractions.rst:214 +#: ../../library/fractions.rst:229 msgid "" ">>> from fractions import Fraction\n" +">>> format(Fraction(103993, 33102), '_')\n" +"'103_993/33_102'\n" +">>> format(Fraction(1, 7), '.^+10')\n" +"'...+1/7...'\n" +">>> format(Fraction(3, 1), '')\n" +"'3'\n" +">>> format(Fraction(3, 1), '#')\n" +"'3/1'\n" ">>> format(Fraction(1, 7), '.40g')\n" "'0.1428571428571428571428571428571428571429'\n" ">>> format(Fraction('1234567.855'), '_.2f')\n" @@ -272,6 +302,14 @@ msgid "" "'34.67% price increase'" msgstr "" ">>> from fractions import Fraction\n" +">>> format(Fraction(103993, 33102), '_')\n" +"'103_993/33_102'\n" +">>> format(Fraction(1, 7), '.^+10')\n" +"'...+1/7...'\n" +">>> format(Fraction(3, 1), '')\n" +"'3'\n" +">>> format(Fraction(3, 1), '#')\n" +"'3/1'\n" ">>> format(Fraction(1, 7), '.40g')\n" "'0.1428571428571428571428571428571428571429'\n" ">>> format(Fraction('1234567.855'), '_.2f')\n" @@ -282,10 +320,10 @@ msgstr "" ">>> \"{:.2%} price increase\".format(Fraction(new_price, old_price) - 1)\n" "'34.67% price increase'" -#: ../../library/fractions.rst:228 +#: ../../library/fractions.rst:251 msgid "Module :mod:`numbers`" msgstr ":mod:`numbers` 模組" -#: ../../library/fractions.rst:229 +#: ../../library/fractions.rst:252 msgid "The abstract base classes making up the numeric tower." msgstr "" diff --git a/library/frameworks.po b/library/frameworks.po index 7fd9ab13c2..3362ffdf1f 100644 --- a/library/frameworks.po +++ b/library/frameworks.po @@ -4,12 +4,13 @@ # # Translators: # Leon H., 2017 +# Weilin Du, 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" -"PO-Revision-Date: 2017-09-22 18:26+0000\n" +"PO-Revision-Date: 2025-06-27 13:41+0800\n" "Last-Translator: Leon H.\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -29,6 +30,8 @@ msgid "" "dictate the structure of your program. Currently the modules described " "here are all oriented toward writing command-line interfaces." msgstr "" +"本章所描述的模組屬於框架性質,它們將在很大程度上決定程式的結構。目前本章介" +"紹的所有模組皆專注於撰寫命令列介面。" #: ../../library/frameworks.rst:11 msgid "The full list of modules described in this chapter is:" diff --git a/library/ftplib.po b/library/ftplib.po index 3042e7310a..8c47a8eb7e 100644 --- a/library/ftplib.po +++ b/library/ftplib.po @@ -5,9 +5,9 @@ # Matt Wang , 2023-2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2024-10-11 00:13+0000\n" "PO-Revision-Date: 2023-04-26 19:44+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -46,17 +46,16 @@ msgid "The default encoding is UTF-8, following :rfc:`2640`." msgstr "預設編碼是 UTF-8,遵循 :rfc:`2640`。" #: ../../includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not Emscripten, not WASI." -msgstr ":ref:`Availability `:非 Emscripten、非 WASI。" +msgid "Availability" +msgstr "可用性" #: ../../includes/wasm-notavail.rst:5 msgid "" -"This module does not work or is not available on WebAssembly platforms " -"``wasm32-emscripten`` and ``wasm32-wasi``. See :ref:`wasm-availability` for " -"more information." +"This module does not work or is not available on WebAssembly. See :ref:`wasm-" +"availability` for more information." msgstr "" -"此模組在 WebAssembly 平台 ``wasm32-emscripten`` 和 ``wasm32-wasi`` 上不起作用" -"或無法使用。有關更多資訊,請參閱 :ref:`wasm-availability`。" +"此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" +"availability`。" #: ../../library/ftplib.rst:26 msgid "Here's a sample session using the :mod:`ftplib` module::" @@ -456,7 +455,7 @@ msgid "" "but server is not guaranteed to return all requested facts." msgstr "" "使用 ``MLSD`` 命令 (:rfc:`3659`) 列出標準格式的目錄。如果省略 *path* 則假定為" -"作用於當前目錄。*facts* 是表示所需資訊類型的字串列表(例如 ``[\"type\", " +"作用於目前目錄。*facts* 是表示所需資訊類型的字串列表(例如 ``[\"type\", " "\"size\", \"perm\"]`` )。會回傳一個產生器物件,為每個在路徑中找到的檔案生成" "一個包含兩個元素的元組,第一個元素是檔案名稱,第二個元素是包含有關檔案名稱 " "facts的字典。該字典的內容可能受 *facts* 引數限制,但不保證伺服器會回傳所有請" @@ -470,7 +469,7 @@ msgid "" "the ``NLST`` command." msgstr "" "回傳由 ``NLST`` 命令回傳的檔案名稱列表。可選的 *argument* 是要列出的目錄(預" -"設為當前伺服器目錄)。多個引數可用於將非標準選項傳遞給 ``NLST`` 命令。" +"設為目前伺服器目錄)。多個引數可用於將非標準選項傳遞給 ``NLST`` 命令。" #: ../../library/ftplib.rst:373 ../../library/ftplib.rst:385 msgid "If your server supports the command, :meth:`mlsd` offers a better API." @@ -486,7 +485,7 @@ msgid "" "default prints to :data:`sys.stdout`. This method returns ``None``." msgstr "" "生成由 ``LIST`` 命令回傳的目錄列表,並將其印出到標準輸出 (standard output)。" -"可選的 *argument* 是要列出的目錄(預設為當前伺服器目錄)。有多個引數可用於將" +"可選的 *argument* 是要列出的目錄(預設為目前伺服器目錄)。有多個引數可用於將" "非標準選項傳遞給 ``LIST`` 命令。如果最後一個引數是一個函式,它被用作 :meth:" "`retrlines` 的 *callback* 函式;預設印出到 :data:`sys.stdout`。此方法回傳 " "``None``。" @@ -506,7 +505,7 @@ msgstr "" #: ../../library/ftplib.rst:402 msgid "Set the current directory on the server." -msgstr "設定伺服器上的當前目錄。" +msgstr "設定伺服器上的目前目錄。" #: ../../library/ftplib.rst:407 msgid "Create a new directory on the server." @@ -514,7 +513,7 @@ msgstr "在伺服器上建立一個新目錄。" #: ../../library/ftplib.rst:412 msgid "Return the pathname of the current directory on the server." -msgstr "回傳伺服器上當前目錄的路徑名。" +msgstr "回傳伺服器上目前目錄的路徑名。" #: ../../library/ftplib.rst:417 msgid "Remove the directory named *dirname* on the server." diff --git a/library/functional.po b/library/functional.po index 9c3ef0e55d..89f98aafb8 100644 --- a/library/functional.po +++ b/library/functional.po @@ -1,12 +1,11 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2017-09-22 18:26+0000\n" @@ -21,13 +20,15 @@ msgstr "" #: ../../library/functional.rst:3 msgid "Functional Programming Modules" -msgstr "函式編程模組" +msgstr "函式程式設計模組" #: ../../library/functional.rst:5 msgid "" "The modules described in this chapter provide functions and classes that " "support a functional programming style, and general operations on callables." msgstr "" +"本章節所描述的模組提供了支援函式程式設計風格的函式和類別,以及對可呼叫物件的" +"一般操作。" #: ../../library/functional.rst:8 msgid "The following modules are documented in this chapter:" diff --git a/library/functions.po b/library/functions.po index 94c87764ac..fb90fa4b56 100644 --- a/library/functions.po +++ b/library/functions.po @@ -8,9 +8,9 @@ # Steven Hsu , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-07 03:11+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2024-05-06 17:06+0800\n" "Last-Translator: KNChiu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -514,13 +514,12 @@ msgid "" "ways." msgstr "如果不一定需要 \"0b\" 前綴,還可以使用如下的方法。" -#: ../../library/functions.rst:141 ../../library/functions.rst:909 -#: ../../library/functions.rst:1246 +#: ../../library/functions.rst:141 ../../library/functions.rst:942 +#: ../../library/functions.rst:1323 msgid "See also :func:`format` for more information." -msgstr "可參考 :func:`format` 獲取更多資訊。" +msgstr "可參考 :func:`format` 取得更多資訊。" #: ../../library/functions.rst:146 -#, fuzzy msgid "" "Return a Boolean value, i.e. one of ``True`` or ``False``. The argument is " "converted using the standard :ref:`truth testing procedure `. If the " @@ -529,13 +528,13 @@ msgid "" "`typesnumeric`). It cannot be subclassed further. Its only instances are " "``False`` and ``True`` (see :ref:`typebool`)." msgstr "" -"回傳一個布林值,即 ``True`` 或者 ``False``。*x* 使用標準的\\ :ref:`真值測試程" -"序 `\\ 來轉換。如果 *x* 為假或者被省略,則回傳 ``False``;其他情況回" +"回傳一個布林值,即 ``True`` 或者 ``False``。引數會使用標準的\\ :ref:`真值測試" +"程序 `\\ 來轉換。如果引數為假或者被省略,則回傳 ``False``;其他情況回" "傳 ``True``。:class:`bool` class(類別)是 :class:`int` 的 subclass(子類別)" "(參見 :ref:`typesnumeric`),其他 class 不能繼承自它。它只有 ``False`` 和 " "``True`` 兩個實例(參見 :ref:`typebool`)。" -#: ../../library/functions.rst:156 ../../library/functions.rst:774 +#: ../../library/functions.rst:156 ../../library/functions.rst:807 msgid "The parameter is now positional-only." msgstr "現在為僅限位置參數。" @@ -764,15 +763,17 @@ msgstr "" #: ../../library/functions.rst:285 msgid "" -"Class methods now inherit the method attributes (``__module__``, " -"``__name__``, ``__qualname__``, ``__doc__`` and ``__annotations__``) and " -"have a new ``__wrapped__`` attribute." +"Class methods now inherit the method attributes (:attr:`~function." +"__module__`, :attr:`~function.__name__`, :attr:`~function.__qualname__`, :" +"attr:`~function.__doc__` and :attr:`~function.__annotations__`) and have a " +"new ``__wrapped__`` attribute." msgstr "" -"Class method 現在繼承了 method 屬性(``__module__``、``__name__``、" -"``__qualname__``、``__doc__`` 和 ``__annotations__``),並擁有一個新的 " +"Class method 現在繼承了 method 屬性(:attr:`~function.__module__`、:attr:" +"`~function.__name__`、:attr:`~function.__qualname__`、:attr:`~function." +"__doc__` 和 :attr:`~function.__annotations__`),並擁有一個新的 " "``__wrapped__`` 屬性。" -#: ../../library/functions.rst:290 +#: ../../library/functions.rst:292 msgid "" "Class methods can no longer wrap other :term:`descriptors ` such " "as :func:`property`." @@ -780,7 +781,7 @@ msgstr "" "Class methods 不能再包裝其他的\\ :term:`描述器 `,例如 :func:" "`property`。" -#: ../../library/functions.rst:297 +#: ../../library/functions.rst:299 msgid "" "Compile the *source* into a code or AST object. Code objects can be " "executed by :func:`exec` or :func:`eval`. *source* can either be a normal " @@ -791,7 +792,7 @@ msgstr "" "`eval` 執行。*source* 可以是一般的字串、bytes 字串、或者 AST 物件。參見 :mod:" "`ast` module(模組)的說明文件瞭解如何使用 AST 物件。" -#: ../../library/functions.rst:302 +#: ../../library/functions.rst:304 msgid "" "The *filename* argument should give the file from which the code was read; " "pass some recognizable value if it wasn't read from a file (``''`` " @@ -800,7 +801,7 @@ msgstr "" "*filename* 引數必須是程式碼的檔名;如果程式碼不是從檔案中讀取,可以傳入一些可" "辨識的值(經常會使用 ``''`` 來替代)。" -#: ../../library/functions.rst:306 +#: ../../library/functions.rst:308 msgid "" "The *mode* argument specifies what kind of code must be compiled; it can be " "``'exec'`` if *source* consists of a sequence of statements, ``'eval'`` if " @@ -813,7 +814,7 @@ msgstr "" "式,可以是 ``'single'``\\ (在最後一種情況下,如果運算式執行結果不是 " "``None`` 則會被印出來)。" -#: ../../library/functions.rst:312 +#: ../../library/functions.rst:314 msgid "" "The optional arguments *flags* and *dont_inherit* control which :ref:" "`compiler options ` should be activated and which :ref:" @@ -831,9 +832,9 @@ msgstr "" "(或兩者都為零),則會呼叫與 :func:`compile` 相同旗標的程式碼來編譯。如果給" "定 *flags* 引數而未給定 *dont_inherit*(或為零)則無論如何都會使用由 *flags* " "引數所指定的編譯器選項和未來陳述式。如果 *dont_inherit* 是一個非零整數,則使" -"用 *flags* 引數 -- 周圍程式碼中的旗標(未來功能和編譯器選項)將被忽略。" +"用 *flags* 引數 -- 周圍程式碼中的旗標(未來功能和編譯器選項)將被忽略。" -#: ../../library/functions.rst:323 +#: ../../library/functions.rst:325 msgid "" "Compiler options and future statements are specified by bits which can be " "bitwise ORed together to specify multiple options. The bitfield required to " @@ -848,7 +849,7 @@ msgstr "" "compiler_flag` 屬性來獲得。:ref:`編譯器旗標 `\\ 可以在 :" "mod:`ast` module 中搜尋有 ``PyCF_`` 前綴的名稱。" -#: ../../library/functions.rst:331 +#: ../../library/functions.rst:333 msgid "" "The argument *optimize* specifies the optimization level of the compiler; " "the default value of ``-1`` selects the optimization level of the " @@ -861,7 +862,7 @@ msgstr "" "``__debug__`` 為真值)、``1``\\ (assert 被刪除,``__debug__`` 為假值)或 " "``2``\\ (說明字串 (docstring) 也被刪除)。" -#: ../../library/functions.rst:337 +#: ../../library/functions.rst:339 msgid "" "This function raises :exc:`SyntaxError` if the compiled source is invalid, " "and :exc:`ValueError` if the source contains null bytes." @@ -869,13 +870,13 @@ msgstr "" "如果編譯的原始碼無效,此函式會引發 :exc:`SyntaxError`,如果原始碼包含 null " "bytes,則會引發 :exc:`ValueError`。" -#: ../../library/functions.rst:340 +#: ../../library/functions.rst:342 msgid "" "If you want to parse Python code into its AST representation, see :func:`ast." "parse`." msgstr "如果你想解析 Python 程式碼為 AST 運算式,請參閱 :func:`ast.parse`。" -#: ../../library/functions.rst:343 ../../library/functions.rst:345 +#: ../../library/functions.rst:345 ../../library/functions.rst:347 msgid "" "Raises an :ref:`auditing event ` ``compile`` with arguments " "``source`` and ``filename``. This event may also be raised by implicit " @@ -884,7 +885,7 @@ msgstr "" "引發一個附帶引數 ``source``、``filename`` 的\\ :ref:`稽核事件 ` " "``compile``。此事件也可能由隱式編譯 (implicit compilation) 所引發。" -#: ../../library/functions.rst:351 +#: ../../library/functions.rst:353 msgid "" "When compiling a string with multi-line code in ``'single'`` or ``'eval'`` " "mode, input must be terminated by at least one newline character. This is " @@ -894,7 +895,7 @@ msgstr "" "在 ``'single'`` 或 ``'eval'`` 模式編譯多行程式碼時,輸入必須以至少一個換行符" "結尾。這使 :mod:`code` module 更容易檢測陳述式的完整性。" -#: ../../library/functions.rst:358 +#: ../../library/functions.rst:360 msgid "" "It is possible to crash the Python interpreter with a sufficiently large/" "complex string when compiling to an AST object due to stack depth " @@ -903,7 +904,7 @@ msgstr "" "如果編譯足夠大或者足夠複雜的字串成 AST 物件時,Python 直譯器會因為 Python " "AST 編譯器的 stack 深度限制而崩潰。" -#: ../../library/functions.rst:362 +#: ../../library/functions.rst:364 msgid "" "Allowed use of Windows and Mac newlines. Also, input in ``'exec'`` mode " "does not have to end in a newline anymore. Added the *optimize* parameter." @@ -911,13 +912,13 @@ msgstr "" "允許使用 Windows 和 Mac 的換行符號。此外,在 ``'exec'`` 模式不需要以換行符號" "結尾。增加了 *optimize* 參數。" -#: ../../library/functions.rst:366 +#: ../../library/functions.rst:368 msgid "" "Previously, :exc:`TypeError` was raised when null bytes were encountered in " "*source*." msgstr "在之前的版本,*source* 中包含 null bytes 會引發 :exc:`TypeError`。" -#: ../../library/functions.rst:370 +#: ../../library/functions.rst:372 msgid "" "``ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`` can now be passed in flags to enable " "support for top-level ``await``, ``async for``, and ``async with``." @@ -925,18 +926,18 @@ msgstr "" "``ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`` 現在可以傳遞旗標以啟用對頂層 ``await``、" "``async for`` 和 ``async with`` 的支援。" -#: ../../library/functions.rst:379 +#: ../../library/functions.rst:381 msgid "" "Convert a single string or number to a complex number, or create a complex " "number from real and imaginary parts." msgstr "" -#: ../../library/functions.rst:382 ../../library/functions.rst:719 -#: ../../library/functions.rst:965 +#: ../../library/functions.rst:384 ../../library/functions.rst:752 +#: ../../library/functions.rst:998 msgid "Examples:" msgstr "例如: ::" -#: ../../library/functions.rst:384 +#: ../../library/functions.rst:386 msgid "" ">>> complex('+1.23')\n" "(1.23+0j)\n" @@ -972,7 +973,7 @@ msgstr "" ">>> complex(-1.23, 4.5)\n" "(-1.23+4.5j)" -#: ../../library/functions.rst:403 +#: ../../library/functions.rst:405 msgid "" "If the argument is a string, it must contain either a real part (in the same " "format as for :func:`float`) or an imaginary part (in the same format but " @@ -987,8 +988,7 @@ msgid "" "parentheses and leading and trailing whitespace characters are removed:" msgstr "" -#: ../../library/functions.rst:422 -#, fuzzy +#: ../../library/functions.rst:424 msgid "" "If the argument is a number, the constructor serves as a numeric conversion " "like :class:`int` and :class:`float`. For a general Python object ``x``, " @@ -997,12 +997,13 @@ msgid "" "If :meth:`!__float__` is not defined then it falls back to :meth:`~object." "__index__`." msgstr "" -"對於一個普通的 Python 物件 ``x``,``complex(x)`` 會委派給 ``x." +"如果引數是一個數字,則建構函式會像 :class:`int` 和 :class:`float` 一樣進行數" +"值轉換。對於一個普通的 Python 物件 ``x``,``complex(x)`` 會委派給 ``x." "__complex__()``。如果 :meth:`~object.__complex__` 未定義,則會回退 (fall " "back) 到 :meth:`~object.__float__`。如果 :meth:`!__float__` 未定義,則會再回" "退到 :meth:`~object.__index__`。" -#: ../../library/functions.rst:431 +#: ../../library/functions.rst:433 msgid "" "If two arguments are provided or keyword arguments are used, each argument " "may be any numeric type (including complex). If both arguments are real " @@ -1013,20 +1014,20 @@ msgid "" "number, only its real component is used in the above expressions." msgstr "" -#: ../../library/functions.rst:441 +#: ../../library/functions.rst:443 msgid "If all arguments are omitted, returns ``0j``." msgstr "" -#: ../../library/functions.rst:443 +#: ../../library/functions.rst:445 msgid "The complex type is described in :ref:`typesnumeric`." msgstr "複數型別在 :ref:`typesnumeric` 中有相關描述。" -#: ../../library/functions.rst:445 ../../library/functions.rst:771 -#: ../../library/functions.rst:1014 +#: ../../library/functions.rst:447 ../../library/functions.rst:804 +#: ../../library/functions.rst:1047 msgid "Grouping digits with underscores as in code literals is allowed." msgstr "可以使用底線將程式碼文字中的數字進行分組。" -#: ../../library/functions.rst:448 +#: ../../library/functions.rst:450 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__complex__` and :" "meth:`~object.__float__` are not defined." @@ -1034,7 +1035,7 @@ msgstr "" "如果 :meth:`~object.__complex__` 和 :meth:`~object.__float__` 未定義,則會回" "退到 :meth:`~object.__index__`。" -#: ../../library/functions.rst:455 +#: ../../library/functions.rst:457 msgid "" "This is a relative of :func:`setattr`. The arguments are an object and a " "string. The string must be the name of one of the object's attributes. The " @@ -1047,7 +1048,7 @@ msgstr "" "'foobar')`` 等價於 ``del x.foobar``。*name* 不必是個 Python 識別符 " "(identifier)(請見 :func:`setattr`)。" -#: ../../library/functions.rst:468 +#: ../../library/functions.rst:470 msgid "" "Create a new dictionary. The :class:`dict` object is the dictionary class. " "See :class:`dict` and :ref:`typesmapping` for documentation about this class." @@ -1055,7 +1056,7 @@ msgstr "" "建立一個新的 dictionary(字典)。:class:`dict` 物件是一個 dictionary class。" "參見 :class:`dict` 和 :ref:`typesmapping` 來瞭解這個 class。" -#: ../../library/functions.rst:471 +#: ../../library/functions.rst:473 msgid "" "For other containers see the built-in :class:`list`, :class:`set`, and :" "class:`tuple` classes, as well as the :mod:`collections` module." @@ -1063,16 +1064,16 @@ msgstr "" "其他容器型別,請參見內建的 :class:`list`、:class:`set` 和 :class:`tuple` " "class,以及 :mod:`collections` module。" -#: ../../library/functions.rst:478 +#: ../../library/functions.rst:480 msgid "" "Without arguments, return the list of names in the current local scope. " "With an argument, attempt to return a list of valid attributes for that " "object." msgstr "" -"如果沒有引數,則回傳當前區域作用域 (local scope) 中的名稱列表。如果有引數,它" +"如果沒有引數,則回傳目前區域作用域 (local scope) 中的名稱列表。如果有引數,它" "會嘗試回傳該物件的有效屬性列表。" -#: ../../library/functions.rst:481 +#: ../../library/functions.rst:483 msgid "" "If the object has a method named :meth:`~object.__dir__`, this method will " "be called and must return the list of attributes. This allows objects that " @@ -1085,7 +1086,7 @@ msgstr "" "或 :func:`~object.__getattribute__` 函式的物件能夠自定義 :func:`dir` 來報告它" "們的屬性。" -#: ../../library/functions.rst:488 +#: ../../library/functions.rst:490 msgid "" "If the object does not provide :meth:`~object.__dir__`, the function tries " "its best to gather information from the object's :attr:`~object.__dict__` " @@ -1097,7 +1098,7 @@ msgstr "" "`~object.__dict__` 屬性和型別物件收集資訊。結果列表並不總是完整的,如果物件有" "自定義 :func:`~object.__getattr__`,那結果可能不準確。" -#: ../../library/functions.rst:494 +#: ../../library/functions.rst:496 msgid "" "The default :func:`dir` mechanism behaves differently with different types " "of objects, as it attempts to produce the most relevant, rather than " @@ -1106,13 +1107,13 @@ msgstr "" "預設的 :func:`dir` 機制對不同型別的物件有不同行為,它會試圖回傳最相關而非最完" "整的資訊:" -#: ../../library/functions.rst:498 +#: ../../library/functions.rst:500 msgid "" "If the object is a module object, the list contains the names of the " "module's attributes." msgstr "如果物件是 module 物件,則列表包含 module 的屬性名稱。" -#: ../../library/functions.rst:501 +#: ../../library/functions.rst:503 msgid "" "If the object is a type or class object, the list contains the names of its " "attributes, and recursively of the attributes of its bases." @@ -1120,7 +1121,7 @@ msgstr "" "如果物件是型別或 class 物件,則列表包含它們的屬性名稱,並且遞迴查詢其基礎的所" "有屬性。" -#: ../../library/functions.rst:504 +#: ../../library/functions.rst:506 msgid "" "Otherwise, the list contains the object's attributes' names, the names of " "its class's attributes, and recursively of the attributes of its class's " @@ -1129,11 +1130,11 @@ msgstr "" "否則,包含物件的屬性名稱列表、它的 class 屬性名稱,並且遞迴查詢它的 class 的" "所有基礎 class 的屬性。" -#: ../../library/functions.rst:508 +#: ../../library/functions.rst:510 msgid "The resulting list is sorted alphabetically. For example:" msgstr "回傳的列表按字母表排序,例如:" -#: ../../library/functions.rst:528 +#: ../../library/functions.rst:530 msgid "" "Because :func:`dir` is supplied primarily as a convenience for use at an " "interactive prompt, it tries to supply an interesting set of names more than " @@ -1146,7 +1147,7 @@ msgstr "" "版本之間改變。例如,當引數是一個 class 時,metaclass 的屬性不包含在結果列表" "中。" -#: ../../library/functions.rst:538 +#: ../../library/functions.rst:540 msgid "" "Take two (non-complex) numbers as arguments and return a pair of numbers " "consisting of their quotient and remainder when using integer division. " @@ -1164,7 +1165,7 @@ msgstr "" "等,如果 ``a % b`` 非零,則它的符號和 *b* 一樣,且 ``0 <= abs(a % b) < " "abs(b)``。" -#: ../../library/functions.rst:550 +#: ../../library/functions.rst:552 msgid "" "Return an enumerate object. *iterable* must be a sequence, an :term:" "`iterator`, or some other object which supports iteration. The :meth:" @@ -1177,11 +1178,11 @@ msgstr "" "__next__` method 回傳一個 tuple(元組),裡面包含一個計數值(從 *start* 開" "始,預設為 0)和透過疊代 *iterable* 獲得的值。" -#: ../../library/functions.rst:562 +#: ../../library/functions.rst:564 msgid "Equivalent to::" msgstr "等價於: ::" -#: ../../library/functions.rst:564 +#: ../../library/functions.rst:566 msgid "" "def enumerate(iterable, start=0):\n" " n = start\n" @@ -1199,15 +1200,15 @@ msgstr "" msgid "Parameters" msgstr "" -#: ../../library/functions.rst:574 +#: ../../library/functions.rst:576 msgid "A Python expression." msgstr "" -#: ../../library/functions.rst:578 +#: ../../library/functions.rst:580 msgid "The global namespace (default: ``None``)." msgstr "" -#: ../../library/functions.rst:582 +#: ../../library/functions.rst:584 msgid "The local namespace (default: ``None``)." msgstr "" @@ -1215,7 +1216,7 @@ msgstr "" msgid "Returns" msgstr "" -#: ../../library/functions.rst:586 +#: ../../library/functions.rst:588 msgid "The result of the evaluated expression." msgstr "" @@ -1223,41 +1224,51 @@ msgstr "" msgid "raises" msgstr "引發" -#: ../../library/functions.rst:587 +#: ../../library/functions.rst:589 msgid "Syntax errors are reported as exceptions." msgstr "" -#: ../../library/functions.rst:589 +#: ../../library/functions.rst:593 ../../library/functions.rst:654 +msgid "" +"This function executes arbitrary code. Calling it with user-supplied input " +"may lead to security vulnerabilities." +msgstr "" + +#: ../../library/functions.rst:596 msgid "" "The *expression* argument is parsed and evaluated as a Python expression " "(technically speaking, a condition list) using the *globals* and *locals* " -"dictionaries as global and local namespace. If the *globals* dictionary is " +"mappings as global and local namespace. If the *globals* dictionary is " "present and does not contain a value for the key ``__builtins__``, a " "reference to the dictionary of the built-in module :mod:`builtins` is " "inserted under that key before *expression* is parsed. That way you can " "control what builtins are available to the executed code by inserting your " "own ``__builtins__`` dictionary into *globals* before passing it to :func:" -"`eval`. If the *locals* dictionary is omitted it defaults to the *globals* " -"dictionary. If both dictionaries are omitted, the expression is executed " -"with the *globals* and *locals* in the environment where :func:`eval` is " -"called. Note, *eval()* does not have access to the :term:`nested scopes " -"` (non-locals) in the enclosing environment." +"`eval`. If the *locals* mapping is omitted it defaults to the *globals* " +"dictionary. If both mappings are omitted, the expression is executed with " +"the *globals* and *locals* in the environment where :func:`eval` is called. " +"Note, *eval()* will only have access to the :term:`nested scopes ` (non-locals) in the enclosing environment if they are already " +"referenced in the scope that is calling :func:`eval` (e.g. via a :keyword:" +"`nonlocal` statement)." msgstr "" "*expression* 引數會被視為一條 Python 運算式(技術上而言,是條件列表)來剖析及" -"求值,而 *globals* 和 *locals* dictionaries 分別用作全域和區域命名空間。如果 " +"求值,而 *globals* 和 *locals* 對映分別用作全域和區域命名空間。如果 " "*globals* dictionary 存在但缺少 ``__builtins__`` 的鍵值,那 *expression* 被剖" "析之前,將為該鍵插入對內建 :mod:`builtins` module dictionary 的引用。這麼一" "來,在將 ``__builtins__`` dictionary 傳入 :func:`eval` 之前,你可以透過將它插" -"入 *globals* 來控制你需要哪些內建函式來執行程式碼。如果 *locals* 被省略,那它" -"的預設值是 *globals* dictionary。如果兩個 dictionary 引數都被省略,則在 :" -"func:`eval` 被呼叫的環境中執行運算式。請注意,*eval()* 在封閉 (enclosing) 環" -"境中無法存取\\ :term:`巢狀作用域 ` (non-locals)。" - -#: ../../library/functions.rst:604 +"入 *globals* 來控制你需要哪些內建函式來執行程式碼。如果 *locals* 對映被省略," +"那它的預設值是 *globals* dictionary。如果兩個對映都被省略,則以在 :func:" +"`eval` 被呼叫的環境中的 *globals* 和 *locals* 執行運算式。請注意,*eval()* 在" +"封閉 (enclosing) 環境中無法存取\\ :term:`巢狀作用域 ` (non-" +"locals),除非呼叫 :func:`eval` 的作用域已經有參照它們(例如透過 :keyword:" +"`nonlocal` 陳述式)。" + +#: ../../library/functions.rst:612 msgid "Example:" msgstr "範例:" -#: ../../library/functions.rst:610 +#: ../../library/functions.rst:618 msgid "" "This function can also be used to execute arbitrary code objects (such as " "those created by :func:`compile`). In this case, pass a code object instead " @@ -1268,7 +1279,7 @@ msgstr "" "情況下,傳入的引數是程式碼物件而不是字串。如果編譯該物件時的 *mode* 引數是 " "``'exec'``,那麼 :func:`eval` 回傳值為 ``None``。" -#: ../../library/functions.rst:615 +#: ../../library/functions.rst:623 msgid "" "Hints: dynamic execution of statements is supported by the :func:`exec` " "function. The :func:`globals` and :func:`locals` functions return the " @@ -1276,16 +1287,16 @@ msgid "" "pass around for use by :func:`eval` or :func:`exec`." msgstr "" "提示::func:`exec` 函式支援動態執行陳述式。:func:`globals` 和 :func:`locals` " -"函式分別回傳當前的全域性和局部性 dictionary,它們對於將引數傳遞給 :func:" +"函式分別回傳目前的全域性和局部性 dictionary,它們對於將引數傳遞給 :func:" "`eval` 或 :func:`exec` 可能會方便許多。" -#: ../../library/functions.rst:620 +#: ../../library/functions.rst:628 msgid "" "If the given source is a string, then leading and trailing spaces and tabs " "are stripped." msgstr "如果給定來源是一個字串,那麼其前後的空格和定位字元會被移除。" -#: ../../library/functions.rst:623 +#: ../../library/functions.rst:631 msgid "" "See :func:`ast.literal_eval` for a function that can safely evaluate strings " "with expressions containing only literals." @@ -1293,8 +1304,8 @@ msgstr "" "另外可以參閱 :func:`ast.literal_eval`,該函式可以安全執行僅包含文字的運算式字" "串。" -#: ../../library/functions.rst:626 ../../library/functions.rst:628 -#: ../../library/functions.rst:671 ../../library/functions.rst:673 +#: ../../library/functions.rst:634 ../../library/functions.rst:636 +#: ../../library/functions.rst:696 ../../library/functions.rst:698 msgid "" "Raises an :ref:`auditing event ` ``exec`` with the code object as " "the argument. Code compilation events may also be raised." @@ -1302,9 +1313,19 @@ msgstr "" "引發一個附帶程式碼物件為引數的\\ :ref:`稽核事件 ` ``exec``。也可能" "會引發程式碼編譯事件。" -#: ../../library/functions.rst:635 +#: ../../library/functions.rst:641 ../../library/functions.rst:718 +msgid "The *globals* and *locals* arguments can now be passed as keywords." +msgstr "" + +#: ../../library/functions.rst:645 ../../library/functions.rst:722 msgid "" -"This function supports dynamic execution of Python code. *object* must be " +"The semantics of the default *locals* namespace have been adjusted as " +"described for the :func:`locals` builtin." +msgstr "" + +#: ../../library/functions.rst:657 +msgid "" +"This function supports dynamic execution of Python code. *source* must be " "either a string or a code object. If it is a string, the string is parsed " "as a suite of Python statements which is then executed (unless a syntax " "error occurs). [#]_ If it is a code object, it is simply executed. In all " @@ -1314,7 +1335,7 @@ msgid "" "not be used outside of function definitions even within the context of code " "passed to the :func:`exec` function. The return value is ``None``." msgstr "" -"這個函式支援動態執行 Python 程式碼。*object* 必須是字串或者程式碼物件。如果是" +"這個函式支援動態執行 Python 程式碼。*source* 必須是字串或者程式碼物件。如果是" "字串,那麼該字串將被剖析為一系列 Python 陳述式並執行(除非發生語法錯誤)。" "[#]_ 如果是程式碼物件,它將被直接執行。無論哪種情況,被執行的程式碼都需要和檔" "案輸入一樣是有效的(可參閱語言參考手冊中關於\\ :ref:`file-input`\\ 的章節)。" @@ -1322,8 +1343,7 @@ msgstr "" "`nonlocal`、:keyword:`yield` 和 :keyword:`return` 陳述式也不能在函式之外使" "用。該函式回傳值是 ``None``。" -#: ../../library/functions.rst:646 -#, fuzzy +#: ../../library/functions.rst:668 msgid "" "In all cases, if the optional parts are omitted, the code is executed in the " "current scope. If only *globals* is provided, it must be a dictionary (and " @@ -1333,22 +1353,22 @@ msgid "" "any mapping object. Remember that at the module level, globals and locals " "are the same dictionary." msgstr "" -"無論哪種情況,如果省略了選擇性引數,程式碼將在當前作用域內執行。如果只提供了 " -"*globals* 引數,就必須是 dictionary 型別,而且會被用作全域性和本地變數。如果" -"同時提供了 *globals* 和 *locals* 引數,它們分別被用作全域性和本地變數。如果提" -"供了 *locals* 引數,則它可以是任何映射物件。請記住在 module 層級中全域性和本" -"地變數是相同的 dictionary。" +"無論哪種情況,如果省略了選擇性的部分,程式碼將在目前作用域內執行。如果只提供" +"了 *globals* 引數,就必須是 dictionary 型別(且不能是 dictionary 的子類別)," +"而且會被用作全域和區域變數。如果同時提供了 *globals* 和 *locals*,它們分別被" +"用作全域和區域變數。如果提供了 *locals*,則它可以是任何對映物件。請記住在 " +"module 層級中全域和區域變數是相同的 dictionary。" -#: ../../library/functions.rst:656 +#: ../../library/functions.rst:678 msgid "" -"Most users should just pass a *globals* argument and never *locals*. If exec " -"gets two separate objects as *globals* and *locals*, the code will be " -"executed as if it were embedded in a class definition." +"When ``exec`` gets two separate objects as *globals* and *locals*, the code " +"will be executed as if it were embedded in a class definition. This means " +"functions and classes defined in the executed code will not be able to " +"access variables assigned at the top level (as the \"top level\" variables " +"are treated as class variables in a class definition)." msgstr "" -"大部分使用者只需要傳入 *globals* 引數,而不用傳遞 *locals*。如果 exec 有兩個" -"不同的 *globals* 和 *locals* 物件,程式碼就像嵌入在 class 定義中一樣執行。" -#: ../../library/functions.rst:660 +#: ../../library/functions.rst:684 msgid "" "If the *globals* dictionary does not contain a value for the key " "``__builtins__``, a reference to the dictionary of the built-in module :mod:" @@ -1361,42 +1381,42 @@ msgstr "" "dictionary 傳入 :func:`exec` 之前,你可以透過將它插入 *globals* 來控制你需要" "哪些內建函式來執行程式碼。" -#: ../../library/functions.rst:666 +#: ../../library/functions.rst:690 msgid "" "The *closure* argument specifies a closure--a tuple of cellvars. It's only " -"valid when the *object* is a code object containing free variables. The " -"length of the tuple must exactly match the number of free variables " -"referenced by the code object." +"valid when the *object* is a code object containing :term:`free (closure) " +"variables `. The length of the tuple must exactly match " +"the length of the code object's :attr:`~codeobject.co_freevars` attribute." msgstr "" "*closure* 引數會指定一個閉包 (closure) — 它是一個 cellvar(格變數)的 tuple。" -"只有在 *object* 是一個含有自由變數 (free variable) 的程式碼物件時,它才有效。" -"Tuple 的長度必須與程式碼物件所引用的自由變數數量完全匹配。" +"只有在 *object* 是一個含有\\ :term:`自由(閉包)變數 (free (closure) " +"variables) ` 的程式碼物件時,它才有效。Tuple 的長度必須與程" +"式碼物件的 :attr:`~codeobject.co_freevars` 屬性完全匹配。" -#: ../../library/functions.rst:678 +#: ../../library/functions.rst:703 msgid "" "The built-in functions :func:`globals` and :func:`locals` return the current " -"global and local dictionary, respectively, which may be useful to pass " -"around for use as the second and third argument to :func:`exec`." +"global and local namespace, respectively, which may be useful to pass around " +"for use as the second and third argument to :func:`exec`." msgstr "" -"內建 :func:`globals` 和 :func:`locals` 函式各自回傳當前的全域性和本地 " -"dictionary,因此可以將它們傳遞給 :func:`exec` 的第二個和第三個引數。" +"內建 :func:`globals` 和 :func:`locals` 函式各自回傳目前的全域和區域命名空間," +"因此可以將它們傳遞給 :func:`exec` 的第二個和第三個引數以供後續使用。" -#: ../../library/functions.rst:684 +#: ../../library/functions.rst:709 msgid "" -"The default *locals* act as described for function :func:`locals` below: " -"modifications to the default *locals* dictionary should not be attempted. " +"The default *locals* act as described for function :func:`locals` below. " "Pass an explicit *locals* dictionary if you need to see effects of the code " "on *locals* after function :func:`exec` returns." msgstr "" -"預設情況下,*locals* 的行為如下面 :func:`locals` 函式描述的一樣:不要試圖改變" -"預設的 *locals* dictionary。如果你想在 :func:`exec` 函式回傳時知道程式碼對 " -"*locals* 的變動,請明確地傳遞 *locals* dictionary 。" +"預設情況下,*locals* 的行為如下面 :func:`locals` 函式描述的一樣。如果你想在 :" +"func:`exec` 函式回傳時知道程式碼對 *locals* 的變動,請明確地傳遞 *locals* " +"dictionary 。" -#: ../../library/functions.rst:689 +#: ../../library/functions.rst:713 msgid "Added the *closure* parameter." msgstr "增加了 *closure* 參數。" -#: ../../library/functions.rst:695 +#: ../../library/functions.rst:728 msgid "" "Construct an iterator from those elements of *iterable* for which *function* " "is true. *iterable* may be either a sequence, a container which supports " @@ -1408,7 +1428,7 @@ msgstr "" "*function* 是 ``None``,則會假設它是一個識別性函式,即 *iterable* 中所有假值" "元素會被移除。" -#: ../../library/functions.rst:701 +#: ../../library/functions.rst:734 msgid "" "Note that ``filter(function, iterable)`` is equivalent to the generator " "expression ``(item for item in iterable if function(item))`` if function is " @@ -1419,7 +1439,7 @@ msgstr "" "是 ``None`` 的時候為 ``(item for item in iterable if function(item))``;" "function 是 ``None`` 的時候為 ``(item for item in iterable if item)``。" -#: ../../library/functions.rst:706 +#: ../../library/functions.rst:739 msgid "" "See :func:`itertools.filterfalse` for the complementary function that " "returns elements of *iterable* for which *function* is false." @@ -1427,11 +1447,11 @@ msgstr "" "請參閱 :func:`itertools.filterfalse`,只有 *function* 為 false 時才選取 " "*iterable* 中元素的互補函式。" -#: ../../library/functions.rst:717 +#: ../../library/functions.rst:750 msgid "Return a floating-point number constructed from a number or a string." msgstr "回傳從數字或字串生成的浮點數。" -#: ../../library/functions.rst:721 +#: ../../library/functions.rst:754 msgid "" ">>> float('+1.23')\n" "1.23\n" @@ -1455,7 +1475,7 @@ msgstr "" ">>> float('-Infinity')\n" "-inf" -#: ../../library/functions.rst:734 +#: ../../library/functions.rst:767 msgid "" "If the argument is a string, it should contain a decimal number, optionally " "preceded by a sign, and optionally embedded in whitespace. The optional " @@ -1470,7 +1490,7 @@ msgstr "" "數也可以是 NaN(非數字)或正負無窮大的字串。確切地說,除去首尾的空格後,輸入" "必須遵循以下語法中 :token:`~float:floatvalue` 的生成規則:" -#: ../../library/functions.rst:755 +#: ../../library/functions.rst:788 msgid "" "Case is not significant, so, for example, \"inf\", \"Inf\", \"INFINITY\", " "and \"iNfINity\" are all acceptable spellings for positive infinity." @@ -1478,7 +1498,7 @@ msgstr "" "字母大小寫不影響,例如,\"inf\"、\"Inf\"、\"INFINITY\"、\"iNfINity\" 都可以表" "示正無窮大。" -#: ../../library/functions.rst:758 +#: ../../library/functions.rst:791 msgid "" "Otherwise, if the argument is an integer or a floating-point number, a " "floating-point number with the same value (within Python's floating-point " @@ -1488,7 +1508,7 @@ msgstr "" "否則,如果引數是整數或浮點數,則回傳具有相同值(在 Python 浮點精度範圍內)的" "浮點數。如果引數在 Python 浮點精度範圍外,則會引發 :exc:`OverflowError`。" -#: ../../library/functions.rst:763 +#: ../../library/functions.rst:796 msgid "" "For a general Python object ``x``, ``float(x)`` delegates to ``x." "__float__()``. If :meth:`~object.__float__` is not defined then it falls " @@ -1497,22 +1517,22 @@ msgstr "" "對於一般的 Python 物件 ``x``,``float(x)`` 會委派給 ``x.__float__()``。如果未" "定義 :meth:`~object.__float__` 則會回退到 :meth:`~object.__index__`。" -#: ../../library/functions.rst:767 +#: ../../library/functions.rst:800 msgid "If no argument is given, ``0.0`` is returned." msgstr "如果沒有引數,則回傳 ``0.0``。" -#: ../../library/functions.rst:769 +#: ../../library/functions.rst:802 msgid "The float type is described in :ref:`typesnumeric`." msgstr ":ref:`typesnumeric` 描述了浮點數型別。" -#: ../../library/functions.rst:777 +#: ../../library/functions.rst:810 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__float__` is not " "defined." msgstr "" "如果 :meth:`~object.__float__` 未定義,則會回退到 :meth:`~object.__index__`。" -#: ../../library/functions.rst:787 +#: ../../library/functions.rst:820 msgid "" "Convert a *value* to a \"formatted\" representation, as controlled by " "*format_spec*. The interpretation of *format_spec* will depend on the type " @@ -1523,7 +1543,7 @@ msgstr "" "取決於 *value* 引數的型別,但是大多數內建型別使用標準格式化語法::ref:" "`formatspec`。" -#: ../../library/functions.rst:792 +#: ../../library/functions.rst:825 msgid "" "The default *format_spec* is an empty string which usually gives the same " "effect as calling :func:`str(value) `." @@ -1531,7 +1551,7 @@ msgstr "" "預設的 *format_spec* 是一個空字串,它通常和呼叫 :func:`str(value) ` 的效" "果相同。" -#: ../../library/functions.rst:795 +#: ../../library/functions.rst:828 msgid "" "A call to ``format(value, format_spec)`` is translated to ``type(value)." "__format__(value, format_spec)`` which bypasses the instance dictionary when " @@ -1545,7 +1565,7 @@ msgstr "" "實例中的字典。如果搜尋到 :mod:`object` 這個 method 但 *format_spec* 不為空," "或是 *format_spec* 或回傳值不是字串,則會引發 :exc:`TypeError`。" -#: ../../library/functions.rst:802 +#: ../../library/functions.rst:835 msgid "" "``object().__format__(format_spec)`` raises :exc:`TypeError` if " "*format_spec* is not an empty string." @@ -1553,7 +1573,7 @@ msgstr "" "當 *format_spec* 不是空字串時,``object().__format__(format_spec)`` 會引發 :" "exc:`TypeError`。" -#: ../../library/functions.rst:811 +#: ../../library/functions.rst:844 msgid "" "Return a new :class:`frozenset` object, optionally with elements taken from " "*iterable*. ``frozenset`` is a built-in class. See :class:`frozenset` and :" @@ -1563,7 +1583,7 @@ msgstr "" "``frozenset`` 是一個內建的 class。有關此 class 的文件,請參閱 :class:" "`frozenset` 和 :ref:`types-set`。" -#: ../../library/functions.rst:815 +#: ../../library/functions.rst:848 msgid "" "For other containers see the built-in :class:`set`, :class:`list`, :class:" "`tuple`, and :class:`dict` classes, as well as the :mod:`collections` module." @@ -1571,7 +1591,7 @@ msgstr "" "請參閱內建的 :class:`set`、:class:`list`、:class:`tuple` 和 :class:`dict` " "class,以及 :mod:`collections` module 來了解其它的容器。" -#: ../../library/functions.rst:823 +#: ../../library/functions.rst:856 msgid "" "Return the value of the named attribute of *object*. *name* must be a " "string. If the string is the name of one of the object's attributes, the " @@ -1586,7 +1606,7 @@ msgstr "" "`AttributeError`。*name* 不必是個 Python 識別符 (identifier)(請見 :func:" "`setattr`)。" -#: ../../library/functions.rst:832 +#: ../../library/functions.rst:865 msgid "" "Since :ref:`private name mangling ` happens at " "compilation time, one must manually mangle a private attribute's (attributes " @@ -1597,16 +1617,16 @@ msgstr "" "發生在編譯期,因此你必須手動改編私有屬性(有兩個前導底線的屬性)的名稱,才能" "使用 :func:`getattr` 來取得它。" -#: ../../library/functions.rst:840 +#: ../../library/functions.rst:873 msgid "" "Return the dictionary implementing the current module namespace. For code " "within functions, this is set when the function is defined and remains the " "same regardless of where the function is called." msgstr "" -"回傳代表當前 module 命名空間的 dictionary。對於在函式中的程式碼來說,這在定義" +"回傳代表目前 module 命名空間的 dictionary。對於在函式中的程式碼來說,這在定義" "函式時設定且不論該函式是在何處呼叫都會保持相同。" -#: ../../library/functions.rst:847 +#: ../../library/functions.rst:880 msgid "" "The arguments are an object and a string. The result is ``True`` if the " "string is the name of one of the object's attributes, ``False`` if not. " @@ -1617,7 +1637,7 @@ msgstr "" "則回傳 ``False``。(此功能是透過呼叫 ``getattr(object, name)`` 並檢查是否引" "發 :exc:`AttributeError` 來實作的。)" -#: ../../library/functions.rst:855 +#: ../../library/functions.rst:888 msgid "" "Return the hash value of the object (if it has one). Hash values are " "integers. They are used to quickly compare dictionary keys during a " @@ -1628,7 +1648,7 @@ msgstr "" "時用來快速比較 dictionary 的鍵。相同大小的數字數值有相同的雜湊值(即使它們型" "別不同,如 1 和 1.0)。" -#: ../../library/functions.rst:862 +#: ../../library/functions.rst:895 msgid "" "For objects with custom :meth:`~object.__hash__` methods, note that :func:" "`hash` truncates the return value based on the bit width of the host machine." @@ -1636,7 +1656,7 @@ msgstr "" "請注意,如果物件帶有自訂的 :meth:`~object.__hash__` 方法,:func:`hash` 將根據" "運行機器的位元長度來截斷回傳值。" -#: ../../library/functions.rst:869 +#: ../../library/functions.rst:902 msgid "" "Invoke the built-in help system. (This function is intended for interactive " "use.) If no argument is given, the interactive help system starts on the " @@ -1647,10 +1667,10 @@ msgid "" msgstr "" "啟動內建的幫助系統(此函式主要以互動式使用)。如果沒有引數,直譯器控制台裡會" "啟動互動式幫助系統。如果引數是一個字串,則會在 module、函式、class、method、" -"關鍵字或說明文件主題中搜索該字串,並在控制台上列印幫助資訊。如果引數是其他任" +"關鍵字或說明文件主題中搜尋該字串,並在控制台上列印幫助資訊。如果引數是其他任" "意物件,則會生成該物件的幫助頁。" -#: ../../library/functions.rst:876 +#: ../../library/functions.rst:909 msgid "" "Note that if a slash(/) appears in the parameter list of a function when " "invoking :func:`help`, it means that the parameters prior to the slash are " @@ -1661,12 +1681,12 @@ msgstr "" "前面的參數是僅限位置 (positional-only) 參數。有關更多資訊,請參閱\\ :ref:`常" "見問答集中的僅限位置參數條目 `。" -#: ../../library/functions.rst:881 +#: ../../library/functions.rst:914 msgid "" "This function is added to the built-in namespace by the :mod:`site` module." msgstr "此函式會被 :mod:`site` module 加入到內建命名空間。" -#: ../../library/functions.rst:883 +#: ../../library/functions.rst:916 msgid "" "Changes to :mod:`pydoc` and :mod:`inspect` mean that the reported signatures " "for callables are now more comprehensive and consistent." @@ -1674,7 +1694,7 @@ msgstr "" "對於 :mod:`pydoc` 和 :mod:`inspect` 的變更,使得可呼叫物件回報的的簽名 " "(signature) 更加全面和一致。" -#: ../../library/functions.rst:890 +#: ../../library/functions.rst:923 msgid "" "Convert an integer number to a lowercase hexadecimal string prefixed with " "\"0x\". If *x* is not a Python :class:`int` object, it has to define an :" @@ -1684,7 +1704,7 @@ msgstr "" "class:`int` 物件,則必須定義一個 :meth:`~object.__index__` method 並且回傳一" "個整數。舉例來說:" -#: ../../library/functions.rst:899 +#: ../../library/functions.rst:932 msgid "" "If you want to convert an integer number to an uppercase or lower " "hexadecimal string with prefix or not, you can use either of the following " @@ -1693,20 +1713,20 @@ msgstr "" "如果要將整數轉換為大寫或小寫的十六進位制字串,並可選擇有無 \"0x\" 前綴,則可" "以使用如下方法:" -#: ../../library/functions.rst:911 +#: ../../library/functions.rst:944 msgid "" "See also :func:`int` for converting a hexadecimal string to an integer using " "a base of 16." msgstr "另請參閱 :func:`int` 將十六進位制字串轉換為以 16 為基數的整數。" -#: ../../library/functions.rst:916 +#: ../../library/functions.rst:949 msgid "" "To obtain a hexadecimal string representation for a float, use the :meth:" "`float.hex` method." msgstr "" -"如果要獲取浮點數的十六進位制字串形式,請使用 :meth:`float.hex` method。" +"如果要取得浮點數的十六進位制字串形式,請使用 :meth:`float.hex` method。" -#: ../../library/functions.rst:922 +#: ../../library/functions.rst:955 msgid "" "Return the \"identity\" of an object. This is an integer which is " "guaranteed to be unique and constant for this object during its lifetime. " @@ -1716,18 +1736,18 @@ msgstr "" "回傳物件的 \"識別性\" 。該值是一個整數,在此物件的生命週期中保證是唯一且恆定" "的。兩個生命期不重疊的物件可能具有相同的 :func:`id` 值。" -#: ../../library/functions.rst:927 +#: ../../library/functions.rst:960 msgid "This is the address of the object in memory." msgstr "這是該物件在記憶體中的位址。" -#: ../../library/functions.rst:929 +#: ../../library/functions.rst:962 msgid "" "Raises an :ref:`auditing event ` ``builtins.id`` with argument " "``id``." msgstr "" "引發一個附帶引數 ``id`` 的\\ :ref:`稽核事件 ` ``builtins.id``。" -#: ../../library/functions.rst:935 +#: ../../library/functions.rst:968 msgid "" "If the *prompt* argument is present, it is written to standard output " "without a trailing newline. The function then reads a line from input, " @@ -1738,19 +1758,19 @@ msgstr "" "從輸入中讀取一行,將其轉換為字串(去除末尾的換行符)並回傳。當讀取到 EOF 時," "則引發 :exc:`EOFError`。例如: ::" -#: ../../library/functions.rst:940 +#: ../../library/functions.rst:973 msgid "" -">>> s = input('--> ') \n" +">>> s = input('--> ')\n" "--> Monty Python's Flying Circus\n" -">>> s \n" +">>> s\n" "\"Monty Python's Flying Circus\"" msgstr "" -">>> s = input('--> ') \n" +">>> s = input('--> ')\n" "--> Monty Python's Flying Circus\n" -">>> s \n" +">>> s\n" "\"Monty Python's Flying Circus\"" -#: ../../library/functions.rst:945 +#: ../../library/functions.rst:978 msgid "" "If the :mod:`readline` module was loaded, then :func:`input` will use it to " "provide elaborate line editing and history features." @@ -1758,7 +1778,7 @@ msgstr "" "如果載入了 :mod:`readline` module,:func:`input` 將使用它來提供複雜的行編輯和" "歷史記錄功能。" -#: ../../library/functions.rst:948 ../../library/functions.rst:950 +#: ../../library/functions.rst:981 ../../library/functions.rst:983 msgid "" "Raises an :ref:`auditing event ` ``builtins.input`` with argument " "``prompt`` before reading input" @@ -1766,7 +1786,7 @@ msgstr "" "引發一個附帶讀取輸入前的引數 ``prompt`` 的\\ :ref:`稽核事件 ` " "``builtins.input``。" -#: ../../library/functions.rst:953 ../../library/functions.rst:955 +#: ../../library/functions.rst:986 ../../library/functions.rst:988 msgid "" "Raises an :ref:`auditing event ` ``builtins.input/result`` with " "the result after successfully reading input." @@ -1774,13 +1794,13 @@ msgstr "" "引發一個附帶成功讀取結果的\\ :ref:`稽核事件 ` ``builtins.input/" "result``。" -#: ../../library/functions.rst:962 +#: ../../library/functions.rst:995 msgid "" "Return an integer object constructed from a number or a string, or return " "``0`` if no arguments are given." msgstr "" -#: ../../library/functions.rst:967 +#: ../../library/functions.rst:1000 msgid "" ">>> int(123.45)\n" "123\n" @@ -1808,7 +1828,7 @@ msgstr "" ">>> int('01110011', base=2)\n" "115" -#: ../../library/functions.rst:982 +#: ../../library/functions.rst:1015 msgid "" "If the argument defines :meth:`~object.__int__`, ``int(x)`` returns ``x." "__int__()``. If the argument defines :meth:`~object.__index__`, it returns " @@ -1821,7 +1841,7 @@ msgstr "" "義了 :meth:`~object.__trunc__` 則回傳 ``x.__trunc__()``。對於浮點數,則會向零" "的方向無條件捨去。" -#: ../../library/functions.rst:988 +#: ../../library/functions.rst:1021 msgid "" "If the argument is not a number or if *base* is given, then it must be a " "string, :class:`bytes`, or :class:`bytearray` instance representing an " @@ -1834,7 +1854,7 @@ msgstr "" "以有 ``+`` 或 ``-``\\ (中間沒有空格)、可有個前導的零、也可被空格包圍、或在" "數字間有單一底線。" -#: ../../library/functions.rst:994 +#: ../../library/functions.rst:1027 msgid "" "A base-n integer string contains digits, each representing a value from 0 to " "n-1. The values 0--9 can be represented by any Unicode decimal digit. The " @@ -1856,11 +1876,11 @@ msgstr "" "進制中的一個,所以 ``int('010', 0)`` 是非法的,但 ``int('010')`` 和 " "``int('010', 8)`` 是有效的。" -#: ../../library/functions.rst:1005 +#: ../../library/functions.rst:1038 msgid "The integer type is described in :ref:`typesnumeric`." msgstr "整數型別定義請參閱\\ :ref:`typesnumeric`。" -#: ../../library/functions.rst:1007 +#: ../../library/functions.rst:1040 msgid "" "If *base* is not an instance of :class:`int` and the *base* object has a :" "meth:`base.__index__ ` method, that method is called to " @@ -1868,26 +1888,26 @@ msgid "" "` instead of :meth:`base.__index__ `." msgstr "" "如果 *base* 不是 :class:`int` 的實例,但 *base* 物件有 :meth:`base.__index__ " -"` method,則會呼叫該 method 來獲取此進位制所需的整數。以前" +"` method,則會呼叫該 method 來取得此進位制所需的整數。以前" "的版本使用 :meth:`base.__int__ ` 而不是 :meth:`base." "__index__ `。" -#: ../../library/functions.rst:1017 +#: ../../library/functions.rst:1050 msgid "The first parameter is now positional-only." msgstr "第一個參數為僅限位置參數。" -#: ../../library/functions.rst:1020 +#: ../../library/functions.rst:1053 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__int__` is not " "defined." msgstr "" "如果未定義 :meth:`~object.__int__` 則會回退到 :meth:`~object.__index__`。" -#: ../../library/functions.rst:1023 +#: ../../library/functions.rst:1056 msgid "The delegation to :meth:`~object.__trunc__` is deprecated." msgstr "對 :meth:`~object.__trunc__` 的委派已棄用。" -#: ../../library/functions.rst:1026 +#: ../../library/functions.rst:1059 msgid "" ":class:`int` string inputs and string representations can be limited to help " "avoid denial of service attacks. A :exc:`ValueError` is raised when the " @@ -1901,7 +1921,7 @@ msgstr "" "`int` 轉換為字串時將會超出限制時,會引發 :exc:`ValueError`。請參閱\\ :ref:`整" "數字串轉換的長度限制 `\\ 說明文件。" -#: ../../library/functions.rst:1036 +#: ../../library/functions.rst:1069 msgid "" "Return ``True`` if the *object* argument is an instance of the *classinfo* " "argument, or of a (direct, indirect, or :term:`virtual `) of *classinfo*. A class is considered a " @@ -1941,7 +1961,7 @@ msgstr "" "是 *classinfo* 中任一元素的 subclass 時則回傳 ``True``。其他情況,會引發 :" "exc:`TypeError`。" -#: ../../library/functions.rst:1068 +#: ../../library/functions.rst:1101 msgid "" "Return an :term:`iterator` object. The first argument is interpreted very " "differently depending on the presence of the second argument. Without a " @@ -1965,11 +1985,11 @@ msgstr "" "__next__` 時會不帶引數地呼叫 *object*;如果回傳的結果是 *sentinel* 則引發 :" "exc:`StopIteration`,否則回傳呼叫結果。" -#: ../../library/functions.rst:1082 +#: ../../library/functions.rst:1115 msgid "See also :ref:`typeiter`." msgstr "另請參閱 :ref:`typeiter`。" -#: ../../library/functions.rst:1084 +#: ../../library/functions.rst:1117 msgid "" "One useful application of the second form of :func:`iter` is to build a " "block-reader. For example, reading fixed-width blocks from a binary database " @@ -1978,7 +1998,7 @@ msgstr "" ":func:`iter` 的第二種形式有一個好用的應用,是能夠建立一個區塊閱讀器 (block-" "reader)。例如,從二進位資料庫檔案中讀取固定寬度的區塊,直到檔案的結尾: ::" -#: ../../library/functions.rst:1088 +#: ../../library/functions.rst:1121 msgid "" "from functools import partial\n" "with open('mydata.db', 'rb') as f:\n" @@ -1990,7 +2010,7 @@ msgstr "" " for block in iter(partial(f.read, 64), b''):\n" " process_block(block)" -#: ../../library/functions.rst:1096 +#: ../../library/functions.rst:1129 msgid "" "Return the length (the number of items) of an object. The argument may be a " "sequence (such as a string, bytes, tuple, list, or range) or a collection " @@ -1999,7 +2019,7 @@ msgstr "" "回傳物件的長度(元素個數)。引數可以是序列(如 string、bytes、tuple、list 或 " "range)或集合(如 dictionary、set 或 frozen set)。" -#: ../../library/functions.rst:1102 +#: ../../library/functions.rst:1135 msgid "" "``len`` raises :exc:`OverflowError` on lengths larger than :data:`sys." "maxsize`, such as :class:`range(2 ** 100) `." @@ -2007,7 +2027,7 @@ msgstr "" "如果物件長度大於 :data:`sys.maxsize`,像是 :class:`range(2 ** 100) `," "則 ``len`` 會引發 :exc:`OverflowError`。" -#: ../../library/functions.rst:1111 +#: ../../library/functions.rst:1144 msgid "" "Rather than being a function, :class:`list` is actually a mutable sequence " "type, as documented in :ref:`typesseq-list` and :ref:`typesseq`." @@ -2015,26 +2035,85 @@ msgstr "" "除了是函式,:class:`list` 也是可變序列型別,詳情請參閱 :ref:`typesseq-list` " "和 :ref:`typesseq`。" -#: ../../library/functions.rst:1117 +#: ../../library/functions.rst:1150 +msgid "" +"Return a mapping object representing the current local symbol table, with " +"variable names as the keys, and their currently bound references as the " +"values." +msgstr "" + +#: ../../library/functions.rst:1154 +msgid "" +"At module scope, as well as when using :func:`exec` or :func:`eval` with a " +"single namespace, this function returns the same namespace as :func:" +"`globals`." +msgstr "" + +#: ../../library/functions.rst:1158 +msgid "" +"At class scope, it returns the namespace that will be passed to the " +"metaclass constructor." +msgstr "" + +#: ../../library/functions.rst:1161 +msgid "" +"When using ``exec()`` or ``eval()`` with separate local and global " +"arguments, it returns the local namespace passed in to the function call." +msgstr "" + +#: ../../library/functions.rst:1164 +msgid "" +"In all of the above cases, each call to ``locals()`` in a given frame of " +"execution will return the *same* mapping object. Changes made through the " +"mapping object returned from ``locals()`` will be visible as assigned, " +"reassigned, or deleted local variables, and assigning, reassigning, or " +"deleting local variables will immediately affect the contents of the " +"returned mapping object." +msgstr "" + +#: ../../library/functions.rst:1171 +msgid "" +"In an :term:`optimized scope` (including functions, generators, and " +"coroutines), each call to ``locals()`` instead returns a fresh dictionary " +"containing the current bindings of the function's local variables and any " +"nonlocal cell references. In this case, name binding changes made via the " +"returned dict are *not* written back to the corresponding local variables or " +"nonlocal cell references, and assigning, reassigning, or deleting local " +"variables and nonlocal cell references does *not* affect the contents of " +"previously returned dictionaries." +msgstr "" + +#: ../../library/functions.rst:1180 +msgid "" +"Calling ``locals()`` as part of a comprehension in a function, generator, or " +"coroutine is equivalent to calling it in the containing scope, except that " +"the comprehension's initialised iteration variables will be included. In " +"other scopes, it behaves as if the comprehension were running as a nested " +"function." +msgstr "" + +#: ../../library/functions.rst:1186 +msgid "" +"Calling ``locals()`` as part of a generator expression is equivalent to " +"calling it in a nested generator function." +msgstr "" + +#: ../../library/functions.rst:1189 msgid "" -"Update and return a dictionary representing the current local symbol table. " -"Free variables are returned by :func:`locals` when it is called in function " -"blocks, but not in class blocks. Note that at the module level, :func:" -"`locals` and :func:`globals` are the same dictionary." +"The behaviour of ``locals()`` in a comprehension has been updated as " +"described in :pep:`709`." msgstr "" -"更新並回傳表示當前本地符號表的 dictionary。在函式區塊而不是 class 區塊中呼" -"叫 :func:`locals` 時會回傳自由變數。請注意,在 module 階層中,:func:`locals` " -"和 :func:`globals` 是相同的 dictionary。" -#: ../../library/functions.rst:1123 +#: ../../library/functions.rst:1193 msgid "" -"The contents of this dictionary should not be modified; changes may not " -"affect the values of local and free variables used by the interpreter." +"As part of :pep:`667`, the semantics of mutating the mapping objects " +"returned from this function are now defined. The behavior in :term:" +"`optimized scopes ` is now as described above. Aside from " +"being defined, the behaviour in other scopes remains unchanged from previous " +"versions." msgstr "" -"此 dictionary 的內容不應該被更動;更改可能不會影響直譯器使用的本地變數或自由" -"變數的值。" -#: ../../library/functions.rst:1128 +#: ../../library/functions.rst:1203 msgid "" "Return an iterator that applies *function* to every item of *iterable*, " "yielding the results. If additional *iterables* arguments are passed, " @@ -2045,17 +2124,17 @@ msgid "" msgstr "" "產生一個將 *function* 應用於 *iterable* 中所有元素,並收集回傳結果的 " "iterator。如果傳遞了額外的 *iterables* 引數,則 *function* 必須接受相同個數的" -"引數,並使用所有從 iterables 中同時獲取的元素。當有多個 iterables 時,最短的 " +"引數,並使用所有從 iterables 中同時取得的元素。當有多個 iterables 時,最短的 " "iteratable 耗盡時 iterator 也會結束。如果函式的輸入已經被編排為引數的 tuple," "請參閱 :func:`itertools.starmap`。" -#: ../../library/functions.rst:1140 +#: ../../library/functions.rst:1215 msgid "" "Return the largest item in an iterable or the largest of two or more " "arguments." msgstr "回傳 iterable 中最大的元素,或者回傳兩個以上的引數中最大的。" -#: ../../library/functions.rst:1143 +#: ../../library/functions.rst:1218 msgid "" "If one positional argument is provided, it should be an :term:`iterable`. " "The largest item in the iterable is returned. If two or more positional " @@ -2064,7 +2143,7 @@ msgstr "" "如果只提供了一個位置引數,它必須是個 :term:`iterable`,iterable 中最大的元素" "會被回傳。如果提供了兩個或以上的位置引數,則回傳最大的位置引數。" -#: ../../library/functions.rst:1148 ../../library/functions.rst:1186 +#: ../../library/functions.rst:1223 ../../library/functions.rst:1261 msgid "" "There are two optional keyword-only arguments. The *key* argument specifies " "a one-argument ordering function like that used for :meth:`list.sort`. The " @@ -2077,7 +2156,7 @@ msgstr "" "的物件。如果 iterable 為空,並且沒有提供 *default*,則會引發 :exc:" "`ValueError`。" -#: ../../library/functions.rst:1154 +#: ../../library/functions.rst:1229 msgid "" "If multiple items are maximal, the function returns the first one " "encountered. This is consistent with other sort-stability preserving tools " @@ -2088,15 +2167,15 @@ msgstr "" "``sorted(iterable, key=keyfunc, reverse=True)[0]`` 和 ``heapq.nlargest(1, " "iterable, key=keyfunc)`` 一致。" -#: ../../library/functions.rst:1159 ../../library/functions.rst:1197 +#: ../../library/functions.rst:1234 ../../library/functions.rst:1272 msgid "Added the *default* keyword-only parameter." msgstr "新增 *default* 僅限關鍵字參數。" -#: ../../library/functions.rst:1162 ../../library/functions.rst:1200 +#: ../../library/functions.rst:1237 ../../library/functions.rst:1275 msgid "The *key* can be ``None``." msgstr "*key* 可以為 ``None``。" -#: ../../library/functions.rst:1170 +#: ../../library/functions.rst:1245 msgid "" "Return a \"memory view\" object created from the given argument. See :ref:" "`typememoryview` for more information." @@ -2104,13 +2183,13 @@ msgstr "" "回傳由給定的引數所建立之「memory view(記憶體檢視)」物件。有關詳細資訊,請參" "閱\\ :ref:`typememoryview`。" -#: ../../library/functions.rst:1178 +#: ../../library/functions.rst:1253 msgid "" "Return the smallest item in an iterable or the smallest of two or more " "arguments." msgstr "回傳 iterable 中最小的元素,或者回傳兩個以上的引數中最小的。" -#: ../../library/functions.rst:1181 +#: ../../library/functions.rst:1256 msgid "" "If one positional argument is provided, it should be an :term:`iterable`. " "The smallest item in the iterable is returned. If two or more positional " @@ -2119,7 +2198,7 @@ msgstr "" "如果只提供了一個位置引數,它必須是 :term:`iterable`,iterable 中最小的元素會" "被回傳。如果提供了兩個以上的位置引數,則回傳最小的位置引數。" -#: ../../library/functions.rst:1192 +#: ../../library/functions.rst:1267 msgid "" "If multiple items are minimal, the function returns the first one " "encountered. This is consistent with other sort-stability preserving tools " @@ -2130,34 +2209,36 @@ msgstr "" "``sorted(iterable, key=keyfunc)[0]`` 和 ``heapq.nsmallest(1, iterable, " "key=keyfunc)`` 一致。" -#: ../../library/functions.rst:1207 +#: ../../library/functions.rst:1282 msgid "" "Retrieve the next item from the :term:`iterator` by calling its :meth:" "`~iterator.__next__` method. If *default* is given, it is returned if the " "iterator is exhausted, otherwise :exc:`StopIteration` is raised." msgstr "" -"透過呼叫 :term:`iterator` 的 :meth:`~iterator.__next__` method 獲取下一個元" +"透過呼叫 :term:`iterator` 的 :meth:`~iterator.__next__` method 取得下一個元" "素。如果 iterator 耗盡,則回傳給定的預設值 *default*,如果沒有預設值則引發 :" "exc:`StopIteration`。" -#: ../../library/functions.rst:1214 +#: ../../library/functions.rst:1289 msgid "" -"Return a new featureless object. :class:`object` is a base for all classes. " -"It has methods that are common to all instances of Python classes. This " -"function does not accept any arguments." +"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." msgstr "" -"回傳一個沒有特徵的新物件。:class:`object` 是所有 class 的基礎,它具有所有 " -"Python class 實例的通用 method。這個函式不接受任何引數。" +"這是所有其他 class 的基礎,它具有所有 Python class 實例的通用 method。當建構" +"函式被呼叫時,它會回傳一個新的沒有特徵 (featureless) 的物件。這個建構函式不接" +"受任何引數。" -#: ../../library/functions.rst:1220 +#: ../../library/functions.rst:1296 msgid "" -":class:`object` does *not* have a :attr:`~object.__dict__`, so you can't " -"assign arbitrary attributes to an instance of the :class:`object` class." +":class:`object` instances do *not* have :attr:`~object.__dict__` attributes, " +"so you can't assign arbitrary attributes to an instance of :class:`object`." msgstr "" -"由於 :class:`object` *沒有* :attr:`~object.__dict__`,因此無法將任意屬性賦" -"給 :class:`object` class 的實例。" +"由於 :class:`object` 實例\\ *沒有* :attr:`~object.__dict__` 屬性,因此無法將" +"任意屬性賦給 :class:`object` 的實例。" -#: ../../library/functions.rst:1226 +#: ../../library/functions.rst:1303 msgid "" "Convert an integer number to an octal string prefixed with \"0o\". The " "result is a valid Python expression. If *x* is not a Python :class:`int` " @@ -2168,7 +2249,7 @@ msgstr "" "Python 運算式。如果 *x* 不是 Python 的 :class:`int` 物件,那它需要定義 :meth:" "`~object.__index__` method 回傳一個整數。舉例來說:" -#: ../../library/functions.rst:1236 +#: ../../library/functions.rst:1313 msgid "" "If you want to convert an integer number to an octal string either with the " "prefix \"0o\" or not, you can use either of the following ways." @@ -2176,7 +2257,7 @@ msgstr "" "如果要將整數轉換為八進位制字串,不論是否具備 \"0o\" 前綴,都可以使用下面的方" "法。" -#: ../../library/functions.rst:1253 +#: ../../library/functions.rst:1330 msgid "" "Open *file* and return a corresponding :term:`file object`. If the file " "cannot be opened, an :exc:`OSError` is raised. See :ref:`tut-files` for more " @@ -2186,7 +2267,7 @@ msgstr "" "啟,則引發 :exc:`OSError`。關於使用此函式的更多方法,請參閱\\ :ref:`tut-" "files`。" -#: ../../library/functions.rst:1257 +#: ../../library/functions.rst:1334 msgid "" "*file* is a :term:`path-like object` giving the pathname (absolute or " "relative to the current working directory) of the file to be opened or an " @@ -2195,11 +2276,11 @@ msgid "" "is set to ``False``.)" msgstr "" "*file* 是一個\\ :term:`類路徑物件 `,是將被開啟之檔案的路徑" -"(絕對路徑或當前工作目錄的相對路徑),或是要被包裝 (wrap) 檔案的整數檔案描述" +"(絕對路徑或目前工作目錄的相對路徑),或是要被包裝 (wrap) 檔案的整數檔案描述" "器 (file descriptor)。(如果有給定檔案描述器,它會隨著回傳的 I/O 物件關閉而關" "閉,除非 *closefd* 被設為 ``False``。)" -#: ../../library/functions.rst:1263 +#: ../../library/functions.rst:1340 msgid "" "*mode* is an optional string that specifies the mode in which the file is " "opened. It defaults to ``'r'`` which means open for reading in text mode. " @@ -2215,76 +2296,76 @@ msgstr "" "*mode* 是一個選擇性字串,用於指定開啟檔案的模式。預設值是 ``'r'``,這意味著它" "以文字模式開啟並讀取。其他常見模式有:寫入 ``'w'``\\ (會捨去已經存在的檔" "案)、唯一性建立 ``'x'``、追加寫入 ``'a'``\\ (在\\ *一些* Unix 系統上,無論" -"當前的檔案指標在什麼位置,*所有* 寫入都會追加到檔案末尾)。在文字模式,如果沒" +"目前的檔案指標在什麼位置,*所有* 寫入都會追加到檔案末尾)。在文字模式,如果沒" "有指定 *encoding*,則根據電腦平臺來決定使用的編碼:呼叫 :func:`locale." -"getencoding` 來獲取當前的本地編碼。(要讀取和寫入原始 bytes,請使用二進位制模" +"getencoding` 來取得目前的本地編碼。(要讀取和寫入原始 bytes,請使用二進位制模" "式且不要指定 *encoding*。)可用的模式有:" -#: ../../library/functions.rst:1280 +#: ../../library/functions.rst:1357 msgid "Character" msgstr "字元" -#: ../../library/functions.rst:1280 +#: ../../library/functions.rst:1357 msgid "Meaning" msgstr "意義" -#: ../../library/functions.rst:1282 +#: ../../library/functions.rst:1359 msgid "``'r'``" msgstr "``'r'``" -#: ../../library/functions.rst:1282 +#: ../../library/functions.rst:1359 msgid "open for reading (default)" msgstr "讀取(預設)" -#: ../../library/functions.rst:1283 +#: ../../library/functions.rst:1360 msgid "``'w'``" msgstr "``'w'``" -#: ../../library/functions.rst:1283 +#: ../../library/functions.rst:1360 msgid "open for writing, truncating the file first" msgstr "寫入,會先清除檔案內容" -#: ../../library/functions.rst:1284 +#: ../../library/functions.rst:1361 msgid "``'x'``" msgstr "``'x'``" -#: ../../library/functions.rst:1284 +#: ../../library/functions.rst:1361 msgid "open for exclusive creation, failing if the file already exists" msgstr "唯一性建立,如果文件已存在則會失敗" -#: ../../library/functions.rst:1285 +#: ../../library/functions.rst:1362 msgid "``'a'``" msgstr "``'a'``" -#: ../../library/functions.rst:1285 +#: ../../library/functions.rst:1362 msgid "open for writing, appending to the end of file if it exists" msgstr "寫入,如果檔案存在則在其末端附加內容" -#: ../../library/functions.rst:1286 +#: ../../library/functions.rst:1363 msgid "``'b'``" msgstr "``'b'``" -#: ../../library/functions.rst:1286 ../../library/functions.rst:1430 +#: ../../library/functions.rst:1363 ../../library/functions.rst:1507 msgid "binary mode" msgstr "二進制模式" -#: ../../library/functions.rst:1287 +#: ../../library/functions.rst:1364 msgid "``'t'``" msgstr "``'t'``" -#: ../../library/functions.rst:1287 +#: ../../library/functions.rst:1364 msgid "text mode (default)" msgstr "文字模式(預設)" -#: ../../library/functions.rst:1288 +#: ../../library/functions.rst:1365 msgid "``'+'``" msgstr "``'+'``" -#: ../../library/functions.rst:1288 +#: ../../library/functions.rst:1365 msgid "open for updating (reading and writing)" msgstr "更新(讀取並寫入)" -#: ../../library/functions.rst:1291 +#: ../../library/functions.rst:1368 msgid "" "The default mode is ``'r'`` (open for reading text, a synonym of ``'rt'``). " "Modes ``'w+'`` and ``'w+b'`` open and truncate the file. Modes ``'r+'`` and " @@ -2294,7 +2375,7 @@ msgstr "" "``'w+b'`` 模式會開啟並清除檔案。``'r+'`` 和 ``'r+b'`` 模式會開啟且保留檔案內" "容。" -#: ../../library/functions.rst:1295 +#: ../../library/functions.rst:1372 msgid "" "As mentioned in the :ref:`io-overview`, Python distinguishes between binary " "and text I/O. Files opened in binary mode (including ``'b'`` in the *mode* " @@ -2310,7 +2391,7 @@ msgstr "" "``'t'``),檔案的內容會以 :class:`str` 回傳,其位元組已經先被解碼,使用的是取" "決於平台的編碼系統或是給定的 *encoding*。" -#: ../../library/functions.rst:1305 +#: ../../library/functions.rst:1382 msgid "" "Python doesn't depend on the underlying operating system's notion of text " "files; all the processing is done by Python itself, and is therefore " @@ -2319,7 +2400,7 @@ msgstr "" "Python 不會使用底層作業系統對於文字檔案的操作概念;所有的處理都是由 Python 獨" "自完成的,因此能獨立於不同平台。" -#: ../../library/functions.rst:1309 +#: ../../library/functions.rst:1386 msgid "" "*buffering* is an optional integer used to set the buffering policy. Pass 0 " "to switch buffering off (only allowed in binary mode), 1 to select line " @@ -2340,7 +2421,7 @@ msgstr "" "``write_through`` 旗標。若未給定 *buffering* 引數,則預設的緩衝策略會運作如" "下:" -#: ../../library/functions.rst:1319 +#: ../../library/functions.rst:1396 msgid "" "Binary files are buffered in fixed-size chunks; the size of the buffer is " "chosen using a heuristic trying to determine the underlying device's \"block " @@ -2352,7 +2433,7 @@ msgstr "" "DEFAULT_BUFFER_SIZE`。在許多系統上,緩衝區的長度通常為 4096 或 8192 個位元" "組。" -#: ../../library/functions.rst:1324 +#: ../../library/functions.rst:1401 msgid "" "\"Interactive\" text files (files for which :meth:`~io.IOBase.isatty` " "returns ``True``) use line buffering. Other text files use the policy " @@ -2361,7 +2442,7 @@ msgstr "" "「互動式」文字檔(:meth:`~io.IOBase.isatty` 回傳 ``True`` 的檔案)會使用列緩" "衝。其他文字檔則使用上述的二進制檔案緩衝策略。" -#: ../../library/functions.rst:1328 +#: ../../library/functions.rst:1405 msgid "" "*encoding* is the name of the encoding used to decode or encode the file. " "This should only be used in text mode. The default encoding is platform " @@ -2374,7 +2455,7 @@ msgstr "" "Python 支援的任何 :term:`text encoding`\\ (文字編碼)都是可以使用的。關於支" "援的編碼系統清單,請參閱 :mod:`codecs` module。" -#: ../../library/functions.rst:1334 +#: ../../library/functions.rst:1411 msgid "" "*errors* is an optional string that specifies how encoding and decoding " "errors are to be handled—this cannot be used in binary mode. A variety of " @@ -2387,7 +2468,7 @@ msgstr "" "handlers`\\ 有列出清單),不過任何已註冊到 :func:`codecs.register_error` 的錯" "誤處理程式名稱也都是有效的。標準的名稱包括:" -#: ../../library/functions.rst:1342 +#: ../../library/functions.rst:1419 msgid "" "``'strict'`` to raise a :exc:`ValueError` exception if there is an encoding " "error. The default value of ``None`` has the same effect." @@ -2395,20 +2476,20 @@ msgstr "" "``'strict'`` 如果發生編碼錯誤,則引發 :exc:`ValueError` 例外。預設值 " "``None`` 也有相同的效果。" -#: ../../library/functions.rst:1346 +#: ../../library/functions.rst:1423 msgid "" "``'ignore'`` ignores errors. Note that ignoring encoding errors can lead to " "data loss." msgstr "``'ignore'`` 忽略錯誤。請注意,忽略編碼錯誤可能導致資料遺失。" -#: ../../library/functions.rst:1349 +#: ../../library/functions.rst:1426 msgid "" "``'replace'`` causes a replacement marker (such as ``'?'``) to be inserted " "where there is malformed data." msgstr "" "``'replace'`` 會在格式不正確的資料位置插入一個替換標誌(像是 ``'?'``)。" -#: ../../library/functions.rst:1352 +#: ../../library/functions.rst:1429 msgid "" "``'surrogateescape'`` will represent any incorrect bytes as low surrogate " "code units ranging from U+DC80 to U+DCFF. These surrogate code units will " @@ -2421,7 +2502,7 @@ msgstr "" "被還原回 ``surrogateescape`` 錯誤處理程式當時所處理的那些相同位元組。這對於處" "理未知編碼方式的檔案會很好用。" -#: ../../library/functions.rst:1359 +#: ../../library/functions.rst:1436 msgid "" "``'xmlcharrefreplace'`` is only supported when writing to a file. Characters " "not supported by the encoding are replaced with the appropriate XML " @@ -2430,7 +2511,7 @@ msgstr "" "``'xmlcharrefreplace'`` 僅在寫入檔案時可支援。編碼系統不支援的字元會被替換為" "適當的 XML 字元參考 (character reference) ``&#nnn;``。" -#: ../../library/functions.rst:1363 +#: ../../library/functions.rst:1440 msgid "" "``'backslashreplace'`` replaces malformed data by Python's backslashed " "escape sequences." @@ -2438,7 +2519,7 @@ msgstr "" "``'backslashreplace'`` 會用 Python 的反斜線跳脫序列 (backslashed escape " "sequence) 替換格式不正確的資料。" -#: ../../library/functions.rst:1366 +#: ../../library/functions.rst:1443 msgid "" "``'namereplace'`` (also only supported when writing) replaces unsupported " "characters with ``\\N{...}`` escape sequences." @@ -2446,7 +2527,7 @@ msgstr "" "``'namereplace'``\\ (也僅在寫入時支援)會將不支援的字元替換為 ``\\N{...}`` " "跳脫序列。" -#: ../../library/functions.rst:1374 +#: ../../library/functions.rst:1451 msgid "" "*newline* determines how to parse newline characters from the stream. It can " "be ``None``, ``''``, ``'\\n'``, ``'\\r'``, and ``'\\r\\n'``. It works as " @@ -2455,7 +2536,7 @@ msgstr "" "*newline* 會決定如何剖析資料串流 (stream) 中的換行字元。它可以是 ``None``、" "``''``、``'\\n'``、``'\\r'`` 或 ``'\\r\\n'``。它的運作規則如下:" -#: ../../library/functions.rst:1378 +#: ../../library/functions.rst:1455 msgid "" "When reading input from the stream, if *newline* is ``None``, universal " "newlines mode is enabled. Lines in the input can end in ``'\\n'``, " @@ -2471,7 +2552,7 @@ msgstr "" "傳給呼叫方時,行尾符號不會被轉換。如果它是任何其他有效的值,則輸入資料的行只" "會由給定的字串做結尾,且在回傳給呼叫方時,行尾符號不會被轉換。" -#: ../../library/functions.rst:1386 +#: ../../library/functions.rst:1463 msgid "" "When writing output to the stream, if *newline* is ``None``, any ``'\\n'`` " "characters written are translated to the system default line separator, :" @@ -2484,7 +2565,7 @@ msgstr "" "``''`` 或 ``'\\n'``,則不做任何轉換。如果 *newline* 是任何其他有效的值,則寫" "入的任何 ``'\\n'`` 字元都將轉換為給定的字串。" -#: ../../library/functions.rst:1392 +#: ../../library/functions.rst:1469 msgid "" "If *closefd* is ``False`` and a file descriptor rather than a filename was " "given, the underlying file descriptor will be kept open when the file is " @@ -2495,7 +2576,7 @@ msgstr "" "則當檔案關閉時,底層的檔案描述器會保持開啟狀態。如果有給定一個檔名,則 " "*closefd* 必須是 ``True``\\ (預設值);否則將引發錯誤。" -#: ../../library/functions.rst:1397 +#: ../../library/functions.rst:1474 msgid "" "A custom opener can be used by passing a callable as *opener*. The " "underlying file descriptor for the file object is then obtained by calling " @@ -2508,11 +2589,11 @@ msgstr "" "必須回傳一個開啟的檔案描述器(將 :mod:`os.open` 作為 *opener* 傳入,在功能上" "的結果會相當於傳入 ``None``)。" -#: ../../library/functions.rst:1403 +#: ../../library/functions.rst:1480 msgid "The newly created file is :ref:`non-inheritable `." msgstr "新建立的檔案是\\ :ref:`不可繼承的 `。" -#: ../../library/functions.rst:1405 +#: ../../library/functions.rst:1482 msgid "" "The following example uses the :ref:`dir_fd ` parameter of the :func:" "`os.open` function to open a file relative to a given directory::" @@ -2520,7 +2601,7 @@ msgstr "" "下面的範例使用 :func:`os.open` 函式回傳值當作 :ref:`dir_fd ` 的參數," "從給定的目錄中用相對路徑開啟檔案: ::" -#: ../../library/functions.rst:1408 +#: ../../library/functions.rst:1485 msgid "" ">>> import os\n" ">>> dir_fd = os.open('somedir', os.O_RDONLY)\n" @@ -2533,7 +2614,7 @@ msgid "" ">>> os.close(dir_fd) # don't leak a file descriptor" msgstr "" -#: ../../library/functions.rst:1418 +#: ../../library/functions.rst:1495 msgid "" "The type of :term:`file object` returned by the :func:`open` function " "depends on the mode. When :func:`open` is used to open a file in a text " @@ -2557,7 +2638,7 @@ msgstr "" "BufferedRandom`。當緩衝被停用時,會回傳原始資料串流 :class:`io.FileIO`,它" "是 :class:`io.RawIOBase` 的一個 subclass。" -#: ../../library/functions.rst:1439 +#: ../../library/functions.rst:1516 msgid "" "See also the file handling modules, such as :mod:`fileinput`, :mod:`io` " "(where :func:`open` is declared), :mod:`os`, :mod:`os.path`, :mod:" @@ -2567,7 +2648,7 @@ msgstr "" "`open` 的 module )、:mod:`os`、:mod:`os.path`、:mod:`tempfile` 以及 :mod:" "`shutil`。" -#: ../../library/functions.rst:1443 +#: ../../library/functions.rst:1520 msgid "" "Raises an :ref:`auditing event ` ``open`` with arguments ``path``, " "``mode``, ``flags``." @@ -2575,25 +2656,25 @@ msgstr "" "引發一個附帶引數 ``path``、``mode``、``flags`` 的\\ :ref:`稽核事件 " "` ``open``。" -#: ../../library/functions.rst:1445 +#: ../../library/functions.rst:1522 msgid "" "The ``mode`` and ``flags`` arguments may have been modified or inferred from " "the original call." msgstr "``mode`` 和 ``flags`` 引數可能會被原始的呼叫所修改或推論 (infer)。" -#: ../../library/functions.rst:1450 +#: ../../library/functions.rst:1527 msgid "The *opener* parameter was added." msgstr "增加了 *opener* 參數。" -#: ../../library/functions.rst:1451 +#: ../../library/functions.rst:1528 msgid "The ``'x'`` mode was added." msgstr "增加了 ``'x'`` 模式。" -#: ../../library/functions.rst:1452 +#: ../../library/functions.rst:1529 msgid ":exc:`IOError` used to be raised, it is now an alias of :exc:`OSError`." msgstr "過去引發的 :exc:`IOError`,現在是 :exc:`OSError` 的別名。" -#: ../../library/functions.rst:1453 +#: ../../library/functions.rst:1530 msgid "" ":exc:`FileExistsError` is now raised if the file opened in exclusive " "creation mode (``'x'``) already exists." @@ -2601,11 +2682,11 @@ msgstr "" "如果檔案已存在但使用了唯一性建立模式 (``'x'``),現在會引發 :exc:" "`FileExistsError`。" -#: ../../library/functions.rst:1458 +#: ../../library/functions.rst:1535 msgid "The file is now non-inheritable." msgstr "檔案在此版本開始是不可繼承的。" -#: ../../library/functions.rst:1462 +#: ../../library/functions.rst:1539 msgid "" "If the system call is interrupted and the signal handler does not raise an " "exception, the function now retries the system call instead of raising an :" @@ -2614,15 +2695,15 @@ msgstr "" "如果系統呼叫被中斷,但訊號處理程式沒有引發例外,此函式現在會重試系統呼叫,而" "不是引發 :exc:`InterruptedError` 例外(原因詳見 :pep:`475`)。" -#: ../../library/functions.rst:1465 +#: ../../library/functions.rst:1542 msgid "The ``'namereplace'`` error handler was added." msgstr "增加了 ``'namereplace'`` 錯誤處理程式。" -#: ../../library/functions.rst:1469 +#: ../../library/functions.rst:1546 msgid "Support added to accept objects implementing :class:`os.PathLike`." msgstr "增加對於實作 :class:`os.PathLike` 物件的支援。" -#: ../../library/functions.rst:1470 +#: ../../library/functions.rst:1547 msgid "" "On Windows, opening a console buffer may return a subclass of :class:`io." "RawIOBase` other than :class:`io.FileIO`." @@ -2630,11 +2711,11 @@ msgstr "" "在 Windows 上,開啟一個控制臺緩衝區可能會回傳 :class:`io.RawIOBase` 的 " "subclass,而不是 :class:`io.FileIO`。" -#: ../../library/functions.rst:1473 +#: ../../library/functions.rst:1550 msgid "The ``'U'`` mode has been removed." msgstr "``'U'`` 模式被移除。" -#: ../../library/functions.rst:1478 +#: ../../library/functions.rst:1555 msgid "" "Given a string representing one Unicode character, return an integer " "representing the Unicode code point of that character. For example, " @@ -2645,7 +2726,7 @@ msgstr "" "``ord('a')`` 回傳整數 ``97``、``ord('€')``\\ (歐元符號)回傳 ``8364``。這" "是 :func:`chr` 的逆函式。" -#: ../../library/functions.rst:1486 +#: ../../library/functions.rst:1563 msgid "" "Return *base* to the power *exp*; if *mod* is present, return *base* to the " "power *exp*, modulo *mod* (computed more efficiently than ``pow(base, exp) % " @@ -2656,8 +2737,7 @@ msgstr "" "*mod* 取餘數(比直接呼叫 ``pow(base, exp) % mod`` 計算更高效)。兩個引數形式" "的 ``pow(exp, exp)`` 等價於次方運算子:``base**exp``。" -#: ../../library/functions.rst:1491 -#, fuzzy +#: ../../library/functions.rst:1568 msgid "" "The arguments must have numeric types. With mixed operand types, the " "coercion rules for binary arithmetic operators apply. For :class:`int` " @@ -2671,15 +2751,17 @@ msgid "" "`float` with an integral exponent, a float result is delivered. For example, " "``pow(-9, 2.0)`` returns ``81.0``." msgstr "" -"引數必須是數值型別。對於不同型別的運算元,會套用二元算術運算子的強制轉型 " +"引數必須是數值型別。對於混合型別的運算元,會套用二元算術運算子的強制轉型 " "(coercion) 規則。對於 :class:`int` 運算元,運算結果會(在強制轉型後)與運算元" "的型別相同,除非第二個引數是負數;在這種情況下,所有的引數都會被轉換為浮點數" "並得到浮點數的結果。例如,``pow(10, 2)`` 會回傳 ``100``,但 ``pow(10, -2)`` " "會回傳 ``0.01``。如果底數 (base) 是型別為 :class:`int` 或 :class:`float` 的負" -"數,且指數 (exponent) 不是整數,則會得到一個複數的結果。例如,``pow(-9, " -"0.5)`` 會回傳一個接近 ``3j`` 的值。" +"數且指數 (exponent) 不是整數,則會得到一個複數的結果,例如 ``pow(-9, 0.5)`` " +"會回傳一個接近 ``3j`` 的值。如果底數 (base) 是型別為 :class:`int` 或 :class:" +"`float` 的負數且指數為整數,則會得到一個浮點數的結果,例如 ``pow(-9, 2.0)`` " +"會回傳 ``81.0``。" -#: ../../library/functions.rst:1503 +#: ../../library/functions.rst:1580 msgid "" "For :class:`int` operands *base* and *exp*, if *mod* is present, *mod* must " "also be of integer type and *mod* must be nonzero. If *mod* is present and " @@ -2692,11 +2774,11 @@ msgstr "" "與 *mod* 互質。在這種情況下,會回傳 ``pow(inv_base, -exp, mod)``,其中 " "*inv_base* 是 *base* 對 *mod* 的模倒數 (inverse modulo)。" -#: ../../library/functions.rst:1509 +#: ../../library/functions.rst:1586 msgid "Here's an example of computing an inverse for ``38`` modulo ``97``::" msgstr "以下是一個計算 ``38`` 對 ``97`` 取模倒數的範例: ::" -#: ../../library/functions.rst:1511 +#: ../../library/functions.rst:1588 msgid "" ">>> pow(38, -1, mod=97)\n" "23\n" @@ -2708,7 +2790,7 @@ msgstr "" ">>> 23 * 38 % 97 == 1\n" "True" -#: ../../library/functions.rst:1516 +#: ../../library/functions.rst:1593 msgid "" "For :class:`int` operands, the three-argument form of ``pow`` now allows the " "second argument to be negative, permitting computation of modular inverses." @@ -2716,12 +2798,12 @@ msgstr "" "對於 :class:`int` 運算元,現在 ``pow`` 的三引數形式允許第二個引數為負數,也容" "許模倒數的計算。" -#: ../../library/functions.rst:1521 +#: ../../library/functions.rst:1598 msgid "" "Allow keyword arguments. Formerly, only positional arguments were supported." msgstr "允許關鍵字引數。在此之前只支援位置引數。" -#: ../../library/functions.rst:1528 +#: ../../library/functions.rst:1605 msgid "" "Print *objects* to the text stream *file*, separated by *sep* and followed " "by *end*. *sep*, *end*, *file*, and *flush*, if present, must be given as " @@ -2730,7 +2812,7 @@ msgstr "" "將 *objects* 列印到文字資料串流 *file*,用 *sep* 分隔並以 *end* 結尾。如果有" "給定 *sep*、*end*、*file* 和 *flush*,那麼它們必須是關鍵字引數的形式。" -#: ../../library/functions.rst:1532 +#: ../../library/functions.rst:1609 msgid "" "All non-keyword arguments are converted to strings like :func:`str` does and " "written to the stream, separated by *sep* and followed by *end*. Both *sep* " @@ -2743,7 +2825,7 @@ msgstr "" "以是 ``None``,這表示使用預設值。如果沒有給定 *objects*,:func:`print` 就只會" "寫入 *end*。" -#: ../../library/functions.rst:1538 +#: ../../library/functions.rst:1615 msgid "" "The *file* argument must be an object with a ``write(string)`` method; if it " "is not present or ``None``, :data:`sys.stdout` will be used. Since printed " @@ -2755,7 +2837,7 @@ msgstr "" "串,所以 :func:`print` 不能用於二進位模式的檔案物件。對於此類物件,請改用 " "``file.write(...)``。" -#: ../../library/functions.rst:1543 +#: ../../library/functions.rst:1620 msgid "" "Output buffering is usually determined by *file*. However, if *flush* is " "true, the stream is forcibly flushed." @@ -2763,15 +2845,15 @@ msgstr "" "輸出緩衝通常會由 *file* 決定。但是如果 *flush* 為 true,則資料串流會被強制清" "除。" -#: ../../library/functions.rst:1547 +#: ../../library/functions.rst:1624 msgid "Added the *flush* keyword argument." msgstr "增加了 *flush* 關鍵字引數。" -#: ../../library/functions.rst:1553 +#: ../../library/functions.rst:1630 msgid "Return a property attribute." msgstr "回傳 property 屬性。" -#: ../../library/functions.rst:1555 +#: ../../library/functions.rst:1632 msgid "" "*fget* is a function for getting an attribute value. *fset* is a function " "for setting an attribute value. *fdel* is a function for deleting an " @@ -2780,11 +2862,11 @@ msgstr "" "*fget* 是一個用於取得屬性值的函式,*fset* 是一個用於設定屬性值的函式,*fdel* " "是一個用於刪除屬性值的函式,而 *doc* 會為該屬性建立一個說明字串。" -#: ../../library/functions.rst:1559 +#: ../../library/functions.rst:1636 msgid "A typical use is to define a managed attribute ``x``::" msgstr "一個典型的用途是定義一個受管理的屬性 ``x``: ::" -#: ../../library/functions.rst:1561 +#: ../../library/functions.rst:1638 msgid "" "class C:\n" " def __init__(self):\n" @@ -2816,15 +2898,15 @@ msgstr "" "\n" " x = property(getx, setx, delx, \"I'm the 'x' property.\")" -#: ../../library/functions.rst:1576 +#: ../../library/functions.rst:1653 msgid "" "If *c* is an instance of *C*, ``c.x`` will invoke the getter, ``c.x = " "value`` will invoke the setter, and ``del c.x`` the deleter." msgstr "" -"如果 *c* 是 *C* 的一個實例,則 ``c.x`` 將會呼叫取得器 (getter),``c.x = " -"value`` 會呼叫設定器 (setter),而 ``del c.x`` 會呼叫刪除器 (deleter)。" +"如果 *c* 是 *C* 的一個實例,則 ``c.x`` 將會叫用取得器 (getter),``c.x = " +"value`` 會呼叫設定器 (setter),而 ``del c.x`` 會叫用刪除器 (deleter)。" -#: ../../library/functions.rst:1579 +#: ../../library/functions.rst:1656 msgid "" "If given, *doc* will be the docstring of the property attribute. Otherwise, " "the property will copy *fget*'s docstring (if it exists). This makes it " @@ -2835,7 +2917,7 @@ msgstr "" "*fget* 的說明字串(如果它存在的話)。這樣一來,就能夠輕鬆地使用 :func:" "`property` 作為\\ :term:`裝飾器 `\\ 來建立唯讀屬性: ::" -#: ../../library/functions.rst:1583 +#: ../../library/functions.rst:1660 msgid "" "class Parrot:\n" " def __init__(self):\n" @@ -2847,14 +2929,14 @@ msgid "" " return self._voltage" msgstr "" -#: ../../library/functions.rst:1592 +#: ../../library/functions.rst:1669 msgid "" "The ``@property`` decorator turns the :meth:`!voltage` method into a " "\"getter\" for a read-only attribute with the same name, and it sets the " "docstring for *voltage* to \"Get the current voltage.\"" msgstr "" -#: ../../library/functions.rst:1600 +#: ../../library/functions.rst:1677 msgid "" "A property object has ``getter``, ``setter``, and ``deleter`` methods usable " "as decorators that create a copy of the property with the corresponding " @@ -2862,7 +2944,7 @@ msgid "" "with an example:" msgstr "" -#: ../../library/functions.rst:1605 +#: ../../library/functions.rst:1682 msgid "" "class C:\n" " def __init__(self):\n" @@ -2898,30 +2980,36 @@ msgstr "" " def x(self):\n" " del self._x" -#: ../../library/functions.rst:1624 +#: ../../library/functions.rst:1701 msgid "" "This code is exactly equivalent to the first example. Be sure to give the " "additional functions the same name as the original property (``x`` in this " "case.)" msgstr "" -#: ../../library/functions.rst:1628 +#: ../../library/functions.rst:1705 msgid "" "The returned property object also has the attributes ``fget``, ``fset``, and " "``fdel`` corresponding to the constructor arguments." msgstr "" -#: ../../library/functions.rst:1631 +#: ../../library/functions.rst:1708 msgid "The docstrings of property objects are now writeable." msgstr "" -#: ../../library/functions.rst:1640 +#: ../../library/functions.rst:1713 +msgid "" +"Attribute holding the name of the property. The name of the property can be " +"changed at runtime." +msgstr "" + +#: ../../library/functions.rst:1724 msgid "" "Rather than being a function, :class:`range` is actually an immutable " "sequence type, as documented in :ref:`typesseq-range` and :ref:`typesseq`." msgstr "" -#: ../../library/functions.rst:1646 +#: ../../library/functions.rst:1730 msgid "" "Return a string containing a printable representation of an object. For " "many types, this function makes an attempt to return a string that would " @@ -2934,11 +3022,11 @@ msgid "" "raise :exc:`RuntimeError`." msgstr "" -#: ../../library/functions.rst:1657 +#: ../../library/functions.rst:1741 msgid "This class has a custom representation that can be evaluated::" msgstr "" -#: ../../library/functions.rst:1659 +#: ../../library/functions.rst:1743 msgid "" "class Person:\n" " def __init__(self, name, age):\n" @@ -2956,7 +3044,7 @@ msgstr "" " def __repr__(self):\n" " return f\"Person('{self.name}', {self.age})\"" -#: ../../library/functions.rst:1670 +#: ../../library/functions.rst:1754 msgid "" "Return a reverse :term:`iterator`. *seq* must be an object which has a :" "meth:`~object.__reversed__` method or supports the sequence protocol (the :" @@ -2964,14 +3052,14 @@ msgid "" "with integer arguments starting at ``0``)." msgstr "" -#: ../../library/functions.rst:1678 +#: ../../library/functions.rst:1762 msgid "" "Return *number* rounded to *ndigits* precision after the decimal point. If " "*ndigits* is omitted or is ``None``, it returns the nearest integer to its " "input." msgstr "" -#: ../../library/functions.rst:1682 +#: ../../library/functions.rst:1766 msgid "" "For the built-in types supporting :func:`round`, values are rounded to the " "closest multiple of 10 to the power minus *ndigits*; if two multiples are " @@ -2982,13 +3070,13 @@ msgid "" "``None``. Otherwise, the return value has the same type as *number*." msgstr "" -#: ../../library/functions.rst:1691 +#: ../../library/functions.rst:1775 msgid "" "For a general Python object ``number``, ``round`` delegates to ``number." "__round__``." msgstr "" -#: ../../library/functions.rst:1696 +#: ../../library/functions.rst:1780 msgid "" "The behavior of :func:`round` for floats can be surprising: for example, " "``round(2.675, 2)`` gives ``2.67`` instead of the expected ``2.68``. This is " @@ -2997,21 +3085,21 @@ msgid "" "information." msgstr "" -#: ../../library/functions.rst:1708 +#: ../../library/functions.rst:1792 msgid "" "Return a new :class:`set` object, optionally with elements taken from " "*iterable*. ``set`` is a built-in class. See :class:`set` and :ref:`types-" "set` for documentation about this class." msgstr "" -#: ../../library/functions.rst:1712 +#: ../../library/functions.rst:1796 msgid "" "For other containers see the built-in :class:`frozenset`, :class:`list`, :" "class:`tuple`, and :class:`dict` classes, as well as the :mod:`collections` " "module." msgstr "" -#: ../../library/functions.rst:1719 +#: ../../library/functions.rst:1803 msgid "" "This is the counterpart of :func:`getattr`. The arguments are an object, a " "string, and an arbitrary value. The string may name an existing attribute " @@ -3020,7 +3108,7 @@ msgid "" "is equivalent to ``x.foobar = 123``." msgstr "" -#: ../../library/functions.rst:1725 +#: ../../library/functions.rst:1809 msgid "" "*name* need not be a Python identifier as defined in :ref:`identifiers` " "unless the object chooses to enforce that, for example in a custom :meth:" @@ -3029,21 +3117,21 @@ msgid "" "notation, but is accessible through :func:`getattr` etc.." msgstr "" -#: ../../library/functions.rst:1733 +#: ../../library/functions.rst:1817 msgid "" "Since :ref:`private name mangling ` happens at " "compilation time, one must manually mangle a private attribute's (attributes " "with two leading underscores) name in order to set it with :func:`setattr`." msgstr "" -#: ../../library/functions.rst:1742 +#: ../../library/functions.rst:1826 msgid "" "Return a :term:`slice` object representing the set of indices specified by " "``range(start, stop, step)``. The *start* and *step* arguments default to " "``None``." msgstr "" -#: ../../library/functions.rst:1750 +#: ../../library/functions.rst:1830 msgid "" "Slice objects have read-only data attributes :attr:`!start`, :attr:`!stop`, " "and :attr:`!step` which merely return the argument values (or their " @@ -3051,48 +3139,48 @@ msgid "" "by NumPy and other third-party packages." msgstr "" -#: ../../library/functions.rst:1755 +#: ../../library/functions.rst:1839 msgid "" "Slice objects are also generated when extended indexing syntax is used. For " "example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See :func:" "`itertools.islice` for an alternate version that returns an :term:`iterator`." msgstr "" -#: ../../library/functions.rst:1760 +#: ../../library/functions.rst:1844 msgid "" "Slice objects are now :term:`hashable` (provided :attr:`~slice.start`, :attr:" "`~slice.stop`, and :attr:`~slice.step` are hashable)." msgstr "" -#: ../../library/functions.rst:1766 +#: ../../library/functions.rst:1850 msgid "Return a new sorted list from the items in *iterable*." msgstr "" -#: ../../library/functions.rst:1768 +#: ../../library/functions.rst:1852 msgid "" "Has two optional arguments which must be specified as keyword arguments." msgstr "有兩個選擇性引數,只能使用關鍵字引數來指定。" -#: ../../library/functions.rst:1770 +#: ../../library/functions.rst:1854 msgid "" "*key* specifies a function of one argument that is used to extract a " "comparison key from each element in *iterable* (for example, ``key=str." "lower``). The default value is ``None`` (compare the elements directly)." msgstr "" -#: ../../library/functions.rst:1774 +#: ../../library/functions.rst:1858 msgid "" "*reverse* is a boolean value. If set to ``True``, then the list elements " "are sorted as if each comparison were reversed." msgstr "" -#: ../../library/functions.rst:1777 +#: ../../library/functions.rst:1861 msgid "" "Use :func:`functools.cmp_to_key` to convert an old-style *cmp* function to a " "*key* function." msgstr "" -#: ../../library/functions.rst:1780 +#: ../../library/functions.rst:1864 msgid "" "The built-in :func:`sorted` function is guaranteed to be stable. A sort is " "stable if it guarantees not to change the relative order of elements that " @@ -3100,7 +3188,7 @@ msgid "" "example, sort by department, then by salary grade)." msgstr "" -#: ../../library/functions.rst:1785 +#: ../../library/functions.rst:1869 msgid "" "The sort algorithm uses only ``<`` comparisons between items. While " "defining an :meth:`~object.__lt__` method will suffice for sorting, :PEP:`8` " @@ -3112,22 +3200,22 @@ msgid "" "method." msgstr "" -#: ../../library/functions.rst:1794 +#: ../../library/functions.rst:1878 msgid "" "For sorting examples and a brief sorting tutorial, see :ref:`sortinghowto`." msgstr "" -#: ../../library/functions.rst:1798 +#: ../../library/functions.rst:1882 msgid "Transform a method into a static method." msgstr "" -#: ../../library/functions.rst:1800 +#: ../../library/functions.rst:1884 msgid "" "A static method does not receive an implicit first argument. To declare a " "static method, use this idiom::" msgstr "" -#: ../../library/functions.rst:1803 +#: ../../library/functions.rst:1887 msgid "" "class C:\n" " @staticmethod\n" @@ -3137,7 +3225,7 @@ msgstr "" " @staticmethod\n" " def f(arg1, arg2, argN): ..." -#: ../../library/functions.rst:1807 +#: ../../library/functions.rst:1891 msgid "" "The ``@staticmethod`` form is a function :term:`decorator` -- see :ref:" "`function` for details." @@ -3145,7 +3233,7 @@ msgstr "" "``@staticmethod`` 語法是一個函式 :term:`decorator` - 參見 :ref:`function` 中" "的詳細介紹。" -#: ../../library/functions.rst:1810 +#: ../../library/functions.rst:1894 msgid "" "A static method can be called either on the class (such as ``C.f()``) or on " "an instance (such as ``C().f()``). Moreover, the static method :term:" @@ -3153,14 +3241,14 @@ msgid "" "(such as ``f()``)." msgstr "" -#: ../../library/functions.rst:1815 +#: ../../library/functions.rst:1899 msgid "" "Static methods in Python are similar to those found in Java or C++. Also, " "see :func:`classmethod` for a variant that is useful for creating alternate " "class constructors." msgstr "" -#: ../../library/functions.rst:1819 +#: ../../library/functions.rst:1903 msgid "" "Like all decorators, it is also possible to call ``staticmethod`` as a " "regular function and do something with its result. This is needed in some " @@ -3169,7 +3257,7 @@ msgid "" "cases, use this idiom::" msgstr "" -#: ../../library/functions.rst:1825 +#: ../../library/functions.rst:1909 msgid "" "def regular_function():\n" " ...\n" @@ -3183,36 +3271,41 @@ msgstr "" "class C:\n" " method = staticmethod(regular_function)" -#: ../../library/functions.rst:1831 +#: ../../library/functions.rst:1915 msgid "For more information on static methods, see :ref:`types`." msgstr "關於 static method 的更多資訊,請參考 :ref:`types`。" -#: ../../library/functions.rst:1833 +#: ../../library/functions.rst:1917 msgid "" -"Static methods now inherit the method attributes (``__module__``, " -"``__name__``, ``__qualname__``, ``__doc__`` and ``__annotations__``), have a " -"new ``__wrapped__`` attribute, and are now callable as regular functions." +"Static methods now inherit the method attributes (:attr:`~function." +"__module__`, :attr:`~function.__name__`, :attr:`~function.__qualname__`, :" +"attr:`~function.__doc__` and :attr:`~function.__annotations__`), have a new " +"``__wrapped__`` attribute, and are now callable as regular functions." msgstr "" +"Static method 現在繼承了 method 屬性(:attr:`~function.__module__`、:attr:" +"`~function.__name__`、:attr:`~function.__qualname__`、:attr:`~function." +"__doc__` 和 :attr:`~function.__annotations__`),並擁有一個新的 " +"``__wrapped__`` 屬性,且為如一般函式的可呼叫物件。" -#: ../../library/functions.rst:1848 +#: ../../library/functions.rst:1933 msgid "" "Return a :class:`str` version of *object*. See :func:`str` for details." msgstr "" -#: ../../library/functions.rst:1850 +#: ../../library/functions.rst:1935 msgid "" "``str`` is the built-in string :term:`class`. For general information about " "strings, see :ref:`textseq`." msgstr "" -#: ../../library/functions.rst:1856 +#: ../../library/functions.rst:1941 msgid "" "Sums *start* and the items of an *iterable* from left to right and returns " "the total. The *iterable*'s items are normally numbers, and the start value " "is not allowed to be a string." msgstr "" -#: ../../library/functions.rst:1860 +#: ../../library/functions.rst:1945 msgid "" "For some use cases, there are good alternatives to :func:`sum`. The " "preferred, fast way to concatenate a sequence of strings is by calling ``''." @@ -3221,45 +3314,45 @@ msgid "" "using :func:`itertools.chain`." msgstr "" -#: ../../library/functions.rst:1866 +#: ../../library/functions.rst:1951 msgid "The *start* parameter can be specified as a keyword argument." msgstr "*start* 參數可被指定為關鍵字引數。" -#: ../../library/functions.rst:1869 +#: ../../library/functions.rst:1954 msgid "" -"Summation of floats switched to an algorithm that gives higher accuracy on " -"most builds." +"Summation of floats switched to an algorithm that gives higher accuracy and " +"better commutativity on most builds." msgstr "" -#: ../../library/functions.rst:1876 +#: ../../library/functions.rst:1961 msgid "" "Return a proxy object that delegates method calls to a parent or sibling " "class of *type*. This is useful for accessing inherited methods that have " "been overridden in a class." msgstr "" -#: ../../library/functions.rst:1880 +#: ../../library/functions.rst:1965 msgid "" "The *object_or_type* determines the :term:`method resolution order` to be " "searched. The search starts from the class right after the *type*." msgstr "" -#: ../../library/functions.rst:1884 +#: ../../library/functions.rst:1969 msgid "" -"For example, if :attr:`~class.__mro__` of *object_or_type* is ``D -> B -> C -" +"For example, if :attr:`~type.__mro__` of *object_or_type* is ``D -> B -> C -" "> A -> object`` and the value of *type* is ``B``, then :func:`super` " "searches ``C -> A -> object``." msgstr "" -#: ../../library/functions.rst:1888 +#: ../../library/functions.rst:1973 msgid "" -"The :attr:`~class.__mro__` attribute of the class corresponding to " +"The :attr:`~type.__mro__` attribute of the class corresponding to " "*object_or_type* lists the method resolution search order used by both :func:" "`getattr` and :func:`super`. The attribute is dynamic and can change " "whenever the inheritance hierarchy is updated." msgstr "" -#: ../../library/functions.rst:1893 +#: ../../library/functions.rst:1978 msgid "" "If the second argument is omitted, the super object returned is unbound. If " "the second argument is an object, ``isinstance(obj, type)`` must be true. " @@ -3267,7 +3360,17 @@ msgid "" "(this is useful for classmethods)." msgstr "" -#: ../../library/functions.rst:1898 +#: ../../library/functions.rst:1983 +msgid "" +"When called directly within an ordinary method of a class, both arguments " +"may be omitted (\"zero-argument :func:`!super`\"). In this case, *type* will " +"be the enclosing class, and *obj* will be the first argument of the " +"immediately enclosing function (typically ``self``). (This means that zero-" +"argument :func:`!super` will not work as expected within nested functions, " +"including generator expressions, which implicitly create nested functions.)" +msgstr "" + +#: ../../library/functions.rst:1990 msgid "" "There are two typical use cases for *super*. In a class hierarchy with " "single inheritance, *super* can be used to refer to parent classes without " @@ -3275,7 +3378,7 @@ msgid "" "closely parallels the use of *super* in other programming languages." msgstr "" -#: ../../library/functions.rst:1903 +#: ../../library/functions.rst:1995 msgid "" "The second use case is to support cooperative multiple inheritance in a " "dynamic execution environment. This use case is unique to Python and is not " @@ -3288,11 +3391,11 @@ msgid "" "classes that are unknown prior to runtime)." msgstr "" -#: ../../library/functions.rst:1913 +#: ../../library/functions.rst:2005 msgid "For both use cases, a typical superclass call looks like this::" msgstr "" -#: ../../library/functions.rst:1915 +#: ../../library/functions.rst:2007 msgid "" "class C(B):\n" " def method(self, arg):\n" @@ -3300,14 +3403,14 @@ msgid "" " # super(C, self).method(arg)" msgstr "" -#: ../../library/functions.rst:1920 +#: ../../library/functions.rst:2012 msgid "" "In addition to method lookups, :func:`super` also works for attribute " "lookups. One possible use case for this is calling :term:`descriptors " "` in a parent or sibling class." msgstr "" -#: ../../library/functions.rst:1924 +#: ../../library/functions.rst:2016 msgid "" "Note that :func:`super` is implemented as part of the binding process for " "explicit dotted attribute lookups such as ``super().__getitem__(name)``. It " @@ -3317,7 +3420,7 @@ msgid "" "using statements or operators such as ``super()[name]``." msgstr "" -#: ../../library/functions.rst:1932 +#: ../../library/functions.rst:2024 msgid "" "Also note that, aside from the zero argument form, :func:`super` is not " "limited to use inside methods. The two argument form specifies the " @@ -3327,50 +3430,60 @@ msgid "" "accessing the current instance for ordinary methods." msgstr "" -#: ../../library/functions.rst:1939 +#: ../../library/functions.rst:2031 msgid "" "For practical suggestions on how to design cooperative classes using :func:" "`super`, see `guide to using super() `_." msgstr "" -#: ../../library/functions.rst:1949 +#: ../../library/functions.rst:2041 msgid "" "Rather than being a function, :class:`tuple` is actually an immutable " "sequence type, as documented in :ref:`typesseq-tuple` and :ref:`typesseq`." msgstr "" -#: ../../library/functions.rst:1958 +#: ../../library/functions.rst:2050 msgid "" "With one argument, return the type of an *object*. The return value is a " "type object and generally the same object as returned by :attr:`object." -"__class__ `." +"__class__`." msgstr "" -#: ../../library/functions.rst:1962 +#: ../../library/functions.rst:2054 msgid "" "The :func:`isinstance` built-in function is recommended for testing the type " "of an object, because it takes subclasses into account." msgstr "" -#: ../../library/functions.rst:1966 +#: ../../library/functions.rst:2057 msgid "" "With three arguments, return a new type object. This is essentially a " "dynamic form of the :keyword:`class` statement. The *name* string is the " -"class name and becomes the :attr:`~definition.__name__` attribute. The " -"*bases* tuple contains the base classes and becomes the :attr:`~class." -"__bases__` attribute; if empty, :class:`object`, 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 :attr:`~object.__dict__` attribute. The following two statements create " -"identical :class:`type` objects:" +"class name and becomes the :attr:`~type.__name__` attribute. The *bases* " +"tuple contains the base classes and becomes the :attr:`~type.__bases__` " +"attribute; if empty, :class:`object`, 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 :attr:`~type." +"__dict__` attribute. The following two statements create identical :class:`!" +"type` objects:" +msgstr "" + +#: ../../library/functions.rst:2072 +msgid "See also:" msgstr "" -#: ../../library/functions.rst:1981 -msgid "See also :ref:`bltin-type-objects`." -msgstr "另請參閱 :ref:`bltin-type-objects`。" +#: ../../library/functions.rst:2074 +msgid "" +":ref:`Documentation on attributes and methods on classes `." +msgstr "" -#: ../../library/functions.rst:1983 +#: ../../library/functions.rst:2075 +msgid ":ref:`bltin-type-objects`" +msgstr ":ref:`bltin-type-objects`" + +#: ../../library/functions.rst:2077 msgid "" "Keyword arguments provided to the three argument form are passed to the " "appropriate metaclass machinery (usually :meth:`~object.__init_subclass__`) " @@ -3378,55 +3491,58 @@ msgid "" "would." msgstr "" -#: ../../library/functions.rst:1988 +#: ../../library/functions.rst:2082 msgid "See also :ref:`class-customization`." msgstr "另請參閱 :ref:`class-customization`。" -#: ../../library/functions.rst:1990 +#: ../../library/functions.rst:2084 msgid "" -"Subclasses of :class:`type` which don't override ``type.__new__`` may no " +"Subclasses of :class:`!type` which don't override ``type.__new__`` may no " "longer use the one-argument form to get the type of an object." msgstr "" -#: ../../library/functions.rst:1997 +#: ../../library/functions.rst:2091 msgid "" "Return the :attr:`~object.__dict__` attribute for a module, class, instance, " -"or any other object with a :attr:`~object.__dict__` attribute." +"or any other object with a :attr:`!__dict__` attribute." msgstr "" -#: ../../library/functions.rst:2000 +#: ../../library/functions.rst:2094 msgid "" "Objects such as modules and instances have an updateable :attr:`~object." "__dict__` attribute; however, other objects may have write restrictions on " -"their :attr:`~object.__dict__` attributes (for example, classes use a :class:" -"`types.MappingProxyType` to prevent direct dictionary updates)." +"their :attr:`!__dict__` attributes (for example, classes use a :class:`types." +"MappingProxyType` to prevent direct dictionary updates)." msgstr "" -#: ../../library/functions.rst:2005 -msgid "" -"Without an argument, :func:`vars` acts like :func:`locals`. Note, the " -"locals dictionary is only useful for reads since updates to the locals " -"dictionary are ignored." +#: ../../library/functions.rst:2099 +msgid "Without an argument, :func:`vars` acts like :func:`locals`." msgstr "" -#: ../../library/functions.rst:2009 +#: ../../library/functions.rst:2101 msgid "" "A :exc:`TypeError` exception is raised if an object is specified but it " "doesn't have a :attr:`~object.__dict__` attribute (for example, if its class " "defines the :attr:`~object.__slots__` attribute)." msgstr "" -#: ../../library/functions.rst:2015 +#: ../../library/functions.rst:2107 +msgid "" +"The result of calling this function without an argument has been updated as " +"described for the :func:`locals` builtin." +msgstr "" + +#: ../../library/functions.rst:2113 msgid "" "Iterate over several iterables in parallel, producing tuples with an item " "from each one." msgstr "" -#: ../../library/functions.rst:2018 +#: ../../library/functions.rst:2116 msgid "Example::" msgstr "例如: ::" -#: ../../library/functions.rst:2020 +#: ../../library/functions.rst:2118 msgid "" ">>> for item in zip([1, 2, 3], ['sugar', 'spice', 'everything nice']):\n" "... print(item)\n" @@ -3442,27 +3558,27 @@ msgstr "" "(2, 'spice')\n" "(3, 'everything nice')" -#: ../../library/functions.rst:2027 +#: ../../library/functions.rst:2125 msgid "" "More formally: :func:`zip` returns an iterator of tuples, where the *i*-th " "tuple contains the *i*-th element from each of the argument iterables." msgstr "" -#: ../../library/functions.rst:2030 +#: ../../library/functions.rst:2128 msgid "" "Another way to think of :func:`zip` is that it turns rows into columns, and " "columns into rows. This is similar to `transposing a matrix `_." msgstr "" -#: ../../library/functions.rst:2034 +#: ../../library/functions.rst:2132 msgid "" ":func:`zip` is lazy: The elements won't be processed until the iterable is " "iterated on, e.g. by a :keyword:`!for` loop or by wrapping in a :class:" "`list`." msgstr "" -#: ../../library/functions.rst:2038 +#: ../../library/functions.rst:2136 msgid "" "One thing to consider is that the iterables passed to :func:`zip` could have " "different lengths; sometimes by design, and sometimes because of a bug in " @@ -3470,14 +3586,14 @@ msgid "" "approaches to dealing with this issue:" msgstr "" -#: ../../library/functions.rst:2043 +#: ../../library/functions.rst:2141 msgid "" "By default, :func:`zip` stops when the shortest iterable is exhausted. It " "will ignore the remaining items in the longer iterables, cutting off the " "result to the length of the shortest iterable::" msgstr "" -#: ../../library/functions.rst:2047 +#: ../../library/functions.rst:2145 msgid "" ">>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))\n" "[(0, 'fee'), (1, 'fi'), (2, 'fo')]" @@ -3485,14 +3601,14 @@ msgstr "" ">>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))\n" "[(0, 'fee'), (1, 'fi'), (2, 'fo')]" -#: ../../library/functions.rst:2050 +#: ../../library/functions.rst:2148 msgid "" ":func:`zip` is often used in cases where the iterables are assumed to be of " "equal length. In such cases, it's recommended to use the ``strict=True`` " "option. Its output is the same as regular :func:`zip`::" msgstr "" -#: ../../library/functions.rst:2054 +#: ../../library/functions.rst:2152 msgid "" ">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" "[('a', 1), ('b', 2), ('c', 3)]" @@ -3500,37 +3616,37 @@ msgstr "" ">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" "[('a', 1), ('b', 2), ('c', 3)]" -#: ../../library/functions.rst:2057 +#: ../../library/functions.rst:2155 msgid "" "Unlike the default behavior, it raises a :exc:`ValueError` if one iterable " "is exhausted before the others:" msgstr "" -#: ../../library/functions.rst:2075 +#: ../../library/functions.rst:2173 msgid "" "Without the ``strict=True`` argument, any bug that results in iterables of " "different lengths will be silenced, possibly manifesting as a hard-to-find " "bug in another part of the program." msgstr "" -#: ../../library/functions.rst:2079 +#: ../../library/functions.rst:2177 msgid "" "Shorter iterables can be padded with a constant value to make all the " "iterables have the same length. This is done by :func:`itertools." "zip_longest`." msgstr "" -#: ../../library/functions.rst:2083 +#: ../../library/functions.rst:2181 msgid "" "Edge cases: With a single iterable argument, :func:`zip` returns an iterator " "of 1-tuples. With no arguments, it returns an empty iterator." msgstr "" -#: ../../library/functions.rst:2086 +#: ../../library/functions.rst:2184 msgid "Tips and tricks:" msgstr "" -#: ../../library/functions.rst:2088 +#: ../../library/functions.rst:2186 msgid "" "The left-to-right evaluation order of the iterables is guaranteed. This " "makes possible an idiom for clustering a data series into n-length groups " @@ -3539,13 +3655,13 @@ msgid "" "iterator. This has the effect of dividing the input into n-length chunks." msgstr "" -#: ../../library/functions.rst:2094 +#: ../../library/functions.rst:2192 msgid "" ":func:`zip` in conjunction with the ``*`` operator can be used to unzip a " "list::" msgstr "" -#: ../../library/functions.rst:2097 +#: ../../library/functions.rst:2195 msgid "" ">>> x = [1, 2, 3]\n" ">>> y = [4, 5, 6]\n" @@ -3563,17 +3679,17 @@ msgstr "" ">>> x == list(x2) and y == list(y2)\n" "True" -#: ../../library/functions.rst:2105 +#: ../../library/functions.rst:2203 msgid "Added the ``strict`` argument." msgstr "增加了 ``strict`` 引數。" -#: ../../library/functions.rst:2117 +#: ../../library/functions.rst:2215 msgid "" "This is an advanced function that is not needed in everyday Python " "programming, unlike :func:`importlib.import_module`." msgstr "" -#: ../../library/functions.rst:2120 +#: ../../library/functions.rst:2218 msgid "" "This function is invoked by the :keyword:`import` statement. It can be " "replaced (by importing the :mod:`builtins` module and assigning to " @@ -3585,7 +3701,7 @@ msgid "" "discouraged in favor of :func:`importlib.import_module`." msgstr "" -#: ../../library/functions.rst:2129 +#: ../../library/functions.rst:2227 msgid "" "The function imports the module *name*, potentially using the given " "*globals* and *locals* to determine how to interpret the name in a package " @@ -3595,7 +3711,7 @@ msgid "" "determine the package context of the :keyword:`import` statement." msgstr "" -#: ../../library/functions.rst:2136 +#: ../../library/functions.rst:2234 msgid "" "*level* specifies whether to use absolute or relative imports. ``0`` (the " "default) means only perform absolute imports. Positive values for *level* " @@ -3604,7 +3720,7 @@ msgid "" "details)." msgstr "" -#: ../../library/functions.rst:2142 +#: ../../library/functions.rst:2240 msgid "" "When the *name* variable is of the form ``package.module``, normally, the " "top-level package (the name up till the first dot) is returned, *not* the " @@ -3612,37 +3728,37 @@ msgid "" "given, the module named by *name* is returned." msgstr "" -#: ../../library/functions.rst:2147 +#: ../../library/functions.rst:2245 msgid "" "For example, the statement ``import spam`` results in bytecode resembling " "the following code::" msgstr "" -#: ../../library/functions.rst:2150 +#: ../../library/functions.rst:2248 msgid "spam = __import__('spam', globals(), locals(), [], 0)" msgstr "spam = __import__('spam', globals(), locals(), [], 0)" -#: ../../library/functions.rst:2152 +#: ../../library/functions.rst:2250 msgid "The statement ``import spam.ham`` results in this call::" msgstr "" -#: ../../library/functions.rst:2154 +#: ../../library/functions.rst:2252 msgid "spam = __import__('spam.ham', globals(), locals(), [], 0)" msgstr "spam = __import__('spam.ham', globals(), locals(), [], 0)" -#: ../../library/functions.rst:2156 +#: ../../library/functions.rst:2254 msgid "" "Note how :func:`__import__` returns the toplevel module here because this is " "the object that is bound to a name by the :keyword:`import` statement." msgstr "" -#: ../../library/functions.rst:2159 +#: ../../library/functions.rst:2257 msgid "" "On the other hand, the statement ``from spam.ham import eggs, sausage as " "saus`` results in ::" msgstr "" -#: ../../library/functions.rst:2162 +#: ../../library/functions.rst:2260 msgid "" "_temp = __import__('spam.ham', globals(), locals(), ['eggs', 'sausage'], 0)\n" "eggs = _temp.eggs\n" @@ -3652,36 +3768,36 @@ msgstr "" "eggs = _temp.eggs\n" "saus = _temp.sausage" -#: ../../library/functions.rst:2166 +#: ../../library/functions.rst:2264 msgid "" "Here, the ``spam.ham`` module is returned from :func:`__import__`. From " "this object, the names to import are retrieved and assigned to their " "respective names." msgstr "" -#: ../../library/functions.rst:2170 +#: ../../library/functions.rst:2268 msgid "" "If you simply want to import a module (potentially within a package) by " "name, use :func:`importlib.import_module`." msgstr "" -#: ../../library/functions.rst:2173 +#: ../../library/functions.rst:2271 msgid "" "Negative values for *level* are no longer supported (which also changes the " "default value to 0)." msgstr "" -#: ../../library/functions.rst:2177 +#: ../../library/functions.rst:2275 msgid "" "When the command line options :option:`-E` or :option:`-I` are being used, " "the environment variable :envvar:`PYTHONCASEOK` is now ignored." msgstr "" -#: ../../library/functions.rst:2182 +#: ../../library/functions.rst:2280 msgid "Footnotes" msgstr "註解" -#: ../../library/functions.rst:2183 +#: ../../library/functions.rst:2281 msgid "" "Note that the parser only accepts the Unix-style end of line convention. If " "you are reading the code from a file, make sure to use newline conversion " @@ -3694,106 +3810,106 @@ msgstr "" msgid "Boolean" msgstr "Boolean(布林值)" -#: ../../library/functions.rst:154 ../../library/functions.rst:1956 +#: ../../library/functions.rst:154 ../../library/functions.rst:2048 msgid "type" msgstr "type(型別)" -#: ../../library/functions.rst:631 +#: ../../library/functions.rst:648 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../library/functions.rst:631 +#: ../../library/functions.rst:648 msgid "exec" msgstr "exec" -#: ../../library/functions.rst:713 +#: ../../library/functions.rst:746 msgid "NaN" msgstr "NaN" -#: ../../library/functions.rst:713 +#: ../../library/functions.rst:746 msgid "Infinity" msgstr "Infinity(無窮)" -#: ../../library/functions.rst:781 +#: ../../library/functions.rst:814 msgid "__format__" msgstr "__format__" -#: ../../library/functions.rst:781 ../../library/functions.rst:1840 +#: ../../library/functions.rst:814 ../../library/functions.rst:1925 msgid "string" msgstr "string(字串)" -#: ../../library/functions.rst:781 +#: ../../library/functions.rst:814 msgid "format() (built-in function)" msgstr "format()(內建函式)" -#: ../../library/functions.rst:1248 +#: ../../library/functions.rst:1325 msgid "file object" msgstr "file object(檔案物件)" -#: ../../library/functions.rst:1248 ../../library/functions.rst:1369 +#: ../../library/functions.rst:1325 ../../library/functions.rst:1446 msgid "open() built-in function" msgstr "open() 內建函式" -#: ../../library/functions.rst:1276 +#: ../../library/functions.rst:1353 msgid "file" msgstr "file(檔案)" -#: ../../library/functions.rst:1276 +#: ../../library/functions.rst:1353 msgid "modes" msgstr "modes(模式)" -#: ../../library/functions.rst:1369 +#: ../../library/functions.rst:1446 msgid "universal newlines" msgstr "universal newlines" -#: ../../library/functions.rst:1430 +#: ../../library/functions.rst:1507 msgid "line-buffered I/O" msgstr "line-buffered I/O(行緩衝 I/O)" -#: ../../library/functions.rst:1430 +#: ../../library/functions.rst:1507 msgid "unbuffered I/O" msgstr "unbuffered I/O(非緩衝 I/O)" -#: ../../library/functions.rst:1430 +#: ../../library/functions.rst:1507 msgid "buffer size, I/O" msgstr "buffer size, I/O(緩衝區大小、I/O)" -#: ../../library/functions.rst:1430 +#: ../../library/functions.rst:1507 msgid "I/O control" msgstr "I/O control(I/O 控制)" -#: ../../library/functions.rst:1430 +#: ../../library/functions.rst:1507 msgid "buffering" msgstr "buffering(緩衝)" -#: ../../library/functions.rst:1430 +#: ../../library/functions.rst:1507 msgid "text mode" msgstr "text mode(文字模式)" -#: ../../library/functions.rst:1430 ../../library/functions.rst:2111 +#: ../../library/functions.rst:1507 ../../library/functions.rst:2209 msgid "module" msgstr "module(模組)" -#: ../../library/functions.rst:1430 +#: ../../library/functions.rst:1507 msgid "sys" msgstr "sys" -#: ../../library/functions.rst:1840 +#: ../../library/functions.rst:1925 msgid "str() (built-in function)" msgstr "str() (內建函式)" -#: ../../library/functions.rst:1956 +#: ../../library/functions.rst:2048 msgid "object" msgstr "object(物件)" -#: ../../library/functions.rst:2111 +#: ../../library/functions.rst:2209 msgid "statement" msgstr "statement(陳述式)" -#: ../../library/functions.rst:2111 +#: ../../library/functions.rst:2209 msgid "import" msgstr "import(引入)" -#: ../../library/functions.rst:2111 +#: ../../library/functions.rst:2209 msgid "builtins" msgstr "builtins(內建)" diff --git a/library/functools.po b/library/functools.po index 8fc6a31c22..69858cd1de 100644 --- a/library/functools.po +++ b/library/functools.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-18 00:04+0000\n" +"POT-Creation-Date: 2025-07-12 00:16+0000\n" "PO-Revision-Date: 2024-05-11 16:02+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -61,7 +61,7 @@ msgstr "" "裝器。因為它永遠不需要丟棄舊值,所以這比有大小限制的 :func:`lru_cache` 更小、" "更快。" -#: ../../library/functools.rst:39 ../../library/functools.rst:291 +#: ../../library/functools.rst:39 ../../library/functools.rst:297 msgid "For example::" msgstr "舉例來說: ::" @@ -80,6 +80,16 @@ msgid "" "cached\n" "479001600" msgstr "" +"@cache\n" +"def factorial(n):\n" +" return n * factorial(n-1) if n else 1\n" +"\n" +">>> factorial(10) # 沒有先前的快取結果,會進行 11 次遞迴呼叫\n" +"3628800\n" +">>> factorial(5) # 只查詢快取的結果\n" +"120\n" +">>> factorial(12) # 進行兩次新的遞迴呼叫,其他 10 次是快取的\n" +"479001600" #: ../../library/functools.rst:52 ../../library/functools.rst:158 msgid "" @@ -111,7 +121,7 @@ msgstr "" "屬性外實質上幾乎是不可變 (immutable) 的實例,針對其所需要繁重計算會很有用。" #: ../../library/functools.rst:70 ../../library/functools.rst:142 -#: ../../library/functools.rst:383 +#: ../../library/functools.rst:389 msgid "Example::" msgstr "範例: ::" @@ -352,24 +362,24 @@ msgstr "" "的 :class:`dict` 以顯示 *maxsize* 和 *typed* 的值。這僅能顯示資訊,改變其值不" "會有任何效果。" -#: ../../library/functools.rst:202 +#: ../../library/functools.rst:205 msgid "" "To help measure the effectiveness of the cache and tune the *maxsize* " -"parameter, the wrapped function is instrumented with a :func:`cache_info` " +"parameter, the wrapped function is instrumented with a :func:`!cache_info` " "function that returns a :term:`named tuple` showing *hits*, *misses*, " "*maxsize* and *currsize*." msgstr "" "為了輔助測量快取的有效性並調整 *maxsize* 參數,包裝的函式使用了一個 :func:" -"`cache_info` 函式來做檢測,該函式會回傳一個\\ :term:`附名元組 `\\ 來顯示 *hits*、*misses*、*maxsize* 和 *currsize*。" -#: ../../library/functools.rst:207 +#: ../../library/functools.rst:213 msgid "" -"The decorator also provides a :func:`cache_clear` function for clearing or " +"The decorator also provides a :func:`!cache_clear` function for clearing or " "invalidating the cache." -msgstr "裝飾器還提供了一個 :func:`cache_clear` 函式來清除或使快取失效。" +msgstr "裝飾器還提供了一個 :func:`!cache_clear` 函式來清除或使快取失效。" -#: ../../library/functools.rst:210 +#: ../../library/functools.rst:216 msgid "" "The original underlying function is accessible through the :attr:" "`__wrapped__` attribute. This is useful for introspection, for bypassing " @@ -378,14 +388,14 @@ msgstr "" "原本的底層函式可以透過 :attr:`__wrapped__` 屬性存取。這對於要自我檢查 " "(introspection)、繞過快取或使用不同的快取重新包裝函式時非常有用。" -#: ../../library/functools.rst:214 +#: ../../library/functools.rst:220 msgid "" "The cache keeps references to the arguments and return values until they age " "out of the cache or until the cache is cleared." msgstr "" "快取會保留對引數和回傳值的參照,直到快取過時 (age out) 或快取被清除為止。" -#: ../../library/functools.rst:217 +#: ../../library/functools.rst:223 msgid "" "If a method is cached, the ``self`` instance argument is included in the " "cache. See :ref:`faq-cache-method-calls`" @@ -393,7 +403,7 @@ msgstr "" "如果方法被快取起來,則 ``self`` 實例引數將包含在快取中。請參閱\\ :ref:`faq-" "cache-method-calls`" -#: ../../library/functools.rst:220 +#: ../../library/functools.rst:226 msgid "" "An `LRU (least recently used) cache `_ works best when the " @@ -408,7 +418,7 @@ msgstr "" "能發揮最好的效果。快取的大小限制可確保快取不會在長時間運行的行程(例如 Web 伺" "服器)上無限制地成長。" -#: ../../library/functools.rst:227 +#: ../../library/functools.rst:233 msgid "" "In general, the LRU cache should only be used when you want to reuse " "previously computed values. Accordingly, it doesn't make sense to cache " @@ -420,11 +430,11 @@ msgstr "" "side-effects 的函式、需要在每次呼叫時建立不同可變物件的函式(例如產生器和非同" "步函式)或不純函式(impure function,例如 time() 或 random())是沒有意義的。" -#: ../../library/functools.rst:233 +#: ../../library/functools.rst:239 msgid "Example of an LRU cache for static web content::" msgstr "靜態網頁內容的 LRU 快取範例: ::" -#: ../../library/functools.rst:235 +#: ../../library/functools.rst:241 msgid "" "@lru_cache(maxsize=32)\n" "def get_pep(num):\n" @@ -443,8 +453,24 @@ msgid "" ">>> get_pep.cache_info()\n" "CacheInfo(hits=3, misses=8, maxsize=32, currsize=8)" msgstr "" +"@lru_cache(maxsize=32)\n" +"def get_pep(num):\n" +" '取得 Python 改進提案的文字'\n" +" resource = f'https://peps.python.org/pep-{num:04d}'\n" +" try:\n" +" with urllib.request.urlopen(resource) as s:\n" +" return s.read()\n" +" except urllib.error.HTTPError:\n" +" return 'Not Found'\n" +"\n" +">>> for n in 8, 290, 308, 320, 8, 218, 320, 279, 289, 320, 9991:\n" +"... pep = get_pep(n)\n" +"... print(n, len(pep))\n" +"\n" +">>> get_pep.cache_info()\n" +"CacheInfo(hits=3, misses=8, maxsize=32, currsize=8)" -#: ../../library/functools.rst:252 +#: ../../library/functools.rst:258 msgid "" "Example of efficiently computing `Fibonacci numbers `_ using a cache to implement a `dynamic " @@ -454,7 +480,7 @@ msgstr "" "wiki/Dynamic_programming>`_ 技法以有效率地計算\\ `費波那契數 (Fibonacci " "numbers) `_ 的範例: ::" -#: ../../library/functools.rst:258 +#: ../../library/functools.rst:264 msgid "" "@lru_cache(maxsize=None)\n" "def fib(n):\n" @@ -468,20 +494,31 @@ msgid "" ">>> fib.cache_info()\n" "CacheInfo(hits=28, misses=16, maxsize=None, currsize=16)" msgstr "" +"@lru_cache(maxsize=None)\n" +"def fib(n):\n" +" if n < 2:\n" +" return n\n" +" return fib(n-1) + fib(n-2)\n" +"\n" +">>> [fib(n) for n in range(16)]\n" +"[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]\n" +"\n" +">>> fib.cache_info()\n" +"CacheInfo(hits=28, misses=16, maxsize=None, currsize=16)" -#: ../../library/functools.rst:272 +#: ../../library/functools.rst:278 msgid "Added the *typed* option." msgstr "新增 *typed* 選項。" -#: ../../library/functools.rst:275 +#: ../../library/functools.rst:281 msgid "Added the *user_function* option." msgstr "新增 *user_function* 選項。" -#: ../../library/functools.rst:278 +#: ../../library/functools.rst:284 msgid "Added the function :func:`!cache_parameters`" msgstr "新增 :func:`!cache_parameters` 函式。" -#: ../../library/functools.rst:283 +#: ../../library/functools.rst:289 msgid "" "Given a class defining one or more rich comparison ordering methods, this " "class decorator supplies the rest. This simplifies the effort involved in " @@ -490,16 +527,16 @@ msgstr "" "給定一個定義一個或多個 rich comparison 排序方法的類別,該類別裝飾器會提供其餘" "部分。這簡化了指定所有可能的 rich comparison 操作所涉及的工作:" -#: ../../library/functools.rst:287 +#: ../../library/functools.rst:293 msgid "" -"The class must define one of :meth:`__lt__`, :meth:`__le__`, :meth:`__gt__`, " -"or :meth:`__ge__`. In addition, the class should supply an :meth:`__eq__` " -"method." +"The class must define one of :meth:`~object.__lt__`, :meth:`~object." +"__le__`, :meth:`~object.__gt__`, or :meth:`~object.__ge__`. In addition, the " +"class should supply an :meth:`~object.__eq__` method." msgstr "" -"類別必須定義 :meth:`__lt__`、:meth:`__le__`、:meth:`__gt__` 或 :meth:" -"`__ge__` 其中之一。此外,該類別應該提供 :meth:`__eq__` 方法。" +"類別必須定義 :meth:`~object.__lt__`、:meth:`~object.__le__`、:meth:`~object.__gt__` " +"或 :meth:`~object.__ge__` 其中之一。此外,該類別應該提供 :meth:`~object.__eq__` 方法。" -#: ../../library/functools.rst:293 +#: ../../library/functools.rst:299 msgid "" "@total_ordering\n" "class Student:\n" @@ -533,7 +570,7 @@ msgstr "" " return ((self.lastname.lower(), self.firstname.lower()) <\n" " (other.lastname.lower(), other.firstname.lower()))" -#: ../../library/functools.rst:311 +#: ../../library/functools.rst:317 msgid "" "While this decorator makes it easy to create well behaved totally ordered " "types, it *does* come at the cost of slower execution and more complex stack " @@ -546,7 +583,7 @@ msgstr "" "其代價。如果效能基準測試顯示這是給定應用程式的效能瓶頸,那麼實作全部六種 " "rich comparison 方法通常能輕鬆地提升速度。" -#: ../../library/functools.rst:320 +#: ../../library/functools.rst:326 msgid "" "This decorator makes no attempt to override methods that have been declared " "in the class *or its superclasses*. Meaning that if a superclass defines a " @@ -557,13 +594,13 @@ msgstr "" "如果超類別定義了比較運算子,*total_ordering* 將不會再次實作它,即使原始方法是" "抽象的。" -#: ../../library/functools.rst:327 +#: ../../library/functools.rst:333 msgid "" "Returning ``NotImplemented`` from the underlying comparison function for " "unrecognised types is now supported." msgstr "現在支援從底層對於未識別型別的比較函式回傳 ``NotImplemented``。" -#: ../../library/functools.rst:333 +#: ../../library/functools.rst:339 msgid "" "Return a new :ref:`partial object` which when called will " "behave like *func* called with the positional arguments *args* and keyword " @@ -576,7 +613,7 @@ msgstr "" "引數,它們將被附加到 *args*。如果提供了額外的關鍵字引數,它們會擴充並覆寫 " "*keywords*。大致相當於: ::" -#: ../../library/functools.rst:340 +#: ../../library/functools.rst:346 msgid "" "def partial(func, /, *args, **keywords):\n" " def newfunc(*fargs, **fkeywords):\n" @@ -596,7 +633,7 @@ msgstr "" " newfunc.keywords = keywords\n" " return newfunc" -#: ../../library/functools.rst:349 +#: ../../library/functools.rst:355 msgid "" "The :func:`partial` is used for partial function application which " "\"freezes\" some portion of a function's arguments and/or keywords resulting " @@ -608,7 +645,7 @@ msgstr "" "分,從而產生具有簡化簽名的新物件。例如,:func:`partial` 可用來建立可呼叫函" "式,其行為類似於 :func:`int` 函式,其中 *base* 引數預設為 2:" -#: ../../library/functools.rst:364 +#: ../../library/functools.rst:370 msgid "" "Return a new :class:`partialmethod` descriptor which behaves like :class:" "`partial` except that it is designed to be used as a method definition " @@ -617,7 +654,7 @@ msgstr "" "回傳一個新的 :class:`partialmethod` 描述器 (descriptor),其行為類似於 :class:" "`partial`,只不過它被設計為用於方法定義而不能直接呼叫。" -#: ../../library/functools.rst:368 +#: ../../library/functools.rst:374 msgid "" "*func* must be a :term:`descriptor` or a callable (objects which are both, " "like normal functions, are handled as descriptors)." @@ -625,20 +662,20 @@ msgstr "" "*func* 必須是一個 :term:`descriptor` 或可呼叫物件(兩者兼具的物件,就像普通函" "式一樣,會被當作描述器處理)。" -#: ../../library/functools.rst:371 +#: ../../library/functools.rst:377 msgid "" "When *func* is a descriptor (such as a normal Python function, :func:" -"`classmethod`, :func:`staticmethod`, :func:`abstractmethod` or another " +"`classmethod`, :func:`staticmethod`, :func:`~abc.abstractmethod` or another " "instance of :class:`partialmethod`), calls to ``__get__`` are delegated to " "the underlying descriptor, and an appropriate :ref:`partial object` returned as the result." msgstr "" "當 *func* 是描述器時(例如普通的 Python 函式、:func:`classmethod`、:func:" -"`staticmethod`、:func:`abstractmethod` 或 :class:`partialmethod` 的另一個實" +"`staticmethod`、:func:`~abc.abstractmethod` 或 :class:`partialmethod` 的另一個實" "例),對 ``__get__`` 的呼叫將被委託 (delegated) 給底層描述器,且一個適當的 :" "ref:`partial 物件 `\\ 會被作為結果回傳。" -#: ../../library/functools.rst:377 +#: ../../library/functools.rst:383 msgid "" "When *func* is a non-descriptor callable, an appropriate bound method is " "created dynamically. This behaves like a normal Python function when used as " @@ -651,7 +688,7 @@ msgstr "" "*self* 引數將作為第一個位置引數插入,甚至會在提供給 :class:`partialmethod` 建" "構函式的 *args* 和 *keywords* 的前面。" -#: ../../library/functools.rst:385 +#: ../../library/functools.rst:391 msgid "" ">>> class Cell:\n" "... def __init__(self):\n" @@ -689,52 +726,56 @@ msgstr "" ">>> c.alive\n" "True" -#: ../../library/functools.rst:408 +#: ../../library/functools.rst:414 msgid "" "Apply *function* of two arguments cumulatively to the items of *iterable*, " "from left to right, so as to reduce the iterable to a single value. For " "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 *initializer* 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 *initializer* is not given and *iterable* contains only one item, " -"the first item is returned." +"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." msgstr "" "從左到右,將兩個引數的 *function* 累加運用到 *iterable* 的項目上,從而將可疊" "代物件減少為單一值。例如,``reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])`` 會計" "算出 ``((((1+2)+3)+4)+5)``。左邊的引數 *x* 是累積值,右邊的引數 *y* 是來自 " -"*iterable* 的更新值。如果可選的 *initializer* 存在,則在計算中會將其放置在可" -"疊代物件的項目之前,並在可疊代物件為空時作為預設值。如果未給定 *initializer* " -"且 *iterable* 僅包含一個項目,則回傳第一個項目。" +"*iterable* 的更新值。如果可選的 *initial* 存在,則在計算中會將其放置在可疊代" +"物件的項目之前,並在可疊代物件為空時作為預設值。如果未給定 *initial* 且 " +"*iterable* 僅包含一個項目,則回傳第一個項目。" -#: ../../library/functools.rst:417 +#: ../../library/functools.rst:423 msgid "Roughly equivalent to::" msgstr "大致相當於: ::" -#: ../../library/functools.rst:419 +#: ../../library/functools.rst:425 msgid "" -"def reduce(function, iterable, initializer=None):\n" +"initial_missing = object()\n" +"\n" +"def reduce(function, iterable, initial=initial_missing, /):\n" " it = iter(iterable)\n" -" if initializer is None:\n" +" if initial is initial_missing:\n" " value = next(it)\n" " else:\n" -" value = initializer\n" +" value = initial\n" " for element in it:\n" " value = function(value, element)\n" " return value" msgstr "" -"def reduce(function, iterable, initializer=None):\n" +"initial_missing = object()\n" +"\n" +"def reduce(function, iterable, initial=initial_missing, /):\n" " it = iter(iterable)\n" -" if initializer is None:\n" +" if initial is initial_missing:\n" " value = next(it)\n" " else:\n" -" value = initializer\n" +" value = initial\n" " for element in it:\n" " value = function(value, element)\n" " return value" -#: ../../library/functools.rst:429 +#: ../../library/functools.rst:437 msgid "" "See :func:`itertools.accumulate` for an iterator that yields all " "intermediate values." @@ -742,7 +783,7 @@ msgstr "" "請參閱 :func:`itertools.accumulate` 以了解產生 (yield) 所有中間值 " "(intermediate value) 的疊代器。" -#: ../../library/functools.rst:434 +#: ../../library/functools.rst:442 msgid "" "Transform a function into a :term:`single-dispatch ` :term:" "`generic function`." @@ -750,7 +791,7 @@ msgstr "" "將函式轉換為\\ :term:`單一調度 `\\ :term:`泛型函式 `。" -#: ../../library/functools.rst:437 +#: ../../library/functools.rst:445 msgid "" "To define a generic function, decorate it with the ``@singledispatch`` " "decorator. When defining a function using ``@singledispatch``, note that the " @@ -760,7 +801,7 @@ msgstr "" "``@singledispatch`` 定義函式時,分派調度 (dispatch) 是發生在第一個引數的型別" "上: ::" -#: ../../library/functools.rst:441 +#: ../../library/functools.rst:449 msgid "" ">>> from functools import singledispatch\n" ">>> @singledispatch\n" @@ -776,17 +817,17 @@ msgstr "" "... print(\"Let me just say,\", end=\" \")\n" "... print(arg)" -#: ../../library/functools.rst:448 +#: ../../library/functools.rst:459 msgid "" -"To add overloaded implementations to the function, use the :func:`register` " +"To add overloaded implementations to the function, use the :func:`!register` " "attribute of the generic function, which can be used as a decorator. For " "functions annotated with types, the decorator will infer the type of the " "first argument automatically::" msgstr "" -"若要為函式新增過載實作,請使用泛型函式的 :func:`register` 屬性,該屬性可用作" +"若要為函式新增過載實作,請使用泛型函式的 :func:`!register` 屬性,該屬性可用作" "裝飾器。對於以型別來註釋的函式,裝飾器將自動推斷第一個引數的型別: ::" -#: ../../library/functools.rst:453 +#: ../../library/functools.rst:464 msgid "" ">>> @fun.register\n" "... def _(arg: int, verbose=False):\n" @@ -814,11 +855,11 @@ msgstr "" "... for i, elem in enumerate(arg):\n" "... print(i, elem)" -#: ../../library/functools.rst:466 +#: ../../library/functools.rst:477 msgid ":data:`types.UnionType` and :data:`typing.Union` can also be used::" msgstr "也可以使用 :data:`types.UnionType` 和 :data:`typing.Union`: ::" -#: ../../library/functools.rst:468 +#: ../../library/functools.rst:479 msgid "" ">>> @fun.register\n" "... def _(arg: int | float, verbose=False):\n" @@ -850,14 +891,14 @@ msgstr "" "... print(i, elem)\n" "..." -#: ../../library/functools.rst:483 +#: ../../library/functools.rst:494 msgid "" "For code which doesn't use type annotations, the appropriate type argument " "can be passed explicitly to the decorator itself::" msgstr "" "對於不使用型別註釋的程式碼,可以將適當的型別引數明確傳遞給裝飾器本身: ::" -#: ../../library/functools.rst:486 +#: ../../library/functools.rst:497 msgid "" ">>> @fun.register(complex)\n" "... def _(arg, verbose=False):\n" @@ -873,15 +914,48 @@ msgstr "" "... print(arg.real, arg.imag)\n" "..." -#: ../../library/functools.rst:494 +#: ../../library/functools.rst:504 +msgid "" +"For code that dispatches on a collections type (e.g., ``list``), but wants " +"to typehint the items of the collection (e.g., ``list[int]``), the dispatch " +"type should be passed explicitly to the decorator itself with the typehint " +"going into the function definition::" +msgstr "" + +#: ../../library/functools.rst:509 +msgid "" +">>> @fun.register(list)\n" +"... def _(arg: list[int], verbose=False):\n" +"... if verbose:\n" +"... print(\"Enumerate this:\")\n" +"... for i, elem in enumerate(arg):\n" +"... print(i, elem)" +msgstr "" +">>> @fun.register(list)\n" +"... def _(arg: list[int], verbose=False):\n" +"... if verbose:\n" +"... print(\"Enumerate this:\")\n" +"... for i, elem in enumerate(arg):\n" +"... print(i, elem)" + +#: ../../library/functools.rst:518 +msgid "" +"At runtime the function will dispatch on an instance of a list regardless of " +"the type contained within the list i.e. ``[1,2,3]`` will be dispatched the " +"same as ``[\"foo\", \"bar\", \"baz\"]``. The annotation provided in this " +"example is for static type checkers only and has no runtime impact." +msgstr "" + +#: ../../library/functools.rst:524 msgid "" "To enable registering :term:`lambdas` and pre-existing functions, " -"the :func:`register` attribute can also be used in a functional form::" +"the :func:`~singledispatch.register` attribute can also be used in a " +"functional form::" msgstr "" -"若要啟用註冊 :term:`lambdas` 和預先存在的函式,:func:`register` 屬性" -"也能以函式形式使用: ::" +"若要啟用註冊 :term:`lambdas` 和預先存在的函式,:func:`~singledispatch.register` " +"屬性也能以函式形式使用: ::" -#: ../../library/functools.rst:497 +#: ../../library/functools.rst:527 msgid "" ">>> def nothing(arg, verbose=False):\n" "... print(\"Nothing.\")\n" @@ -893,16 +967,16 @@ msgstr "" "...\n" ">>> fun.register(type(None), nothing)" -#: ../../library/functools.rst:502 +#: ../../library/functools.rst:532 msgid "" -"The :func:`register` attribute returns the undecorated function. This " -"enables decorator stacking, :mod:`pickling`, and the creation of " -"unit tests for each variant independently::" +"The :func:`~singledispatch.register` attribute returns the undecorated " +"function. This enables decorator stacking, :mod:`pickling`, and the " +"creation of unit tests for each variant independently::" msgstr "" -":func:`register` 屬性回傳未加裝飾器的函式。這讓使得裝飾器堆疊 (decorator " +":func:`~singledispatch.register` 屬性回傳未加裝飾器的函式。這讓使得裝飾器堆疊 (decorator " "stacking)、:mod:`pickling` 以及為每個變體獨立建立單元測試成為可能:" -#: ../../library/functools.rst:506 +#: ../../library/functools.rst:536 msgid "" ">>> @fun.register(float)\n" "... @fun.register(Decimal)\n" @@ -924,13 +998,13 @@ msgstr "" ">>> fun_num is fun\n" "False" -#: ../../library/functools.rst:516 +#: ../../library/functools.rst:546 msgid "" "When called, the generic function dispatches on the type of the first " "argument::" msgstr "呼叫時,泛型函式會分派第一個引數的型別: ::" -#: ../../library/functools.rst:519 +#: ../../library/functools.rst:549 msgid "" ">>> fun(\"Hello, world.\")\n" "Hello, world.\n" @@ -966,7 +1040,7 @@ msgstr "" ">>> fun(1.23)\n" "0.615" -#: ../../library/functools.rst:536 +#: ../../library/functools.rst:566 msgid "" "Where there is no registered implementation for a specific type, its method " "resolution order is used to find a more generic implementation. The original " @@ -978,7 +1052,7 @@ msgstr "" "尋找更通用的實作。用 ``@singledispatch`` 裝飾的原始函式是為基底 :class:" "`object` 型別註冊的,這意味著如果沒有找到更好的實作就會使用它。" -#: ../../library/functools.rst:542 +#: ../../library/functools.rst:572 msgid "" "If an implementation is registered to an :term:`abstract base class`, " "virtual subclasses of the base class will be dispatched to that " @@ -987,7 +1061,7 @@ msgstr "" "如果一個實作有被註冊到一個\\ :term:`抽象基底類別 `,則基" "底類別的虛擬子類別將被分派到該實作: ::" -#: ../../library/functools.rst:546 +#: ../../library/functools.rst:576 msgid "" ">>> from collections.abc import Mapping\n" ">>> @fun.register\n" @@ -1011,14 +1085,14 @@ msgstr "" ">>> fun({\"a\": \"b\"})\n" "a => b" -#: ../../library/functools.rst:557 +#: ../../library/functools.rst:587 msgid "" "To check which implementation the generic function will choose for a given " "type, use the ``dispatch()`` attribute::" msgstr "" "若要檢查泛型函式將為給定型別選擇哪種實作,請使用 ``dispatch()`` 屬性: ::" -#: ../../library/functools.rst:560 +#: ../../library/functools.rst:590 msgid "" ">>> fun.dispatch(float)\n" "\n" @@ -1026,13 +1100,13 @@ msgid "" "" msgstr "" -#: ../../library/functools.rst:565 +#: ../../library/functools.rst:595 msgid "" "To access all registered implementations, use the read-only ``registry`` " "attribute::" msgstr "若要存取所有已註冊的實作,請使用唯讀 ``registry`` 屬性: ::" -#: ../../library/functools.rst:568 +#: ../../library/functools.rst:598 msgid "" ">>> fun.registry.keys()\n" "dict_keys([, , ,\n" @@ -1052,19 +1126,21 @@ msgstr "" ">>> fun.registry[object]\n" "" -#: ../../library/functools.rst:579 -msgid "The :func:`register` attribute now supports using type annotations." -msgstr ":func:`register` 屬性現在支援使用型別註釋。" +#: ../../library/functools.rst:609 +msgid "" +"The :func:`~singledispatch.register` attribute now supports using type " +"annotations." +msgstr ":func:`~singledispatch.register` 屬性現在支援使用型別註釋。" -#: ../../library/functools.rst:582 +#: ../../library/functools.rst:612 msgid "" -"The :func:`register` attribute now supports :data:`types.UnionType` and :" -"data:`typing.Union` as type annotations." +"The :func:`~singledispatch.register` attribute now supports :data:`types." +"UnionType` and :data:`typing.Union` as type annotations." msgstr "" -":func:`register` 屬性現在支援以 :data:`types.UnionType` 和 :data:`typing." +":func:`~singledispatch.register` 屬性現在支援以 :data:`types.UnionType` 和 :data:`typing." "Union` 作為型別註釋。" -#: ../../library/functools.rst:589 +#: ../../library/functools.rst:619 msgid "" "Transform a method into a :term:`single-dispatch ` :term:" "`generic function`." @@ -1072,7 +1148,7 @@ msgstr "" "將方法轉換為\\ :term:`單一調度 `\\ :term:`泛型函式 `。" -#: ../../library/functools.rst:592 +#: ../../library/functools.rst:622 msgid "" "To define a generic method, decorate it with the ``@singledispatchmethod`` " "decorator. When defining a function using ``@singledispatchmethod``, note " @@ -1083,7 +1159,7 @@ msgstr "" "用 ``@singledispatchmethod`` 定義函式時,分派調度是發生在第一個非 *self* 或" "非 *cls* 引數的型別上: ::" -#: ../../library/functools.rst:597 +#: ../../library/functools.rst:627 msgid "" "class Negator:\n" " @singledispatchmethod\n" @@ -1111,7 +1187,7 @@ msgstr "" " def _(self, arg: bool):\n" " return not arg" -#: ../../library/functools.rst:610 +#: ../../library/functools.rst:640 msgid "" "``@singledispatchmethod`` supports nesting with other decorators such as :" "func:`@classmethod`. Note that to allow for ``dispatcher." @@ -1124,7 +1200,7 @@ msgstr "" "``singledispatchmethod`` 必須是\\ *最外面的*\\ 裝飾器。以下範例是 " "``Negator`` 類別,其 ``neg`` 方法繫結到該類別,而不是該類別的實例: ::" -#: ../../library/functools.rst:616 +#: ../../library/functools.rst:646 msgid "" "class Negator:\n" " @singledispatchmethod\n" @@ -1158,7 +1234,7 @@ msgstr "" " def _(cls, arg: bool):\n" " return not arg" -#: ../../library/functools.rst:632 +#: ../../library/functools.rst:662 msgid "" "The same pattern can be used for other similar decorators: :func:" "`@staticmethod`, :func:`@abstractmethod`, " @@ -1167,7 +1243,7 @@ msgstr "" "相同的模式可用於其他類似的裝飾器::func:`@staticmethod`、:func:" "`@abstractmethod` 等。" -#: ../../library/functools.rst:641 +#: ../../library/functools.rst:671 msgid "" "Update a *wrapper* function to look like the *wrapped* function. The " "optional arguments are tuples to specify which attributes of the original " @@ -1175,19 +1251,23 @@ msgid "" "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 ``__module__``, ``__name__``, " -"``__qualname__``, ``__annotations__``, ``__type_params__``, and ``__doc__``, " -"the documentation string) and ``WRAPPER_UPDATES`` (which updates the wrapper " -"function's ``__dict__``, i.e. the instance dictionary)." +"(which assigns to the wrapper function's :attr:`~function.__module__`, :attr:" +"`~function.__name__`, :attr:`~function.__qualname__`, :attr:`~function." +"__annotations__`, :attr:`~function.__type_params__`, and :attr:`~function." +"__doc__`, the documentation string) and ``WRAPPER_UPDATES`` (which updates " +"the wrapper function's :attr:`~function.__dict__`, i.e. the instance " +"dictionary)." msgstr "" "更新 *wrapper* 函式,使其看起來像 *wrapped* 函式。可選引數是元組,用於指定原" "始函式的哪些屬性直接賦值給包裝函式上的匹配屬性,以及包裝函式的哪些屬性使用原" "始函式中的對應屬性進行更新。這些引數的預設值是模組層級的常數 " -"``WRAPPER_ASSIGNMENTS``\\ (它賦值給包裝函式的 ``__module__``、``__name__``、" -"``__qualname__``、``__annotations__`` 和 ``__doc__`` 文件字串 (docstring)和 " -"``WRAPPER_UPDATES``\\ (更新包裝器函式的 ``__dict__``,即實例字典)。" +"``WRAPPER_ASSIGNMENTS``\\ (它賦值給包裝函式的 :attr:`~function." +"__module__`、:attr:`~function.__name__`、:attr:`~function.__qualname__`、:" +"attr:`~function.__annotations__`、:attr:`~function.__type_params__` 和 :attr:" +"`~function.__doc__` 文件字串 (docstring))和 ``WRAPPER_UPDATES``\\ (更新包" +"裝器函式的 :attr:`~function.__dict__`,即實例字典)。" -#: ../../library/functools.rst:652 +#: ../../library/functools.rst:683 msgid "" "To allow access to the original function for introspection and other " "purposes (e.g. bypassing a caching decorator such as :func:`lru_cache`), " @@ -1198,7 +1278,7 @@ msgstr "" "飾器,如 :func:`lru_cache`),此函式會自動向包裝器新增 ``__wrapped__`` 屬性," "該包裝器參照被包裝的函式。" -#: ../../library/functools.rst:657 +#: ../../library/functools.rst:688 msgid "" "The main intended use for this function is in :term:`decorator` functions " "which wrap the decorated function and return the wrapper. If the wrapper " @@ -1210,7 +1290,7 @@ msgstr "" "裝器函式未更新,則回傳函式的元資料 (metadata) 將反映包裝器定義而非原始函式定" "義,這通常不太會有幫助。" -#: ../../library/functools.rst:663 +#: ../../library/functools.rst:694 msgid "" ":func:`update_wrapper` may be used with callables other than functions. Any " "attributes named in *assigned* or *updated* that are missing from the object " @@ -1223,16 +1303,16 @@ msgstr "" "器函式上設定它們)。如果包裝函式本身缺少 *updated* 中指定的任何屬性,仍然會引" "發 :exc:`AttributeError`。" -#: ../../library/functools.rst:669 +#: ../../library/functools.rst:700 msgid "" -"The ``__wrapped__`` attribute is now automatically added. The " -"``__annotations__`` attribute is now copied by default. Missing attributes " -"no longer trigger an :exc:`AttributeError`." +"The ``__wrapped__`` attribute is now automatically added. The :attr:" +"`~function.__annotations__` attribute is now copied by default. Missing " +"attributes no longer trigger an :exc:`AttributeError`." msgstr "" -"現在會自動新增 ``__wrapped__`` 屬性。現在預設會複製 ``__annotations__`` 屬" -"性。缺少的屬性不再觸發 :exc:`AttributeError`。" +"現在會自動新增 ``__wrapped__`` 屬性。現在預設會複製 :attr:`~function." +"__annotations__` 屬性。缺少的屬性不再觸發 :exc:`AttributeError`。" -#: ../../library/functools.rst:674 +#: ../../library/functools.rst:705 msgid "" "The ``__wrapped__`` attribute now always refers to the wrapped function, " "even if that function defined a ``__wrapped__`` attribute. (see :issue:" @@ -1241,11 +1321,12 @@ msgstr "" "``__wrapped__`` 屬性現在都會參照包裝函式,即便函式有定義 ``__wrapped__`` 屬" "性。(參見 :issue:`17482`)" -#: ../../library/functools.rst:679 -msgid "The ``__type_params__`` attribute is now copied by default." -msgstr "現在預設會複製 ``__type_params__`` 屬性。" +#: ../../library/functools.rst:710 +msgid "" +"The :attr:`~function.__type_params__` attribute is now copied by default." +msgstr "現在預設會複製 :attr:`~function.__type_params__` 屬性。" -#: ../../library/functools.rst:685 +#: ../../library/functools.rst:716 msgid "" "This is a convenience function for invoking :func:`update_wrapper` as a " "function decorator when defining a wrapper function. It is equivalent to " @@ -1256,7 +1337,7 @@ msgstr "" "式裝飾器。它相當於 ``partial(update_wrapper, wrapped=wrapped, " "assigned=assigned, updated=updated)``。例如: ::" -#: ../../library/functools.rst:690 +#: ../../library/functools.rst:721 msgid "" ">>> from functools import wraps\n" ">>> def my_decorator(f):\n" @@ -1280,20 +1361,20 @@ msgid "" "'Docstring'" msgstr "" -#: ../../library/functools.rst:711 +#: ../../library/functools.rst:742 msgid "" "Without the use of this decorator factory, the name of the example function " -"would have been ``'wrapper'``, and the docstring of the original :func:" -"`example` would have been lost." +"would have been ``'wrapper'``, and the docstring of the original :func:`!" +"example` would have been lost." msgstr "" "如果不使用這個裝飾器工廠 (decorator factory),範例函式的名稱將會是 " -"``'wrapper'``,並且原始 :func:`example` 的文件字串將會遺失。" +"``'wrapper'``,並且原始 :func:`!example` 的文件字串將會遺失。" -#: ../../library/functools.rst:719 +#: ../../library/functools.rst:750 msgid ":class:`partial` Objects" msgstr ":class:`partial` 物件" -#: ../../library/functools.rst:721 +#: ../../library/functools.rst:752 msgid "" ":class:`partial` objects are callable objects created by :func:`partial`. " "They have three read-only attributes:" @@ -1301,7 +1382,7 @@ msgstr "" ":class:`partial` 物件是由 :func:`partial` 所建立的可呼叫物件。它們有三個唯讀" "屬性:" -#: ../../library/functools.rst:727 +#: ../../library/functools.rst:758 msgid "" "A callable object or function. Calls to the :class:`partial` object will be " "forwarded to :attr:`func` with new arguments and keywords." @@ -1309,7 +1390,7 @@ msgstr "" "一個可呼叫的物件或函式。對 :class:`partial` 物件的呼叫將被轉送到帶有新引數和" "關鍵字的 :attr:`func`。" -#: ../../library/functools.rst:733 +#: ../../library/functools.rst:764 msgid "" "The leftmost positional arguments that will be prepended to the positional " "arguments provided to a :class:`partial` object call." @@ -1317,23 +1398,24 @@ msgstr "" "最左邊的位置引數將會被加入到提供給 :class:`partial` 物件呼叫的位置引數的前" "面。" -#: ../../library/functools.rst:739 +#: ../../library/functools.rst:770 msgid "" "The keyword arguments that will be supplied when the :class:`partial` object " "is called." msgstr "呼叫 :class:`partial` 物件時將提供的關鍵字引數。" -#: ../../library/functools.rst:742 -msgid "" -":class:`partial` objects are like :class:`function` objects in that they are " -"callable, weak referenceable, and can have attributes. There are some " -"important differences. For instance, the :attr:`~definition.__name__` and :" -"attr:`__doc__` attributes are not created automatically. Also, :class:" -"`partial` objects defined in classes behave like static methods and do not " -"transform into bound methods during instance attribute look-up." -msgstr "" -":class:`partial` 物件與 :class:`function` 物件類似,因為它們是可呼叫的、可弱" -"參照的 (weak referencable) 且可以具有屬性。有一些重要的區別,例如,:attr:" -"`~definition.__name__` 和 :attr:`__doc__` 屬性不會自動建立。此外,類別中定義" -"的 :class:`partial` 物件的行為類似於靜態方法,並且在實例屬性查找期間不會轉換" -"為繫結方法。" +#: ../../library/functools.rst:773 +msgid "" +":class:`partial` objects are like :ref:`function objects ` in that they are callable, weak referenceable, and can have " +"attributes. There are some important differences. For instance, the :attr:" +"`~function.__name__` and :attr:`function.__doc__` attributes are not created " +"automatically. Also, :class:`partial` objects defined in classes behave " +"like static methods and do not transform into bound methods during instance " +"attribute look-up." +msgstr "" +":class:`partial` 物件與\\ :ref:`函式物件 `\\ 類似,因為它" +"們是可呼叫的、可弱參照的 (weak referencable) 且可以具有屬性。有一些重要的區" +"別,例如,:attr:`~function.__name__` 和 :attr:`function.__doc__` 屬性不會自動" +"建立。此外,類別中定義的 :class:`partial` 物件的行為類似於靜態方法,並且在實" +"例屬性查找期間不會轉換為繫結方法。" diff --git a/library/gc.po b/library/gc.po index ac05411f77..78ce3ab4e8 100644 --- a/library/gc.po +++ b/library/gc.po @@ -1,16 +1,15 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Liang-Bo Wang , 2015 -# Matt Wang , 2022 +# Matt Wang , 2022-2024 # msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2024-10-01 00:15+0000\n" "PO-Revision-Date: 2023-04-24 21:25+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -67,8 +66,8 @@ msgstr "如果啟用了自動回收則回傳 ``True``。" msgid "" "With no arguments, run a full collection. The optional argument " "*generation* may be an integer specifying which generation to collect (from " -"0 to 2). A :exc:`ValueError` is raised if the generation number is " -"invalid. The number of unreachable objects found is returned." +"0 to 2). A :exc:`ValueError` is raised if the generation number is invalid. " +"The sum of collected objects and uncollectable objects is returned." msgstr "" "若被呼叫時沒有引數,則啟動完整垃圾回收。可選的引數 *generation* 可以是一個指" "明需要回收哪一代垃圾的整數(從 0 到 2)。當引數 *generation* 無效時,會引發 :" @@ -89,7 +88,7 @@ msgstr "" msgid "" "The effect of calling ``gc.collect()`` while the interpreter is already " "performing a collection is undefined." -msgstr "" +msgstr "當直譯器已經執行收集時呼叫 ``gc.collect()`` 的效果是未定義的。" #: ../../library/gc.rst:59 msgid "" @@ -102,17 +101,16 @@ msgstr "" #: ../../library/gc.rst:66 msgid "Return the debugging flags currently set." -msgstr "回傳當前設置的除錯旗標。" +msgstr "回傳目前設置的除錯旗標。" #: ../../library/gc.rst:71 -#, fuzzy msgid "" "Returns a list of all objects tracked by the collector, excluding the list " "returned. If *generation* is not ``None``, return only the objects tracked " "by the collector that are in that generation." msgstr "" "回傳一個包含回收器正在追蹤的所有物件的 list,除去所回傳的 list。如果 " -"*generation* 不為 None,只回傳回收器正在追蹤且屬於該代的物件。" +"*generation* 不為 ``None``,只回傳回收器正在追蹤且屬於該代的物件。" #: ../../library/gc.rst:75 msgid "New *generation* parameter." @@ -193,14 +191,14 @@ msgstr "" msgid "" "Return the current collection counts as a tuple of ``(count0, count1, " "count2)``." -msgstr "將當前回收計數以 ``(count0, count1, count2)`` 形式的 tuple 回傳。" +msgstr "將目前回收計數以 ``(count0, count1, count2)`` 形式的 tuple 回傳。" #: ../../library/gc.rst:127 msgid "" "Return the current collection thresholds as a tuple of ``(threshold0, " "threshold1, threshold2)``." msgstr "" -"將當前回收閾值以 ``(threshold0, threshold1, threshold2)`` 形式的 tuple 回傳。" +"將目前回收閾值以 ``(threshold0, threshold1, threshold2)`` 形式的 tuple 回傳。" #: ../../library/gc.rst:133 msgid "" @@ -220,7 +218,7 @@ msgid "" "call :func:`collect` before calling :func:`get_referrers`." msgstr "" "需要注意的是,已經解除參照的物件,但仍存在於參照迴圈中未被回收時,該物件仍然" -"會被作為參照者出現在回傳的 list 中。若只要獲取當前正在參照的物件,需要在呼" +"會被作為參照者出現在回傳的 list 中。若只要取得目前正在參照的物件,需要在呼" "叫 :func:`get_referrers` 之前呼叫 :func:`collect`。" #: ../../library/gc.rst:144 @@ -254,9 +252,9 @@ msgid "" "object may or may not appear in the result list." msgstr "" "回傳包含被任意一個引數直接參照之物件的 list。回傳的被參照物件是有被引數的 C " -"語言級別 :c:member:`~PyTypeObject.tp_traverse` 方法(若存在)訪問到的物件,可" +"語言級別 :c:member:`~PyTypeObject.tp_traverse` 方法(若存在)瀏覽到的物件,可" "能不是所有的實際直接可達物件。只有支援垃圾回收的物件支援 :c:member:" -"`~PyTypeObject.tp_traverse` 方法,並且此方法只會訪問涉及參照迴圈的物件。因" +"`~PyTypeObject.tp_traverse` 方法,並且此方法只會瀏覽涉及參照迴圈的物件。因" "此,可以有以下例子:一個整數對於一個引數是直接可達的,這個整數物件有可能出現" "或不出現在結果的 list 當中。" @@ -431,7 +429,7 @@ msgid "" "after collection. The callbacks will be called with two arguments, *phase* " "and *info*." msgstr "" -"會被垃圾回收器在回收開始前和完成後呼叫的一系列回呼函式 (callback) 。這些回呼" +"會被垃圾回收器在回收開始前和完成後叫用的一系列回呼函式 (callback) 。這些回呼" "函式在被呼叫時附帶兩個引數:*phase* 和 *info*。" #: ../../library/gc.rst:271 diff --git a/library/getopt.po b/library/getopt.po index 01b5b5326d..f9d84aca9d 100644 --- a/library/getopt.po +++ b/library/getopt.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2024-12-29 11:18+0000\n" "PO-Revision-Date: 2016-01-31 07:19+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -28,44 +27,54 @@ msgstr "**原始碼:**\\ :source:`Lib/getopt.py`" #: ../../library/getopt.rst:12 msgid "" -"The :mod:`getopt` module is a parser for command line options whose API is " -"designed to be familiar to users of the C :c:func:`getopt` function. Users " -"who are unfamiliar with the C :c:func:`getopt` function or who would like to " -"write less code and get better help and error messages should consider using " -"the :mod:`argparse` module instead." +"This module is considered feature complete. A more declarative and " +"extensible alternative to this API is provided in the :mod:`optparse` " +"module. Further functional enhancements for command line parameter " +"processing are provided either as third party modules on PyPI, or else as " +"features in the :mod:`argparse` module." msgstr "" #: ../../library/getopt.rst:20 msgid "" "This module helps scripts to parse the command line arguments in ``sys." -"argv``. It supports the same conventions as the Unix :c:func:`getopt` " +"argv``. It supports the same conventions as the Unix :c:func:`!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." msgstr "" #: ../../library/getopt.rst:26 -msgid "This module provides two functions and an exception:" +msgid "" +"Users who are unfamiliar with the Unix :c:func:`!getopt` function should " +"consider using the :mod:`argparse` module instead. Users who are familiar " +"with the Unix :c:func:`!getopt` function, but would like to get equivalent " +"behavior while writing less code and getting better help and error messages " +"should consider using the :mod:`optparse` module. See :ref:`choosing-an-" +"argument-parser` for additional details." msgstr "" -#: ../../library/getopt.rst:32 +#: ../../library/getopt.rst:33 +msgid "This module provides two functions and an exception:" +msgstr "這個模組提供兩個函式和一個例外:" + +#: ../../library/getopt.rst:39 msgid "" "Parses command line options and parameter list. *args* is the argument list " "to be parsed, without the leading reference to the running program. " "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 :c:" -"func:`getopt` uses)." +"func:`!getopt` uses)." msgstr "" -#: ../../library/getopt.rst:40 +#: ../../library/getopt.rst:47 msgid "" -"Unlike GNU :c:func:`getopt`, after a non-option argument, all further " +"Unlike GNU :c:func:`!getopt`, after a non-option argument, all further " "arguments are considered also non-options. This is similar to the way non-" "GNU Unix systems work." msgstr "" -#: ../../library/getopt.rst:44 +#: ../../library/getopt.rst:51 msgid "" "*longopts*, if specified, must be a list of strings with the names of the " "long options which should be supported. The leading ``'--'`` characters " @@ -79,7 +88,7 @@ msgid "" "uniquely, so :exc:`GetoptError` will be raised." msgstr "" -#: ../../library/getopt.rst:55 +#: ../../library/getopt.rst:62 msgid "" "The return value consists of two elements: the first is a list of ``(option, " "value)`` pairs; the second is the list of program arguments left after the " @@ -92,7 +101,7 @@ msgid "" "occurrences. Long and short options may be mixed." msgstr "" -#: ../../library/getopt.rst:68 +#: ../../library/getopt.rst:75 msgid "" "This function works like :func:`getopt`, except that GNU style scanning mode " "is used by default. This means that option and non-option arguments may be " @@ -100,41 +109,91 @@ msgid "" "a non-option argument is encountered." msgstr "" -#: ../../library/getopt.rst:73 +#: ../../library/getopt.rst:80 msgid "" "If the first character of the option string is ``'+'``, or if the " -"environment variable :envvar:`POSIXLY_CORRECT` is set, then option " +"environment variable :envvar:`!POSIXLY_CORRECT` is set, then option " "processing stops as soon as a non-option argument is encountered." msgstr "" -#: ../../library/getopt.rst:80 +#: ../../library/getopt.rst:87 msgid "" "This is raised when an unrecognized option is found in the argument list or " "when an option requiring an argument is given none. The argument to the " "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 :attr:`msg` and :attr:`opt` " +"this exception to be raised. The attributes :attr:`!msg` and :attr:`!opt` " "give the error message and related option; if there is no specific option to " -"which the exception relates, :attr:`opt` is an empty string." +"which the exception relates, :attr:`!opt` is an empty string." msgstr "" -#: ../../library/getopt.rst:91 +#: ../../library/getopt.rst:98 msgid "Alias for :exc:`GetoptError`; for backward compatibility." -msgstr "" +msgstr "為了向後相容性而設的 :exc:`GetoptError` 別名。" -#: ../../library/getopt.rst:93 +#: ../../library/getopt.rst:100 msgid "An example using only Unix style options:" +msgstr "一個僅使用 Unix 風格選項的範例:" + +#: ../../library/getopt.rst:102 +msgid "" +">>> import getopt\n" +">>> args = '-a -b -cfoo -d bar a1 a2'.split()\n" +">>> args\n" +"['-a', '-b', '-cfoo', '-d', 'bar', 'a1', 'a2']\n" +">>> optlist, args = getopt.getopt(args, 'abc:d:')\n" +">>> optlist\n" +"[('-a', ''), ('-b', ''), ('-c', 'foo'), ('-d', 'bar')]\n" +">>> args\n" +"['a1', 'a2']" msgstr "" +">>> import getopt\n" +">>> args = '-a -b -cfoo -d bar a1 a2'.split()\n" +">>> args\n" +"['-a', '-b', '-cfoo', '-d', 'bar', 'a1', 'a2']\n" +">>> optlist, args = getopt.getopt(args, 'abc:d:')\n" +">>> optlist\n" +"[('-a', ''), ('-b', ''), ('-c', 'foo'), ('-d', 'bar')]\n" +">>> args\n" +"['a1', 'a2']" -#: ../../library/getopt.rst:105 +#: ../../library/getopt.rst:114 msgid "Using long option names is equally easy:" -msgstr "" +msgstr "使用長選項名稱同樣容易:" -#: ../../library/getopt.rst:118 -msgid "In a script, typical usage is something like this::" +#: ../../library/getopt.rst:116 +msgid "" +">>> s = '--condition=foo --testing --output-file abc.def -x a1 a2'\n" +">>> args = s.split()\n" +">>> args\n" +"['--condition=foo', '--testing', '--output-file', 'abc.def', '-x', 'a1', " +"'a2']\n" +">>> optlist, args = getopt.getopt(args, 'x', [\n" +"... 'condition=', 'output-file=', 'testing'])\n" +">>> optlist\n" +"[('--condition', 'foo'), ('--testing', ''), ('--output-file', 'abc.def'), ('-" +"x', '')]\n" +">>> args\n" +"['a1', 'a2']" msgstr "" +">>> s = '--condition=foo --testing --output-file abc.def -x a1 a2'\n" +">>> args = s.split()\n" +">>> args\n" +"['--condition=foo', '--testing', '--output-file', 'abc.def', '-x', 'a1', " +"'a2']\n" +">>> optlist, args = getopt.getopt(args, 'x', [\n" +"... 'condition=', 'output-file=', 'testing'])\n" +">>> optlist\n" +"[('--condition', 'foo'), ('--testing', ''), ('--output-file', 'abc.def'), ('-" +"x', '')]\n" +">>> args\n" +"['a1', 'a2']" + +#: ../../library/getopt.rst:129 +msgid "In a script, typical usage is something like this:" +msgstr "在腳本中,典型的用法如下:" -#: ../../library/getopt.rst:120 +#: ../../library/getopt.rst:131 msgid "" "import getopt, sys\n" "\n" @@ -160,20 +219,73 @@ msgid "" " output = a\n" " else:\n" " assert False, \"unhandled option\"\n" -" # ...\n" +" process(args, output=output, verbose=verbose)\n" "\n" "if __name__ == \"__main__\":\n" " main()" msgstr "" +"import getopt, sys\n" +"\n" +"def main():\n" +" try:\n" +" opts, args = getopt.getopt(sys.argv[1:], \"ho:v\", [\"help\", " +"\"output=\"])\n" +" except getopt.GetoptError as err:\n" +" # 印出幫助訊息並退出:\n" +" print(err) # 會印出像是 \"option -a not recognized\" 的訊息\n" +" usage()\n" +" sys.exit(2)\n" +" output = None\n" +" verbose = False\n" +" for o, a in opts:\n" +" if o == \"-v\":\n" +" verbose = True\n" +" elif o in (\"-h\", \"--help\"):\n" +" usage()\n" +" sys.exit()\n" +" elif o in (\"-o\", \"--output\"):\n" +" output = a\n" +" else:\n" +" assert False, \"unhandled option\"\n" +" process(args, output=output, verbose=verbose)\n" +"\n" +"if __name__ == \"__main__\":\n" +" main()" -#: ../../library/getopt.rst:147 +#: ../../library/getopt.rst:160 msgid "" "Note that an equivalent command line interface could be produced with less " "code and more informative help and error messages by using the :mod:" -"`argparse` module::" +"`optparse` module:" +msgstr "" + +#: ../../library/getopt.rst:163 +msgid "" +"import optparse\n" +"\n" +"if __name__ == '__main__':\n" +" parser = optparse.OptionParser()\n" +" parser.add_option('-o', '--output')\n" +" parser.add_option('-v', dest='verbose', action='store_true')\n" +" opts, args = parser.parse_args()\n" +" process(args, output=opts.output, verbose=opts.verbose)" +msgstr "" +"import optparse\n" +"\n" +"if __name__ == '__main__':\n" +" parser = optparse.OptionParser()\n" +" parser.add_option('-o', '--output')\n" +" parser.add_option('-v', dest='verbose', action='store_true')\n" +" opts, args = parser.parse_args()\n" +" process(args, output=opts.output, verbose=opts.verbose)" + +#: ../../library/getopt.rst:174 +msgid "" +"A roughly equivalent command line interface for this case can also be " +"produced by using the :mod:`argparse` module:" msgstr "" -#: ../../library/getopt.rst:150 +#: ../../library/getopt.rst:177 msgid "" "import argparse\n" "\n" @@ -181,15 +293,41 @@ msgid "" " parser = argparse.ArgumentParser()\n" " parser.add_argument('-o', '--output')\n" " parser.add_argument('-v', dest='verbose', action='store_true')\n" +" parser.add_argument('rest', nargs='*')\n" " args = parser.parse_args()\n" -" # ... do something with args.output ...\n" -" # ... do something with args.verbose .." +" process(args.rest, output=args.output, verbose=args.verbose)" msgstr "" +"import argparse\n" +"\n" +"if __name__ == '__main__':\n" +" parser = argparse.ArgumentParser()\n" +" parser.add_argument('-o', '--output')\n" +" parser.add_argument('-v', dest='verbose', action='store_true')\n" +" parser.add_argument('rest', nargs='*')\n" +" args = parser.parse_args()\n" +" process(args.rest, output=args.output, verbose=args.verbose)" + +#: ../../library/getopt.rst:189 +msgid "" +"See :ref:`choosing-an-argument-parser` for details on how the ``argparse`` " +"version of this code differs in behaviour from the ``optparse`` (and " +"``getopt``) version." +msgstr "" +"參見 :ref:`choosing-an-argument-parser` 以瞭解這段程式碼的 ``argparse`` 版本" +"與 ``optparse``\\(以及 ``getopt``)版本在行為上的差異。" -#: ../../library/getopt.rst:162 +#: ../../library/getopt.rst:195 +msgid "Module :mod:`optparse`" +msgstr ":mod:`optparse` 模組" + +#: ../../library/getopt.rst:196 +msgid "Declarative command line option parsing." +msgstr "宣告式命令列選項剖析。" + +#: ../../library/getopt.rst:198 msgid "Module :mod:`argparse`" msgstr ":mod:`argparse` 模組" -#: ../../library/getopt.rst:163 -msgid "Alternative command line option and argument parsing library." +#: ../../library/getopt.rst:199 +msgid "More opinionated command line option and argument parsing library." msgstr "" diff --git a/library/getpass.po b/library/getpass.po index 16b7ea0454..8904954af2 100644 --- a/library/getpass.po +++ b/library/getpass.po @@ -3,13 +3,14 @@ # # Translators: # Matt Wang , 2022 +# Weilin Du, 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-30 18:24+0000\n" +"POT-Creation-Date: 2024-10-11 00:13+0000\n" "PO-Revision-Date: 2022-02-11 12:04+0800\n" -"Last-Translator: Matt Wang \n" +"Last-Translator: Weilin Du\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -17,7 +18,6 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Poedit 3.0.1\n" #: ../../library/getpass.rst:2 msgid ":mod:`!getpass` --- Portable password input" @@ -28,17 +28,16 @@ msgid "**Source code:** :source:`Lib/getpass.py`" msgstr "**原始碼:**\\ :source:`Lib/getpass.py`" #: ../../includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not Emscripten, not WASI." -msgstr "" +msgid "Availability" +msgstr "可用性" #: ../../includes/wasm-notavail.rst:5 msgid "" -"This module does not work or is not available on WebAssembly platforms " -"``wasm32-emscripten`` and ``wasm32-wasi``. See :ref:`wasm-availability` for " -"more information." +"This module does not work or is not available on WebAssembly. See :ref:`wasm-" +"availability` for more information." msgstr "" -"此模組在 WebAssembly 平台 ``wasm32-emscripten`` 和 ``wasm32-wasi`` 上無法作用" -"或無法使用。有關更多資訊,請參閱 :ref:`wasm-availability`。" +"此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" +"availability`。" #: ../../library/getpass.rst:17 msgid "The :mod:`getpass` module provides two functions:" @@ -62,8 +61,8 @@ msgstr "" #: ../../library/getpass.rst:28 msgid "" "If echo free input is unavailable getpass() falls back to printing a warning " -"message to *stream* and reading from ``sys.stdin`` and issuing a :exc:" -"`GetPassWarning`." +"message to *stream* and reading from ``sys.stdin`` and issuing " +"a :exc:`GetPassWarning`." msgstr "" "如果無回音輸入 (echo-free input) 無法使用則 getpass() 將回退為印出一條警告訊" "息到 *stream*,並從 ``sys.stdin`` 讀取且同時發出 :exc:`GetPassWarning`。" @@ -86,17 +85,22 @@ msgstr "回傳使用者的\"登入名稱\"。" #: ../../library/getpass.rst:45 msgid "" -"This function checks the environment variables :envvar:`LOGNAME`, :envvar:" -"`USER`, :envvar:`!LNAME` and :envvar:`USERNAME`, in order, and returns the " -"value of the first one which is set to a non-empty string. If none are set, " -"the login name from the password database is returned on systems which " -"support the :mod:`pwd` module, otherwise, an exception is raised." +"This function checks the environment " +"variables :envvar:`LOGNAME`, :envvar:`USER`, :envvar:`!LNAME` " +"and :envvar:`USERNAME`, in order, and returns the value of the first one " +"which is set to a non-empty string. If none are set, the login name from " +"the password database is returned on systems which support the :mod:`pwd` " +"module, otherwise, an :exc:`OSError` is raised." msgstr "" "此函式會按順序檢查環境變數 :envvar:`LOGNAME`、:envvar:`USER`、:envvar:`!" "LNAME` 和 :envvar:`USERNAME`,並回傳其中第一個被設定成非空字串的值。如果均未" "設定,則在支援 :mod:`pwd` 模組的系統上將會回傳來自密碼資料庫的登入名稱,否則" -"將引發一個例外。" +"將引發一個 :exc:`OSError` 例外。" #: ../../library/getpass.rst:52 msgid "In general, this function should be preferred over :func:`os.getlogin`." msgstr "大部分情況下,此函式應該要比 :func:`os.getlogin` 優先使用。" + +#: ../../library/getpass.rst:54 +msgid "Previously, various exceptions beyond just :exc:`OSError` were raised." +msgstr "在過去,除了 :exc:`OSError` 外還會引發各種例外。" diff --git a/library/gettext.po b/library/gettext.po index 88431c49e5..3c6b357a30 100644 --- a/library/gettext.po +++ b/library/gettext.po @@ -5,7 +5,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2018-05-23 16:02+0000\n" @@ -44,7 +44,7 @@ msgstr "" #: ../../library/gettext.rst:26 msgid "GNU :program:`gettext` API" -msgstr "" +msgstr "GNU :program:`gettext` API" #: ../../library/gettext.rst:28 msgid "" @@ -227,7 +227,7 @@ msgstr "" #: ../../library/gettext.rst:169 msgid ":exc:`IOError` used to be raised, it is now an alias of :exc:`OSError`." -msgstr "" +msgstr ":exc:`IOError` 曾經被引發,現在它是一個 :exc:`OSError` 的別名。" #: ../../library/gettext.rst:172 msgid "*codeset* parameter is removed." diff --git a/library/glob.po b/library/glob.po index 5b2a4cde1e..0bdd842e89 100644 --- a/library/glob.po +++ b/library/glob.po @@ -5,9 +5,9 @@ # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2023-01-24 01:21+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -39,7 +39,7 @@ msgstr "" ":mod:`glob` 模組根據 Unix shell 使用的規則查找與指定模式匹配的所有路徑名稱," "結果以任意順序回傳。沒有波浪號 (tilde) 擴展,但是 ``*``、``?`` 和用 ``[]`` 表" "示的字元範圍將被正確匹配。這是透過同時使用 :func:`os.scandir` 和 :func:" -"`fnmatch.fnmatch` 函式來完成的,而沒有實際調用 subshell。" +"`fnmatch.fnmatch` 函式來完成的,而沒有實際呼叫 subshell。" #: ../../library/glob.rst:28 msgid "" @@ -60,11 +60,11 @@ msgstr "" "對於文本 (literal) 匹配,將元字元 (meta-character) 括在方括號中。例如," "``'[?]'`` 會匹配 ``'?'`` 字元。" -#: ../../library/glob.rst:39 -msgid "The :mod:`pathlib` module offers high-level path objects." -msgstr ":mod:`pathlib` 模組提供高階路徑物件。" +#: ../../library/glob.rst:37 +msgid "The :mod:`glob` module defines the following functions:" +msgstr ":mod:`glob` 模組定義了以下函式:" -#: ../../library/glob.rst:45 +#: ../../library/glob.rst:43 msgid "" "Return a possibly empty list of path names that match *pathname*, which must " "be a string containing a path specification. *pathname* can be either " @@ -82,25 +82,25 @@ msgstr "" "取決於檔案系統 (file system)。如果在呼叫此函式期間刪除或新增滿足條件的檔案," "則結果不一定會包含該檔案的路徑名稱。" -#: ../../library/glob.rst:54 +#: ../../library/glob.rst:52 msgid "" "If *root_dir* is not ``None``, it should be a :term:`path-like object` " "specifying the root directory for searching. It has the same effect on :" "func:`glob` as changing the current directory before calling it. If " "*pathname* is relative, the result will contain paths relative to *root_dir*." msgstr "" -"如果 *root_dir* 不是 ``None``,它應該是一個指定搜索根目錄的 :term:`path-like " -"object`。它在呼叫它之前更改當前目錄的影響與 :func:`glob` 相同。如果 " +"如果 *root_dir* 不是 ``None``,它應該是一個指定搜尋根目錄的 :term:`path-like " +"object`。它在呼叫它之前更改目前目錄的影響與 :func:`glob` 相同。如果 " "*pathname* 是相對的,結果將包含相對於 *root_dir* 的路徑。" -#: ../../library/glob.rst:60 +#: ../../library/glob.rst:58 msgid "" "This function can support :ref:`paths relative to directory descriptors " "` with the *dir_fd* parameter." msgstr "" "此函式可以支援以 *dir_fd* 參數使用\\ :ref:`相對目錄描述器的路徑 `。" -#: ../../library/glob.rst:66 +#: ../../library/glob.rst:64 msgid "" "If *recursive* is true, the pattern \"``**``\" will match any files and zero " "or more directories, subdirectories and symbolic links to directories. If " @@ -111,13 +111,13 @@ msgstr "" "和目錄的符號連結。如果模式後面有 :data:`os.sep` 或 :data:`os.altsep` 那麼檔案" "將不會被匹配。" -#: ../../library/glob.rst:71 +#: ../../library/glob.rst:69 msgid "" "If *include_hidden* is true, \"``**``\" pattern will match hidden " "directories." msgstr "如果 *include_hidden* 為真,\"``**``\" 模式將匹配被隱藏的目錄。" -#: ../../library/glob.rst:73 ../../library/glob.rst:100 +#: ../../library/glob.rst:71 ../../library/glob.rst:98 msgid "" "Raises an :ref:`auditing event ` ``glob.glob`` with arguments " "``pathname``, ``recursive``." @@ -125,7 +125,7 @@ msgstr "" "引發一個附帶引數 ``pathname``、``recursive`` 的\\ :ref:`稽核事件 ` " "``glob.glob``。" -#: ../../library/glob.rst:74 ../../library/glob.rst:101 +#: ../../library/glob.rst:72 ../../library/glob.rst:99 msgid "" "Raises an :ref:`auditing event ` ``glob.glob/2`` with arguments " "``pathname``, ``recursive``, ``root_dir``, ``dir_fd``." @@ -133,39 +133,39 @@ msgstr "" "引發一個附帶引數 ``pathname``、``recursive``、``root_dir``、``dir_fd`` 的\\ :" "ref:`稽核事件 ` ``glob.glob/2``。" -#: ../../library/glob.rst:77 +#: ../../library/glob.rst:75 msgid "" "Using the \"``**``\" pattern in large directory trees may consume an " "inordinate amount of time." msgstr "在大型目錄樹中使用 \"``**``\" 模式可能會消耗過多的時間。" -#: ../../library/glob.rst:81 ../../library/glob.rst:104 +#: ../../library/glob.rst:79 ../../library/glob.rst:102 msgid "" "This function may return duplicate path names if *pathname* contains " "multiple \"``**``\" patterns and *recursive* is true." msgstr "" -#: ../../library/glob.rst:84 ../../library/glob.rst:107 +#: ../../library/glob.rst:82 ../../library/glob.rst:105 msgid "Support for recursive globs using \"``**``\"." msgstr "支援以 \"``**``\" 使用遞迴 glob。" -#: ../../library/glob.rst:87 ../../library/glob.rst:110 +#: ../../library/glob.rst:85 ../../library/glob.rst:108 msgid "Added the *root_dir* and *dir_fd* parameters." msgstr "新增 *root_dir* 與 *dir_fd* 參數。" -#: ../../library/glob.rst:90 ../../library/glob.rst:113 +#: ../../library/glob.rst:88 ../../library/glob.rst:111 msgid "Added the *include_hidden* parameter." msgstr "新增 *include_hidden* 參數。" -#: ../../library/glob.rst:97 +#: ../../library/glob.rst:95 msgid "" "Return an :term:`iterator` which yields the same values as :func:`glob` " "without actually storing them all simultaneously." msgstr "" -"回傳一個會產生與 :func:`glob` 相同的值的 :term:`iterator` ,而不是同時存儲全" +"回傳一個會產生與 :func:`glob` 相同的值的 :term:`iterator` ,而不是同時儲存全" "部的值。" -#: ../../library/glob.rst:119 +#: ../../library/glob.rst:117 msgid "" "Escape all special characters (``'?'``, ``'*'`` and ``'['``). This is useful " "if you want to match an arbitrary literal string that may have special " @@ -180,17 +180,61 @@ msgstr "" #: ../../library/glob.rst:128 msgid "" -"For example, consider a directory containing the following files: :file:`1." -"gif`, :file:`2.txt`, :file:`card.gif` and a subdirectory :file:`sub` which " -"contains only the file :file:`3.txt`. :func:`glob` will produce the " -"following results. Notice how any leading components of the path are " -"preserved. ::" +"Convert the given path specification to a regular expression for use with :" +"func:`re.match`. The path specification can contain shell-style wildcards." +msgstr "" + +#: ../../library/glob.rst:131 +msgid "For example:" +msgstr "舉例來說:" + +#: ../../library/glob.rst:142 +msgid "" +"Path separators and segments are meaningful to this function, unlike :func:" +"`fnmatch.translate`. By default wildcards do not match path separators, and " +"``*`` pattern segments match precisely one path segment." +msgstr "" + +#: ../../library/glob.rst:146 +msgid "" +"If *recursive* is true, the pattern segment \"``**``\" will match any number " +"of path segments." +msgstr "" + +#: ../../library/glob.rst:149 +msgid "" +"If *include_hidden* is true, wildcards can match path segments that start " +"with a dot (``.``)." +msgstr "" + +#: ../../library/glob.rst:152 +msgid "" +"A sequence of path separators may be supplied to the *seps* argument. If not " +"given, :data:`os.sep` and :data:`~os.altsep` (if available) are used." +msgstr "" + +#: ../../library/glob.rst:157 +msgid "" +":meth:`pathlib.PurePath.full_match` and :meth:`pathlib.Path.glob` methods, " +"which call this function to implement pattern matching and globbing." +msgstr "" + +#: ../../library/glob.rst:165 +msgid "Examples" +msgstr "範例" + +#: ../../library/glob.rst:167 +msgid "" +"Consider a directory containing the following files: :file:`1.gif`, :file:`2." +"txt`, :file:`card.gif` and a subdirectory :file:`sub` which contains only " +"the file :file:`3.txt`. :func:`glob` will produce the following results. " +"Notice how any leading components of the path are preserved. ::" msgstr "" "例如,在一個包含以下檔案的目錄::file:`1.gif`、:file:`2.txt`、:file:`card." "gif`,和一個僅包含 :file:`3.txt` 檔案的子目錄 :file:`sub`,:func:`glob` 將產" "生以下結果。請注意路徑的任何前導部分是如何保留的。 ::" -#: ../../library/glob.rst:134 +#: ../../library/glob.rst:173 msgid "" ">>> import glob\n" ">>> glob.glob('./[0-9].*')\n" @@ -216,7 +260,7 @@ msgstr "" ">>> glob.glob('./**/', recursive=True)\n" "['./', './sub/']" -#: ../../library/glob.rst:146 +#: ../../library/glob.rst:185 msgid "" "If the directory contains files starting with ``.`` they won't be matched by " "default. For example, consider a directory containing :file:`card.gif` and :" @@ -225,7 +269,7 @@ msgstr "" "如果目錄包含以 ``.`` 開頭的檔案,則預設情況下不會去匹配到它們。例如,一個包" "含 :file:`card.gif` 和 :file:`.card.gif` 的目錄: ::" -#: ../../library/glob.rst:150 +#: ../../library/glob.rst:189 msgid "" ">>> import glob\n" ">>> glob.glob('*.gif')\n" @@ -239,13 +283,14 @@ msgstr "" ">>> glob.glob('.c*')\n" "['.card.gif']" -#: ../../library/glob.rst:158 -msgid "Module :mod:`fnmatch`" -msgstr ":mod:`fnmatch` 模組" +#: ../../library/glob.rst:196 +msgid "" +"The :mod:`fnmatch` module offers shell-style filename (not path) expansion." +msgstr ":mod:`fnmatch` 模組提供了 shell 風格檔案名(不是路徑)的擴展" -#: ../../library/glob.rst:159 -msgid "Shell-style filename (not path) expansion" -msgstr "Shell 風格檔案名(不是路徑)的擴展" +#: ../../library/glob.rst:199 +msgid "The :mod:`pathlib` module offers high-level path objects." +msgstr ":mod:`pathlib` 模組提供高階路徑物件。" #: ../../library/glob.rst:9 msgid "filenames" @@ -259,7 +304,7 @@ msgstr "pathname expansion(路徑名稱展開)" msgid "* (asterisk)" msgstr "* (星號)" -#: ../../library/glob.rst:13 ../../library/glob.rst:63 +#: ../../library/glob.rst:13 ../../library/glob.rst:61 msgid "in glob-style wildcards" msgstr "於 glob 風格的萬用字元中" @@ -283,6 +328,6 @@ msgstr "- (減號)" msgid ". (dot)" msgstr ". (點)" -#: ../../library/glob.rst:63 +#: ../../library/glob.rst:61 msgid "**" msgstr "**" diff --git a/library/graphlib.po b/library/graphlib.po index 4ee16bd428..8e8f8e4479 100644 --- a/library/graphlib.po +++ b/library/graphlib.po @@ -6,7 +6,7 @@ # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2023-01-04 16:35+0800\n" diff --git a/library/grp.po b/library/grp.po index f035088276..cb3b4333c2 100644 --- a/library/grp.po +++ b/library/grp.po @@ -3,13 +3,14 @@ # This file is distributed under the same license as the Python package. # # Translators: +# Weilin Du, 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-09 00:03+0000\n" -"PO-Revision-Date: 2018-05-23 16:02+0000\n" -"Last-Translator: Adrian Liaw \n" +"POT-Creation-Date: 2024-10-11 00:13+0000\n" +"PO-Revision-Date: 2025-06-28 17:17+0800\n" +"Last-Translator: Weilin Du\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -26,11 +27,11 @@ msgstr ":mod:`!grp` --- 群組資料庫" msgid "" "This module provides access to the Unix group database. It is available on " "all Unix versions." -msgstr "" +msgstr "該模組提供對 Unix 群組資料庫的存取, 所有 Unix 版本皆可使用。" #: ../../library/grp.rst:13 -msgid ":ref:`Availability `: Unix, not Emscripten, not WASI." -msgstr ":ref:`適用 `:Unix、非 Emscripten、非 WASI。" +msgid "Availability" +msgstr "可用性" #: ../../library/grp.rst:15 msgid "" @@ -38,10 +39,12 @@ msgid "" "correspond to the members of the ``group`` structure (Attribute field below, " "see ````):" msgstr "" +"群組資料庫條目以類似 tuple 物件的方式報傳入, 其屬性對應於 ``group`` 結構的成" +"員(屬性欄位如下, 請參閱 ````):" #: ../../library/grp.rst:20 msgid "Index" -msgstr "" +msgstr "索引" #: ../../library/grp.rst:20 msgid "Attribute" @@ -61,7 +64,7 @@ msgstr "gr_name" #: ../../library/grp.rst:22 msgid "the name of the group" -msgstr "" +msgstr "群組名稱" #: ../../library/grp.rst:24 msgid "1" @@ -73,7 +76,7 @@ msgstr "gr_passwd" #: ../../library/grp.rst:24 msgid "the (encrypted) group password; often empty" -msgstr "" +msgstr "(被加密後的)群組密碼;大部分情況下是空的" #: ../../library/grp.rst:27 msgid "2" @@ -85,7 +88,7 @@ msgstr "gr_gid" #: ../../library/grp.rst:27 msgid "the numerical group ID" -msgstr "" +msgstr "群組的數字 ID" #: ../../library/grp.rst:29 msgid "3" @@ -97,7 +100,7 @@ msgstr "gr_mem" #: ../../library/grp.rst:29 msgid "all the group member's user names" -msgstr "" +msgstr "所有群組成員的使用者名稱" #: ../../library/grp.rst:33 msgid "" @@ -109,31 +112,40 @@ msgid "" "reference and may not be accessible via :func:`getgrnam` or :func:" "`getgrgid`.)" msgstr "" +"gid 是整數,name 和 password 是字串, 而 member list 是字串串列。(請注" +"意, 根據密碼資料庫, 大多數使用者並未被明確列為其所在群組的成員。 請檢查這兩" +"個資料庫,以取得完整的成員資訊。 另外請注意,以 ``+`` 或 ``-`` 開頭的 " +"``gr_name`` 很可能是 YP/NIS 參照,可能無法透過 :func:`getgrnam` 或 :func:" +"`getgrgid` 取得)。" #: ../../library/grp.rst:40 msgid "It defines the following items:" -msgstr "" +msgstr "它定義了以下項目:" #: ../../library/grp.rst:45 msgid "" "Return the group database entry for the given numeric group ID. :exc:" "`KeyError` is raised if the entry asked for cannot be found." msgstr "" +"回傳給定群組 ID 的群組資料庫條目。 :exc:`KeyError` 會在找不到所要求的條目時被引" +"發。" #: ../../library/grp.rst:48 msgid "" ":exc:`TypeError` is raised for non-integer arguments like floats or strings." -msgstr "" +msgstr ":exc:`TypeError` 會在非整數的引數如浮點數或字串被傳入時被引發。" #: ../../library/grp.rst:53 msgid "" "Return the group database entry for the given group name. :exc:`KeyError` is " "raised if the entry asked for cannot be found." msgstr "" +"回傳給定群組名稱的群組資料庫條目。 :exc:`KeyError` 會在找不到所要求的條目時引" +"發。" #: ../../library/grp.rst:59 msgid "Return a list of all available group entries, in arbitrary order." -msgstr "" +msgstr "以任意順序傳回所有可用群組條目的串列。" #: ../../library/grp.rst:64 msgid "Module :mod:`pwd`" @@ -141,20 +153,4 @@ msgstr ":mod:`pwd` 模組" #: ../../library/grp.rst:65 msgid "An interface to the user database, similar to this." -msgstr "" - -#: ../../library/grp.rst:67 -msgid "Module :mod:`spwd`" -msgstr ":mod:`spwd` 模組" - -#: ../../library/grp.rst:68 -msgid "An interface to the shadow password database, similar to this." -msgstr "" - -#~ msgid "" -#~ "This module does not work or is not available on WebAssembly platforms " -#~ "``wasm32-emscripten`` and ``wasm32-wasi``. See :ref:`wasm-availability` " -#~ "for more information." -#~ msgstr "" -#~ "此模組在 WebAssembly 平台 ``wasm32-emscripten`` 和 ``wasm32-wasi`` 上無法" -#~ "作用或無法使用。有關更多資訊,請參閱 :ref:`wasm-availability`。" +msgstr "使用者資料庫的介面,與此類似。" diff --git a/library/gzip.po b/library/gzip.po index 8e7285d25a..80147ac8e0 100644 --- a/library/gzip.po +++ b/library/gzip.po @@ -5,9 +5,9 @@ # Adrian Liaw , 2018 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-04-26 00:14+0000\n" "PO-Revision-Date: 2018-05-23 16:03+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -105,7 +105,7 @@ msgstr "" msgid "Added support for the ``'x'``, ``'xb'`` and ``'xt'`` modes." msgstr "新增 ``'x'``、``'xb'`` 和 ``'xt'`` 模式的支援。" -#: ../../library/gzip.rst:59 ../../library/gzip.rst:171 +#: ../../library/gzip.rst:59 ../../library/gzip.rst:173 msgid "Accepts a :term:`path-like object`." msgstr "接受\\ :term:`類路徑物件 `。" @@ -168,14 +168,19 @@ msgstr "" #: ../../library/gzip.rst:103 msgid "" -"The *mtime* argument is an optional numeric timestamp to be written to the " -"last modification time field in the stream when compressing. It should only " -"be provided in compression mode. If omitted or ``None``, the current time " -"is used. See the :attr:`mtime` attribute for more details." +"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." msgstr "" #: ../../library/gzip.rst:108 msgid "" +"See below for the :attr:`mtime` attribute that is set when decompressing." +msgstr "" + +#: ../../library/gzip.rst:110 +msgid "" "Calling a :class:`GzipFile` object's :meth:`!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 :class:`io.BytesIO` object opened for " @@ -183,22 +188,21 @@ msgid "" "class:`io.BytesIO` object's :meth:`~io.BytesIO.getvalue` method." msgstr "" -#: ../../library/gzip.rst:114 +#: ../../library/gzip.rst:116 msgid "" ":class:`GzipFile` supports the :class:`io.BufferedIOBase` interface, " "including iteration and the :keyword:`with` statement. Only the :meth:`~io." "IOBase.truncate` method isn't implemented." msgstr "" -#: ../../library/gzip.rst:118 +#: ../../library/gzip.rst:120 msgid ":class:`GzipFile` also provides the following method and attribute:" msgstr ":class:`GzipFile` 也提供了以下的方法和屬性:" -#: ../../library/gzip.rst:122 +#: ../../library/gzip.rst:124 msgid "" -"Read *n* uncompressed bytes without advancing the file position. At most one " -"single read on the compressed stream is done to satisfy the call. The " -"number of bytes returned may be more or less than requested." +"Read *n* uncompressed bytes without advancing the file position. The number " +"of bytes returned may be more or less than requested." msgstr "" #: ../../library/gzip.rst:127 @@ -209,72 +213,70 @@ msgid "" msgstr "" #: ../../library/gzip.rst:136 -msgid "" -"When decompressing, the value of the last modification time field in the " -"most recently read header may be read from this attribute, as an integer. " -"The initial value before reading any headers is ``None``." +msgid "``'rb'`` for reading and ``'wb'`` for writing." msgstr "" -#: ../../library/gzip.rst:140 +#: ../../library/gzip.rst:138 +msgid "In previous versions it was an integer ``1`` or ``2``." +msgstr "" + +#: ../../library/gzip.rst:143 msgid "" -"All :program:`gzip` compressed streams are required to contain this " -"timestamp field. Some programs, such as :program:`gunzip`\\ , make use of " -"the timestamp. The format is the same as the return value of :func:`time." -"time` and the :attr:`~os.stat_result.st_mtime` attribute of the object " -"returned by :func:`os.stat`." +"When decompressing, this attribute is set to the last timestamp in the most " +"recently read header. It is an integer, holding the number of seconds since " +"the Unix epoch (00:00:00 UTC, January 1, 1970). The initial value before " +"reading any headers is ``None``." msgstr "" -#: ../../library/gzip.rst:148 +#: ../../library/gzip.rst:150 msgid "" "The path to the gzip file on disk, as a :class:`str` or :class:`bytes`. " "Equivalent to the output of :func:`os.fspath` on the original input path, " "with no other normalization, resolution or expansion." msgstr "" -#: ../../library/gzip.rst:152 +#: ../../library/gzip.rst:154 msgid "" "Support for the :keyword:`with` statement was added, along with the *mtime* " "constructor argument and :attr:`mtime` attribute." msgstr "" -#: ../../library/gzip.rst:156 +#: ../../library/gzip.rst:158 msgid "Support for zero-padded and unseekable files was added." msgstr "" -#: ../../library/gzip.rst:159 +#: ../../library/gzip.rst:161 msgid "The :meth:`io.BufferedIOBase.read1` method is now implemented." msgstr ":meth:`io.BufferedIOBase.read1` 方法現在已有實作。" -#: ../../library/gzip.rst:162 +#: ../../library/gzip.rst:164 msgid "Added support for the ``'x'`` and ``'xb'`` modes." msgstr "新增 ``'x'`` 和 ``'xb'`` 模式的支援。" -#: ../../library/gzip.rst:165 +#: ../../library/gzip.rst:167 msgid "" "Added support for writing arbitrary :term:`bytes-like objects `. The :meth:`~io.BufferedIOBase.read` method now accepts an argument " "of ``None``." msgstr "" -#: ../../library/gzip.rst:174 +#: ../../library/gzip.rst:176 msgid "" -"Remove the ``filename`` attribute, use the :attr:`~GzipFile.name` attribute " -"instead." +"Opening :class:`GzipFile` for writing without specifying the *mode* argument " +"is deprecated." msgstr "" -#: ../../library/gzip.rst:178 +#: ../../library/gzip.rst:180 msgid "" -"Opening :class:`GzipFile` for writing without specifying the *mode* argument " -"is deprecated." +"Remove the ``filename`` attribute, use the :attr:`~GzipFile.name` attribute " +"instead." msgstr "" -#: ../../library/gzip.rst:185 +#: ../../library/gzip.rst:187 msgid "" "Compress the *data*, returning a :class:`bytes` object containing the " "compressed data. *compresslevel* and *mtime* have the same meaning as in " -"the :class:`GzipFile` constructor above. When *mtime* is set to ``0``, this " -"function is equivalent to :func:`zlib.compress` with *wbits* set to ``31``. " -"The zlib function is faster." +"the :class:`GzipFile` constructor above." msgstr "" #: ../../library/gzip.rst:192 @@ -290,7 +292,13 @@ msgid "" "underlying zlib implementation." msgstr "" -#: ../../library/gzip.rst:203 +#: ../../library/gzip.rst:201 +msgid "" +"The gzip header OS byte is guaranteed to be set to 255 when this function is " +"used as was the case in 3.10 and earlier." +msgstr "" + +#: ../../library/gzip.rst:207 msgid "" "Decompress the *data*, returning a :class:`bytes` object containing the " "uncompressed data. This function is capable of decompressing multi-member " @@ -299,21 +307,21 @@ msgid "" "*wbits* set to 31 is faster." msgstr "" -#: ../../library/gzip.rst:210 +#: ../../library/gzip.rst:214 msgid "" "Speed is improved by decompressing members at once in memory instead of in a " "streamed fashion." msgstr "" -#: ../../library/gzip.rst:217 +#: ../../library/gzip.rst:221 msgid "Examples of usage" msgstr "用法範例" -#: ../../library/gzip.rst:219 +#: ../../library/gzip.rst:223 msgid "Example of how to read a compressed file::" msgstr "如何讀取壓縮檔案的範例: ::" -#: ../../library/gzip.rst:221 +#: ../../library/gzip.rst:225 msgid "" "import gzip\n" "with gzip.open('/home/joe/file.txt.gz', 'rb') as f:\n" @@ -323,11 +331,11 @@ msgstr "" "with gzip.open('/home/joe/file.txt.gz', 'rb') as f:\n" " file_content = f.read()" -#: ../../library/gzip.rst:225 +#: ../../library/gzip.rst:229 msgid "Example of how to create a compressed GZIP file::" msgstr "如何建立一個壓縮的 GZIP 檔案的範例: ::" -#: ../../library/gzip.rst:227 +#: ../../library/gzip.rst:231 msgid "" "import gzip\n" "content = b\"Lots of content here\"\n" @@ -339,11 +347,11 @@ msgstr "" "with gzip.open('/home/joe/file.txt.gz', 'wb') as f:\n" " f.write(content)" -#: ../../library/gzip.rst:232 +#: ../../library/gzip.rst:236 msgid "Example of how to GZIP compress an existing file::" msgstr "如何壓縮一個已存在的檔案的範例: ::" -#: ../../library/gzip.rst:234 +#: ../../library/gzip.rst:238 msgid "" "import gzip\n" "import shutil\n" @@ -357,11 +365,11 @@ msgstr "" " with gzip.open('/home/joe/file.txt.gz', 'wb') as f_out:\n" " shutil.copyfileobj(f_in, f_out)" -#: ../../library/gzip.rst:240 +#: ../../library/gzip.rst:244 msgid "Example of how to GZIP compress a binary string::" msgstr "如何壓縮一個二進位字串的範例: ::" -#: ../../library/gzip.rst:242 +#: ../../library/gzip.rst:246 msgid "" "import gzip\n" "s_in = b\"Lots of content here\"\n" @@ -371,56 +379,62 @@ msgstr "" "s_in = b\"Lots of content here\"\n" "s_out = gzip.compress(s_in)" -#: ../../library/gzip.rst:248 +#: ../../library/gzip.rst:252 msgid "Module :mod:`zlib`" msgstr ":mod:`zlib` 模組" -#: ../../library/gzip.rst:249 +#: ../../library/gzip.rst:253 msgid "" "The basic data compression module needed to support the :program:`gzip` file " "format." msgstr "" -#: ../../library/gzip.rst:258 +#: ../../library/gzip.rst:256 +msgid "" +"In case gzip (de)compression is a bottleneck, the `python-isal`_ package " +"speeds up (de)compression with a mostly compatible API." +msgstr "" + +#: ../../library/gzip.rst:266 msgid "Command Line Interface" msgstr "命令列介面" -#: ../../library/gzip.rst:260 +#: ../../library/gzip.rst:268 msgid "" "The :mod:`gzip` module provides a simple command line interface to compress " "or decompress files." msgstr "" -#: ../../library/gzip.rst:263 +#: ../../library/gzip.rst:271 msgid "Once executed the :mod:`gzip` module keeps the input file(s)." msgstr "" -#: ../../library/gzip.rst:267 +#: ../../library/gzip.rst:275 msgid "" "Add a new command line interface with a usage. By default, when you will " "execute the CLI, the default compression level is 6." msgstr "" -#: ../../library/gzip.rst:271 +#: ../../library/gzip.rst:279 msgid "Command line options" msgstr "命令列選項" -#: ../../library/gzip.rst:275 +#: ../../library/gzip.rst:283 msgid "If *file* is not specified, read from :data:`sys.stdin`." msgstr "如果未指定 *file*,則從 :data:`sys.stdin` 讀取。" -#: ../../library/gzip.rst:279 +#: ../../library/gzip.rst:287 msgid "Indicates the fastest compression method (less compression)." msgstr "" -#: ../../library/gzip.rst:283 +#: ../../library/gzip.rst:291 msgid "Indicates the slowest compression method (best compression)." msgstr "" -#: ../../library/gzip.rst:287 +#: ../../library/gzip.rst:295 msgid "Decompress the given file." msgstr "解壓縮指定的檔案。" -#: ../../library/gzip.rst:291 +#: ../../library/gzip.rst:299 msgid "Show the help message." msgstr "顯示幫助訊息。" diff --git a/library/hashlib.po b/library/hashlib.po index 9d2a0e698b..358886b433 100644 --- a/library/hashlib.po +++ b/library/hashlib.po @@ -5,9 +5,9 @@ # Matt Wang , 2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-18 00:04+0000\n" +"POT-Creation-Date: 2025-04-24 05:58+0000\n" "PO-Revision-Date: 2024-05-11 16:03+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -29,42 +29,39 @@ msgstr "**原始碼:**\\ :source:`Lib/hashlib.py`" #: ../../library/hashlib.rst:23 msgid "" -"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`_), the SHA-3 series (defined in `the FIPS 202 standard`_) as well " -"as RSA's MD5 algorithm (defined in internet :rfc:`1321`). The terms " -"\"secure hash\" and \"message digest\" are interchangeable. Older " -"algorithms were called message digests. The modern term is secure hash." +"This module implements a common interface to many different hash algorithms. " +"Included are the FIPS secure hash algorithms SHA224, SHA256, SHA384, SHA512, " +"(defined in `the FIPS 180-4 standard`_), the SHA-3 series (defined in `the " +"FIPS 202 standard`_) as well as the legacy algorithms SHA1 (`formerly part " +"of FIPS`_) and the MD5 algorithm (defined in internet :rfc:`1321`)." msgstr "" -"該模組實作了許多不同安全雜湊和訊息摘要演算法的通用介面,其中包括 FIPS 安全雜" -"湊演算法 SHA1、SHA224、SHA256、SHA384、SHA512(定義於 `FIPS 180-4 標準 `_)、SHA-3 系列(定義於 `FIPS 202 標準 `_)以及 RSA 的 MD5 演算法(定義於網際網路 :rfc:`1321`)。「安全雜" -"湊 (secure hash)」和「訊息摘要 (message digest)」這兩個術語是可以互換的。較舊" -"的演算法稱為訊息摘要、現代則較常稱之安全雜湊。" +"該模組實作了許多不同雜湊演算法的通用介面,其中包括 FIPS 安全雜湊演算法 SHA1、" +"SHA224、SHA256、SHA384、SHA512(定義於 `FIPS 180-4 標準 `_)、SHA-3 系列(定義於 `FIPS 202 標準 `_)以及遺留的 SHA1 演算法(`先前為 FIPS 的一部分 `_)和 MD5 演算法(定義於網際網路 :rfc:`1321`)。" -#: ../../library/hashlib.rst:33 +#: ../../library/hashlib.rst:31 msgid "" -"If you want the adler32 or crc32 hash functions, they are available in the :" -"mod:`zlib` module." +"If you want the adler32 or crc32 hash functions, they are available in " +"the :mod:`zlib` module." msgstr "" "如果你需要 adler32 或 crc32 雜湊函式,可以在 :mod:`zlib` 模組中找到它們。" -#: ../../library/hashlib.rst:40 +#: ../../library/hashlib.rst:38 msgid "Hash algorithms" msgstr "雜湊演算法" -#: ../../library/hashlib.rst:42 +#: ../../library/hashlib.rst:40 msgid "" "There is one constructor method named for each type of :dfn:`hash`. All " -"return a hash object with the same simple interface. For example: use :func:" -"`sha256` to create a SHA-256 hash object. You can now feed this object with :" -"term:`bytes-like objects ` (normally :class:`bytes`) " -"using the :meth:`update` method. At any point you can ask it " -"for the :dfn:`digest` of the concatenation of the data fed to it so far " -"using the :meth:`digest()` or :meth:`hexdigest()` methods." +"return a hash object with the same simple interface. For example: " +"use :func:`sha256` to create a SHA-256 hash object. You can now feed this " +"object with :term:`bytes-like objects ` " +"(normally :class:`bytes`) using the :meth:`update` method. At " +"any point you can ask it for the :dfn:`digest` of the concatenation of the " +"data fed to it so far using the :meth:`digest()` " +"or :meth:`hexdigest()` methods." msgstr "" "每種種類的 :dfn:`hash` 都有一個以其命名的建構函式方法。全部都會回傳具有相同簡" "單介面的雜湊物件。例如:可使用 :func:`sha256` 來建立 SHA-256 雜湊物件。現在你" @@ -74,45 +71,43 @@ msgstr "" "` 方法來要求它提供迄今為止傳遞給它的資料串聯的\\ :dfn:`摘要 " "(digest)`。" -#: ../../library/hashlib.rst:50 +#: ../../library/hashlib.rst:48 msgid "" "To allow multithreading, the Python :term:`GIL` is released while computing " -"a hash supplied more than 2047 bytes of data at once in its constructor or :" -"meth:`.update` method." +"a hash supplied more than 2047 bytes of data at once in its constructor " +"or :meth:`.update` method." msgstr "" "為了允許多執行緒 (multithreading),Python :term:`GIL` 被釋放,同時在其建構函" "式或 :meth:`.update` 方法中計算一次提供超過 2047 位元組資料的雜" "湊值。" -#: ../../library/hashlib.rst:57 +#: ../../library/hashlib.rst:55 msgid "" -"Constructors for hash algorithms that are always present in this module are :" -"func:`sha1`, :func:`sha224`, :func:`sha256`, :func:`sha384`, :func:" -"`sha512`, :func:`sha3_224`, :func:`sha3_256`, :func:`sha3_384`, :func:" -"`sha3_512`, :func:`shake_128`, :func:`shake_256`, :func:`blake2b`, and :func:" -"`blake2s`. :func:`md5` 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 :data:`algorithms_guaranteed`." +"Constructors for hash algorithms that are always present in this module " +"are :func:`sha1`, :func:`sha224`, :func:`sha256`, :func:`sha384`, :func:`sha512`, :func:`sha3_224`, :func:`sha3_256`, :func:`sha3_384`, :func:`sha3_512`, :func:`shake_128`, :func:`shake_256`, :func:`blake2b`, " +"and :func:`blake2s`. :func:`md5` 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 :data:`algorithms_guaranteed`." msgstr "" -"此模組中始終存在的雜湊演算法之建構函式有 :func:`sha1`、:func:`sha224`、:func:" -"`sha256`、:func:`sha384`、:func:`sha512`、:func:`sha3_224`、:func:" -"`sha3_256`、:func:`sha3_384`、:func:`sha3_512`、:func:`shake_128`、:func:" -"`shake_256`、:func:`blake2b` 和 :func:`blake2s`。:func:`md5` 通常也可用,但如" -"果你使用罕見的「符合 FIPS (FIPS compliant)」的 Python 建置版本,它可能不存在" -"或者不被允許使用。以上會對應到 :data:`algorithms_guaranteed`。" +"此模組中始終存在的雜湊演算法之建構函式" +"有 :func:`sha1`、:func:`sha224`、:func:`sha256`、:func:`sha384`、:func:`sha512`、:func:`sha3_224`、:func:`sha3_256`、:func:`sha3_384`、:func:`sha3_512`、:func:`shake_128`、:func:`shake_256`、:func:`blake2b` " +"和 :func:`blake2s`。:func:`md5` 通常也可用,但如果你使用罕見的「符合 FIPS " +"(FIPS compliant)」的 Python 建置版本,它可能不存在或者不被允許使用。以上會對" +"應到 :data:`algorithms_guaranteed`。" -#: ../../library/hashlib.rst:65 +#: ../../library/hashlib.rst:63 msgid "" -"Additional algorithms may also be available if your Python distribution's :" -"mod:`hashlib` was linked against a build of OpenSSL that provides others. " -"Others *are not guaranteed available* on all installations and will only be " -"accessible by name via :func:`new`. See :data:`algorithms_available`." +"Additional algorithms may also be available if your Python " +"distribution's :mod:`hashlib` was linked against a build of OpenSSL that " +"provides others. Others *are not guaranteed available* on all installations " +"and will only be accessible by name via :func:`new`. " +"See :data:`algorithms_available`." msgstr "" "如果你的 Python 發行版的 :mod:`hashlib` 與提供其他演算法的 OpenSSL 版本鏈結," "也可能有其他演算法可用。其他則\\ *不保證可用*\\ 於在所有安裝上,並且只能以名" "稱來透過 :func:`new` 存取。請參閱 :data:`algorithms_available`。" -#: ../../library/hashlib.rst:72 +#: ../../library/hashlib.rst:70 msgid "" "Some algorithms have known hash collision weaknesses (including MD5 and " "SHA1). Refer to `Attacks on cryptographic hash algorithms`_ and the `hashlib-" @@ -122,17 +117,17 @@ msgstr "" "閱 `Attacks on cryptographic hash algorithms`_ 和本文件後面的\\ `也參考 " "`_\\ 部分。" -#: ../../library/hashlib.rst:76 +#: ../../library/hashlib.rst:74 msgid "" -"SHA3 (Keccak) and SHAKE constructors :func:`sha3_224`, :func:`sha3_256`, :" -"func:`sha3_384`, :func:`sha3_512`, :func:`shake_128`, :func:`shake_256` were " -"added. :func:`blake2b` and :func:`blake2s` were added." +"SHA3 (Keccak) and SHAKE " +"constructors :func:`sha3_224`, :func:`sha3_256`, :func:`sha3_384`, :func:`sha3_512`, :func:`shake_128`, :func:`shake_256` " +"were added. :func:`blake2b` and :func:`blake2s` were added." msgstr "" -"新增了 SHA3 (Keccak) 和 SHAKE 建構函式 :func:`sha3_224`、:func:`sha3_256`、:" -"func:`sha3_384`、:func:`sha3_512`、:func:`shake_128`、:func:`shake_256`。也新" -"增了 :func:`blake2b` 和 :func:`blake2s`。" +"新增了 SHA3 (Keccak) 和 SHAKE 建構函" +"式 :func:`sha3_224`、:func:`sha3_256`、:func:`sha3_384`、:func:`sha3_512`、:func:`shake_128`、:func:`shake_256`。" +"也新增了 :func:`blake2b` 和 :func:`blake2s`。" -#: ../../library/hashlib.rst:84 +#: ../../library/hashlib.rst:82 msgid "" "All hashlib constructors take a keyword-only argument *usedforsecurity* with " "default value ``True``. A false value allows the use of insecure and blocked " @@ -145,11 +140,11 @@ msgstr "" "全 (insecure) 和阻塞的 (blocked) 雜湊演算法。``False`` 表示雜湊演算法未在安全" "情境中使用,例如作為一種非加密用途的單向壓縮函式。" -#: ../../library/hashlib.rst:91 +#: ../../library/hashlib.rst:89 msgid "Hashlib now uses SHA3 and SHAKE from OpenSSL if it provides it." msgstr "Hashlib 現在使用 OpenSSL 中的 SHA3 和 SHAKE(如果有提供的話)。" -#: ../../library/hashlib.rst:94 +#: ../../library/hashlib.rst:92 msgid "" "For any of the MD5, SHA1, SHA2, or SHA3 algorithms that the linked OpenSSL " "does not provide we fall back to a verified implementation from the `HACL\\* " @@ -158,18 +153,18 @@ msgstr "" "對於鏈結之 OpenSSL 未提供的任何 MD5、SHA1、SHA2 或 SHA3 演算法,我們會回退使" "用 `HACL\\* 專案 `_\\ 中經過驗證的實作。" -#: ../../library/hashlib.rst:100 +#: ../../library/hashlib.rst:98 msgid "Usage" msgstr "用法" -#: ../../library/hashlib.rst:102 +#: ../../library/hashlib.rst:100 msgid "" "To obtain the digest of the byte string ``b\"Nobody inspects the spammish " "repetition\"``::" msgstr "" -"獲取位元組字串 ``b\"Nobody inspects the spammish repetition\"`` 的摘要: ::" +"取得位元組字串 ``b\"Nobody inspects the spammish repetition\"`` 的摘要: ::" -#: ../../library/hashlib.rst:105 +#: ../../library/hashlib.rst:103 msgid "" ">>> import hashlib\n" ">>> m = hashlib.sha256()\n" @@ -177,8 +172,7 @@ msgid "" ">>> m.update(b\" the spammish repetition\")\n" ">>> m.digest()\n" "b'\\x03\\x1e\\xdd}Ae\\x15\\x93\\xc5\\xfe\\\\" -"\\x00o\\xa5u+7\\xfd\\xdf\\xf7\\xbcN\\x84:" -"\\xa6\\xaf\\x0c\\x95\\x0fK\\x94\\x06'\n" +"\\x00o\\xa5u+7\\xfd\\xdf\\xf7\\xbcN\\x84:\\xa6\\xaf\\x0c\\x95\\x0fK\\x94\\x06'\n" ">>> m.hexdigest()\n" "'031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9406'" msgstr "" @@ -188,20 +182,19 @@ msgstr "" ">>> m.update(b\" the spammish repetition\")\n" ">>> m.digest()\n" "b'\\x03\\x1e\\xdd}Ae\\x15\\x93\\xc5\\xfe\\\\" -"\\x00o\\xa5u+7\\xfd\\xdf\\xf7\\xbcN\\x84:" -"\\xa6\\xaf\\x0c\\x95\\x0fK\\x94\\x06'\n" +"\\x00o\\xa5u+7\\xfd\\xdf\\xf7\\xbcN\\x84:\\xa6\\xaf\\x0c\\x95\\x0fK\\x94\\x06'\n" ">>> m.hexdigest()\n" "'031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9406'" -#: ../../library/hashlib.rst:114 +#: ../../library/hashlib.rst:112 msgid "More condensed:" msgstr "更濃縮:" -#: ../../library/hashlib.rst:120 +#: ../../library/hashlib.rst:118 msgid "Constructors" msgstr "建構函式" -#: ../../library/hashlib.rst:124 +#: ../../library/hashlib.rst:122 msgid "" "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 " @@ -211,25 +204,25 @@ msgstr "" "是一個通用建構函式,它將目標演算法的字串 *name* 作為其第一個參數。它還允許使" "用者取得上面列出的雜湊值以及 OpenSSL 函式庫可能提供的任何其他演算法。" -#: ../../library/hashlib.rst:129 +#: ../../library/hashlib.rst:127 msgid "Using :func:`new` with an algorithm name:" msgstr "使用 :func:`new` 和演算法名稱:" -#: ../../library/hashlib.rst:148 +#: ../../library/hashlib.rst:146 msgid "" "Named constructors such as these are faster than passing an algorithm name " "to :func:`new`." msgstr "諸如此類的附名建構函式比將演算法名稱傳遞給 :func:`new` 更快。" -#: ../../library/hashlib.rst:152 +#: ../../library/hashlib.rst:150 msgid "Attributes" msgstr "屬性" -#: ../../library/hashlib.rst:154 +#: ../../library/hashlib.rst:152 msgid "Hashlib provides the following constant module attributes:" msgstr "Hashlib 提供以下常數模組屬性:" -#: ../../library/hashlib.rst:158 +#: ../../library/hashlib.rst:156 msgid "" "A set containing the names of the hash algorithms guaranteed to be supported " "by this module on all platforms. Note that 'md5' is in this list despite " @@ -240,41 +233,41 @@ msgstr "" "列表中,儘管有一些上游供應商提供了奇怪的「符合 FIPS (FIPS compliant)」的 " "Python 建置,並將其排除在外。" -#: ../../library/hashlib.rst:167 +#: ../../library/hashlib.rst:165 msgid "" "A set containing the names of the hash algorithms that are available in the " -"running Python interpreter. These names will be recognized when passed to :" -"func:`new`. :attr:`algorithms_guaranteed` will always be a subset. The " +"running Python interpreter. These names will be recognized when passed " +"to :func:`new`. :attr:`algorithms_guaranteed` will always be a subset. The " "same algorithm may appear multiple times in this set under different names " "(thanks to OpenSSL)." msgstr "" -"包含正在運行的 Python 直譯器中可用的雜湊演算法名稱的集合。這些名稱在傳遞給 :" -"func:`new` 時將被識別。:attr:`algorithms_guaranteed` 都會是它的一個子集。相同" -"的演算法可能會以不同的名稱多次出現在該集合中(多虧了 OpenSSL)。" +"包含正在運行的 Python 直譯器中可用的雜湊演算法名稱的集合。這些名稱在傳遞" +"給 :func:`new` 時將被識別。:attr:`algorithms_guaranteed` 都會是它的一個子集。" +"相同的演算法可能會以不同的名稱多次出現在該集合中(多虧了 OpenSSL)。" -#: ../../library/hashlib.rst:176 +#: ../../library/hashlib.rst:174 msgid "Hash Objects" msgstr "雜湊物件" -#: ../../library/hashlib.rst:178 +#: ../../library/hashlib.rst:176 msgid "" "The following values are provided as constant attributes of the hash objects " "returned by the constructors:" msgstr "以下的值皆為建構函式回傳之雜湊物件的常數屬性:" -#: ../../library/hashlib.rst:183 +#: ../../library/hashlib.rst:181 msgid "The size of the resulting hash in bytes." msgstr "生成雜湊的大小(以位元組為單位)。" -#: ../../library/hashlib.rst:187 +#: ../../library/hashlib.rst:185 msgid "The internal block size of the hash algorithm in bytes." msgstr "雜湊演算法的內部區塊大小(以位元組為單位)。" -#: ../../library/hashlib.rst:189 +#: ../../library/hashlib.rst:187 msgid "A hash object has the following attributes:" msgstr "雜湊物件具有以下屬性:" -#: ../../library/hashlib.rst:193 +#: ../../library/hashlib.rst:191 msgid "" "The canonical name of this hash, always lowercase and always suitable as a " "parameter to :func:`new` to create another hash of this type." @@ -282,7 +275,7 @@ msgstr "" "該雜湊的規範名稱,都會是小寫,且都會適合作為 :func:`new` 的參數以建立此型別的" "另一個雜湊。" -#: ../../library/hashlib.rst:196 +#: ../../library/hashlib.rst:194 msgid "" "The name attribute has been present in CPython since its inception, but " "until Python 3.4 was not formally specified, so may not exist on some " @@ -291,30 +284,31 @@ msgstr "" "name 屬性自 CPython 誕生以來就存在於其中,但直到 Python 3.4 才正式確立,因此" "在某些平台上可能不存在。" -#: ../../library/hashlib.rst:201 +#: ../../library/hashlib.rst:199 msgid "A hash object has the following methods:" msgstr "雜湊物件具有以下方法:" -#: ../../library/hashlib.rst:206 +#: ../../library/hashlib.rst:204 msgid "" "Update the hash object with the :term:`bytes-like object`. Repeated calls " "are equivalent to a single call with the concatenation of all the arguments: " "``m.update(a); m.update(b)`` is equivalent to ``m.update(a+b)``." msgstr "" "使用\\ :term:`類位元組物件 `\\ 來更新雜湊物件。重複呼叫相" -"當於連接所有引數的單一呼叫:``m.update(a); m.update(b)`` 等價於 ``m." -"update(a+b)``。" +"當於連接所有引數的單一呼叫:``m.update(a); m.update(b)`` 等價於 " +"``m.update(a+b)``。" -#: ../../library/hashlib.rst:214 +#: ../../library/hashlib.rst:212 msgid "" "Return the digest of the data passed to the :meth:`update` method so far. " "This is a bytes object of size :attr:`digest_size` which may contain bytes " "in the whole range from 0 to 255." msgstr "" -"回傳目前有傳遞給 :meth:`update` 方法的資料之摘要。這是一個大小為 :attr:" -"`digest_size` 的位元組物件,它可能包含從 0 到 255 的整個範圍內的位元組。" +"回傳目前有傳遞給 :meth:`update` 方法的資料之摘要。這是一個大小" +"為 :attr:`digest_size` 的位元組物件,它可能包含從 0 到 255 的整個範圍內的位元" +"組。" -#: ../../library/hashlib.rst:221 +#: ../../library/hashlib.rst:219 msgid "" "Like :meth:`digest` except the digest is returned as a string object of " "double length, containing only hexadecimal digits. This may be used to " @@ -323,7 +317,7 @@ msgstr "" "與 :meth:`digest` 類似,只不過摘要會是作為雙倍長度的字串物件回傳,僅包含十六" "進位數字。這可用於在電子郵件或其他非二進位環境中安全地交換值。" -#: ../../library/hashlib.rst:228 +#: ../../library/hashlib.rst:226 msgid "" "Return a copy (\"clone\") of the hash object. This can be used to " "efficiently compute the digests of data sharing a common initial substring." @@ -331,11 +325,11 @@ msgstr "" "回傳雜湊物件的副本(「複製 (clone)」),這可用於高效率地計算出共享同一初始子" "字串的資料之摘要。" -#: ../../library/hashlib.rst:233 +#: ../../library/hashlib.rst:231 msgid "SHAKE variable length digests" msgstr "SHAKE 可變長度摘要" -#: ../../library/hashlib.rst:238 +#: ../../library/hashlib.rst:236 msgid "" "The :func:`shake_128` and :func:`shake_256` algorithms provide variable " "length digests with length_in_bits//2 up to 128 or 256 bits of security. As " @@ -346,7 +340,7 @@ msgstr "" "length_in_bits//2 最高為 128 或 256 位元安全性。因此,他們的摘要方法會需要長" "度。最大長度不受 SHAKE 演算法限制。" -#: ../../library/hashlib.rst:245 +#: ../../library/hashlib.rst:243 msgid "" "Return the digest of the data passed to the :meth:`~hash.update` method so " "far. This is a bytes object of size *length* which may contain bytes in the " @@ -355,7 +349,7 @@ msgstr "" "回傳目前有傳遞給 :meth:`~hash.update` 方法的資料之摘要。這是一個大小為 " "*length* 的位元組物件,可能包含從 0 到 255 的整個範圍內的位元組。" -#: ../../library/hashlib.rst:252 +#: ../../library/hashlib.rst:250 msgid "" "Like :meth:`digest` except the digest is returned as a string object of " "double length, containing only hexadecimal digits. This may be used to " @@ -364,15 +358,15 @@ msgstr "" "與 :meth:`digest` 類似,只不過摘要作為雙倍長度的字串物件回傳,僅包含十六進位" "數字。這可用於交換電子郵件或其他非二進位環境中的值。" -#: ../../library/hashlib.rst:256 +#: ../../library/hashlib.rst:254 msgid "Example use:" msgstr "範例:" -#: ../../library/hashlib.rst:263 +#: ../../library/hashlib.rst:261 msgid "File hashing" msgstr "檔案雜湊" -#: ../../library/hashlib.rst:265 +#: ../../library/hashlib.rst:263 msgid "" "The hashlib module provides a helper function for efficient hashing of a " "file or file-like object." @@ -380,28 +374,36 @@ msgstr "" "hashlib 模組提供了一個輔助函式,用於對檔案或類檔案物件 (file-like object) 進" "行有效率的雜湊。" -#: ../../library/hashlib.rst:270 +#: ../../library/hashlib.rst:268 msgid "" "Return a digest object that has been updated with contents of file object." msgstr "回傳已用檔案物件內容更新的摘要物件。" -#: ../../library/hashlib.rst:272 +#: ../../library/hashlib.rst:270 msgid "" "*fileobj* must be a file-like object opened for reading in binary mode. It " "accepts file objects from builtin :func:`open`, :class:`~io.BytesIO` " "instances, SocketIO objects from :meth:`socket.socket.makefile`, and " -"similar. The function may bypass Python's I/O and use the file descriptor " +"similar. *fileobj* must be opened in blocking mode, otherwise " +"a :exc:`BlockingIOError` may be raised." +msgstr "" +"*fileobj* 必須是以二進位模式讀取的類檔案物件。它接受來自內建 :func:`open` 的" +"檔案物件、:class:`~io.BytesIO` 實例、來自 :meth:`socket.socket.makefile` 的 " +"SocketIO 物件等。*fileobj* 必須以阻塞模式開啟,否則可能會引" +"發 :exc:`BlockingIOError`。" + +#: ../../library/hashlib.rst:276 +msgid "" +"The function may bypass Python's I/O and use the file descriptor " "from :meth:`~io.IOBase.fileno` directly. *fileobj* must be assumed to be in " "an unknown state after this function returns or raises. It is up to the " "caller to close *fileobj*." msgstr "" -"*fileobj* 必須是以二進位模式讀取的類檔案物件。它接受來自內建 :func:`open` 的" -"檔案物件、:class:`~io.BytesIO` 實例、來自 :meth:`socket.socket.makefile` 的 " -"SocketIO 物件等。該函式可以繞過 Python 的 I/O 並直接使用 :meth:`~io.IOBase." -"fileno` 中的檔案描述器 (file descriptor)。在此函式回傳或引發後,必須假定 " -"*fileobj* 處於未知狀態 (unknown state)。由呼叫者決定是否關閉 *fileobj*。" +"該函式可以繞過 Python 的 I/O 並直接使用 :meth:`~io.IOBase.fileno` 中的檔案描" +"述器 (file descriptor)。在此函式回傳或引發後,必須假定 *fileobj* 處於未知狀" +"態 (unknown state)。由呼叫者決定是否關閉 *fileobj*。" -#: ../../library/hashlib.rst:280 +#: ../../library/hashlib.rst:281 msgid "" "*digest* must either be a hash algorithm name as a *str*, a hash " "constructor, or a callable that returns a hash object." @@ -409,15 +411,21 @@ msgstr "" "*digest* 必須是名稱作為 *str* 的雜湊演算法、雜湊建構函式或會回傳雜湊物件的可" "呼叫函式。" -#: ../../library/hashlib.rst:283 +#: ../../library/hashlib.rst:284 msgid "Example:" msgstr "範例:" -#: ../../library/hashlib.rst:306 +#: ../../library/hashlib.rst:305 +msgid "" +"Now raises a :exc:`BlockingIOError` if the file is opened in blocking mode. " +"Previously, spurious null bytes were added to the digest." +msgstr "" + +#: ../../library/hashlib.rst:311 msgid "Key derivation" msgstr "密鑰的生成" -#: ../../library/hashlib.rst:308 +#: ../../library/hashlib.rst:313 msgid "" "Key derivation and key stretching algorithms are designed for secure " "password hashing. Naive algorithms such as ``sha1(password)`` are not " @@ -430,7 +438,7 @@ msgstr "" "的密碼雜湊函式必須是可調校的 (tunable)、緩慢的,並且有包含 `salt(鹽) " "`_。" -#: ../../library/hashlib.rst:316 +#: ../../library/hashlib.rst:321 msgid "" "The function provides PKCS#5 password-based key derivation function 2. It " "uses HMAC as pseudorandom function." @@ -438,7 +446,7 @@ msgstr "" "該函式提供基於密碼的 PKCS#5 密鑰生成函式 2。它使用 HMAC 作為偽隨機函式 " "(pseudorandom function)。" -#: ../../library/hashlib.rst:319 +#: ../../library/hashlib.rst:324 msgid "" "The string *hash_name* is the desired name of the hash digest algorithm for " "HMAC, e.g. 'sha1' or 'sha256'. *password* and *salt* are interpreted as " @@ -448,10 +456,10 @@ msgid "" msgstr "" "字串 *hash_name* 是 HMAC 的雜湊摘要演算法所需的名稱,例如 ``sha1`` 或 " "``sha256``。*password* 和 *salt* 被直譯為位元組緩衝區。應用程式和函式庫應為 " -"*password* 設下合理的長度限制(例如 1024)。*salt* 應該是來自適當來源(例如 :" -"func:`os.urandom`)且大約 16 或更多位元組。" +"*password* 設下合理的長度限制(例如 1024)。*salt* 應該是來自適當來源(例" +"如 :func:`os.urandom`)且大約 16 或更多位元組。" -#: ../../library/hashlib.rst:325 +#: ../../library/hashlib.rst:330 msgid "" "The number of *iterations* should be chosen based on the hash algorithm and " "computing power. As of 2022, hundreds of thousands of iterations of SHA-256 " @@ -464,7 +472,7 @@ msgstr "" "讀 NIST-SP-800-132_ 的 *Appendix A.2.2*。`stackexchange pbkdf2 疊代問題`_\\ " "上的答案有詳細解釋。" -#: ../../library/hashlib.rst:331 +#: ../../library/hashlib.rst:336 msgid "" "*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 " @@ -473,11 +481,11 @@ msgstr "" "*dklen* 是生成的密鑰長度。如果 *dklen* 為 ``None``,則會使用雜湊演算法 " "*hash_name* 的摘要大小,例如 SHA-512 為 64。" -#: ../../library/hashlib.rst:340 +#: ../../library/hashlib.rst:345 msgid "Function only available when Python is compiled with OpenSSL." msgstr "僅當有使用 OpenSSL 編譯 Python 時該函式才可用。" -#: ../../library/hashlib.rst:344 +#: ../../library/hashlib.rst:349 msgid "" "Function now only available when Python is built with OpenSSL. The slow pure " "Python implementation has been removed." @@ -485,13 +493,13 @@ msgstr "" "該函式現在僅在有使用 OpenSSL 建置 Python 時可用。緩慢的純 Python 實作已被刪" "除。" -#: ../../library/hashlib.rst:350 +#: ../../library/hashlib.rst:355 msgid "" "The function provides scrypt password-based key derivation function as " "defined in :rfc:`7914`." msgstr "該函式提供(如 :rfc:`7914` 中所定義的)scrypt 基於密碼的密鑰衍生函式。" -#: ../../library/hashlib.rst:353 +#: ../../library/hashlib.rst:358 msgid "" "*password* and *salt* must be :term:`bytes-like objects `. Applications and libraries should limit *password* to a sensible " @@ -502,7 +510,7 @@ msgstr "" "程式和函式庫應為 *password* 設下合理的長度限制(例如 1024)。*salt* 應該是來" "自適當來源(例如 :func:`os.urandom`)且大約 16 或更多位元組。" -#: ../../library/hashlib.rst:358 +#: ../../library/hashlib.rst:363 msgid "" "*n* is the CPU/Memory cost factor, *r* the block size, *p* parallelization " "factor and *maxmem* limits memory (OpenSSL 1.1.0 defaults to 32 MiB). " @@ -511,17 +519,17 @@ msgstr "" "*n* 是 CPU/記憶體開銷係數、*r* 是區塊大小、*p* 為平行化係數、*maxmem* 為記憶" "體限制(OpenSSL 1.1.0 預設為 32 MiB)。*dklen* 是生成密鑰的長度。" -#: ../../library/hashlib.rst:366 +#: ../../library/hashlib.rst:373 msgid "BLAKE2" msgstr "BLAKE2" -#: ../../library/hashlib.rst:373 +#: ../../library/hashlib.rst:380 msgid "" "BLAKE2_ is a cryptographic hash function defined in :rfc:`7693` that comes " "in two flavors:" msgstr "BLAKE2_ 是在 :rfc:`7693` 中定義的加密雜湊函式,有兩種類型:" -#: ../../library/hashlib.rst:376 +#: ../../library/hashlib.rst:383 msgid "" "**BLAKE2b**, optimized for 64-bit platforms and produces digests of any size " "between 1 and 64 bytes," @@ -529,7 +537,7 @@ msgstr "" "**BLAKE2b**,針對 64 位元平台進行了最佳化,可生成 1 到 64 位元組之間任意大小" "的摘要," -#: ../../library/hashlib.rst:379 +#: ../../library/hashlib.rst:386 msgid "" "**BLAKE2s**, optimized for 8- to 32-bit platforms and produces digests of " "any size between 1 and 32 bytes." @@ -537,7 +545,7 @@ msgstr "" "**BLAKE2s**,針對 8 至 32 位元平台進行了最佳化,可生成 1 至 32 位元組之間任意" "大小的摘要。" -#: ../../library/hashlib.rst:382 +#: ../../library/hashlib.rst:389 msgid "" "BLAKE2 supports **keyed mode** (a faster and simpler replacement for HMAC_), " "**salted hashing**, **personalization**, and **tree hashing**." @@ -545,21 +553,21 @@ msgstr "" "BLAKE2 支援\\ **密鑰模式 (keyed mode)** (更快、更簡單的 HMAC_ 替代品)、**加" "鹽雜湊 (salted hashing)**、**個人化**\\ 和\\ **樹狀雜湊**。" -#: ../../library/hashlib.rst:385 +#: ../../library/hashlib.rst:392 msgid "" -"Hash objects from this module follow the API of standard library's :mod:" -"`hashlib` objects." +"Hash objects from this module follow the API of standard " +"library's :mod:`hashlib` objects." msgstr "該模組中的雜湊物件遵循標準函式庫的 :mod:`hashlib` 物件 API。" -#: ../../library/hashlib.rst:390 +#: ../../library/hashlib.rst:397 msgid "Creating hash objects" msgstr "建立雜湊物件" -#: ../../library/hashlib.rst:392 +#: ../../library/hashlib.rst:399 msgid "New hash objects are created by calling constructor functions:" msgstr "新的雜湊物件是透過呼叫建構函式建立的:" -#: ../../library/hashlib.rst:406 +#: ../../library/hashlib.rst:413 msgid "" "These functions return the corresponding hash objects for calculating " "BLAKE2b or BLAKE2s. They optionally take these general parameters:" @@ -567,7 +575,7 @@ msgstr "" "這些函式回傳相應的雜湊物件以計算 BLAKE2b 或 BLAKE2s。他們可以選擇採用這些通用" "參數:" -#: ../../library/hashlib.rst:409 +#: ../../library/hashlib.rst:416 msgid "" "*data*: initial chunk of data to hash, which must be :term:`bytes-like " "object`. It can be passed only as positional argument." @@ -575,18 +583,18 @@ msgstr "" "*data*:要雜湊的初始資料塊 (data chunk),它必須是\\ :term:`類位元組物件 " "`。它只能作為位置引數傳遞。" -#: ../../library/hashlib.rst:412 +#: ../../library/hashlib.rst:419 msgid "*digest_size*: size of output digest in bytes." msgstr "*digest_size*:輸出摘要的大小(以位元組為單位)。" -#: ../../library/hashlib.rst:414 +#: ../../library/hashlib.rst:421 msgid "" "*key*: key for keyed hashing (up to 64 bytes for BLAKE2b, up to 32 bytes for " "BLAKE2s)." msgstr "" "*key*:用於密鑰雜湊的密鑰(BLAKE2b 最多 64 位元組、BLAKE2s 最多 32 位元組)。" -#: ../../library/hashlib.rst:417 +#: ../../library/hashlib.rst:424 msgid "" "*salt*: salt for randomized hashing (up to 16 bytes for BLAKE2b, up to 8 " "bytes for BLAKE2s)." @@ -594,62 +602,62 @@ msgstr "" "*salt*:用於隨機雜湊的鹽(BLAKE2b 最多 16 個位元組、BLAKE2s 最多 8 個位元" "組)。" -#: ../../library/hashlib.rst:420 +#: ../../library/hashlib.rst:427 msgid "" "*person*: personalization string (up to 16 bytes for BLAKE2b, up to 8 bytes " "for BLAKE2s)." msgstr "" "*person*:個人化字串(BLAKE2b 最多 16 個位元組、BLAKE2s 最多 8 個位元組)。" -#: ../../library/hashlib.rst:423 +#: ../../library/hashlib.rst:430 msgid "The following table shows limits for general parameters (in bytes):" msgstr "下表顯示了一般參數的限制(以位元組為單位):" -#: ../../library/hashlib.rst:426 +#: ../../library/hashlib.rst:433 msgid "Hash" msgstr "雜湊" -#: ../../library/hashlib.rst:426 +#: ../../library/hashlib.rst:433 msgid "digest_size" msgstr "digest_size" -#: ../../library/hashlib.rst:426 +#: ../../library/hashlib.rst:433 msgid "len(key)" msgstr "len(key)" -#: ../../library/hashlib.rst:426 +#: ../../library/hashlib.rst:433 msgid "len(salt)" msgstr "len(salt)" -#: ../../library/hashlib.rst:426 +#: ../../library/hashlib.rst:433 msgid "len(person)" msgstr "len(person)" -#: ../../library/hashlib.rst:428 +#: ../../library/hashlib.rst:435 msgid "BLAKE2b" msgstr "BLAKE2b" -#: ../../library/hashlib.rst:428 +#: ../../library/hashlib.rst:435 msgid "64" msgstr "64" -#: ../../library/hashlib.rst:428 +#: ../../library/hashlib.rst:435 msgid "16" msgstr "16" -#: ../../library/hashlib.rst:429 +#: ../../library/hashlib.rst:436 msgid "BLAKE2s" msgstr "BLAKE2s" -#: ../../library/hashlib.rst:429 +#: ../../library/hashlib.rst:436 msgid "32" msgstr "32" -#: ../../library/hashlib.rst:429 +#: ../../library/hashlib.rst:436 msgid "8" msgstr "8" -#: ../../library/hashlib.rst:434 +#: ../../library/hashlib.rst:441 msgid "" "BLAKE2 specification defines constant lengths for salt and personalization " "parameters, however, for convenience, this implementation accepts byte " @@ -663,26 +671,26 @@ msgstr "" "以像是 ``b'salt`` 和 ``b'salt\\x00`` 是相同的值。(但 *key* 的情況並非如" "此。)" -#: ../../library/hashlib.rst:441 +#: ../../library/hashlib.rst:448 msgid "These sizes are available as module `constants`_ described below." msgstr "這些大小可作為模組\\ `常數 `_\\ 使用,如下所述。" -#: ../../library/hashlib.rst:443 +#: ../../library/hashlib.rst:450 msgid "" "Constructor functions also accept the following tree hashing parameters:" msgstr "建構函式還接受以下樹狀雜湊參數:" -#: ../../library/hashlib.rst:445 +#: ../../library/hashlib.rst:452 msgid "*fanout*: fanout (0 to 255, 0 if unlimited, 1 in sequential mode)." msgstr "*fanout*:扇出(0 到 255,如果無限制則為 0、順序模式為 1)。" -#: ../../library/hashlib.rst:447 +#: ../../library/hashlib.rst:454 msgid "" "*depth*: maximal depth of tree (1 to 255, 255 if unlimited, 1 in sequential " "mode)." msgstr "*depth*:樹的最大深度(1 到 255,如果無限制則為 255、順序模式為 1)。" -#: ../../library/hashlib.rst:450 +#: ../../library/hashlib.rst:457 msgid "" "*leaf_size*: maximal byte length of leaf (0 to ``2**32-1``, 0 if unlimited " "or in sequential mode)." @@ -690,7 +698,7 @@ msgstr "" "*leaf_size*:葉的最大位元組長度(0 到 ``2**32-1``,如果無限制或處於順序模式則" "為 0)。" -#: ../../library/hashlib.rst:453 +#: ../../library/hashlib.rst:460 msgid "" "*node_offset*: node offset (0 to ``2**64-1`` for BLAKE2b, 0 to ``2**48-1`` " "for BLAKE2s, 0 for the first, leftmost, leaf, or in sequential mode)." @@ -698,12 +706,12 @@ msgstr "" "*node_offset*:節點偏移量(BLAKE2b 為 0 到 ``2**64-1``,BLAKE2s 為 0 到 " "``2**48-1``,0 表示第一個、最左邊、葉子或在順序模式下)。" -#: ../../library/hashlib.rst:456 +#: ../../library/hashlib.rst:463 msgid "" "*node_depth*: node depth (0 to 255, 0 for leaves, or in sequential mode)." msgstr "*node_depth*:節點深度(0 到 255,葉為 0,或在順序模式下)。" -#: ../../library/hashlib.rst:458 +#: ../../library/hashlib.rst:465 msgid "" "*inner_size*: inner digest size (0 to 64 for BLAKE2b, 0 to 32 for BLAKE2s, 0 " "in sequential mode)." @@ -711,18 +719,18 @@ msgstr "" "*inner_size*:內部摘要大小(BLAKE2b 為 0 到 64,BLAKE2s 為 0 到 32,順序模式" "為 0)。" -#: ../../library/hashlib.rst:461 +#: ../../library/hashlib.rst:468 msgid "" "*last_node*: boolean indicating whether the processed node is the last one " "(``False`` for sequential mode)." msgstr "" "*last_node*:布林值,代表處理的節點是否為最後一個(``False`` 代表順序模式)。" -#: ../../library/hashlib.rst:464 +#: ../../library/hashlib.rst:471 msgid "Explanation of tree mode parameters." msgstr "樹狀模式參數說明。" -#: ../../library/hashlib.rst:468 +#: ../../library/hashlib.rst:475 msgid "" "See section 2.10 in `BLAKE2 specification `_ for comprehensive review of tree hashing." @@ -730,49 +738,51 @@ msgstr "" "關於樹狀雜湊的綜合回顧,請參閱 `BLAKE2 規範 `_\\ 中的第 2.10 節。" -#: ../../library/hashlib.rst:474 +#: ../../library/hashlib.rst:481 msgid "Constants" msgstr "常數" -#: ../../library/hashlib.rst:479 +#: ../../library/hashlib.rst:486 msgid "Salt length (maximum length accepted by constructors)." msgstr "鹽長度(建構函式接受的最大長度)。" -#: ../../library/hashlib.rst:485 +#: ../../library/hashlib.rst:492 msgid "" "Personalization string length (maximum length accepted by constructors)." msgstr "個人化字串長度(建構函式接受的最大長度)。" -#: ../../library/hashlib.rst:491 +#: ../../library/hashlib.rst:498 msgid "Maximum key size." msgstr "最大密鑰大小。" -#: ../../library/hashlib.rst:497 +#: ../../library/hashlib.rst:504 msgid "Maximum digest size that the hash function can output." msgstr "雜湊函式可以輸出的最大摘要大小。" -#: ../../library/hashlib.rst:501 +#: ../../library/hashlib.rst:508 msgid "Examples" msgstr "範例" -#: ../../library/hashlib.rst:504 +#: ../../library/hashlib.rst:511 msgid "Simple hashing" msgstr "簡單雜湊" -#: ../../library/hashlib.rst:506 +#: ../../library/hashlib.rst:513 msgid "" "To calculate hash of some data, you should first construct a hash object by " -"calling the appropriate constructor function (:func:`blake2b` or :func:" -"`blake2s`), then update it with the data by calling :meth:`~hash.update` on " -"the object, and, finally, get the digest out of the object by calling :meth:" -"`~hash.digest` (or :meth:`~hash.hexdigest` for hex-encoded string)." +"calling the appropriate constructor function (:func:`blake2b` " +"or :func:`blake2s`), then update it with the data by " +"calling :meth:`~hash.update` on the object, and, finally, get the digest out " +"of the object by calling :meth:`~hash.digest` (or :meth:`~hash.hexdigest` " +"for hex-encoded string)." msgstr "" "要計算某些資料的雜湊值,你應該首先透過呼叫適當的建構函式(:func:`blake2b` " -"或 :func:`blake2s`)以建構一個雜湊物件,然後透過於物件呼叫 :meth:`~hash." -"update` 來以資料對它更新,最後透過呼叫 :meth:`~hash.digest`\\ (或對於十六進" -"位編碼字串則為 :meth:`~hash.hexdigest`)從物件中獲得摘要。" +"或 :func:`blake2s`)以建構一個雜湊物件,然後透過於物件呼" +"叫 :meth:`~hash.update` 來以資料對它更新,最後透過呼" +"叫 :meth:`~hash.digest`\\ (或對於十六進位編碼字串則" +"為 :meth:`~hash.hexdigest`)從物件中獲得摘要。" -#: ../../library/hashlib.rst:519 +#: ../../library/hashlib.rst:526 msgid "" "As a shortcut, you can pass the first chunk of data to update directly to " "the constructor as the positional argument:" @@ -780,17 +790,17 @@ msgstr "" "作為一個快捷方式,你可以將要更新的第一個資料塊作為位置引數直接傳遞給建構函" "式:" -#: ../../library/hashlib.rst:526 +#: ../../library/hashlib.rst:533 msgid "" "You can call :meth:`hash.update` as many times as you need to iteratively " "update the hash:" msgstr "你可以根據需求來多次呼叫 :meth:`hash.update` 以疊代更新雜湊:" -#: ../../library/hashlib.rst:540 +#: ../../library/hashlib.rst:547 msgid "Using different digest sizes" msgstr "使用不同的摘要大小" -#: ../../library/hashlib.rst:542 +#: ../../library/hashlib.rst:549 msgid "" "BLAKE2 has configurable size of digests up to 64 bytes for BLAKE2b and up to " "32 bytes for BLAKE2s. For example, to replace SHA-1 with BLAKE2b without " @@ -800,7 +810,7 @@ msgstr "" "組。例如,要在不改變輸出大小的情況下用 BLAKE2b 替換 SHA-1,我們可以指定 " "BLAKE2b 生成 20 位元組的摘要:" -#: ../../library/hashlib.rst:556 +#: ../../library/hashlib.rst:563 msgid "" "Hash objects with different digest sizes have completely different outputs " "(shorter hashes are *not* prefixes of longer hashes); BLAKE2b and BLAKE2s " @@ -809,31 +819,31 @@ msgstr "" "具有不同摘要大小的雜湊物件具有完全不同的輸出(較短的雜湊值\\ *不是*\\ 較長雜" "湊值的前綴);即使輸出長度相同,BLAKE2b 和 BLAKE2s 也會產生不同的輸出:" -#: ../../library/hashlib.rst:572 +#: ../../library/hashlib.rst:579 msgid "Keyed hashing" msgstr "密鑰雜湊 (Keyed hashing)" -#: ../../library/hashlib.rst:574 +#: ../../library/hashlib.rst:581 msgid "" "Keyed hashing can be used for authentication as a faster and simpler " -"replacement for `Hash-based message authentication code `_ (HMAC). BLAKE2 can be securely used in prefix-MAC " -"mode thanks to the indifferentiability property inherited from BLAKE." +"replacement for `Hash-based message authentication code `_ (HMAC). BLAKE2 can be securely used in prefix-" +"MAC mode thanks to the indifferentiability property inherited from BLAKE." msgstr "" "密鑰雜湊可用於身份驗證,作為\\ `基於雜湊的訊息驗證碼 (Hash-based message " "authentication code) `_ (HMAC) 的更快、" "更簡單的替代方案。由於繼承自 BLAKE 的不可微特性 (indifferentiability " "property),BLAKE2 可以安全地用於 prefix-MAC 模式。" -#: ../../library/hashlib.rst:580 +#: ../../library/hashlib.rst:587 msgid "" "This example shows how to get a (hex-encoded) 128-bit authentication code " "for message ``b'message data'`` with key ``b'pseudorandom key'``::" msgstr "" -"此範例示範了如何使用密鑰 ``b'pseudorandom key'`` 獲取訊息 ``b'message " +"此範例示範了如何使用密鑰 ``b'pseudorandom key'`` 取得訊息 ``b'message " "data'`` 的(十六進位編碼)128 位元驗證碼: ::" -#: ../../library/hashlib.rst:583 +#: ../../library/hashlib.rst:590 msgid "" ">>> from hashlib import blake2b\n" ">>> h = blake2b(key=b'pseudorandom key', digest_size=16)\n" @@ -847,7 +857,7 @@ msgstr "" ">>> h.hexdigest()\n" "'3d363ff7401e02026f4a4687d4863ced'" -#: ../../library/hashlib.rst:590 +#: ../../library/hashlib.rst:597 msgid "" "As a practical example, a web application can symmetrically sign cookies " "sent to users and later verify them to make sure they weren't tampered with::" @@ -855,7 +865,7 @@ msgstr "" "舉一個實際的例子,網頁應用程式可以對發送給使用者的 cookie 進行對稱簽名 " "(symmetrically sign),然後驗證它們以確保它們沒有被篡改: ::" -#: ../../library/hashlib.rst:593 +#: ../../library/hashlib.rst:600 msgid "" ">>> from hashlib import blake2b\n" ">>> from hmac import compare_digest\n" @@ -909,7 +919,7 @@ msgstr "" ">>> verify(cookie, b'0102030405060708090a0b0c0d0e0f00')\n" "False" -#: ../../library/hashlib.rst:619 +#: ../../library/hashlib.rst:626 msgid "" "Even though there's a native keyed hashing mode, BLAKE2 can, of course, be " "used in HMAC construction with :mod:`hmac` module::" @@ -917,7 +927,7 @@ msgstr "" "儘管有原生密鑰雜湊模式,BLAKE2 還是可以透過 :mod:`hmac` 模組用於建構 " "HMAC: ::" -#: ../../library/hashlib.rst:622 +#: ../../library/hashlib.rst:629 msgid "" ">>> import hmac, hashlib\n" ">>> m = hmac.new(b'secret key', digestmod=hashlib.blake2s)\n" @@ -931,11 +941,11 @@ msgstr "" ">>> m.hexdigest()\n" "'e3c8102868d28b5ff85fc35dda07329970d1a01e273c37481326fe0c861c8142'" -#: ../../library/hashlib.rst:630 +#: ../../library/hashlib.rst:637 msgid "Randomized hashing" msgstr "隨機雜湊 (Randomized hashing)" -#: ../../library/hashlib.rst:632 +#: ../../library/hashlib.rst:639 msgid "" "By setting *salt* parameter users can introduce randomization to the hash " "function. Randomized hashing is useful for protecting against collision " @@ -944,7 +954,7 @@ msgstr "" "透過設定 *salt* 參數,使用者可以向雜湊函式引入隨機化。隨機雜湊在防止針對數位" "簽章中雜湊函式的碰撞攻擊 (collision attacks) 非常有用。" -#: ../../library/hashlib.rst:636 +#: ../../library/hashlib.rst:643 msgid "" "Randomized hashing is designed for situations where one party, the message " "preparer, generates all or part of a message to be signed by a second party, " @@ -968,14 +978,14 @@ msgstr "" "方(訊息簽名者)簽名。如果訊息準備者能夠發現加密雜湊函式發生碰撞(collision," "即兩條訊息產生相同的雜湊值),那麼他們可能會準備有意義的訊息版本,該版本將產" "生相同的雜湊值和數位簽章,但結果不同(例如,將 $1,000,000 轉入賬戶,而不是 " -"$10)。加密雜湊函式的設計以抗碰撞性為主要目標,但當前對加密雜湊函式攻擊的關注" +"$10)。加密雜湊函式的設計以抗碰撞性為主要目標,但目前對加密雜湊函式攻擊的關注" "可能會導致給定的加密雜湊函式所提供的抗碰撞性低於預期。隨機雜湊透過降低準備者" "在數位簽章生成過程中生成最終產生相同雜湊值的兩個或多個訊息的可能性,為簽名者" "提供額外的保護 —— 即便嘗試去找到雜湊函式碰撞的發生是實際可行的。然而,若訊息" "的所有部分都是由簽名者所準備好的,使用隨機雜湊可能會降低數位簽章提供的安全" "性。" -#: ../../library/hashlib.rst:655 +#: ../../library/hashlib.rst:662 msgid "" "(`NIST SP-800-106 \"Randomized Hashing for Digital Signatures\" `_)" @@ -983,7 +993,7 @@ msgstr "" "(`NIST SP-800-106 「數位簽章的隨機雜湊 (Randomized Hashing for Digital " "Signatures)」 `_)" -#: ../../library/hashlib.rst:658 +#: ../../library/hashlib.rst:665 msgid "" "In BLAKE2 the salt is processed as a one-time input to the hash function " "during initialization, rather than as an input to each compression function." @@ -991,7 +1001,7 @@ msgstr "" "在 BLAKE2 中,鹽在初始化期間作為雜湊函式的一次性輸入被處理,而不是作為每個壓" "縮函式的輸入。" -#: ../../library/hashlib.rst:663 +#: ../../library/hashlib.rst:670 msgid "" "*Salted hashing* (or just hashing) with BLAKE2 or any other general-purpose " "cryptographic hash function, such as SHA-256, is not suitable for hashing " @@ -1002,11 +1012,11 @@ msgstr "" "純雜湊)不適合對密碼進行雜湊處理。有關更多資訊,請參閱 `BLAKE2 FAQ `_ 。" -#: ../../library/hashlib.rst:686 +#: ../../library/hashlib.rst:693 msgid "Personalization" msgstr "個人化" -#: ../../library/hashlib.rst:688 +#: ../../library/hashlib.rst:695 msgid "" "Sometimes it is useful to force hash function to produce different digests " "for the same input for different purposes. Quoting the authors of the Skein " @@ -1015,7 +1025,7 @@ msgstr "" "有時候強制雜湊函式為不同目的的相同輸入生成不同的摘要是很有用的。引用 Skein 雜" "湊函式的作者的話:" -#: ../../library/hashlib.rst:692 +#: ../../library/hashlib.rst:699 msgid "" "We recommend that all application designers seriously consider doing this; " "we have seen many protocols where a hash that is computed in one part of the " @@ -1024,12 +1034,12 @@ msgid "" "force the application to make the hash inputs the same. Personalizing each " "hash function used in the protocol summarily stops this type of attack." msgstr "" -"我們建議所有應用程式設計者認真考慮這樣做;我們已經看到許多協議,其中在協議的" +"我們建議所有應用程式設計者認真考慮這樣做;我們已經看到許多協定,其中在協定的" "一個部分中計算的雜湊可以在完全不同的部分中使用,因為兩次雜湊計算是在相似或相" -"關的資料上完成的,並且攻擊者可以強制應用程式將雜湊輸入設為相同的。對協議中使" +"關的資料上完成的,並且攻擊者可以強制應用程式將雜湊輸入設為相同的。對協定中使" "用的每個雜湊函式進行個人化可以立即阻止此類攻擊。" -#: ../../library/hashlib.rst:699 +#: ../../library/hashlib.rst:706 msgid "" "(`The Skein Hash Function Family `_, p. 21)" @@ -1037,11 +1047,11 @@ msgstr "" "(`Skein 雜湊函式系列 `_,第 21 頁)" -#: ../../library/hashlib.rst:703 +#: ../../library/hashlib.rst:710 msgid "BLAKE2 can be personalized by passing bytes to the *person* argument::" msgstr "BLAKE2 可以透過將位元組傳遞給 *person* 引數來做個人化: ::" -#: ../../library/hashlib.rst:705 +#: ../../library/hashlib.rst:712 msgid "" ">>> from hashlib import blake2b\n" ">>> FILES_HASH_PERSON = b'MyApp Files Hash'\n" @@ -1067,21 +1077,21 @@ msgstr "" ">>> h.hexdigest()\n" "'cf68fb5761b9c44e7878bfb2c4c9aea52264a80b75005e65619778de59f383a3'" -#: ../../library/hashlib.rst:717 +#: ../../library/hashlib.rst:724 msgid "" "Personalization together with the keyed mode can also be used to derive " "different keys from a single one." msgstr "個人化與密鑰模式還可以一起用於從單個密鑰得出不同的密鑰。" -#: ../../library/hashlib.rst:731 +#: ../../library/hashlib.rst:738 msgid "Tree mode" msgstr "樹狀模式" -#: ../../library/hashlib.rst:733 +#: ../../library/hashlib.rst:740 msgid "Here's an example of hashing a minimal tree with two leaf nodes::" msgstr "下面是對具有兩個葉節點的最小樹進行雜湊處理的範例: ::" -#: ../../library/hashlib.rst:735 +#: ../../library/hashlib.rst:742 msgid "" " 10\n" " / \\\n" @@ -1091,13 +1101,13 @@ msgstr "" " / \\\n" "00 01" -#: ../../library/hashlib.rst:739 +#: ../../library/hashlib.rst:746 msgid "" "This example uses 64-byte internal digests, and returns the 32-byte final " "digest::" msgstr "此範例使用 64-byte 內部摘要,並回傳 32-byte 最終摘要: ::" -#: ../../library/hashlib.rst:742 +#: ../../library/hashlib.rst:749 msgid "" ">>> from hashlib import blake2b\n" ">>>\n" @@ -1151,11 +1161,11 @@ msgstr "" ">>> h10.hexdigest()\n" "'3ad2a9b37c6070e374c7a8c508fe20ca86b6ed54e286e93a0318e95e881db5aa'" -#: ../../library/hashlib.rst:769 +#: ../../library/hashlib.rst:776 msgid "Credits" msgstr "製作人員" -#: ../../library/hashlib.rst:771 +#: ../../library/hashlib.rst:778 msgid "" "BLAKE2_ was designed by *Jean-Philippe Aumasson*, *Samuel Neves*, *Zooko " "Wilcox-O'Hearn*, and *Christian Winnerlein* based on SHA-3_ finalist BLAKE_ " @@ -1167,13 +1177,13 @@ msgstr "" "Henzen*、*Willi Meier* 和 *Raphael C.-W. Phan* 所建立的 SHA-3_ 最終版本 " "BLAKE_。" -#: ../../library/hashlib.rst:776 +#: ../../library/hashlib.rst:783 msgid "" "It uses core algorithm from ChaCha_ cipher designed by *Daniel J. " "Bernstein*." msgstr "它使用 *Daniel J. Bernstein* 設計的 ChaCha_ 密碼的核心演算法。" -#: ../../library/hashlib.rst:778 +#: ../../library/hashlib.rst:785 msgid "" "The stdlib implementation is based on pyblake2_ module. It was written by " "*Dmitry Chestnykh* based on C implementation written by *Samuel Neves*. The " @@ -1183,17 +1193,17 @@ msgstr "" "Neves* 的 C 版本實作為基礎所編寫的。該文件是由 *Dmitry Chestnykh* 編寫並從 " "pyblake2_ 複製過來的。" -#: ../../library/hashlib.rst:782 +#: ../../library/hashlib.rst:789 msgid "The C code was partly rewritten for Python by *Christian Heimes*." msgstr "*Christian Heimes* 為 Python 重寫了部分 C 程式碼。" -#: ../../library/hashlib.rst:784 +#: ../../library/hashlib.rst:791 msgid "" "The following public domain dedication applies for both C hash function " "implementation, extension code, and this documentation:" msgstr "以下公開領域貢獻適用於 C 雜湊函式實作、擴充程式碼和此文件:" -#: ../../library/hashlib.rst:787 +#: ../../library/hashlib.rst:794 msgid "" "To the extent possible under law, the author(s) have dedicated all copyright " "and related and neighboring rights to this software to the public domain " @@ -1202,7 +1212,7 @@ msgstr "" "在法律允許的範圍內,作者已將該軟體的所有版權以及相關和鄰接權利奉獻給全球的公" "開領域。該軟體的發布沒有任何授權 (warranty)。" -#: ../../library/hashlib.rst:791 +#: ../../library/hashlib.rst:798 msgid "" "You should have received a copy of the CC0 Public Domain Dedication along " "with this software. If not, see https://creativecommons.org/publicdomain/" @@ -1212,7 +1222,7 @@ msgstr "" "Dedication) 的副本。如果沒有,請參閱 https://creativecommons.org/" "publicdomain/zero/1.0/ 。" -#: ../../library/hashlib.rst:795 +#: ../../library/hashlib.rst:802 msgid "" "The following people have helped with development or contributed their " "changes to the project and the public domain according to the Creative " @@ -1221,55 +1231,55 @@ msgstr "" "以下人員根據創用 CC 通用公眾領域貢獻宣告 1.0 (Creative Commons Public Domain " "Dedication 1.0 Universal) 於專案和公開領域做出了開發或貢獻:" -#: ../../library/hashlib.rst:799 +#: ../../library/hashlib.rst:806 msgid "*Alexandr Sokolovskiy*" msgstr "*Alexandr Sokolovskiy*" -#: ../../library/hashlib.rst:819 +#: ../../library/hashlib.rst:827 msgid "Module :mod:`hmac`" msgstr ":mod:`hmac` 模組" -#: ../../library/hashlib.rst:820 +#: ../../library/hashlib.rst:828 msgid "A module to generate message authentication codes using hashes." msgstr "使用雜湊生成訊息驗證程式碼的模組。" -#: ../../library/hashlib.rst:822 +#: ../../library/hashlib.rst:830 msgid "Module :mod:`base64`" msgstr ":mod:`base64` 模組" -#: ../../library/hashlib.rst:823 +#: ../../library/hashlib.rst:831 msgid "Another way to encode binary hashes for non-binary environments." msgstr "另一種在非二進位環境中編碼二進位雜湊的方法。" -#: ../../library/hashlib.rst:825 +#: ../../library/hashlib.rst:833 msgid "https://nvlpubs.nist.gov/nistpubs/fips/nist.fips.180-4.pdf" msgstr "https://nvlpubs.nist.gov/nistpubs/fips/nist.fips.180-4.pdf" -#: ../../library/hashlib.rst:826 +#: ../../library/hashlib.rst:834 msgid "The FIPS 180-4 publication on Secure Hash Algorithms." msgstr "有關安全雜湊演算法的 FIPS 180-4 出版物。" -#: ../../library/hashlib.rst:828 +#: ../../library/hashlib.rst:836 msgid "https://csrc.nist.gov/pubs/fips/202/final" msgstr "https://csrc.nist.gov/pubs/fips/202/final" -#: ../../library/hashlib.rst:829 +#: ../../library/hashlib.rst:837 msgid "The FIPS 202 publication on the SHA-3 Standard." msgstr "有關 SHA-3 標準的 FIPS 202 出版物。" -#: ../../library/hashlib.rst:831 +#: ../../library/hashlib.rst:839 msgid "https://www.blake2.net/" msgstr "https://www.blake2.net/" -#: ../../library/hashlib.rst:832 +#: ../../library/hashlib.rst:840 msgid "Official BLAKE2 website." msgstr "BLAKE2 官方網站。" -#: ../../library/hashlib.rst:834 +#: ../../library/hashlib.rst:842 msgid "https://en.wikipedia.org/wiki/Cryptographic_hash_function" msgstr "https://en.wikipedia.org/wiki/Cryptographic_hash_function" -#: ../../library/hashlib.rst:835 +#: ../../library/hashlib.rst:843 msgid "" "Wikipedia article with information on which algorithms have known issues and " "what that means regarding their use." @@ -1277,21 +1287,21 @@ msgstr "" "包含有關哪些演算法存在已知問題以及這些問題對其使用意味著什麼資訊的維基百科文" "章。" -#: ../../library/hashlib.rst:838 +#: ../../library/hashlib.rst:846 msgid "https://www.ietf.org/rfc/rfc8018.txt" msgstr "https://www.ietf.org/rfc/rfc8018.txt" -#: ../../library/hashlib.rst:839 +#: ../../library/hashlib.rst:847 msgid "PKCS #5: Password-Based Cryptography Specification Version 2.1" msgstr "PKCS #5:基於密碼的加密規範版本 2.1" -#: ../../library/hashlib.rst:841 +#: ../../library/hashlib.rst:849 msgid "" "https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf" msgstr "" "https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf" -#: ../../library/hashlib.rst:842 +#: ../../library/hashlib.rst:850 msgid "NIST Recommendation for Password-Based Key Derivation." msgstr "NIST(美國國家標準技術研究院)針對基於密碼的密鑰衍生的建議。" @@ -1307,14 +1317,14 @@ msgstr "" "安全雜湊演算法、SHA1、SHA2、SHA224、SHA256、SHA384、SHA512、SHA3、Shake、" "Blake2" -#: ../../library/hashlib.rst:55 +#: ../../library/hashlib.rst:53 msgid "OpenSSL" msgstr "OpenSSL" -#: ../../library/hashlib.rst:55 +#: ../../library/hashlib.rst:53 msgid "(use in module hashlib)" msgstr "(使用於 hashlib 模組中)" -#: ../../library/hashlib.rst:370 +#: ../../library/hashlib.rst:377 msgid "blake2b, blake2s" msgstr "blake2b, blake2s" diff --git a/library/heapq.po b/library/heapq.po index 41ee95e112..fb9399796c 100644 --- a/library/heapq.po +++ b/library/heapq.po @@ -6,7 +6,7 @@ # 周 忠毅 , 2016 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2023-07-01 18:20+0800\n" @@ -123,8 +123,8 @@ msgstr "在線性時間內將 list *x* 轉為 heap,且過程不會申請額外 #: ../../library/heapq.rst:71 msgid "" "Pop and return the smallest item from the *heap*, and also push the new " -"*item*. The heap size doesn't change. If the heap is empty, :exc:" -"`IndexError` is raised." +"*item*. The heap size doesn't change. If the heap is " +"empty, :exc:`IndexError` is raised." msgstr "" "從 *heap* 取出並回傳最小的元素,接著將新的 *item* 放進heap。heap 的大小不會改" "變。如果 heap 是空的會產生 :exc:`IndexError` 錯誤。" @@ -220,26 +220,26 @@ msgid "" "Return a list with the *n* smallest elements from the dataset defined by " "*iterable*. *key*, if provided, specifies a function of one argument that " "is used to extract a comparison key from each element in *iterable* (for " -"example, ``key=str.lower``). Equivalent to: ``sorted(iterable, key=key)[:" -"n]``." +"example, ``key=str.lower``). Equivalent to: ``sorted(iterable, key=key)" +"[:n]``." msgstr "" "回傳一個包含資料 *iterable* 中前 *n* 小元素的 list 。如果有指定 *key* 引數," "*key* 會是只有一個引數的函式,用來從每一個在 *iterable* 中的元素提取一個比較" -"的依據(例如 ``key=str.lower`` )。效果相當於 ``sorted(iterable, key=key)[:" -"n]`` 。" +"的依據(例如 ``key=str.lower`` )。效果相當於 ``sorted(iterable, key=key)" +"[:n]`` 。" #: ../../library/heapq.rst:130 msgid "" "The latter two functions perform best for smaller values of *n*. For larger " "values, it is more efficient to use the :func:`sorted` function. Also, when " -"``n==1``, it is more efficient to use the built-in :func:`min` and :func:" -"`max` functions. If repeated usage of these functions is required, consider " -"turning the iterable into an actual heap." +"``n==1``, it is more efficient to use the built-in :func:`min` " +"and :func:`max` functions. If repeated usage of these functions is " +"required, consider turning the iterable into an actual heap." msgstr "" -"後兩個函式在 *n* 值比較小時有最好的表現。對於較大的 *n* 值,只用 :func:" -"`sorted` 函式會更有效率。同樣地,當 ``n==1`` 時,使用內建函式 :func:`min` " -"和 :func:`max` 會有更好的效率。如果需要重複使用這些函式,可以考慮將 iterable " -"轉成真正的 heap 。" +"後兩個函式在 *n* 值比較小時有最好的表現。對於較大的 *n* 值,只" +"用 :func:`sorted` 函式會更有效率。同樣地,當 ``n==1`` 時,使用內建函" +"式 :func:`min` 和 :func:`max` 會有更好的效率。如果需要重複使用這些函式,可以" +"考慮將 iterable 轉成真正的 heap 。" #: ../../library/heapq.rst:138 msgid "Basic Examples" @@ -358,10 +358,10 @@ msgid "" "returned in the order they were added. And since no two entry counts are the " "same, the tuple comparison will never attempt to directly compare two tasks." msgstr "" -"一個針對前兩個問題的解法是:儲存一個包含 priority 、 entry count 和 task 三個" -"元素的 tuple 。兩個 task 有相同 priority 時, entry count 會讓兩個 task 能根" -"據加入的順序排序。因為沒有任何兩個 task 擁有相同的 entry count ,所以永遠不會" -"直接使用 task 做比較。" +"一個針對前兩個問題的解法是:儲存一個包含 priority、entry count 和 task 三個元" +"素的 tuple 。兩個 task 有相同 priority 時,entry count 會讓兩個 task 能根據加" +"入的順序排序。因為沒有任何兩個 task 擁有相同的 entry count,所以永遠不會直接" +"使用 task 做比較。" #: ../../library/heapq.rst:192 msgid "" @@ -439,6 +439,33 @@ msgid "" " return task\n" " raise KeyError('pop from an empty priority queue')" msgstr "" +"pq = [] # 在 heap 中的 entry 串列\n" +"entry_finder = {} # task 對應到 entry 的對映\n" +"REMOVED = '' # 被刪除的 task 的佔位器\n" +"counter = itertools.count() # 唯一的序列計數\n" +"\n" +"def add_task(task, priority=0):\n" +" '新增一個 task 或更新一個已存在 task 的 priority'\n" +" if task in entry_finder:\n" +" remove_task(task)\n" +" count = next(counter)\n" +" entry = [priority, count, task]\n" +" entry_finder[task] = entry\n" +" heappush(pq, entry)\n" +"\n" +"def remove_task(task):\n" +" '將一個已存在的 task 標記為 REMOVED。如果找不到會引發 KeyError。'\n" +" entry = entry_finder.pop(task)\n" +" entry[-1] = REMOVED\n" +"\n" +"def pop_task():\n" +" '移除並回傳最低 priority 的 task。如果 heap 是空的會引發 KeyError。'\n" +" while pq:\n" +" priority, count, task = heappop(pq)\n" +" if task is not REMOVED:\n" +" del entry_finder[task]\n" +" return task\n" +" raise KeyError('從空的優先佇列中 pop 出元素')" #: ../../library/heapq.rst:241 msgid "Theory" @@ -566,7 +593,7 @@ msgstr "" "序涉及 \"runs\" 的產生(也就是預先排序的序列,其大小通常與 CPU 記憶體的大小有" "關),之後再對這些 run 合併,而這些合併的過程通常相當巧妙 [#]_。很重要的一點" "是,初始排序產生的 run 越長越好。錦標賽是達成這一點的好方法,若你用所有可用記" -"憶體來舉行一場錦標賽,並透過替換與向下交換來處理所有適配當前 run 的值,那麼對" +"憶體來舉行一場錦標賽,並透過替換與向下交換來處理所有適配目前 run 的值,那麼對" "於隨機產生的輸入,將可以產生長度兩倍於記憶體大小的 run。對於已模糊排序過的輸" "入,效果更好。" @@ -580,7 +607,7 @@ msgid "" "the first heap is melting. When the first heap completely vanishes, you " "switch heaps and start a new run. Clever and quite effective!" msgstr "" -"此外,若你將索引為 0 的項目輸出至磁碟,並取得一個無法適配當前錦標賽的輸入(因" +"此外,若你將索引為 0 的項目輸出至磁碟,並取得一個無法適配目前錦標賽的輸入(因" "為該值「勝過」最後的輸出值),則該輸入值就無法插入至 heap 當中,因此 heap 的" "大小會減小。釋放出來的記憶體可以巧妙地立即再被運用,逐步建構出第二個 heap,其" "大小增加的速度會與第一個 heap 減少的速度一致。當第一個 heap 完全消失時,你可" diff --git a/library/hmac.po b/library/hmac.po index 6dea034e07..1fa7d828ed 100644 --- a/library/hmac.po +++ b/library/hmac.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,9 +6,9 @@ # Phil Lin , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-09 00:03+0000\n" +"POT-Creation-Date: 2025-07-16 00:16+0000\n" "PO-Revision-Date: 2022-03-30 00:16+0800\n" "Last-Translator: Phil Lin \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -30,10 +29,16 @@ msgid "**Source code:** :source:`Lib/hmac.py`" msgstr "**原始碼:**\\ :source:`Lib/hmac.py`" #: ../../library/hmac.rst:14 -msgid "This module implements the HMAC algorithm as described by :rfc:`2104`." -msgstr "此模組 (module) 實現了 :rfc:`2014` 所描述的 HMAC 演算法。" +msgid "" +"This module implements the HMAC algorithm as described by :rfc:`2104`. The " +"interface allows to use any hash function with a *fixed* digest size. In " +"particular, extendable output functions such as SHAKE-128 or SHAKE-256 " +"cannot be used with HMAC." +msgstr "" +"此模組實作了 :rfc:`2014` 所描述的 HMAC 演算法。此介面允許使用具有\\ *固定*\\ 摘要 (digest) 長" +"度的任意雜湊函式。要特別注意的是擴充輸出函式(如 SHAKE-128 或 SHAKE-256)不能與 HMAC 一起使用。" -#: ../../library/hmac.rst:19 +#: ../../library/hmac.rst:22 msgid "" "Return a new hmac object. *key* is a bytes or bytearray object giving the " "secret key. If *msg* is present, the method call ``update(msg)`` is made. " @@ -46,7 +51,7 @@ msgstr "" "所用的摘要名稱、摘要建構函式 (constructor) 或模組。它可以是適用於 :func:" "`hashlib.new` 的任何名稱。儘管該引數的位置在後,但它卻是必須的。" -#: ../../library/hmac.rst:25 +#: ../../library/hmac.rst:28 msgid "" "Parameter *key* can be a bytes or bytearray object. Parameter *msg* can be " "of any type supported by :mod:`hashlib`. Parameter *digestmod* can be the " @@ -55,7 +60,7 @@ msgstr "" "參數 *key* 可以為 bytes 或 bytearray 物件。參數 *msg* 可以為 :mod:`hashlib` " "所支援的任意型別。參數 *digestmod* 可以為雜湊演算法的名稱。" -#: ../../library/hmac.rst:30 +#: ../../library/hmac.rst:33 msgid "" "The *digestmod* argument is now required. Pass it as a keyword argument to " "avoid awkwardness when you do not have an initial *msg*." @@ -63,7 +68,7 @@ msgstr "" "*digestmod* 引數現在是必須的。請將其作為關鍵字引數傳入以避免當你沒有初始 " "*msg* 時導致的麻煩。" -#: ../../library/hmac.rst:37 +#: ../../library/hmac.rst:40 msgid "" "Return digest of *msg* for given secret *key* and *digest*. The function is " "equivalent to ``HMAC(key, msg, digest).digest()``, but uses an optimized C " @@ -76,7 +81,7 @@ msgstr "" "implementation),對放入記憶體的訊息能處理得更快。參數 *key*、*msg* 和 " "*digest* 在 :func:`~hmac.new` 中具有相同含義。" -#: ../../library/hmac.rst:43 +#: ../../library/hmac.rst:46 msgid "" "CPython implementation detail, the optimized C implementation is only used " "when *digest* is a string and name of a digest algorithm, which is supported " @@ -85,11 +90,11 @@ msgstr "" "作為 CPython 的實現細節,C 的優化實作只有當 *digest* 為字串並且是一個 " "OpenSSL 所支持的摘要演算法的名稱時才會被使用。" -#: ../../library/hmac.rst:50 +#: ../../library/hmac.rst:53 msgid "An HMAC object has the following methods:" msgstr "HMAC 物件具有下列方法 (method):" -#: ../../library/hmac.rst:54 +#: ../../library/hmac.rst:57 msgid "" "Update the hmac object with *msg*. Repeated calls are equivalent to a " "single call with the concatenation of all the arguments: ``m.update(a); m." @@ -98,22 +103,22 @@ msgstr "" "用 *msg* 來更新 hmac 物件。重複呼叫相當於單次呼叫並傳入所有引數的拼接結果:" "``m.update(a); m.update(b)`` 等價於 ``m.update(a + b)``。" -#: ../../library/hmac.rst:58 +#: ../../library/hmac.rst:61 msgid "Parameter *msg* can be of any type supported by :mod:`hashlib`." msgstr "參數 *msg* 可以是 :mod:`hashlib` 所支援的任何型別。" -#: ../../library/hmac.rst:64 +#: ../../library/hmac.rst:67 msgid "" "Return the digest of the bytes passed to the :meth:`update` method so far. " "This bytes object will be the same length as the *digest_size* of the digest " "given to the constructor. It may contain non-ASCII bytes, including NUL " "bytes." msgstr "" -"回傳當前已傳給 :meth:`update` 方法的 bytes 摘要。這個 bytes 物件的長度會與傳" +"回傳目前已傳給 :meth:`update` 方法的 bytes 摘要。這個 bytes 物件的長度會與傳" "給建構函式的摘要 *digest_size* 的長度相同。它可以包含 NUL bytes 以及 non-" "ASCII bytes。" -#: ../../library/hmac.rst:71 +#: ../../library/hmac.rst:74 msgid "" "When comparing the output of :meth:`digest` to an externally supplied digest " "during a verification routine, it is recommended to use the :func:" @@ -124,7 +129,7 @@ msgstr "" "較時,建議使用 :func:`compare_digest` 函式而不是 ``==`` 運算子以減少被定時攻" "擊時的漏洞。" -#: ../../library/hmac.rst:79 +#: ../../library/hmac.rst:82 msgid "" "Like :meth:`digest` except the digest is returned as a string twice the " "length containing only hexadecimal digits. This may be used to exchange the " @@ -133,7 +138,7 @@ msgstr "" "像是 :meth:`digest` 但摘要的回傳形式為兩倍長度的字串,且此字串只包含十六進位" "數位。這可以被用於在電子郵件或其他非二進位制環境中安全地交換數據。" -#: ../../library/hmac.rst:85 +#: ../../library/hmac.rst:88 msgid "" "When comparing the output of :meth:`hexdigest` to an externally supplied " "digest during a verification routine, it is recommended to use the :func:" @@ -144,7 +149,7 @@ msgstr "" "比較時,建議使用 :func:`compare_digest` 函式而不是 ``==`` 運算子以減少被定時" "攻擊時的漏洞。" -#: ../../library/hmac.rst:93 +#: ../../library/hmac.rst:96 msgid "" "Return a copy (\"clone\") of the hmac object. This can be used to " "efficiently compute the digests of strings that share a common initial " @@ -153,23 +158,23 @@ msgstr "" "回傳 hmac 物件的拷貝 (\"clone\")。這可以被用來有效率地計算那些共享相同初始子" "字串的字串的摘要。" -#: ../../library/hmac.rst:97 +#: ../../library/hmac.rst:100 msgid "A hash object has the following attributes:" msgstr "一個 hash 物件具有以下屬性:" -#: ../../library/hmac.rst:101 +#: ../../library/hmac.rst:104 msgid "The size of the resulting HMAC digest in bytes." msgstr "以 bytes 表示最終 HMAC 摘要的大小。" -#: ../../library/hmac.rst:105 +#: ../../library/hmac.rst:108 msgid "The internal block size of the hash algorithm in bytes." msgstr "以 bytes 表示雜湊演算法的內部區塊大小。" -#: ../../library/hmac.rst:111 +#: ../../library/hmac.rst:114 msgid "The canonical name of this HMAC, always lowercase, e.g. ``hmac-md5``." msgstr "HMAC 的正準名稱總是為小寫形式,例如 ``hmac-md5``。" -#: ../../library/hmac.rst:116 +#: ../../library/hmac.rst:119 msgid "" "Removed the undocumented attributes ``HMAC.digest_cons``, ``HMAC.inner``, " "and ``HMAC.outer``." @@ -177,11 +182,11 @@ msgstr "" "未寫入文件的屬性 ``HMAC.digest_cons``,``HMAC.inner`` 和 ``HMAC.outer`` 已被" "移除。" -#: ../../library/hmac.rst:120 +#: ../../library/hmac.rst:123 msgid "This module also provides the following helper function:" msgstr "這個模組還提供了下列輔助函式:" -#: ../../library/hmac.rst:124 +#: ../../library/hmac.rst:127 msgid "" "Return ``a == b``. This function uses an approach designed to prevent " "timing analysis by avoiding content-based short circuiting behaviour, making " @@ -194,24 +199,24 @@ msgstr "" "`str`\\ (僅限 ASCII,如 :meth:`HMAC.hexdigest` 的回傳值),或者是 :term:" "`bytes-like object`。" -#: ../../library/hmac.rst:132 +#: ../../library/hmac.rst:135 msgid "" "If *a* and *b* are of different lengths, or if an error occurs, a timing " "attack could theoretically reveal information about the types and lengths of " "*a* and *b*—but not their values." msgstr "" -"如果 *a* 和 *b* 具有不同的長度,或者如果發生了錯誤,定時攻擊在理論上可以獲取" -"有關 *a* 和 *b* 的型別和長度的訊息 — 但不能獲取他們的值。" +"如果 *a* 和 *b* 具有不同的長度,或者如果發生了錯誤,定時攻擊在理論上可以取得" +"有關 *a* 和 *b* 的型別和長度的訊息 — 但不能取得他們的值。" -#: ../../library/hmac.rst:140 +#: ../../library/hmac.rst:143 msgid "" "The function uses OpenSSL's ``CRYPTO_memcmp()`` internally when available." msgstr "此函式在可能的情況下會在內部使用 OpenSSL 的 ``CRYPTO_memcmp()``。" -#: ../../library/hmac.rst:146 +#: ../../library/hmac.rst:149 msgid "Module :mod:`hashlib`" msgstr ":mod:`hashlib` 模組" -#: ../../library/hmac.rst:147 +#: ../../library/hmac.rst:150 msgid "The Python module providing secure hash functions." msgstr "Python 模組提供安全的雜湊函式。" diff --git a/library/html.entities.po b/library/html.entities.po index 369e99c012..1131e507aa 100644 --- a/library/html.entities.po +++ b/library/html.entities.po @@ -6,7 +6,7 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-05-09 00:03+0000\n" "PO-Revision-Date: 2022-06-27 09:38+0800\n" diff --git a/library/html.parser.po b/library/html.parser.po index 69c985c715..da6a091b3e 100644 --- a/library/html.parser.po +++ b/library/html.parser.po @@ -5,9 +5,9 @@ # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.12\n" +"Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-05-08 00:15+0000\n" "PO-Revision-Date: 2023-05-04 22:54+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -57,8 +57,8 @@ msgid "" "methods to implement the desired behavior." msgstr "" ":class:`.HTMLParser` 實例被提供 HTML 資料,並在遇到開始標籤、結束標籤、文本、" -"註解和其他標記元素時呼叫處理程式 (handler) 方法。使用者應該繼承 :class:`." -"HTMLParser` 並覆蓋其方法以實作所需的行為。" +"註解和其他標記元素時呼叫處理程式 (handler) 方法。使用者應該繼" +"承 :class:`.HTMLParser` 並覆蓋其方法以實作所需的行為。" #: ../../library/html.parser.rst:31 msgid "" @@ -83,12 +83,12 @@ msgstr "HTML 剖析器應用程式範例" #: ../../library/html.parser.rst:44 msgid "" -"As a basic example, below is a simple HTML parser that uses the :class:" -"`HTMLParser` class to print out start tags, end tags, and data as they are " -"encountered::" +"As a basic example, below is a simple HTML parser that uses " +"the :class:`HTMLParser` class to print out start tags, end tags, and data as " +"they are encountered:" msgstr "" "以下的基礎範例是一個簡單的 HTML 剖析器,它使用 :class:`HTMLParser` 類別,當遇" -"到開始標籤、結束標籤和資料時將它們印出: ::" +"到開始標籤、結束標籤和資料時將它們印出:" #: ../../library/html.parser.rst:48 msgid "" @@ -124,11 +124,11 @@ msgstr "" "parser.feed('Test'\n" " '

Parse me!

')" -#: ../../library/html.parser.rst:64 +#: ../../library/html.parser.rst:66 msgid "The output will then be:" msgstr "輸出將是:" -#: ../../library/html.parser.rst:66 +#: ../../library/html.parser.rst:68 msgid "" "Encountered a start tag: html\n" "Encountered a start tag: head\n" @@ -156,24 +156,24 @@ msgstr "" "Encountered an end tag : body\n" "Encountered an end tag : html" -#: ../../library/html.parser.rst:83 +#: ../../library/html.parser.rst:85 msgid ":class:`.HTMLParser` Methods" msgstr ":class:`.HTMLParser` 方法" -#: ../../library/html.parser.rst:85 +#: ../../library/html.parser.rst:87 msgid ":class:`HTMLParser` instances have the following methods:" msgstr ":class:`HTMLParser` 實例具有以下方法:" -#: ../../library/html.parser.rst:90 +#: ../../library/html.parser.rst:92 msgid "" "Feed some text to the parser. It is processed insofar as it consists of " -"complete elements; incomplete data is buffered until more data is fed or :" -"meth:`close` is called. *data* must be :class:`str`." +"complete elements; incomplete data is buffered until more data is fed " +"or :meth:`close` is called. *data* must be :class:`str`." msgstr "" "向剖析器提供一些文本。只要它由完整的元素組成,它就會被處理;不完整的資料會被" "緩衝,直到輸入更多資料或呼叫 :meth:`close`。 *data* 必須是 :class:`str`。" -#: ../../library/html.parser.rst:97 +#: ../../library/html.parser.rst:99 msgid "" "Force processing of all buffered data as if it were followed by an end-of-" "file mark. This method may be redefined by a derived class to define " @@ -181,20 +181,20 @@ msgid "" "should always call the :class:`HTMLParser` base class method :meth:`close`." msgstr "" "強制處理所有緩衝資料,如同它後面跟有文件結束標籤一樣。此方法可能有被衍生類別" -"重新定義,以在輸入末尾定義額外的處理,但重新定義的版本仍應要呼叫 :class:" -"`HTMLParser` 基底類別方法 :meth:`close`。" +"重新定義,以在輸入末尾定義額外的處理,但重新定義的版本仍應要呼" +"叫 :class:`HTMLParser` 基底類別方法 :meth:`close`。" -#: ../../library/html.parser.rst:105 +#: ../../library/html.parser.rst:107 msgid "" "Reset the instance. Loses all unprocessed data. This is called implicitly " "at instantiation time." msgstr "重置實例。丟棄所有未處理的資料。這在實例化時被會隱晦地呼叫。" -#: ../../library/html.parser.rst:111 +#: ../../library/html.parser.rst:113 msgid "Return current line number and offset." -msgstr "回傳當前列號 (line number) 和偏移量 (offset)。" +msgstr "回傳目前列號 (line number) 和偏移量 (offset)。" -#: ../../library/html.parser.rst:116 +#: ../../library/html.parser.rst:118 msgid "" "Return the text of the most recently opened start tag. This should not " "normally be needed for structured processing, but may be useful in dealing " @@ -205,23 +205,23 @@ msgstr "" "「已部署」的 HTML 或以最少的更改重新生成輸入(可以保留屬性之間的空白等)時可" "能很有用。" -#: ../../library/html.parser.rst:122 +#: ../../library/html.parser.rst:124 msgid "" "The following methods are called when data or markup elements are " "encountered and they are meant to be overridden in a subclass. The base " -"class implementations do nothing (except for :meth:`~HTMLParser." -"handle_startendtag`):" +"class implementations do nothing (except " +"for :meth:`~HTMLParser.handle_startendtag`):" msgstr "" "當遇到資料或標記元素時將呼叫以下方法,並且它們應在子類別中被覆蓋。基底類別實" "作什麼都不做(除了 :meth:`~HTMLParser.handle_startendtag`):" -#: ../../library/html.parser.rst:129 +#: ../../library/html.parser.rst:131 msgid "" "This method is called to handle the start tag of an element (e.g. ``
``)." msgstr "呼叫此方法來處理元素的開始標籤(例如 ``
``)。" -#: ../../library/html.parser.rst:131 +#: ../../library/html.parser.rst:133 msgid "" "The *tag* argument is the name of the tag converted to lower case. The " "*attrs* argument is a list of ``(name, value)`` pairs containing the " @@ -233,44 +233,44 @@ msgstr "" "列表,包含在標籤的 ``<>`` 括號內找到的屬性。 *name* 將被轉成小寫,*value* 中" "的引號會被刪除,字元和實體參照也會被替換。" -#: ../../library/html.parser.rst:137 +#: ../../library/html.parser.rst:139 msgid "" "For instance, for the tag ````, this method " -"would be called as ``handle_starttag('a', [('href', 'https://www.cwi." -"nl/')])``." +"would be called as ``handle_starttag('a', [('href', 'https://" +"www.cwi.nl/')])``." msgstr "" "例如,對於標籤 ````,這個方法會以 " "``handle_starttag('a', [('href', 'https://www.cwi.nl/')])`` 的形式被呼叫。" -#: ../../library/html.parser.rst:140 +#: ../../library/html.parser.rst:142 msgid "" "All entity references from :mod:`html.entities` are replaced in the " "attribute values." msgstr "在屬性值中來自 :mod:`html.entities` 的所有實體參照都會被替換。" -#: ../../library/html.parser.rst:146 +#: ../../library/html.parser.rst:148 msgid "" "This method is called to handle the end tag of an element (e.g. ``
``)." msgstr "呼叫此方法來處理元素的結束標籤(例如 ``
``)。" -#: ../../library/html.parser.rst:148 +#: ../../library/html.parser.rst:150 msgid "The *tag* argument is the name of the tag converted to lower case." msgstr "*tag* 引數是轉換為小寫的標籤名稱。" -#: ../../library/html.parser.rst:153 +#: ../../library/html.parser.rst:155 msgid "" "Similar to :meth:`handle_starttag`, but called when the parser encounters an " "XHTML-style empty tag (````). This method may be overridden by " "subclasses which require this particular lexical information; the default " -"implementation simply calls :meth:`handle_starttag` and :meth:" -"`handle_endtag`." +"implementation simply calls :meth:`handle_starttag` " +"and :meth:`handle_endtag`." msgstr "" "與 :meth:`handle_starttag` 類似,但在剖析器遇到 XHTML 樣式的空標籤 " "(````) 時呼叫。這個方法可能被需要這個特定詞彙資訊 (lexical " -"information) 的子類別覆蓋;預設實作只是呼叫 :meth:`handle_starttag` 和 :meth:" -"`handle_endtag`。" +"information) 的子類別覆蓋;預設實作只是呼叫 :meth:`handle_starttag` " +"和 :meth:`handle_endtag`。" -#: ../../library/html.parser.rst:161 +#: ../../library/html.parser.rst:163 msgid "" "This method is called to process arbitrary data (e.g. text nodes and the " "content of ```` and ````)." @@ -278,7 +278,7 @@ msgstr "" "呼叫此方法來處理任意資料(例如文本節點與 ```` 和 " "```` 的內容)。" -#: ../../library/html.parser.rst:167 +#: ../../library/html.parser.rst:169 msgid "" "This method is called to process a named character reference of the form " "``&name;`` (e.g. ``>``), where *name* is a general entity reference (e.g. " @@ -288,7 +288,7 @@ msgstr "" "*name* 是一般實體參照(例如 ``'gt'``)。如果 *convert_charrefs* 為 ``True``," "則永遠不會呼叫此方法。" -#: ../../library/html.parser.rst:175 +#: ../../library/html.parser.rst:177 msgid "" "This method is called to process decimal and hexadecimal numeric character " "references of the form :samp:`&#{NNN};` and :samp:`&#x{NNN};`. For example, " @@ -297,17 +297,17 @@ msgid "" "This method is never called if *convert_charrefs* is ``True``." msgstr "" "呼叫此方法來處理 :samp:`&#{NNN};` 和 :samp:`&#x{NNN};` 形式的十進位和十六進位" -"數字字元參照。例如,``>`` 的十進位等效為 ``>``,而十六進位為 ``>" -"``;在這種情況下,該方法將收到 ``'62'`` 或 ``'x3E'``。如果 " +"數字字元參照。例如,``>`` 的十進位等效為 ``>``,而十六進位為 " +"``>``;在這種情況下,該方法將收到 ``'62'`` 或 ``'x3E'``。如果 " "*convert_charrefs* 為 ``True``,則永遠不會呼叫此方法。" -#: ../../library/html.parser.rst:184 +#: ../../library/html.parser.rst:186 msgid "" "This method is called when a comment is encountered (e.g. ````)。" -#: ../../library/html.parser.rst:186 +#: ../../library/html.parser.rst:188 msgid "" "For example, the comment ```` will cause this method to be " "called with the argument ``' comment '``." @@ -315,7 +315,7 @@ msgstr "" "舉例來說,註解 ```` 會使得此方法被以引數 ``' comment '`` 來呼" "叫。" -#: ../../library/html.parser.rst:189 +#: ../../library/html.parser.rst:191 msgid "" "The content of Internet Explorer conditional comments (condcoms) will also " "be sent to this method, so, for ```` 為例," "這個方法將會收到 ``'[if IE 9]>IE9-specific content``)." @@ -334,7 +334,7 @@ msgstr "" "呼叫此方法來處理 HTML 文件類型聲明 (doctype declaration)(例如 ````)。" -#: ../../library/html.parser.rst:199 +#: ../../library/html.parser.rst:201 msgid "" "The *decl* parameter will be the entire contents of the declaration inside " "the ```` markup (e.g. ``'DOCTYPE html'``)." @@ -342,7 +342,7 @@ msgstr "" "*decl* 參數將是 ```` 標記內聲明部分的全部內容(例如 ``'DOCTYPE " "html'``)。" -#: ../../library/html.parser.rst:205 +#: ../../library/html.parser.rst:207 msgid "" "Method called when a processing instruction is encountered. The *data* " "parameter will contain the entire processing instruction. For example, for " @@ -355,7 +355,7 @@ msgstr "" "``handle_pi(\"proc color='red'\")`` 形式被呼叫。它旨在被衍生類別覆蓋;基底類" "別實作中什麼都不做。" -#: ../../library/html.parser.rst:213 +#: ../../library/html.parser.rst:215 msgid "" "The :class:`HTMLParser` class uses the SGML syntactic rules for processing " "instructions. An XHTML processing instruction using the trailing ``'?'`` " @@ -364,12 +364,12 @@ msgstr "" ":class:`HTMLParser` 類別使用 SGML 語法規則來處理指示。使用有 ``?`` 跟隨在後面" "的 XHTML 處理指示將導致 ``?`` 被包含在 *data* 中。" -#: ../../library/html.parser.rst:220 +#: ../../library/html.parser.rst:222 msgid "" "This method is called when an unrecognized declaration is read by the parser." msgstr "當剖析器讀取無法識別的聲明時會呼叫此方法。" -#: ../../library/html.parser.rst:222 +#: ../../library/html.parser.rst:224 msgid "" "The *data* parameter will be the entire contents of the declaration inside " "the ```` markup. It is sometimes useful to be overridden by a " @@ -378,17 +378,17 @@ msgstr "" "*data* 參數將是 ```` 標記內聲明的全部內容。有時被衍生類別被覆蓋會是好" "用的。在基底類別實作中什麼都不做。" -#: ../../library/html.parser.rst:230 +#: ../../library/html.parser.rst:232 msgid "Examples" msgstr "範例" -#: ../../library/html.parser.rst:232 +#: ../../library/html.parser.rst:234 msgid "" "The following class implements a parser that will be used to illustrate more " -"examples::" -msgstr "以下類別實作了一個剖析器,將用於解說更多範例: ::" +"examples:" +msgstr "以下類別實作了一個剖析器,將用於解說更多範例:" -#: ../../library/html.parser.rst:235 +#: ../../library/html.parser.rst:237 msgid "" "from html.parser import HTMLParser\n" "from html.entities import name2codepoint\n" @@ -458,27 +458,27 @@ msgstr "" "\n" "parser = MyHTMLParser()" -#: ../../library/html.parser.rst:269 -msgid "Parsing a doctype::" -msgstr "剖析文件類型: ::" +#: ../../library/html.parser.rst:273 +msgid "Parsing a doctype:" +msgstr "剖析文件類型:" -#: ../../library/html.parser.rst:271 +#: ../../library/html.parser.rst:275 msgid "" ">>> parser.feed('')\n" -"Decl : 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\"" msgstr "" ">>> parser.feed('')\n" -"Decl : 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\"" -#: ../../library/html.parser.rst:275 -msgid "Parsing an element with a few attributes and a title::" -msgstr "剖析一個具有一些屬性和標題的元素: ::" +#: ../../library/html.parser.rst:281 +msgid "Parsing an element with a few attributes and a title:" +msgstr "剖析一個具有一些屬性和標題的元素:" -#: ../../library/html.parser.rst:277 +#: ../../library/html.parser.rst:283 msgid "" ">>> parser.feed('\"The')\n" "Start tag: img\n" @@ -500,13 +500,13 @@ msgstr "" "Data : Python\n" "End tag : h1" -#: ../../library/html.parser.rst:287 +#: ../../library/html.parser.rst:295 msgid "" "The content of ``script`` and ``style`` elements is returned as is, without " -"further parsing::" -msgstr "``script`` 和 ``style`` 元素的內容按原樣回傳,無需進一步剖析: ::" +"further parsing:" +msgstr "``script`` 和 ``style`` 元素的內容按原樣回傳,無需進一步剖析:" -#: ../../library/html.parser.rst:290 +#: ../../library/html.parser.rst:298 msgid "" ">>> parser.feed('