@@ -7,8 +7,8 @@ msgstr ""
7
7
"Project-Id-Version :Python 3.13\n "
8
8
"Report-Msgid-Bugs-To :\n "
9
9
"POT-Creation-Date :2024-09-03 11:11+0800\n "
10
- "PO-Revision-Date :2024-10-07 21:14 +0800\n "
11
- "Last-Translator :Adrian Liaw <adrianliaw2000 @gmail.com>\n "
10
+ "PO-Revision-Date :2024-10-08 15:45 +0800\n "
11
+ "Last-Translator :Ken Cheng <ken71301 @gmail.com>\n "
12
12
"Language-Team :Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
13
13
"tw)\n "
14
14
"Language :zh_TW\n "
@@ -599,14 +599,16 @@ msgstr ""
599
599
600
600
#: ../../reference/import.rst:342
601
601
msgid "Loading"
602
- msgstr ""
602
+ msgstr "載入 "
603
603
604
604
#: ../../reference/import.rst:344
605
605
msgid ""
606
606
"If and when a module spec is found, the import machinery will use it (and "
607
607
"the loader it contains) when loading the module. Here is an approximation "
608
608
"of what happens during the loading portion of import::"
609
609
msgstr ""
610
+ "如果找到模組規格,引入機制會在載入模組時使用該規格(以及它包含的載入器)。以"
611
+ "下是引入過程中載入部分的大致情況: ::"
610
612
611
613
#: ../../reference/import.rst:348
612
614
msgid ""
@@ -639,16 +641,45 @@ msgid ""
639
641
" raise\n"
640
642
"return sys.modules[spec.name]"
641
643
msgstr ""
644
+ "module = None\n"
645
+ "if spec.loader is not None and hasattr(spec.loader, 'create_module'):\n"
646
+ " # 這裡假設載入器上也會定義 'exec_module'\n"
647
+ " module = spec.loader.create_module(spec)\n"
648
+ "if module is None:\n"
649
+ " module = ModuleType(spec.name)\n"
650
+ "# 與引入相關的模組屬性會在此處設定:\n"
651
+ "_init_module_attrs(spec, module)\n"
652
+ "\n"
653
+ "if spec.loader is None:\n"
654
+ " # 不支援\n"
655
+ " raise ImportError\n"
656
+ "if spec.origin is None and spec.submodule_search_locations is not None:\n"
657
+ " # 命名空間套件\n"
658
+ " sys.modules[spec.name] = module\n"
659
+ "elif not hasattr(spec.loader, 'exec_module'):\n"
660
+ " module = spec.loader.load_module(spec.name)\n"
661
+ "else:\n"
662
+ " sys.modules[spec.name] = module\n"
663
+ " try:\n"
664
+ " spec.loader.exec_module(module)\n"
665
+ " except BaseException:\n"
666
+ " try:\n"
667
+ " del sys.modules[spec.name]\n"
668
+ " except KeyError:\n"
669
+ " pass\n"
670
+ " raise\n"
671
+ "return sys.modules[spec.name]"
642
672
643
673
#: ../../reference/import.rst:377
644
674
msgid "Note the following details:"
645
- msgstr ""
675
+ msgstr "請注意下列細節: "
646
676
647
677
#: ../../reference/import.rst:379
648
678
msgid ""
649
679
"If there is an existing module object with the given name in :data:`sys."
650
680
"modules`, import will have already returned it."
651
681
msgstr ""
682
+ "如果 :data:`sys.modules` 中已存在具有給定名稱的模組物件,引入會已回傳該物件。"
652
683
653
684
#: ../../reference/import.rst:382
654
685
msgid ""
@@ -658,6 +689,9 @@ msgid ""
658
689
"prevents unbounded recursion in the worst case and multiple loading in the "
659
690
"best."
660
691
msgstr ""
692
+ "在載入器執行模組程式碼之前,模組將已存在於 :data:`sys.modules` 中。這一點至關"
693
+ "重要,因為模組程式碼可能會(直接或間接)引入自己;事先將其增加到 :data:`sys."
694
+ "modules` 可以預防類似無限遞迴以及多次重覆載入等情形。"
661
695
662
696
#: ../../reference/import.rst:388
663
697
msgid ""
@@ -667,6 +701,10 @@ msgid ""
667
701
"effect, must remain in the cache. This contrasts with reloading where even "
668
702
"the failing module is left in :data:`sys.modules`."
669
703
msgstr ""
704
+ "如果載入失敗,只有載入失敗的模組會從 :data:`sys.modules` 中刪除。任何已存在"
705
+ "於 :data:`sys.modules` 快取中的模組,以及任何在載入失敗前成功載入的模組,都必"
706
+ "須保留在快取中。此情形與重新載入不同,在重新載入時,即使載入失敗的模組也會保"
707
+ "留在 :data:`sys.modules` 中。"
670
708
671
709
#: ../../reference/import.rst:394
672
710
msgid ""
@@ -675,26 +713,35 @@ msgid ""
675
713
"code example above), as summarized in a :ref:`later section <import-mod-"
676
714
"attrs>`."
677
715
msgstr ""
716
+ "模組建立後,在執行之前,引入機制會設置與引入相關的模組屬性(在上面的偽程式碼"
717
+ "範例中為\" _init_module_attrs\" ),具體內容在\\ :ref:`之後的段落<import-mod-"
718
+ "attrs>`\\ 會總結。"
678
719
679
720
#: ../../reference/import.rst:399
680
721
msgid ""
681
722
"Module execution is the key moment of loading in which the module's "
682
723
"namespace gets populated. Execution is entirely delegated to the loader, "
683
724
"which gets to decide what gets populated and how."
684
725
msgstr ""
726
+ "模組執行是載入過程中的關鍵時刻,此時模組的命名空間會被新增名稱。執行過程完全"
727
+ "交由載入器處理,由其決定如何新增以及新增什麼。"
685
728
686
729
#: ../../reference/import.rst:403
687
730
msgid ""
688
731
"The module created during loading and passed to exec_module() may not be the "
689
732
"one returned at the end of import [#fnlo]_."
690
733
msgstr ""
734
+ "在載入過程中建立並傳遞給 exec_module() 的模組,可能不會是引入結束時回傳的模"
735
+ "組 [#fnlo]_。"
691
736
692
737
#: ../../reference/import.rst:406
693
738
msgid ""
694
739
"The import system has taken over the boilerplate responsibilities of "
695
740
"loaders. These were previously performed by the :meth:`importlib.abc.Loader."
696
741
"load_module` method."
697
742
msgstr ""
743
+ "引入系統已接管載入器中載入模組的功能。之前是由 :meth:`importlib.abc.Loader."
744
+ "load_module` 方法執行的。"
698
745
699
746
#: ../../reference/import.rst:412
700
747
msgid "Loaders"